[antlr-interest] bug or strange behaviour in rewrite operator ?

Jim Idle jimi at temporal-wave.com
Thu Jun 14 07:22:59 PDT 2007



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Alessandro


> I have also another problem with this rule : ( I replaced
> "stream_prog" with "stream_retval" because of the bug quoted above)
> 
> prog:
>        ((func  | (decvar SEMI)) -> $prog? func? decvar? )*
>        -> ^(PROG_DEC $prog?);
> 
> This rule always catch the first result of "func" and "decvar" because
> the generated code includes stream_func.reset() and
> stream_decvar.reset().

What are you trying to produce with this rule? Assuming that it is the
whole rule, you effectively have an empty rule sometimes and then are
trying to write two trees. Basically this just does not look correct. I
would strongly recommend the book, but it looks like you need to put
your rewrite rules after func and decvar SEMI respectively and maybe
move the * qualifier up one rule to  something: prog* ;


Jim



More information about the antlr-interest mailing list