[antlr-interest] Template Rewrite Rule consumes one more Token than expected

Thomas Karcher thkarcher at gmx.de
Mon Apr 21 06:18:47 PDT 2008


Hi Felix,

> a * b; \n
> returns "where's the semicolon?", i.e. the trailing semicolon is eaten 
> up too...

What do you expect?

> grammar Test;
> statement
>     :    expression ';'!

The "!" at the end prevents the construction of a ";" node in the
resulting AST, so ...

> tree grammar TestTree;
> expression
>     :    ^('*' ID ID)
>             -> template(text={"where's the semicolon?"}) "<text>"

... doesn't expect any ";" node in the AST ... your example does exactly
what I hope it should do :)
Where do you see the problem?


Thomas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080421/6f39cb4e/attachment.bin 


More information about the antlr-interest mailing list