[antlr-interest] Unable to throw custom exceptions - possiblebug?

Lorenzo Dalla Vecchia lor.dv at tiscali.it
Sun Sep 30 03:03:26 PDT 2007


>> [...] I added
>> "throws MyException" to the rule declaration in order to declare the
>> exception throwing in the parser code.
>>
>> The modified grammar compiles correctly with antlr Tool, but nothing is
>> added to the method signature in the generated parser! Is this a bug?
>> Maybe the reason is that I am using a return value for the rule?
>
> Looks to me like you stumbled upon an open TODO issue. The ANTLR grammar
> does infact recognizer 'throws' declarations, but I can't see anything in
> the codegen templates that actually makes use of this. But I'm the Python
> guy here, so I don't care about such formalities anyway ;)

I'm using Java as output language.
Anyway, I see the problem.

I wonder what would be my best option to signal the error to the code that 
called the parser without using custom exceptions. Any ideas?

Thanks.

--
Lorenzo 



More information about the antlr-interest mailing list