[antlr-interest] Tree Parser Rule - 'throws' my-own-exception is silently ignored

Michael Lee antlr at quantdev.com
Wed Dec 3 21:55:00 PST 2008


Hi,

I am troubling to throw my-own-exception during tree parsing.

I have a tree rule - nothing too complicated.

Here is the snippet

expression returns [ Expression exp ] *throws* *ExpressionParseException*
: ^(op='+' a=expression b=expression ) { $exp = 
NumericOperationExpression.createOperation( op.getText().charAt(0) , 
(NumericExpression) dynamicToNumeric(a) , (NumericExpression) 
dynamicToNumeric(b)); }


However the antlr generates

/*/ src/main/antlr/Eval.g:63:1: expression returns [ Expression exp ] : 
*( ^(op= '+' a= expression b= expression ) ....
public final Expression expression() *throws RecognitionException* {
Expression exp = null;

It looks like it is silently dropping 'throws' my-own-exception.

Is it a bug? Or am I doing wrong?

Thanks in advance.


Michael Lee


More information about the antlr-interest mailing list