I am an ANTLR newbie. Here is a grammar for which I am trying to write a Visitor class.
grammar extremelysimpleexpr ;
stat : expr ;
expr : sub ;
sub : add ( '-' add )* ;
add : VAL ( '+' VAL )*
| VAL
;
VAL : [0-9]+ ;
[ \t\n\r]+ -> skip ;
Vistor.java
.........
public Integer vistAdd(ctx) {
if (some cond) {
throw new Exception()
}
}
..........
The problem is I am not able to throw exception since the generated code does not handle exceptions, the method signature does not have throws exception
in its signature. Is there any way out of it ?
stack overflow link for this question
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Jim is exactly right here.
Note that if for some reason you need to be able to cancel the parsing operation, the runtime includes a standard exception for this purpose:
http://www.antlr.org/api/Java/org/antlr/v4/runtime/misc/ParseCancellationException.html
Sam