[cfe-dev] Back-navigation of the Syntax Tree!

steve naroff snaroff at apple.com
Thu Jan 29 08:03:43 PST 2009


Hi Simone,

Check out ParentMap (and it's various clients).

snaroff

On Jan 29, 2009, at 10:55 AM, Simone Pellegrini wrote:

> Dear all,
> I need to make some kind of manipulation of a syntax tree in Clang.
>
> Actually what I want to do is just move some statement (mainly the
> entire line... until the ';' which enclose a statement I want to  
> move).
> Apparently this kind of work is more complex than what I thought.
>
> At the beginning I perform a simple data-flow analysis to determine  
> the
> positions where the statement can be placed (and that's is quite
> trivial). It can be easily done by using a visitor of the AST, but for
> example when I found, let's say a DeclRefExpr I'd like to have the
> possibility to access to the statement that encloses the var  
> reference.
> Practically, what I need is the possibility from a statement to access
> to the PARENT! I know that I can manually save a reference to the  
> parent
> node before entering into a node and that will solve my problem but it
> is ugly! :) Is this possible with the current API to access the parent
> of a node? I searched a lot and there is no way to get this  
> information.
>
> regards Simone
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list