using GCC internal tree representation.

Alexandre E. Kopilovitch aek@vib.usr.pu.ru
Thu Dec 6 06:57:00 GMT 2001


>I am planning to use the gcc to parse my initial file and later walk through the
>internal TREE to dump the output as I need.
>
>I looked at the GCC  manual (TREEs usage), but I am not quite sure how can I
>get access to the internal TREE from my own program any pointers in this regard
>will be appreciated.

If you can build GCC 3.0 then it is quite simple to get access to the tree.
Put the following lines into your module:

void your_program(tree t);
void (*back_end_hook) PARAMS ((tree)) = &your_program;

That your_program starts after the GCC parse phase is completed. GCC calls
your_program automatically as back_end_hook function (from cp/decl2.c/finish_file
function) and passes the syntax tree root to it. No change in the GCC is needed
for the call (linking of that module is sufficient).
  It works for GCC 3.0, but I didn't look into GCC 3.0.1 and 3.0.2 .


Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia





More information about the Gcc mailing list