From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,448990452c132610 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-28 18:58:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!news.maxwell.syr.edu!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!news-in-austin.nuthinbutnews.com!usc.edu!newspeer.cts.com!galanthis.cts.com!127.0.0.1.MISMATCH!not-for-mail Sender: kst@king.cts.com Newsgroups: comp.lang.ada Subject: Re: The making of compilers References: From: Keith Thompson Date: 28 Feb 2002 18:58:14 -0800 Message-ID: X-Newsreader: Gnus v5.7/Emacs 20.7 NNTP-Posting-Host: 209.68.192.180 X-Trace: 1014951494 nntp.cts.com 63545 209.68.192.180 Xref: archiver1.google.com comp.lang.ada:20621 Date: 2002-02-28T18:58:14-08:00 List-Id: "tony gair" 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 San Diego Supercomputer Center <*> Schroedinger does Shakespeare: "To be *and* not to be"