public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: using GCC internal tree representation.
@ 2001-12-06  6:57 Alexandre E. Kopilovitch
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre E. Kopilovitch @ 2001-12-06  6:57 UTC (permalink / raw)
  To: gcc; +Cc: goli, goli

>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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* using GCC internal TREE representation.
@ 2001-12-06  6:07 Sri Sairam Goli
  0 siblings, 0 replies; 2+ messages in thread
From: Sri Sairam Goli @ 2001-12-06  6:07 UTC (permalink / raw)
  To: gcc; +Cc: goli

Hi,

In one  of my project I need a tool that parses a c++ file and generates

output which contains all the struct declarations encounetered in the
original c++ file.  If struct contains another struct it needs to be
expanded
there.

Say for example if a have a code like this embedded insode any c++
code.

strcu A {
   int x;
   int y;
};

struct B {
   struct A a;
   int z;
};

I need an output like this for the second struct

struct B {
    struct A {
           int x;
            int y;
     } a;
     int z;
};


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 there is any better way of doing the same thing instead of using the
gcc TREEs
 please suggest me).

Thanks,
goli



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-12-06 14:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-06  6:57 using GCC internal tree representation Alexandre E. Kopilovitch
  -- strict thread matches above, loose matches on Subject: below --
2001-12-06  6:07 using GCC internal TREE representation Sri Sairam Goli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).