drom icon indicating copy to clipboard operation
drom copied to clipboard

Add configuration means for better support of `menhir`

Open nberth opened this issue 2 years ago • 6 comments

At the moment there does not seem to be a way to pass options to menhir. As a use case, here's what I'd need in the dune file of a package:

(library
  …
  (libraries … menhirLib)

…
(menhir (modules parser)
  (flags --table))

One can add dune-libraries = "menhirLib" in [fields] to deal with the library dependency. The part I fail to specify is the --table, and a custom name for the parser module.

nberth avatar Dec 14 '21 10:12 nberth

For the second part, it should be in:

dune-trailer = """
(menhir (modules parser)
   (flags --table))
"""

I think it should work

lefessan avatar Dec 14 '21 13:12 lefessan

For the menhirLib, you can use:

[[dependencies]]
menhir = { libname = "menhirLib", version = ">=1.2" }

It should put menhir as the dependency in opam files, and menhirLib as the dependency in dune files.

lefessan avatar Dec 14 '21 13:12 lefessan

Ok thanks that's a way. However note that with the dune trailer added as you suggested along with a generators = [… "menhir"], the generated dune file has multiple rules for a parser parser, i.e. multiple (menhir (modules parser) …) structs. Removing "menhir" from the list of generators leads to a functioning dune file, yet drom outputs a little line saying, e.g, no generator for parser.mly, which looks like a future warning.

nberth avatar Dec 14 '21 14:12 nberth

Clearly, using dune-trailer is just a way to make it work, it is not a long term solution. The long term solution would probably to add a menhir-flags entry or something like that.

lefessan avatar Dec 14 '21 14:12 lefessan

Yes indeed. I'll leave the issue open as a reminder.

nberth avatar Dec 14 '21 14:12 nberth

Soon available in https://github.com/OCamlPro/drom/pull/173

lefessan avatar Dec 16 '21 05:12 lefessan