问题
Menhir allows to add arbitrary ocaml code to the end of the .mly file, where I want to declare a few functions. But I could not find a way to make menhir add my functions to the .mli file, so that they are visible from the other modules. Is it possible?
回答1:
The answer is simple, it's no. The code defined in the .mly
file is only used by the parser.
As stated in the manual :
A header is a piece of OCaml code, surrounded with %{ and %} . It is copied verbatim at the beginning of the .ml file.
来源:https://stackoverflow.com/questions/40514349/make-menhir-add-user-defined-functions-from-mly-to-mli