[antlr-interest] Error handeling - Illigal input termination

Vitaliy Vitaliy at dbsophic.com
Wed Oct 29 05:05:10 PDT 2008


Hi,



I would like Antlr to fail upon any error, instead of trying to recover.

I've managed to do this for almost all types of errors, following the directives in the reference,

but for some reason if there is an illegal input termination, Antlr won't report an error for it.



That is, If we've got the input:

LegalStatement1,

LegalStatement2,

...

LegalStatementN,

IllegalStatement,



Antlr would stop on LegalStatementN,

Instead of reporting an error for IllegalStatement.



Following are all the steps I took to achieve the bail-upon-any-error behavior:



1.       Overriding NextToken method of the lexer, so it would always throw an exception

2.       Overriding methods Mismatch and RecoverFromMismatchedSet of the parser, so they would always throw an exception

3.       Adding @parser::rulecatch directive, so a RecognitionException would always be thrown.



So, what did I miss?



I would really appreciate any help,

Vitaliy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081029/2ed75730/attachment.html 


More information about the antlr-interest mailing list