3

我想验证我的 ANTLR 4 语法是 LL(1)。在旧版本的 ANTLR 中有一个选项可以做到这一点。ANTLR 4 中有类似的东西吗?

我浏览了文档,但没有找到任何东西。尽管似乎缺少选项页面,但我什至没有找到所有可能选项的列表。

4

1 回答 1

4

One of the design goals of ANTLR 4 is allowing language designers to focus on writing accurate grammars rather than worrying about characteristics like "LL(1)" which have little to no impact on users of the language.

However, it is likely that you can identify an LL(1) grammar by examining the generated parser. If there are no calls to adaptivePredict in the generated code, then the grammar is LL(1). The intent is for the inverse to also be true, but considering a call to adaptivePredict produces the same result as the inline version of an LL(1) decision, we have not rigorously evaluated this.

于 2014-10-20T01:08:44.507 回答