Found in 2 comments on Hacker News
stiff · 2013-03-18 · Original thread
The single best resource on this topic is the "Dragon Book"

Your advice is great in general, but I wish people would back up statements like this with some context, for example, what specifically have you compared it with? Inspired by Steve Yegge blogposts I once decided to write a toy compiler for educational purposes and I started with reading the Dragon Book, in fact I eventually read it almost cover to cover and implemented many algorithms from it, it is definitely full of valuable information. But it also is a very roundabout way of learning how to write an actual compiler, it is more a theoretical reference work than anything else. There are several hundreds of pages devoted to parsing, but some of the more modern techniques are not covered, runtime is treated much more briefly and many practical issues are not discussed at all. There are some nice modern textbooks that are more to the point:

http://www.amazon.com/Modern-Compiler-Design-D-Grune/dp/0471... http://www.amazon.com/Engineering-Compiler-Second-Keith-Coop...

ANTLR is a great tool and many practical issues I solved with the help of this book about it:

http://www.amazon.com/gp/product/1934356999/

Finally, source code of original AWK is a great example codebase to learn about real-world parsing, building and traversing parse trees etc.:

https://github.com/danfuzz/one-true-awk

It is an interpreter and not a compiler but once you know how to do the things just mentioned converting it to a naive compiler isn't that hard if you are not interested in fancy optimization like the OP said.

eru · 2013-02-01 · Original thread
I haven't read all of them. But I liked "Modern Compiler Design" (http://www.amazon.com/Modern-Compiler-Design-D-Grune/dp/0471...).

If you have a functional bend, Simon Peyton Jones' book (https://research.microsoft.com/en-us/um/people/simonpj/Paper...) is worth reading, too. His book, however, is not a complete treatment. It assumes you know e.g. how to write a parser, and concentrates on the challenges unique to lazy functional languages.

Fresh book recommendations delivered straight to your inbox every Thursday.