help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ compiler


From: Pascal Bourguignon
Subject: Re: g++ compiler
Date: Sat, 08 Oct 2005 17:26:37 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Pascal Bourguignon <spam@mouse-potato.com> writes:

> Paul Pluzhnikov <ppluzhnikov-nsp@charter.net> writes:
>
>> ganeshb@gmail.com writes:
>>
>>> I am planning to write a source to source (C++ to C++) translator. The
>>> translator's job is to parse the C++ program augemented with some
>>> annotations (not part of C++ standard) and produce a standard C++ code.
>>> The annotations are written in the form of comments (/* ...*/). Will
>>> g++ be ideal for this project? 
>>
>> G++ is quite unlikely to be "ideal" for this: AFAIK it lacks the
>> machinery to print (reconstruct) internal representation back as
>> valid C++. Such reconstructor is entirely non-trivial.
>
> Wrong: gccxml

Oops, sorry, gccxml only does the declarations, not the bodies.
But you don't need it, just use -fdump-tree-original:

g++ -c -fdump-tree-original test-body.c

Unfortunately this doesn't dump comments that are deleted soon from
the source.  However, you could define a dummy function:

             void comment(char*){}
and write:   comment("Do something");
instead of:  /* Do Something */


Another  thing, is that the syntactic tree is dumped after the cpp
phase, so you lose all #include and #define along with normal
comments.  If you want to keep them, either you'll have to merge the
code substituted in the source file (note that the syntactic tree
contains file and line anotations), or you'll need to hack inside g++
sources.  Modifying the front-end of g++ (adding an alternate
front-end) would provide the opportunity to define a normal language
extension instead of puting it comments (add keywords and syntax).

You may also have a look at: http://gcc.gnu.org/projects/tree-ssa/

>> Also, depending on what the annotations are to be transformed into,
>> you may have much easier time with text-processing languages,
>> such as Perl.
>
> LOL
>
>
>>> How long does it take to master g++?
>>
>> I doubt anyone can "master" g++ in less then 2 years.
>> But then what you mean by "master" may be very different from what
>> I mean by that.
>
> You don't need to enter the entrails of g++.
>
>
>>> Duration of the project is 1 month.  
>>
>> Well, if you are a genius, you might be able to complete this
>> project in a month using g++. But I doubt both the antecedent
>> and the consequent :(
>
> It can be done in one week, with the right tools.

-- 
"A TRUE Klingon warrior does not comment his code!"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]