Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能帮助我如何在 ocamlyacc 中启用 C 风格的包含文件?例如:#include "mylib.txt";。
#include "mylib.txt";
该#include工具不是 yacc 的一部分,它是 C 的一部分。您可以将它与 yacc 一起使用,因为 yacc 生成 C 作为其输出。由于 OCaml 没有预处理器,因此您不能对 ocamlyacc 做同样的事情。
#include
这个工具与 yacc 的通常使用是为了在你的扫描器和你的解析器之间共享令牌定义。
使用 ocamlyacc,标准做法是在 ocamlyacc 输入中定义标记符号。然后在您的扫描仪中,您使用解析器模块中的名称。具体来说,您可能会open在扫描仪代码中使用您的解析器模块。
open