I discovered that Menhir provides --dump and --explain options and it helps debugging a lot. But how can I enable these options under ocamlbuild so that Menhir always generates dump files at compile time?
I tried to write myocamlbuild file handling custom tag menhir_dump
like the 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 options are inserted into sub-command and the compilation fails during 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?
I answer it myself.
There is, of course, a built-in ocamlbuild option for this. Just put explain
in _tags
like the below.
true: use_menhir, explain
You may lookup built-in options using ocamlbuild -documentation
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With