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?