For Programmers: Free Programming Magazines  


Home > Archive > Compilers > September 2004 > AST capture in gcc









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author AST capture in gcc
Gregory Seront

2004-09-14, 8:58 pm

Hello,

I need to capture an intermediate representation for C++ in order to
take measurements on the code.
I was thinking of hacking gcc in order to capture the abstract
synthatic tree (AST) it is building.
So I was asking myself:

1) do gcc produce an AST?
2) can I capture it?


thanks in advance for your replies,

Gregory Seront
Steven Bosscher

2004-09-22, 3:59 am

gs@cetic.be (Gregory Seront) wrote in message news:<04-09-099@comp.compilers>...
> Hello,
>
> I need to capture an intermediate representation for C++ in order to
> take measurements on the code.
> I was thinking of hacking gcc in order to capture the abstract
> synthatic tree (AST) it is building.
> So I was asking myself:
>
> 1) do gcc produce an AST?
> 2) can I capture it?


1) From GCC 4.0 (ie. CVS HEAD) onwards, yes it does.
2) Yes you can, GCC has options to dump the AST after
every optimization pass.

Whether the dump is good enough for you depends on what measurements
you want to do. The dumps are not self contained nor compilable.

Gr.
Steven
George Huber

2004-09-22, 3:59 am

On Tue, 14 Sep 2004 16:37:12 -0400, Gregory Seront wrote:

Gregory wrote:

[snip]
>
> 1) do gcc produce an AST?

yes it does.

> 2) can I capture it?

yes you can. Take a look at the man page for gcc especially
the following flags:

-fdump-translation-unit
-fdump-tree-switch

Hope this helps,
George
Joan Pujol

2004-09-22, 3:59 am

Hello,

ANTLR (www.antlr.org) is a compilers tool that constructs AST.
And a c++ grammar is available to download.
ANTLR constucts descendent parsers and can generate code for JAva,C++ and C#

Possibly it can helps you.

Cheers,


On 14 Sep 2004 16:37:12 -0400, Gregory Seront <gs@cetic.be> wrote:
> Hello,
>
> I need to capture an intermediate representation for C++ in order to
> take measurements on the code.

--
Joan Jesús Pujol Espinar
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com