[antlr-interest] How to force ANTLR 3.1.2 to raise exceptions on invalid tokens?
Indhu Bharathi
indhu.b at s7software.com
Thu Jun 4 03:26:58 PDT 2009
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: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Liviu U
Sent: Thursday, June 04, 2009 3:43 PM
To: antlr-interest at antlr.org
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 <liviu.u at gmail.com> 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
More information about the antlr-interest
mailing list