使menhir将用户定义的函数从.mly添加到.mli [英] Make menhir add user-defined functions from .mly to .mli

查看:112
本文介绍了使menhir将用户定义的函数从.mly添加到.mli的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Menhir允许在.mly文件的末尾添加任意的ocaml代码,在该文件中我想声明一些函数.但是我找不到一种方法来使竖起的函数添加到.mli文件中,从而使它们在其他模块中可见.有可能吗?

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?

推荐答案

答案很简单,. .mly文件中定义的代码仅由解析器使用.

The answer is simple, it's no. The code defined in the .mly file is only used by the parser.

如手册中所述:

标头是一段OCaml代码,用 %{ 和 %} .它在开始时逐字复制. .ml 文件.

A header is a piece of OCaml code, surrounded with %{ and %} . It is copied verbatim at the beginning of the .ml file.

这篇关于使menhir将用户定义的函数从.mly添加到.mli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆