Fwd: [antlr-interest] Question about tree grammar (antlr 3)
Jose Ventura
jose.ventura.roda at gmail.com
Wed Jul 5 00:31:18 PDT 2006
Hi Terence,
I have added "ASTLabelType=CommonTree" and then I can use $LITERAL.text
Thank's a lot.
José Ventura.
---------- Forwarded message ----------
From: Terence Parr <parrt at cs.usfca.edu>
Date: Jul 4, 2006 5:51 PM
Subject: Re: [antlr-interest] Question about tree grammar (antlr 3)
To: ANTLR Interest <antlr-interest at antlr.org>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060705/1bed7936/attachment.html
More information about the antlr-interest
mailing list