Hi Joe, this looks like a bug to me!! yikes. You are correct that you should
see only one copy of the tree returned by option for each iteration of the tree
constructor in search. grr! ok, I will add a bug. Can you do me a favor and
look at the generated code for -> ^(GROUP c option)+?? It might tell you
something that will help me fix the bug and also a way for you to get around.
Thanks!
T
On Feb 23, 2010, at 11:40 AM, [email protected] wrote:
> I'm having some trouble understanding the behavior of AST rewrite rule
> element cardinality in certain cases. Consider the following grammar:
>
> grammar Test;
>
> options {
> output=AST;
> }
>
> tokens {
> GROUP;
> FOO;
> BAR;
> BAZ;
> }
>
> search
> : c (SPACE option)+ -> ^(GROUP c option)+
> ;
>
> c
> : C -> FOO BAR
> ;
>
> option
> : (A | B) -> BAZ
> ;
>
> A : 'a';
> B : 'b';
> C : 'c';
> SPACE : ' ';
>
> If we feed the parser the input string: "c a b a", I'm expecting to see the
> following AST:
>
> (GROUP FOO BAR BAZ) (GROUP FOO BAR BAZ) (GROUP FOO BAR BAZ)
>
> but instead, I get the following:
>
> (GROUP FOO BAR BAZ) (GROUP FOO BAR BAZ BAZ) (GROUP FOO BAR BAZ BAZ)
>
> Notice the extra BAZ in each child after the first? Can someone explain why
> this is happening? I'm using ANTLR 3.2 with the java target.
>
> Thanks
>
> - Joe
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/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.