[antlr-interest] HOW To catch error (no exception is thown)

Johannes Luber jaluber at gmx.de
Mon Apr 21 16:14:57 PDT 2008


Guntis Ozols schrieb:
>> it's been 2 days, I try to catch error from the parser.
> 
> To catch error, you need to throw it first.
> For some reason still unclear to me,
> antlr lexer does not throw error by default.
> 
> The answer you are looking for is in FAQ.
> For some reason, not error handling FAQ but lexing FAQ instead.
> 
> !The code there is version specific!
> 
> It suggests you to override nextToken() with lots of code.
> 
> I am just overriding reportError() with one line to throw
> RuntimeException from there, but then I can not use syntactic
> predicates for lexer rules.
> 
> Perhaps there are other options, too.
> 
> http://www.antlr.org/wiki/pages/viewpage.action?pageId=5341217.
> 

ANTLR 3.1 does change its behaviour regarding this issue. Maybe Jabon 
should try out the latest build?

Johannes


More information about the antlr-interest mailing list