|preprocessing C++ with new features email@example.com (Lorenzo Bettini) (2003-03-30)|
|Re: preprocessing C++ with new features firstname.lastname@example.org (2003-03-30)|
|Re: preprocessing C++ with new features email@example.com (Ira Baxter) (2003-03-30)|
|Re: preprocessing C++ with new features Nicola.Musatti@ObjectWay.it (2003-03-31)|
|Re: preprocessing C++ with new features firstname.lastname@example.org (2003-04-13)|
|Re: preprocessing C++ with new features email@example.com (Lorenzo Bettini) (2003-04-15)|
|Re: preprocessing C++ with new features Thomas.Aigner@bfd-r.bayern.de (Thomas Aigner) (2003-05-23)|
|From:||firstname.lastname@example.org (Paolo Bonzini)|
|Date:||13 Apr 2003 12:38:50 -0400|
|Posted-Date:||13 Apr 2003 12:38:50 EDT|
> I would like to add some new features to C++ and so I'd need mechanisms
> for preprocessing C++ code in order to handle only the new features and
> thus to generate new (translated) C++ code.
> Are there any tools for helping me do this (apart from Open C++)?
Flex and Bison can be used; you can have the lexer output the generic
C++ code and pass the new features to Bison. If you can be sure that
the new keywords are not used as variable names and the like (which
you should be unless you want to write PL/1...) it is very easy.
I used this approach in GNU Smalltalk where I have a primitive
definitions file that's something like
prim_id VMpr_Float_plus [succeed],
prim_id VMpr_Float_minus [succeed],
prim_id VMpr_Float_divide [succeed,fail],
case prim_id (VMpr_Float_plus): ...
The 'primitive' declaration is turned into a prototype, the
declaration of an array (with the attributes that were specified into
square brackets) and the routine with the body. The 'prim_id'
expressions in the routine are turned into numbers (-1, -2, -3, ...)
You can find it in ftp://alpha.gnu.org/gnu/smalltalk-2.1-pre.tar.gz
Hope this helps,
Return to the
Search the comp.compilers archives again.