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
--
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.