3 ms·
Oh my god, a dream come true! I had always hoped Bob Nystrom would write a book about interpreters/compilers. Back when I tried to learn how to write a recurs
by w23j 10y ago
Oh my god, a dream come true!
I had always hoped Bob Nystrom would write a book about interpreters/compilers.
Back when I tried to learn how to write a recursive descent parser, the examples I found either ignored correct expression parsing or wrote an additional parse method for each precedence level. Writing a parser by hand seemed just too much work. Along comes this great article about pratt parsers http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/ http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-e... and all can be done with two simple functions, a loop and a map. :) Saved my enthusiasm right there.
Another great example is this article about garbage collection: http://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/ http://journal.stuffwithstuff.com/2013/12/08/babys-first-gar...
Instead of making things more complicated than they are, Bob Nystrom simplifies daunting topics and makes the accessible.
Thanks so much for your work! Really looking forward to this one. Will there be code generation too? :)
- munificent 10y agoYou're welcome! Some of the book will revisit topics I've already covered in my blog (but I'll write all new prose to seamlessly integrate it into the rest of the material and the language we're building). In Part III where we build an interpreter in C, it will use a Pratt parser and we'll implement a mark-sweep GC from scratch. The book doesn't touch on native code generation because (1) that's a really big, messy topic and (2) I don't have much experience with it. The C interpreter does compile to bytecode, though, so we cover a lot of the basic concepts around lowering the code into a denser more efficient representation, representing the stack and callframes, etc.