Create Menhir Dump / Explain Files Using ocamlbuild

I found that Menhir provides the --dump and --explain options, and that helps debug a lot. But how to include these parameters in ocamlbuild so that Menhir always generates dump files at compile time?

I tried writing my own myocamlbuild tag with the menhir_dump tag, as shown below:

 ... snip ... (* OASIS_STOP *) Ocamlbuild_plugin.dispatch ( MyOCamlbuildBase.dispatch_combine [ (function | After_rules -> flag ["menhir_dump"] (S [A "--dump"; A "--explain"]) | _ -> () ); dispatch_default ] ) 

But when it compiles, the parameters are inserted into the subcommand, and compilation is not performed at the ocamlc stage.

 menhir --dump --explain --raw-depend --ocamldep 'ocamlfind ocamldep -modules' src/parser.mly > src/parser.mly.depends menhir --ocamlc 'ocamlfind ocamlc -g -annot -bin-annot --dump --explain -I src -package cmdliner -package menhirLib -I src' --dump --explain --infer src/parser.mly + menhir --ocamlc 'ocamlfind ocamlc -g -annot -bin-annot --dump --explain -I src -package cmdliner -package menhirLib -I src' --dump --explain --infer src/parser.mly ^^^^^^^^^^^^^^^^ ocamlc: unknown option '--dump'. ...snip... 

Any suggestions?

+7
ocaml menhir ocamlbuild
source share
1 answer

I answer it myself.

There is, of course, a built-in ocamlbuild option for this. Just type explain in _tags as shown below.

 true: use_menhir, explain 

You can find the built-in options using ocamlbuild -documentation .

+3
source share

All Articles