Antlr 3.2 重写规则
我最近开始学习 Antlr 并下载 AntlrWorks 1.4,其中应该包含 Antlr 3.2。现在,3.2 应该支持重写规则语法,如“->”但我什至无法获得基于 Lexer 或 Parser 规则构建的最简单的情况:
grammar TestRewrite;
ab : a b -> a;
a : A;
b : B;
A : 'a';
B : 'b';
当我尝试编译它时,我收到错误:
[11:26:29] error(100): TestRewrite.g:3:13: syntax error: antlr: TestRewrite.g:3:13: unexpected token: a
为什么是这样。构造看起来很简单:ab 应该生成一棵树,其中仅捕获 a 节点。你不就是这样做的吗?我也无法让它与生根('^')或忽略('!')一起工作。我已经很迷茫了。
I've recently started learning Antlr and downloading AntlrWorks 1.4 which supposedly includes Antlr 3.2. Now, 3.2 is supposed to support the rewrite rules grammars like '->' but I've not been able to get even the simplest case I could construct to work either based on Lexer or Parser rules:
grammar TestRewrite;
ab : a b -> a;
a : A;
b : B;
A : 'a';
B : 'b';
When I try to compile this, I get the error:
[11:26:29] error(100): TestRewrite.g:3:13: syntax error: antlr: TestRewrite.g:3:13: unexpected token: a
Why is this. The construction seems simple enough: ab should generate a tree where only the a node is captured. Isn't that how you do it? I can't get it to work with rooting ('^') or ignoring ('!') either. I've very confused.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选项 {输出=AST;}
options {output=AST;}