3 ms·
If you want any chance of understanding real compilers, the "optional" optimizations and parsing algorithms are actually pretty important. I do think starting w
by Rusky 12y ago
If you want any chance of understanding real compilers, the "optional" optimizations and parsing algorithms are actually pretty important. I do think starting with an interpreter for an AST is just as good a method as starting with code generation, and code optimization can probably wait until the end, but teaching parsing should avoid any kind of CYK/LL/LR unless you're specifically teaching grammar theory.
Using a parser generator of some kind is possibly okay to teach the concept of a grammar, but it's terrible for error handling, efficiency, and simplicity. For most programming languages, nothing beats a plain old hand-written recursive descent parser (optionally with pratt parsing for expressions) on those metrics. And indeed, most compilers I've seen in production are written that way.