Re: parent pointers in AST nodes

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Sat, 28 Nov 2009 01:57:14 +0100

          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)
Re: parent pointers in AST nodes kkylheku@gmail.com (Kaz Kylheku) (2009-12-01)
Re: parent pointers in AST nodes quinn_jackson2004@yahoo.ca (Quinn Tyler Jackson) (2009-12-01)
Re: parent pointers in AST nodes mwso@earthlink.net (Gary Oblock) (2009-12-14)
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Sat, 28 Nov 2009 01:57:14 +0100
Organization: Compilers Central
References: 09-11-060
Keywords: AST
Posted-Date: 29 Nov 2009 00:37:25 EST

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



Post a followup to this message

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