Hacker News new | ask | show | jobs
by neatcoder 2642 days ago
Any recommendations for introductory text for writing compilers and interpreters?
4 comments

You can start by reading these ones,

"Let's Build a Compiler", by Jack Crenshaw

https://compilers.iecc.com/crenshaw/

"Compiler Construction" by Niklaus Wirth

http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf

Then you can follow up with "Project Oberon (New Edition 2013)" by Niklaus Wirth, for the whole stack experience

https://inf.ethz.ch/personal/wirth/ProjectOberon/index.html

I think "Programming Languages: Application and Interpretation" does much of what you want: in particular, it takes the view that "from our perspective parsing is mostly a distraction, because we want to study the parts of programming languages that are not parsing." The author, Shriram Krishnamurthi, puts the complete text online for free at http://cs.brown.edu/courses/cs173/2012/book/
What sort of language are you interested in implementing? Once you've got past the lexing and parsing stages, the implementation strategy can be quite different for, say, a functional-style language and an imperative OO-style language, so it would be helpful to know more and then perhaps some of us could suggest suitable material.
Preferably something with the syntax of Java.
His point is that syntax is nearly the most irrelevant part of language implementation.

- "I want to build a house"

- "OK, what kind of house"

- "Preferably red"