6 ms·
Jack Crenshaw's book Let's Build a Compiler http://compilers.iecc.com/crenshaw/ http://compilers.iecc.com/crenshaw/ is probably too far to the pragmatic end; it
by chbarts 16y ago
Jack Crenshaw's book Let's Build a Compiler http://compilers.iecc.com/crenshaw/ http://compilers.iecc.com/crenshaw/ is probably too far to the pragmatic end; it essentially walks you through the process of writing a recursive-descent compiler in Pascal for a Pascal-like language that generates code for the m68k. No separate parser and lexer as such, but he does teach you how to turn those kinds of ideas (regexes and EBNF equations) into code more-or-less directly in your head. In short, it was just about perfect for someone who wanted to whip up a nice little compiler for a foogol on a late-1980s DOS box without paying for or finding any tools beyond Turbo Pascal.
It's entirely possible to use the techniques in the book to, say, whip up a compiler in Ruby that turns an inconvenient data format into JSON. The real utility of doing this by hand in 2010 is, however, debatable.