我正在尝试生成 .automaton 文件,我将其添加到 lib/ 文件夹内的沙丘文件中
(menhir
(flags --explain --dump)
(modules parser))
然后我运行
dune build
,如果我运行find . -name '*.automaton'
,它找不到文件,我期待的是自动机文件。我缺少什么?
我在这里设置了项目:https://github.com/dhilst/pfpy,以重现
git clone https://github.com/dhilst/pfpy.git && cd pfpy
opam install --deps-only .
dune build
---更新---
运行后
dune build --verbose
我发现了石碑正在被处决:Running[23]: (cd _build/.sandbox/740f245a4e0ba91f52e6ab53118b4542/default && /home/me/.opam/4.14.1/bin/menhir --explain --inspection --table --dump lib/parser.mly --base lib/parser --infer-read-reply lib/parser__mock.mli.inferred)
问题是构建后
.sandbox
文件夹为空
$ ls -l _build/.sandbox
total 0
---更新---
对于那些有同样问题的人,我正在做的是运行
menhir --explain --dump lib/parser.mly
。这会以错误状态退出,但它确实生成了我需要的文件。
我在我的项目中使用这些标志:
(menhir
(modules parser)
(flags --dump --explain --automaton-graph --cmly))
使
parser.automaton
和 parser.conflicts
文件出现似乎必需的是 --cmly
选项。 --automaton-graph
选项(似乎没有记录)对于拥有 parser.dot
文件(一个 Graphviz 文件)很有用,可以直观地表示自动机。
这与文档不一致,根据文档
--dump --explain
就足够了。我知道正确的标志,因为我的老师为我们的学校项目设置了它们。
这是menhir版本20230608和dune 3.11.1。