[antlr-interest] How to force ANTLR 3.1.2 to raise exceptions on invalid tokens?

Liviu U liviu.u at gmail.com
Thu Jun 4 03:13:29 PDT 2009


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...
>


More information about the antlr-interest mailing list