Thanks John, that worked.
On Mon, Jul 18, 2011 at 3:52 PM, John B. Brodie <[email protected]> wrote:
> Greetings!
>
> On Mon, 2011-07-18 at 15:35 -0500, Dejas Ninethousand wrote:
> > Hello,
> >
> > If I have the rule:
> >
> > text : t=(UNQUOTED_ALPHA_TEXT | DECIMAL_NUMBER)+ {
> > stack.pushUnquotedText(...); };
> >
> > Is there any way for me to gather the text of all the ALPHA_TEXT and
> > DECIMAL_NUMBER tokens in this production into a single string and shove
> that
> > string as an argument in my action?
> >
>
> Basically accumulate the text into a variable using an action inside the
> (...)+ loop and then push the accumulation. Something like (UNTESTED):
>
> text
> @init{ String str = ""; } :
> ( t=(UNQUOTED_ALPHA_TEXT | DECIMAL_NUMBER) { str+=$t.text; } )+
> { stack.pushUnquotedText(str); }
> ;
>
> Note that the t=(...) only works because all of the stuff inside the
> (...) are Tokens (i think).
>
> Note that any tokens that were put on the HIDDEN channel (or skip();d)
> by the Lexer will not be accumulated/pushed.
>
> Hope this helps...
> -jbb
>
>
>
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.