[antlr-interest] Newbie: Is it an ANTLRWorks bug or a feature?

Heinrich du Toit heinrich at silasvalley.com
Thu Oct 23 01:16:34 PDT 2008


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/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>   



More information about the antlr-interest mailing list