[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] AST traversal
|
The current ASTNode.accept() method first visit the current node, then visit its children. What I need is to visit Children first, collect some information from them, and feedback to their parent. This traversal is bottom-up because leaves nodes are visted before the root node. This can be achieved by calling, say
ASTVisitor.leave(), upon leaving the ASTNode.accept(). But I am afraid all subclasses of ASTVisitor have to be changed. So I am wondering whether I can implement this bottom-up traversal in some other way without changing the current code?
Thanks,
Yuan
On 7/8/06, Doug Schaefer <DSchaefer@xxxxxxx> wrote:
Not sure what you mean by bottom up. Certainly you can navigate from a child node to its parent by following the getParent links. You can also tell what property you are in the parent by looking at getPropertyInParent. Not sure what else you would need.
I noticed that ASTNode.accept() and ASTVisitor.visit() together provide a top-down traversal of the AST. I am wondering whether there is a way to traverse the AST from bottom-up without modifying the current code? I have thought to associate each node a "property", and during the traversal change the parent node's property of the currently visited node. However, I cannot find any appropriate place to store this "property". Anybody can give me some hint?
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev