[antlr-interest] accessing the current node

mzukowski at bco.com mzukowski at bco.com
Tue Feb 19 08:39:05 PST 2002


Use a label.

 declaration
     { MyNode aNode = new MyNode(); }
     :
      #( decl:DeclarationNode
             declaration[aNode]
             statementBlock
        )
     { aNode.addASTNode(decl);
       someDataStructure.add(aNode);
     }

Monty

> -----Original Message-----
> From: Greg Smolyn [mailto:smolyn at cs.ubc.ca]
> Sent: Saturday, February 16, 2002 1:42 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] accessing the current node
> 
> 
> Hi,
> 
> I'm making a tree grammar right now, and I'm coming upon a simple
> problem.
> 
> The names have been changed, but the problems are real. :)
> 
> What I'm trying to do is take a set of nodes in a tree  and (a) save a
> reference to the node and (b) glean some info to put into that same
> structure.
> 
> ie.
> 
> declaration
>     { MyNode aNode = new MyNode(); }
>     :
>      #( DeclarationNode
>             declaration[aNode]
>             statementBlock
>        )
>     { aNode.addASTNode(***this_node***);
>       someDataStructure.add(aNode);
>     }
> 
> basically I'm just converting this node into some other node 
> type (with a
> slightly easier to understand data structure).  How can I add 
> the node at
> the current rule?  buildAST=false, so ## isn't really an option.
> 
> Any suggestions?
> Thanks!
> 
> ---
> Greg Smolyn (smolyn at cs.ubc.ca)
> Staff Researcher
> Software Practices Lab, UBC
> 
> 
> 
> 
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 



 

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



More information about the antlr-interest mailing list