home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.compilers      Compiler construction, theory, etc. (Mod      2,753 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,772 of 2,753   
   Hans-Peter Diettrich to eliben   
   Re: parent pointers in AST nodes   
   28 Nov 09 01:57:14   
   
   From: DrDiettrich1@aol.com   
      
   eliben schrieb:   
      
   > When implementing an AST for some language, each AST node typically   
   > holds information about the language construct it represents and   
   > pointers to children nodes (such as a binary op node pointing to its   
   > left-hand and right-hand operands).   
   >   
   > Is it common / useful to supply a pointer to the node's parent as   
   > well?   
      
   It depends on your later usage of the AST. Tree transformations may need   
   the parent node of an subtree.   
      
   When all child nodes are kept in an array, that array may have a   
   reference to its owning (parent) node. Or a sentinel (dummy node) may be   
   added to every child list, referring to the parent node. In the latter   
   model no bidirectional node links are required, since parent, children   
   and sentinel reside in a closed loop.   
      
   DoDi   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca