忽略 ANTLR 语法规则上声明的异常
我有一个树解析器,它对我生成的 AST 进行语义分析 解析器。它有一个规则声明如下:
transitionDefinition throws WorkflowStateNotFoundException: /* ... */
这可以很好地编译并匹配 ANTLR 中的规则语法维基百科 但我的例外是从来没有 声明,因此 Java 编译器会抱怨未声明的异常。
./ tool/src/main/antlr3/org/antlr/grammar/v3/ANTLRv3.g 显示它正在构建 一棵树(但我实际上并不肯定它是 ANTLR 的 v2 或 v3 语法 3.2 正在使用):
throwsSpec
: 'throws' id ( ',' id )* -> ^('throws' id+)
;
我知道我可以将其设为运行时异常,但我想使用我的异常 等级制度。我做错了什么或者该语法应该起作用吗?
I have a tree parser that's doing semantic analysis on the AST generated by my
parser. It has a rule declared as follows:
transitionDefinition throws WorkflowStateNotFoundException: /* ... */
This compiles just fine and matches the rule syntax at the ANTLR Wiki
but my exception is never
declared so the Java compiler complains about undeclared exceptions.
./tool/src/main/antlr3/org/antlr/grammar/v3/ANTLRv3.g shows that it's building
a tree (but I'm not actually positive if it's the v2 or v3 grammar that ANTLR
3.2 is using):
throwsSpec
: 'throws' id ( ',' id )* -> ^('throws' id+)
;
I know I can make it a runtime exception, but I'd like to use my exception
hierarchy. Am I doing something wrong or should that syntax work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这是一个已知问题: http://www.antlr.org/jira /browse/ANTLR-100
不幸的是,因为我正在尝试做同样的事情。
It looks like this is a known issue: http://www.antlr.org/jira/browse/ANTLR-100
Unfortunate, as I'm trying to do the same thing.