[antlr-interest] Why $rule.text does not get the whole rule text ?

Amr Muhammad amr.muhammad.w at gmail.com
Wed Nov 10 06:05:26 PST 2010


Hello,

Let's say, I have the following grammar:

rule1: key = value
          -> ^(RULE1_TOKEN  value)

value:  signed_int
           | ......

signed_int:   ('+' | '-') ? INT
               ;

in the tree grammar,
i do the following

rule1: ^(RULE1_TOKEN  value)
{
     char* temp = value.text->chars;
}


but in the case of value is signed_int, temp only contains the  + or - sign,
but not the INT part,
and this also happens for any alternative of value in which the rule is
composed of more than one token

So, i was wondering why does this happen, and how to get the whole text
matched for the rule?

Thank you for your time :)

Amr Muhammad
Cairo Univ. Computer Eng. Grad.
twitter:@amrmuhammad <http://twitter.com/amrmuhammad>


More information about the antlr-interest mailing list