parent pointers in AST nodes

eliben <eliben@gmail.com>
Fri, 27 Nov 2009 05:32:11 -0800 (PST)

          From comp.compilers

Related articles
parent pointers in AST nodes eliben@gmail.com (eliben) (2009-11-27)
Re: parent pointers in AST nodes bobduff@shell01.TheWorld.com (Robert A Duff) (2009-11-27)
Re: parent pointers in AST nodes zaimoni@zaimoni.com (Kenneth 'Bessarion' Boyd) (2009-11-27)
Re: parent pointers in AST nodes idbaxter@semdesigns.com (Ira Baxter) (2009-11-27)
Re: parent pointers in AST nodes DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-28)
Re: parent pointers in AST nodes bartc@freeuk.com (bartc) (2009-11-30)
Re: parent pointers in AST nodes torbenm@diku.dk (2009-11-30)
[3 later articles]
| List of all articles for this month |
From: eliben <eliben@gmail.com>
Newsgroups: comp.compilers
Date: Fri, 27 Nov 2009 05:32:11 -0800 (PST)
Organization: Compilers Central
Keywords: AST, code, question
Posted-Date: 27 Nov 2009 11:42:07 EST

Hello,


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?


In favor:
* This can simplify some AST processing tasks, especially when using
the visitor pattern - we may get to an interesting node and then need
to look at its ancestors to do the required analysis.


Against:
* Maintaining parent nodes makes the AST creation code more complex
* Wastes space (another pointer for each node)


What are your thoughts?


Thanks in advance,
Eli



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.