Exception declared on ANTLR grammar rule ignored
Posted
by Kaleb Pederson
on Stack Overflow
See other posts from Stack Overflow
or by Kaleb Pederson
Published on 2010-05-14T17:21:36Z
Indexed on
2010/05/14
17:24 UTC
Read the original article
Hit count: 402
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?
© Stack Overflow or respective owner