comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@cts.com>
Subject: Re: The making of compilers
Date: 28 Feb 2002 18:58:14 -0800
Date: 2002-02-28T18:58:14-08:00	[thread overview]
Message-ID: <yecelj5c7uh.fsf@king.cts.com> (raw)
In-Reply-To: a5btuv$f62$1@knossos.btinternet.com

"tony gair" <tonygair@nespamtome.btinternet.com> writes:
> After sticking my neck out and being shot out out of the sky by the big
> guns.....................................
> 
> I heard from a lecturer in 1990 that compilers were built by writing a
> language subset compiler in assembler (or C or C++ or.....) and then by
> using that subset to step by step extend the language to its desired form.

That's a pretty common approach.  These days, though, there's almost
never any need to start with assembler; it's far easier to start with
a higher-level language.

The first-generation TeleSoft Ada subset compiler, which I used to
work on, was written in Pascal.  The version of Pascal we used was
derived from UCSD Pascal.  (The Pascal compiler compiled itself, and
had done so for several generations of development; I don't know how
it was first bootstrapped.)

Once the first-generation subset compiler was sufficiently reliable
and supported enough features, the second-generation compiler was
written in the Ada subset supported by the first-generation compiler.
After a while, the second-generation compiler was expanded to support
all the features supported by the first-generation compiler.  At that
point, we started using the second-generation compiler to compile
itself, and pretty much abandoned both the first-generation Ada subset
compiler and the Pascal compiler.  The hosting compiler was usually a
few generations behind the product compiler, and was updated less
often.

Note that a compiler doesn't necessarily have to be self-hosting;
there are advantages and disadvantages.  One advantage is that you
only have one language to support, and if you run across a bug in the
hosting compiler, you can probably fix it yourself.  Also, increases
in the speed of the generated code result in faster compilation speed
as soon as you change hosting compilers.

On the other hand, the language you're implementing may not be a good
one for implementing compilers.  You could write a Fortran compiler in
Fortran (I'm sure it's been done), but personally I'd rather use Ada
or some other more suitable systems language.  It *may* be possible to
create an Intercal implementation in Intercal, but it's certainly not
a sane idea.  (I would have thought that Cobol was a poor language for
implementing a compiler, but Robert Dewar and others apparently did
just that with Realia Cobol.)

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"



  parent reply	other threads:[~2002-03-01  2:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-24 23:45 The making of compilers tony gair
2002-02-25 12:53 ` Marc A. Criley
2002-02-25 14:55 ` Robert Dewar
2002-02-27  1:16   ` Adrian Hoe
2002-02-27 17:46     ` Jeffrey Carter
2002-03-01  5:00       ` Robert Dewar
2002-03-01 17:33         ` Jeffrey Carter
2002-03-01 19:03           ` Florian Weimer
2002-02-26  1:05 ` Nick Roberts
2002-02-26  2:22   ` GVD for Mac OS X? Michael Card
2002-02-26  4:52     ` jim
2002-02-26 15:16   ` The making of compilers tony gair
2002-02-26 15:33     ` Hyman Rosen
2002-02-28 22:09     ` Nick Roberts
2002-02-28 22:14       ` Pat Rogers
2002-03-01  5:02     ` Robert Dewar
2002-03-01  8:25       ` tony gair
2002-03-01  2:58 ` Keith Thompson [this message]
2002-03-01  5:35   ` OT, was " tmoran
2002-03-01 19:35   ` Robert Dewar
2002-03-01 21:15     ` Keith Thompson
2002-03-02  0:50     ` John H. Lindsay
2002-03-02  1:13     ` Adrian Hoe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox