[antlr-interest] Re: Modification of Node Attributes using Tree Grammar
jsrs701
jsrs701 at yahoo.com
Thu Jun 13 09:55:24 PDT 2002
--- In antlr-interest at y..., "Niall Gormley" <ngormley at h...> wrote:
> Hi,
>
> Is it possible to use a Tree Grammar to modify Node attributes?
>
> The node "i" is getting modified buy the call to "setVariantType"
but I
> can't seem to get it copied to the output AST for the dims
expression. So
> the real question might be, how can I get source node "i" to end up
in the
> output expression?
>
> dims!
> : #( LITERAL_DIM i:IDENT )
> {
> i.setVariantType(0);
> #dims = #( #[LITERAL_DIM], #(i));
> }
> ;
>
That's odd. I pull this stunt all the time. The only thing i can
think of is to remove the parens in the expression #(i), and just
leave it as #i.
#dims = #( [LITERAL_DIM], #i );
(I usually eschew the optional # in the [type] expressions, too.)
That should work like a charm.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list