我有一个由 menhir 和传统 makefile 构建的大项目。首先,我想在我的项目中添加一个像这个项目这样的错误处理机制。
通过跟踪示例项目的沙丘,我设法通过以下命令生成.mly、.mli、.ml和of :.cmi.cmounitActionsParser_e.mly
$ menhir --only-preprocess-u parser_e.mly > unitActionsParser_e.mly
$ menhir --table --external-tokens Parser_e unitActionsParser_e.mly
$ ocamlfind ocamlc -package menhirLib -c unitActionsParser_e.mli
增量 API 和错误处理确实有效。
然后,我想将像这个项目这样的错误恢复添加到我的项目中。然后,在我的项目中items state引发了错误。Error: Unbound value items根据手册和沙丘,我想我需要在--inspection某处添加。
我试过了menhir --explain --inspection --table --dump --infer --external-tokens Parser_e unitActionsParser_e.mly,然后camlfind ocamlc -package menhirLib -c unitActionsParser_e.mli报错Unbound type constructor Parser_e.terminal。
我也尝试直接处理parser_e.mly而不是使用unitActionsParser_eby menhir --explain --inspection --table --dump --infer parser_e.mly,但它返回了一个错误Unbound module Utilitywhere Utilityis a module in another folder required by parser_e.mly。在我手动复制utility.cm*到 的文件夹后parser_e.mly,它返回了一个错误Unbound module Sedlexing(这里是一个我们可以重现错误的 fork)(这可能与手册的与构建系统的交互有关)。
有谁知道生成解析器(UnitActionsParser_e或Parser_e)的正确命令和标志是什么,以启用 Menhir 的增量 API 和检查 API?
(* 在讨论.ocaml.org 中的链接:https ://discuss.ocaml.org/t/generate-a-parser-enabling-incremental-api-and-inspection-api/9380 *)