[antlr-interest] Unable to throw custom exceptions - possible bug?

Benjamin Niemann pink at odahoda.de
Sat Sep 29 04:42:34 PDT 2007


Hi Lorenzo,

Lorenzo Dalla Vecchia wrote:
> I'm building a tree parser with ANTLR 3.0 for a project I am currently
> working on. Now, one method I'm calling from one of the actions in the
> grammar throws a custom exception (let's call it MyException), so 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 ;)

clickediclick... Ah, seems to be a known issue:
<http://www.antlr.org:8888/browse/ANTLR-100>


HTH



More information about the antlr-interest mailing list