From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11907 invoked by alias); 6 Dec 2001 14:29:39 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 11883 invoked from network); 6 Dec 2001 14:29:36 -0000 Received: from unknown (HELO wg.pu.ru) (193.124.85.219) by sources.redhat.com with SMTP; 6 Dec 2001 14:29:36 -0000 Received: from vib.UUCP (uucp@localhost) by wg.pu.ru (8.9.1a/8.9.1) with UUCP id OAA13622; Thu, 6 Dec 2001 14:29:33 GMT Received: by vib.usr.pu.ru (UUPC/@ v7.00, 07Jan97) id AA02922; Thu, 6 Dec 2001 17:34:32 +0300 (MSK) To: gcc@gcc.gnu.org Cc: goli@lucent.com, goli@optonline.net Message-Id: Organization: h w c employees, b f From: "Alexandre E. Kopilovitch" Date: Thu, 06 Dec 2001 06:57:00 -0000 X-Mailer: Mail/@ [v2.44 MSDOS] Subject: Re: using GCC internal tree representation. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2001-12/txt/msg00280.txt.bz2 >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