[antlr-interest] (POST THIRD TIME) how to bail on MissingTokenException

Jim Idle jimi at temporal-wave.com
Thu Oct 30 08:49:25 PDT 2008


On Wed, 2008-10-29 at 21:25 -0700, Geoff hendrey wrote:
> Hi,
> 
> thanks for the response, I really appreciate it. Do you mean
> "mismatch" or "missing"? Just to be sure we are on the same page, I am
> getting a MissingTokenException, not MismatchedTokenException. My
> grammar file already deals with MismatchedTokenException, nd I have no
> problem with that. I need to find out how to abort parsing on
> MISSINGTokenException.
> 
> Thanks, and sorry for using caps and bold. Just wanted to make sure we
> are on the same page.


Look at the comments for the methods in base recognizer. They tell you
how to override a method so that you don't get missing token exceptions.
Your issue is that when the standard mechanisms predict that there is a
missing or extraneous token, they can report the error, insert or delete
the token, then carry on without an exception being thrown. Overriding
the base recognizer allows you to not check for such things but just
throw an exception. The comments explain it. Perhaps there should be a
wiki article but it needs someone to take the time to write it. Perhaps
you can write this article when you have it working, as most people
don't wish to override it.

This kind of thing can also be necessary because there are situations
where the input could be construed as either having an extra token or a
missing token and the default isn't the best for all circumstances
(though it usually is).

Jim

>  
> 
> -geoff
> 
> 
> 
> 
> 
> 
> 
> ______________________________________________________________________
> From: Terence Parr <parrt at cs.usfca.edu>
> To: Geoff hendrey <geoff_hendrey at yahoo.com>
> Cc: antlr-interest at antlr.org
> Sent: Wednesday, October 29, 2008 12:58:28 PM
> Subject: Re: [antlr-interest] (POST THIRD TIME) how to bail on
> MissingTokenException
> 
> Hi Geoff, isn't there something in the source code that says "
> override me if you want to turn off automatic in-line error recovery
> for mismatch token"?
> Ter
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081030/049c0452/attachment.html 


More information about the antlr-interest mailing list