antlr - Throwing Exception from from ANTLR4 visitor -
i antlr newbie. here grammar trying write 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 not able throw exception since generated code not handle exceptions, method signature not have throws exception
in signature. there way out of ?
an unchecked exception work, suggested sam harwell - 1 of 2 options - here. tried it.
you can catch exception wherever want.
Comments
Post a Comment