This question is indeed related to the interaction of menhir and build systems. Precisely, the inspection API (--inspection) requires the type information of .mly (including its semantic actions) to be known. I chose to directly work on parse_e.mly rather than unitActionsParser_e.mly, and followed the approach of “Obtaining OCaml type information without calling the OCaml compiler”:
-
menhir --explain --inspection --table --dump --infer-write-query mockfile.ml parser_e.mlyto generatemockfile.ml -
ocamlfind ocamlc -I lib -package sedlex -package menhirLib -i mockfile.ml > sigfileto generatesigfile. Note that-I librefers to the directory of external modules, their.cm[io]files should be ready to use. -
menhir --explain --inspection --table --dump --infer-read-reply sigfile parser_e.mlyto generate especiallyparser_e.ml,parser_e.mli,.conflictsandautomaton.
As a result, parser_e.ml contains more type information and the inspection API is in Parser_e.MenhirInterpreter.