|Making my first compiler firstname.lastname@example.org (2006-09-16)|
|Re: Making my first compiler email@example.com (Pascal Bourguignon) (2006-09-18)|
|Re: Making my first compiler firstname.lastname@example.org (Tommy Thorn) (2006-09-18)|
|Re: Making my first compiler email@example.com (firstname.lastname@example.org) (2006-09-18)|
|Re: Making my first compiler email@example.com (2006-09-18)|
|Re: Making my first compiler firstname.lastname@example.org (Jeff Kenton) (2006-09-25)|
|Re: Making my first compiler email@example.com (Peter \Firefly\Lund) (2006-09-25)|
|Re: Making my first compiler firstname.lastname@example.org (Stefan Monnier) (2006-11-23)|
|Re: Making my first compiler ValdoFerrari@libero.it (Valdo Ferrari) (2006-11-24)|
|Re: Making my first compiler email@example.com (2006-11-27)|
|Re: Making my first compiler firstname.lastname@example.org (John) (2006-11-29)|
|Re: Making my first compiler email@example.com (2006-11-29)|
|Re: Making my first compiler firstname.lastname@example.org (Matthias Blume) (2006-11-29)|
|[4 later articles]|
|From:||"Peter \"Firefly\" Lund" <email@example.com>|
|Date:||25 Sep 2006 01:15:21 -0400|
|Organization:||Department of Computer Science, University of Copenhagen|
On Mon, 18 Sep 2006, [iso-8859-1] Torben Ęgidius Mogensen wrote:
> You can generate code directly, most compilers pre 1990 did that. It
> makes it a bit harder to optimize code, but for simple code it will
> work, especially if you output textual assembler (with labels), so you
> don't have to worry about back-patching branch targets.
I can really recommend direct code generation. It is very easy to get
the compiler off the ground that way.
Don't worry about register allocation, either. Just treat the machine
as a stack machine where the top-most element is (usually) in a
With some extra work one can end up with code that is quite good --
that's what Borland's Pascal/Delphi compilers used to do.
> Going through three-address code seems like taking a detour. Most
> constructs in Pascal can be directly translated into source-level
> constructs in C. The main problems would be nested function
> declarations and functions as parameters, but you can handle these
> with lambda lifting (discussed here recently).
Or you can use the gcc extension for nested functions. Yes, you can even
take the address of such functions and pass them as parameters. And they
will still be able to access the correct local variables/parameters in
their enclosing scopes.
Gcc has supported them since 1988 or thereabouts.
> > So my steps would be:
> 1. Build syntax tree
> 2. Do lambda lifting
> 3. Emit C.
And mine would be:
1. a loop that reads pascal code and emits C code.
Return to the
Search the comp.compilers archives again.