Antlr3 中的所有语法选项在哪里?
Antlr2 中有许多可以设置的语法选项(参考)。现在在 Antlr3 中,我们有大约 1/3 的选项数量(参考)。
所以我对此有两个问题:
- 有谁知道为什么这么多选择被取消,并且其中有任何一个会回来吗?
- 即使没有所有这些选项,Antlr3 是否有能力做 Antlr2 可以做的事情?
更具体地说我的第二个问题,我希望能够做一些事情。首先,我想更改生成的词法分析器和解析器类的可见性(即 Antlr2 选项“classHeaderPrefix”)。
其次,我希望能够忽略某些关键字中发现的任何空格标记,例如“&keyword&”和“&关键字&”两者都匹配(即 Antlr2 选项“忽略”,我认为?)。
最后,我想让某些关键字不区分大小写(即 Antlr2 选项“caseSensitive”)。
In Antlr2 there were numerous grammar options that could be set (reference). Now in Antlr3 we have like 1/3 of the amount of options (reference).
So I have two questions concerning this:
- Does anyone know why so many options were taken out and are any of them coming back?
- Does Antlr3 have the ability to do what Antlr2 could, even without all those options?
To be more specific on my second question, I want to be able to do a few things. First, I want to change the visibility of the generated lexer and parser classes (i.e. Antlr2 option "classHeaderPrefix").
Secondly, I want to be able to ignore any whitespace tokens found within certain keywords, like having "&keyword&" and "& k ey w o rd &" both match (i.e. Antlr2 option "ignore", I think?).
Finally, I want to make certain keywords case insensitive (i.e. Antlr2 option "caseSensitive").
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 v3 中没有办法做到这一点。
该选项可能已被删除,因为词法分析器中的 LL(*) 算法比 v2 中使用的算法强大得多。现在,不需要这样的选项,因为这可以解决问题:
除了“硬”方式之外,这在 v3 中也是不可能的:
In v3 there is no way to do this.
That options might have been removed because the LL(*) algorithm in the lexer is far more powerful than what was used in v2. Now, there is no need for such an option since this would do the trick:
That is also not possible in v3 other than doing it the "hard" way: