[antlr-interest] Question about tree grammar (antlr 3)
Terence Parr
parrt at cs.usfca.edu
Tue Jul 4 08:51:13 PDT 2006
On Jul 4, 2006, at 7:34 AM, Jose Ventura wrote:
> I have this rule in a tree grammar (antlr 3)
>
> setDir : ^('dir' LITERAL )
>
> I need to invoke a method with the LITERAL token text, I use this rule
>
> setDir : ^('dir' LITERAL {s.setDirIn(((Tree)$LITERAL).getText());})
>
> Do somebody know one better, without cast?
You can try setting ASTLabelType as a grammar option or more simply
do this:
setDir : ^('dir' LITERAL {s.setDirIn($LITERAL.text);}) ;
:)
Ter
More information about the antlr-interest
mailing list