我不确定这是否是Nearley.js 库、Moo 分词器/词法分析器或我自己的代码的问题。所以我可能需要将此作为问题提交给 Nearley 回购。所有引用的文件都可以在这个 Gist中找到。
我正在尝试编写一个 Nearley 语法,它将解析我的一门课程的家庭作业问题列表。问题在issues.txt中,如下所示:
Section 5.2 (Due 4/23)- #3, 5*, 8*, 9, 11, 14*, 15, 17*, 18*, 20, 21*, 22*, 24*, 25 (see example 5, not discussed in class)
Section 5.3 (Due 4/30)- #1, 3*, 4, 5, 6*, 7, 9*, 11, 13*, 16, 20*, 21*, 22*, 23, 24*, 25*, 27, 28*, 31, 32
仅以两行为例,整个文件更大。
我写的 Nearley 语法在problems-grammar.ne
这里,我还没有完全完成。我正在根据Nearley 文档中的这些说明使用 Moo 标记器/词法分析器。
我目前正在使用这里解释的命令来测试我的语法,nearley-unparse
这里使用这个命令,problems-grammar.js
Nearley 编译的解析器在哪里。
nearley-unparse problems-grammar.js -o test.txt
不幸的是,除了换行符之外,反解析器似乎没有正确地生成带有标记示例的语法。这是一个输出nearley-unparse
:
Section (Due )- #*, ,
Section (Due )- #, *,
Section (Due )- #*, , , *,
Section (Due )- #*, *
Section (Due )- #*, *, *, *
我想知道这是我的语法缺陷还是 Nearley/Moo 本身的缺陷。如果我的代码有问题,我该如何解决?