expr : INT (('+'|'-'|'*') INT )*

NEWLINE?;


I'm not sure why your version doesn't work.
Maybe it is a bug with how the interpreter in antlrworks work?


孟岩 wrote:
>
> Hi all,
>
> I am learning ANTLR and just joined this mailing list. I don’t know
> where to submit bugs, is here the right place?
>
> Anyway, I found something unusual in ANTLRWorks. Consider this grammar:
>
> /////////////////////////////////////////
>
> grammar G;
>
> expr : INT (('+' INT {System.out.println("matched +");})
>
> |('-' INT {System.out.println("matched -");})
>
> |('*' INT {System.out.println("matched *");})
>
> )* NEWLINE;
>
> INT : '0'..'9'+;
>
> NEWLINE : '\r'? '\n';
>
> ///////////////////////////////////////
>
> In ANTLRWorks 1.2, put this grammar text in the main editor, switch to
> the “Interpreter” tab view, input “3+2<Enter>” or “3*2<Enter>” and
> click the triangle button, it will show the right tree diagram.
> Nevertheless, the “3-2<Enter>” expression will encounter a wrong
> diagram. I tried several times, and it turns out that the whatever the
> second sub-expression will fail to generate correct tree diagram.
>
> Is it a bug or a feature?
>
> Regards,
>
> Mike Meng
>
> October 22, 2008
>
> ------------------------------------------------------------------------
>
>
> List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
>
>   


List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/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
-~----------~----~----~----~------~----~------~--~---

Reply via email to