Re: Source to Source Compiler?

mac@coos.dartmouth.edu (Alex Colvin)
13 May 1996 14:30:33 -0400

          From comp.compilers

Related articles
Source to Source Compiler? Christoph.Niedermeier@zfe.siemens.de (1996-05-10)
Re: Source to Source Compiler? derek@knosof.co.uk (Derek M Jones) (1996-05-13)
Re: Source to Source Compiler? mac@coos.dartmouth.edu (1996-05-13)
Re: Source to Source Compiler? pdonovan@netcom.com (1996-05-14)
Re: Source to Source Compiler? kalle@poet.de (Dr. Karl Prott) (1996-05-14)
Re: Source to Source Compiler? ndc@icanect.net (Norman Culver) (1996-05-19)
Re: Source to Source Compiler? grosch@cocolab.sub.com (1996-05-19)
| List of all articles for this month |

From: mac@coos.dartmouth.edu (Alex Colvin)
Newsgroups: comp.compilers
Date: 13 May 1996 14:30:33 -0400
Organization: Dartmouth College, Hanover, NH, USA
References: 96-05-077
Keywords: translator, C

Christoph.Niedermeier@zfe.siemens.de (Christoph Niedermeier) writes:


>We are intending to build a frontend compiler which translates ANSI C
>plus our own extensions to pure ANSI C. Our idea is to use the sources
>of the GNU C-Compiler and modify them such that C code is produced
>instead of assembler code.


I'm doing this for a C* to C translator. I agree that taking a real
compiler is probably not the way to go. C makes a lousy machine
language to emit, and too much useful information is lost.


What I do is turn the C source into a parse tree, then do tree
transforms on it. This is hard or easy depending on the nature of the
transforms. I annotate tree nodes with various information - the
declaration node for each variable reference, the type for
expressions, as well as bits for const, lvalue, etc.


One useful attribute is a bit marking subtrees that contain
nonstandard features. Anything not so marked is left alone. Types
keep their C structure, so generating a declaration for a temporary is
pretty straightforward.


Since this is essentially a C parse tree, the back end is just a table
of formats for printing.


My work started with the UNH C* to C compiler. You can probably also
have my work-in-progress, in C++.
:
--
Alex Colvin
alex.colvin@dartmouth.edu
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.