[antlr-interest] Re: dangling else problem (maybe bug in ANTLr 2.7.2?)

Mark markl at glyphic.com
Wed Mar 24 17:20:42 PST 2004


--- In antlr-interest at yahoogroups.com, "Jan Oetting"
<jan.oetting at g...> wrote:
> If I use correct statements, everything works fine.
> But following script doesn't work
> 
> if (a==0)
>    statement1;
>    statement2;
> else
>   statement3;
> statement4;
> 
> this script should be rejected.
> But it it interpreted like
> if (a==0)
>   statement1;
> statement2;
> 
> 
> the else part is ignored.
> No error is thrown.
> Anybody knows why?

Just a guess: Does your top level production (program or script or some such) end with the  
token EOF?  Bet not....

Without the EOF token at the end of the top level rule, Antlr doesn't need to match the 
whole input.  So, it is happily matching the first part of the input and returning the tree for  
that.




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list