[antlr-interest] is an id required to access the root text?

Monty Zukowski monty at codetransform.com
Wed Sep 22 09:44:47 PDT 2004


On Sep 22, 2004, at 9:36 AM, kozchris wrote:

>
> Say I have some grammer like this (assume strings for vars):
>
> #(pl:PLUS left=expr right=expr) {out= left + pl->getText() + right;}
> |#(mi:MINUS left=expr right=expr) {out= left + mi->getText() + right;}
>
> Is there a way to access the root text so that I can do something like
> this without having to assign an id to each root:
>
> (#(PLUS left=expr right=expr)
> |#(MINUS left=expr right=expr)) {out= left + CURRENT_ROOT->getText() +
> right;}
>
> Thanks for the help,
> Chris
>
>

## is a shorthand for the root node of a rule.  Another shorthand is 
#ruleName.  That should do it.

Monty



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list