Re:If I ever design a first course in compilers, I'll do it ...
by mattgreenrocks on Thursday August 07, 2014 @10:40AM
(#8147922)
I'm convinced this is the only sane method when you are self-teaching. If you try to write an entire LALR grammar at once and then you screw up, you're in a world of hurt trying to figure out what went wrong.
Ghuloum's scheme compiler tutorial essentially follows this method: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf. It starts with emitting x86 machine code for constants, then unary and binary primitives, local variables, conditionals, heap allocation, procedure calls, and finally closures. It helps that Scheme has little to no parser to speak of, but it is straightforward to extend the technique to a language that does.