ocamlocaml-dunemenhir

How to generate Menhir .automaton files with dune in OCaml?


I'm trying to generate .automaton files I added this to the dune file inside lib/ folder

(menhir
  (flags --explain --dump)
  (modules parser))

Then I run dune build, if I do find . -name '*.automaton', it finds no file, I was expecting the automaton file. What I'm missing?

I set up the project here: https://github.com/dhilst/pfpy, to reproduce

git clone https://github.com/dhilst/pfpy.git && cd pfpy
opam install --deps-only .
dune build

--- update ---

After running dune build --verbose I caught the menhir being executed: Running[23]: (cd _build/.sandbox/740f245a4e0ba91f52e6ab53118b4542/default && /home/me/.opam/4.14.1/bin/menhir --explain --inspection --table --dump lib/parser.mly --base lib/parser --infer-read-reply lib/parser__mock.mli.inferred)

The problem is that the .sandbox folder is empty after the build

$ ls -l _build/.sandbox 
total 0

--- update ---

For those that have the same problem, what I'm doing is run menhir --explain --dump lib/parser.mly. This exits with an error status but it does generate the files that I need.


Solution

  • I am using these flags in my project:

    (menhir
     (modules parser)
     (flags --dump --explain --automaton-graph --cmly))
    

    What seems necessary to make the parser.automaton and parser.conflicts files appear is the --cmly option. The --automaton-graph option (which seems undocumented) is useful to have a parser.dot file, a Graphviz file to have a visual representation of the automaton.

    This is not coherent with the documentation, according to which --dump --explain should suffice. I know the correct flags because my teacher set them for our school project.

    This is with menhir version 20230608, and dune 3.11.1.