Mike Lischke | 4 May 2012 10:16
Picon
Favicon

[C-target] AST navigation

Hi Jim,

I'm trying to navigate through my AST using the children of a node and the parent, which seems like an easy task. However, it looks as if the parent pointer isn't maintained properly. I found child nodes of a node that don't have their parent pointer set. I found http://antlr.markmail.org/search/?q=ast%20setparent#query:ast%20setparent+page:1+mid:ykstbb66lqknnvkl+state:results from just a year ago where Dmitri had exactly the same problem as I face now, but this was never solved.

To clarify: the getParent() call is done *after* the parsing completed successfully. I have my AST and am searching for specific nodes in it. Unless I'm missing something important I'd say the parent handling is definitely broken in addChild (pANTLR3_BASE_TREE), because the parent is not set properly. Additionally, setParent (pANTLR3_BASE_TREE) still sets the parent of the parent as new parent in the child node, which makes no sense at all.

<div>Hi Jim,<div><br></div>
<div>I'm trying to navigate through my AST using the children of a node and the parent, which seems like an easy task. However, it looks as if the parent pointer isn't maintained properly. I found child nodes of a node that don't have their parent pointer set. I found&nbsp;<a href="http://antlr.markmail.org/search/?q=ast%20setparent#query:ast%20setparent+page:1+mid:ykstbb66lqknnvkl+state:results">http://antlr.markmail.org/search/?q=ast%20setparent#query:ast%20setparent+page:1+mid:ykstbb66lqknnvkl+state:results</a> from just a year ago where Dmitri had exactly the same problem as I face now, but this was never solved.</div>
<div><br></div>
<div>To clarify: the getParent() call is done *after* the parsing completed successfully. I have my AST and am searching for specific nodes in it. Unless I'm missing something important I'd say the parent handling is definitely broken in addChild (<span class="Apple-style-span">pANTLR3_BASE_TREE</span>), because the parent is not set properly. Additionally, setParent (<span class="Apple-style-span">pANTLR3_BASE_TREE</span>) still sets the parent of the parent as new parent in the child node, which makes no sense at all.</div>
<div><br></div>
<div>
<div apple-content-edited="true">
Mike<br>--&nbsp;<br><a href="http://www.soft-gems.net">www.soft-gems.net</a><br>
</div>

<br>
</div>
</div>

Gmane