Tuesday, September 20, 2011

Let's Build a Compiler

September 20, 2011 11:01 am

I decided to LaTeX-ify Jack Crenshaw's 'Let's Build a Compiler' series. Between 1988 and 1995 Jack Crenshaw wrote a sixteen-part series on how to build a compiler. This was a non-technical introduction (No Dragon book necessary) and appears to have encouraged many people to try their hand at developing a compiler.

The entire series does not seem to be available now on the original web site but I tracked down a word doc that I used as the basis for this LaTeX version. You can download a pdf copy here. There may still be some tuning of the formatting but the document is in a decent shape. For Delphi users, the compiler series used Pascal.

Download pdf

The LaTeX source code is available on GitHub 

For those interested in writing interpreters, I would also highly recommend the book by Kernighan and Pike where the authors introduce yacc, lex and the programming language hoc. This is one of the easiest introductions to writing an interpreter I have come across (apart perhaps from the book by Brown). What is nice about hoc is how the authors introduce the interpreter step by step. Both books can be bought very cheaply on the second-hand market.

Kernighan, Brian W.; Pike, Rob (1984). The Unix Programming Environment. Prentice Hall. ISBN 013937681X.

Brown, P.J (1992) Writing Interactive Compilers and Interpreters John Wiley & Sons Inc, ISBN 10: 0471100722

No comments: