[antlr-interest] Modification of Node Attributes using Tree Grammar

Terence Parr parrt at jguru.com
Thu Jun 13 11:32:07 PDT 2002


On Thursday, June 13, 2002, at 09:40  AM, Niall Gormley 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));
>     }
>   ;

Howdy.  i points to the output node created from IDENT so you it seems 
you are setting the proper variable.  #(i) is very strange though.  What 
do you mean here?  #i or i works, but #(i) is a long way to say make i 
the root of a tree with only one  node: i.  That may be something for 
which the code gen is broken.  Try removing the #(...) around the i and 
see what happens.  Let me know if this is a bug and I'll add to the 
list.  Loring may already have found this ;)

Ter


 

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



More information about the antlr-interest mailing list