Antlr3 中的所有语法选项在哪里?

发布于 2024-10-11 02:00:08 字数 585 浏览 0 评论 0原文

Antlr2 中有许多可以设置的语法选项(参考)。现在在 Antlr3 中,我们有大约 1/3 的选项数量(参考)。

所以我对此有两个问题:

  1. 有谁知道为什么这么多选择被取消,并且其中有任何一个会回来吗?
  2. 即使没有所有这些选项,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:

  1. Does anyone know why so many options were taken out and are any of them coming back?
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋凉 2024-10-18 02:00:08

BluePlateSpecial 写道

更具体地说我的第二个问题,我希望能够做一些事情。首先,我想更改生成的词法分析器和解析器类的可见性(即 Antlr2 选项“classHeaderPrefix”)。

在 v3 中没有办法做到这一点。

BluePlateSpecial 写道

其次,我希望能够忽略在某些关键字中找到的任何空白标记,例如“&keyword&”和“&关键字&”两者都匹配(即 Antlr2 选项“忽略”,我认为?)。

该选项可能已被删除,因为词法分析器中的 LL(*) 算法比 v2 中使用的算法强大得多。现在,不需要这样的选项,因为这可以解决问题:

FOO
  :  '&' (' ' | 'a'..'z')+ '&'
  ;

BluePlateSpecial 写道

最后,我想让某些关键字不区分大小写(即 Antlr2 选项“caseSensitive”)。

除了“硬”方式之外,这在 v3 中也是不可能的:

BAR
  :  ('b' | 'B') ('a' | 'A') ('r' | 'R')
  ;

BluePlateSpecial wrote:

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").

In v3 there is no way to do this.

BluePlateSpecial wrote:

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?).

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:

FOO
  :  '&' (' ' | 'a'..'z')+ '&'
  ;

BluePlateSpecial wrote:

Finally, I want to make certain keywords case insensitive (i.e. Antlr2 option "caseSensitive").

That is also not possible in v3 other than doing it the "hard" way:

BAR
  :  ('b' | 'B') ('a' | 'A') ('r' | 'R')
  ;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文