[Tutor] OT self-implementation?
alan.gauld at freenet.co.uk
Sat Jul 2 09:53:06 CEST 2005
> the original 19th c. German ;-) Naively, one thinks that to write
> anything in C, you'd have to *have* C to write in, etc.
You are correct. Or at least you need the subset of C needed for a
So you figure out your minimal comiler in C.
Then you write a basic assembler program to compile that one program.
This is much easier than writing a general purpose C compiler, it
only needs to deal with a single program - the compiler.
Then once your compiler has been compiled, you use it to recompile
>From there in you can extend the original program and recompile it.
Provided each new feature that you sadd doesn't use any new features
then it will be compile by the previous version. ONce you've built
the new feature you can use it to add the next new feature, and so
> Now's not the time in my life to start a comp. sci. degree. So, my
> questions are:
> 1) What would be good terms to google for to find an explanation of
> how the seeming magic doesn't violate all reason?
Compiler, Computer Language, Programming, History of C,
> 2) Much harder, so please pass unless you've a link you know of
> off-hand: any recommendations of particular things that I could
There are lots of CS books on language design and most will cover
this process in detail, usually including staged excercises so you
wind up building your own compiler for your own language!
A more general CS intro will usually have a chapter on language
design and comiler construction.
You might find books on Lex and Yacc (Or GNUs Flex and Bison)
(*)One of the hardest malicious bugs I've seen was by a
disgruntled employee who deliberately inserted a bug into the C
source of the companies compiler. He then recompiled the compiler
(using the working compiler) to produce a faulty compiler. He then
removed his bugs in the source code so it was back to the correct
version. He then recompiled the good source with the faulty
compiler to produce a new faulty compiler. He then left the
It took a long time to figure out what was wrong and why...
Author of the Learn to Program web tutor
More information about the Tutor