[antlr-interest] Use of index attribute in tree gramar
Bernardo Elayda
belayda at gmail.com
Sun Apr 27 15:12:29 PDT 2008
Hi!
Shouldn't this rule which uses the token attribute 'index' result in
compilable code in Java:
expression : ^(p='+' expression expression)
{ $statement::plus.add( $p.token.index); }
| NUMBER
| IDENTIFIER
;
When the above code is compiled with javac , javac complains that index
can't be found. Technically, that's true since 'index' is protected in the
CommonToken class. The workaround to this problem is to use
$p.token.getTokenIndex(). Is that a feature? To be consistant with other
places I've used token attributes, I expected $p.token.index to work.
thx in advance!
-Bernardo Elayda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080427/a78f40eb/attachment.html
More information about the antlr-interest
mailing list