From: Ed Davis Newsgroups: alt.folklore.computers Subject: Small Self-Compiling Compilers (C/Pascal like) Date: Fri, 10 Nov 2000 16:40:52 GMT Organization: Deja.com - Before you buy. Lines: 34 Message-ID: <8uh8ei$6t7$1@nnrp1.deja.com> NNTP-Posting-Host: 206.65.52.171 X-Article-Creation-Date: Fri Nov 10 16:40:52 2000 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98) X-Http-Proxy: 1.1 x55.deja.com:80 (Squid/1.1.22) for client 206.65.52.171 X-MyDeja-Info: XMYDJUIDed_davis Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!machtgarnix.switch.ch!news-ge.switch.ch!bignews.mediaways.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!xfer13.netnews.com!netnews.com!cpk-news-hub1.bbnplanet.com!news.gtei.net!nntp2.deja.com!nnrp1.deja.com!not-for-mail Xref: chonsp.franklin.ch alt.folklore.computers:67960 What are the smallest C/Pascal-family self-compiling compilers that you have seen? I saw a C subset compiler - supported int and char, and arrays of same, if-else, while, do, and functions with parameters, two builtin 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 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 Cains' 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 of course makes a difference. 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. Of course one could dispense with functions with parameters, but relying on global variables makes the compiler quite ugly and somewhat harder to follow! Sent via Deja.com http://www.deja.com/ Before you buy.