By default error recovery is turned on and ANTLR will try to recover from syntax errors. However it will print error message on stderr.
If you need error recovery to be turned off and throw an exception at the first sight of an error, you need to override 'recoverFromMismatchedToken' as shown in http://www.antlr.org/wiki/display/ANTLR3/Error+reporting+and+recovery Cheers, Indhu -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Liviu U Sent: Thursday, June 04, 2009 3:43 PM To: [email protected] Subject: Re: [antlr-interest] How to force ANTLR 3.1.2 to raise exceptions on invalid tokens? I found something on ANTLR wiki, to override netxtToken but still the 1 number on first line does not raise an exception while if there are two numbers it does: --NO ERROR although it should have been if ( x.Age = 10) 1 then alert(x.Age); alert(true); else alert(false); end -- ERROR: if ( x.Age = 10) 1 2 then alert(x.Age); alert(true); else alert(false); end On Thu, Jun 4, 2009 at 12:45 PM, Liviu U <[email protected]> wrote: > I notices something strange in 3.1.2 > > If i have a rule: var x = int; and another that matches: if cond then > statements end > > for a script: > > if var x=3 .... > > ANTLR ignores the if and parses an assignment. This is not what i > expect. I need to have an error raised. > > Is there a way to configure the behaviour i expect? I remember that in > older versions the behavior of the parser was different... > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
