4 ms·
Graydon Hoare's "One-Day Compilers" (http://www.venge.net/graydon/talks/mkc/html/mgp00001.html http://www.venge.net/graydon/talks/mkc/html/mgp00001.html) presen
by silentbicycle 18y ago
Graydon Hoare's "One-Day Compilers" (http://www.venge.net/graydon/talks/mkc/html/mgp00001.html http://www.venge.net/graydon/talks/mkc/html/mgp00001.html) presentation is worth a look. It uses OCaml to build a compiler for basic makefiles (using C as an intermediate language).
Kragen Sitaker has a great collection of links for amateur compiler writers on his Ur-Scheme (http://www.canonical.org/~kragen/sw/urscheme/ http://www.canonical.org/~kragen/sw/urscheme/) page.
This paper (http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf) by Abdulaziz Ghuloum is also very interesting - he shows step-by-step how to write a simple native-code Scheme-like compiler by writing small C functions, compiling them with gcc, and then saving the assembly output. ("Since we don’t know yet how to do that,
we ask for some help from another compiler that does know: gcc.") Heavy theory about optimizing? Nope. Demystifying and inspiring? Heck yeah.
- gjm11 18y agoUm, that's not what the paper does at all. There's exactly one invocation of gcc in the whole paper, and its only point is to enable the (human) developer to see what the calling convention for a function should look like. A couple of sentences after the one you quote we get: "Let's compile it using gcc [...] Generating this file from Scheme is straightforward." and then comes the very first compiler in the incrementally-improving series, which accepts a small integer and outputs assembler code for a function that returns that integer as its value.
- silentbicycle 18y agoRight. He uses grabbing assembly output from gcc to demystify the process. (I guess I worded that poorly.)
- kragen 18y agoThanks! I'm glad my page was helpful. I'm working on a much simpler compiler than Ur-Scheme now. I call it StoneKnifeForth.
- silentbicycle 18y agoDude! Keep me posted. :)
- kragen 18y agoYou can git clone it from http://canonical.org/~kragen/sw/tinybootstrap.git http://canonical.org/~kragen/sw/tinybootstrap.git if you like.