Interesting. then, the debugger is your friend.  A simple grmmar + dbg  
should explain all. please post what was wrong.  I've not had a  
problem before.
Ter
On Oct 30, 2008, at 10:40 PM, Geoff hendrey wrote:

> I already have the following in my grammer:
>
> @members{
> protected void mismatch(IntStream input, int ttype, BitSet  
> follow)throws RecognitionException{
>     throw new MismatchedTokenException(ttype, input);
> }
> public Object recoverFromMismatchedSet(IntStream input,  
> RecognitionException e, BitSet follow)throws RecognitionException{
>     throw e;
> }
> }
> @rulecatch{
> catch(RecognitionException e){
>     throw e;
> }
>
> And when I look in the generated parser I find this:
>
>     protected void mismatch(IntStream input, int ttype, BitSet  
> follow)throws RecognitionException{
>         throw new MismatchedTokenException(ttype, input);
>     }
>     public Object recoverFromMismatchedSet(IntStream input,  
> RecognitionException e, BitSet follow)throws RecognitionException{
>         throw e;
>     }
>
>
> But it doesn't seem to make any difference. The parser still  
> silently accepts syntactically incorrect inputs. In ANTLRWorks I can  
> see the MissingTokenExceptions in the concrete parse tree. (see  
> attached picture). But the AST just happily builds, even though my  
> input includes a token that is supposed to be surrounded with a pair  
> of angle brackets, but isn't. I've got a rule in my grammar that  
> should force the Identifier to be surrounded by angle brackets.
>
> typedSURID
>     :    'SURID' '<' queryNames'>' Identifier ->^(SURID queryNames  
> Identifier)
>
> I can substitute square brackets instead of angle brackets in my  
> input, and I still just get MissingTokenException in the concrete  
> parse tree, with the AST happily building and no exception thrown  
> out to my application that invokes the parser.
>
> -geoff
>
>
>
> From: Terence Parr <[EMAIL PROTECTED]>
> To: Geoff hendrey <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED]
> Sent: Thursday, October 30, 2008 10:55:51 AM
> Subject: Re: [antlr-interest] (POST THIRD TIME) how to bail on  
> MissingTokenException
>
> Missing comes from the automatic in-line error recovery. You need to  
> override
>
>     protected Object recoverFromMismatchedToken(IntStream input, int  
> ttype, BitSet follow)
>
> just throw an exception. make sure you don't catch anything later...  
> this should be in the book under how to make the parser bail on  
> first exception.
> Ter
> On Oct 29, 2008, at 9:25 PM, 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.
> >
> > -geoff
> >
> >
> >
> > From: Terence Parr <[EMAIL PROTECTED]>
> > To: Geoff hendrey <[EMAIL PROTECTED]>
> > Cc: [EMAIL PROTECTED]
> > 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:8080/mailman/listinfo/antlr-interest
> > Unsubscribe: 
> > http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
> >
>
> <Picture 2.png>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address

Reply via email to