minimal c/pascal self-compiling compilers

Ed Davis <>
6 Dec 2000 00:12:15 -0500

          From comp.compilers

Related articles
minimal c/pascal self-compiling compilers (Ed Davis) (2000-12-06)
Re: minimal c/pascal self-compiling compilers (Nils M Holm) (2000-12-07)
Re: minimal c/pascal self-compiling compilers (Franck Pissotte) (2000-12-08)
Re: minimal c/pascal self-compiling compilers (Franck Pissotte) (2000-12-18)
| List of all articles for this month |

From: Ed Davis <>
Newsgroups: comp.compilers
Date: 6 Dec 2000 00:12:15 -0500
Organization: - Before you buy.
Keywords: C, Pascal
Posted-Date: 06 Dec 2000 00:12:14 EST

What are the smallest C/Pascal-family self-compiling compilers that
you have seen?

Obfuscated C is a self-compiling C subset compiler - supported int and
char, and arrays of same, if-else, while, do, and functions with
parameters, two built-in functions, getchar/putchar - that produced
code for a virtual machine.

With one statement per line, all comments and {} characters removed,
and resulting blank lines removed, it was 451 lines. And if I
remember correctly, it (the non obfuscated version!) was quite well
written, and not too hard to follow. More complicated than the famous
PL/0, but not too much more!

For comparison, Ron Cain's original (or what purports to be) small c,
is 1662 lines. Version 2.2 (rewritten by J.E. Hendrix) is 2164 lines.

The creation of code for a real vs. a virtual machine makes a big
difference, of course.

The smallest self-compiling Pascal compiler I have seen is the P4
compiler, but it is a full Pascal compiler, and so is much larger than
the C compilers already mentioned.

Surely someone has written a Pascal-S subset or PL/0-extended that
compiles itself?

From my remembrances of the C subset compiler mentioned above, it
seems that it included just about the bare essentials needed to write
a self- compiling compiler. One could dispense with functions with
parameters, but relying on global variables makes the compiler quite
ugly and somewhat harder to follow!

Any other small, self-compiling, C or Pascal like compilers out there?

Post a followup to this message

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