[antlr-interest] Getting information about first error occurance C Target V3.4

Jim Idle jimi at temporal-wave.com
Mon Jul 23 08:34:16 PDT 2012

You are given the token with the call to displayRecognitionError(). The
token knows its own index so you can record that. You could also set the
current token index to the last one in the input stream (check the input
stream code) so that the next LA/LT will hit EOF and drop out of the parse
(although you will likely trigger one or more additional errors while it
does so.)

So, install your own error handler and record any information you need from


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Paxi
> Sent: Monday, July 23, 2012 6:14 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Getting information about first error
> occurance C Target V3.4
> Is there a simple way of getting the index of the token that caused the
> first error (if there was one)?
> The problem I´m currently facing is, when I´m passing some malformed JS
> to my program that f.e has its last line with some corrupted symbols
> inside I want to immediately quit moving on but work with the tokens
> before that have been successfully lexed.
> I can check for errors of course within the pANTLR3_BASE_RECOGNIZER
> struct
> like:
> rec->state->errorCount != 0
> but i need to know which specific token caused the first error and stop
> my loop before i hit this token.
> Regards Chris
> --
> View this message in context:
> http://antlr.1301665.n2.nabble.com/Getting-information-about-first-
> error-occurance-C-Target-V3-4-tp7578454.html
> Sent from the ANTLR mailing list archive at Nabble.com.
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address

More information about the antlr-interest mailing list