[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cdt-dev] AST traversal
- From: Thomas Fletcher <ThomasF@xxxxxxx>
- Date: Wed, 19 Jul 2006 17:18:59 -0400
- Delivered-to: firstname.lastname@example.org
> -----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.