Make menhir add user-defined functions from .mly t

2019-07-29 03:57发布

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?

标签: ocaml menhir
1条回答
Lonely孤独者°
2楼-- · 2019-07-29 04:36

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.

查看更多
登录 后发表回答