
This new, expanded textbook describes all phases of a modern compiler: lexical analysis, parsing, abstract syntax, semantic actions, intermediate representations, instruction selection via tree matching, dataflow analysis, graph-coloring register allocation, and runtime systems. It includes good coverage of current techniques in code generation and register allocation, as well as functional and object-oriented languages, that are missing from most books. In addition, more advanced chapters are now included so that it can be used as the basis for two-semester or graduate course. The most accepted and successful techniques are described in a concise way, rather than as an exhaustive catalog of every possible variant. Detailed descriptions of the interfaces between modules of a compiler are illustrated with actual C header files. The first part of the book, Fundamentals of Compilation, is suitable for a one-semester first course in compiler design. The second part, Advanced Topics, which includes the advanced chapters, covers the compilation of object-oriented and functional languages, garbage collection, loop optimizations, SSA form, loop scheduling, and optimization for cache-memory hierarchies.
There are (inferior) versions of the same in C and Java. I'd use them together with the ML version.
Then you should get a copy of Modern Compiler implementation in ML. I love the Crafting Interpreters book, and also the Writing A Compiler In Go book; but they will not satisfy any person with undergraduate CS education.
I personally enjoyed `Modern Compiler Implementation in ML` and Crenshaw's tutorial [0] There's also a Forth translation [1] if you're into that :)
If I had to say one text that is the fundamental one, I would go with a paper: “On Computable Numbers, with an Application to the Entscheidungsproblem” [1], by Alan Turing.
---
But if you just started your course in Computer Science, then I will give you some “bookshelf advice" based on my experience. I had the pleasure to study all the books I am going to recommend you, and most of them I was able to read cover-to-cover during the university years. And they are also in my bookshelf for reference.
The book order does not represent rank of importance.
* “Introduction to the Theory of Computation”, by Michael Sipser.
* I also recommend the “Elements of the Theory of Computation”, by Christos Papadimitriou.
* Another good complement is “Introduction to Automata Theory, Languages and Computation”, by Hopcroft and Ullman. (Thanks, @reacweb, for the reminder.)
* “Graph Theory”, by Reinhard Diestel. * If you feel you want to go deeper, and like a book which you cannot skip a single word, I strongly recommend “Modern Graph Theory”, by Béla Bollobás: it is one of my favorite textbooks ever!
* “The Algorithm Design Manual”, by Steven Skiena. * While a lot of people seems to praise either the Cormen et al. or the Sedgewick books, I have the feeling that “Algorithms” by Dasgupta, Papadimitriou and Vazirani is my choice for “fundamental” book. But I decided to
* “Computer Architecture: a Quantitative Approach”, by Hennessy and Patterson.* “Modern Operating Systems”, by Andrew Tanenbaum.
* “Artificial Intelligence: a Modern Approach”, by Russel and Norvig.
* “Modern Compiler Implementation (in ML)”, by Andrew Appel.
I would like to also recommend “Concrete Mathematics”, by Graham, Knuth and Patashnik, but I remember to not feel it the most pedagogical book on the subject.
Good luck!
---
[1]: https://www.cs.virginia.edu/~robins/Turing_Paper_1936.pdf