[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
|
RE: [cdt-dev] AST traversal
|
> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Yuan Zhang
> Sent: July 9, 2006 9:36 AM
> To: CDT General developers list.
> Subject: 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?
Write your own visitor class that implements your custom traversal.
Thomas