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.