4 ms·
I think everyone should manually implement a simple recursive descent parser at least once in their careers. It's surprisingly easy, and really (in my experienc
by ttd 10y ago
I think everyone should manually implement a simple recursive descent parser at least once in their careers. It's surprisingly easy, and really (in my experience) helps to break through the mental barrier of parsers being magical black boxes.
Plus, once you have an understanding of recursive descent parsing, it's a relatively small leap to recursive descent code generation. And once you're there, you have a pretty good high-level understanding of the entire compilation pipeline (minus optimization).
Then all of a sudden, compilers are a whole lot less impenetrable.
- Terr_ 10y agoOn that note, Parr also has a nice little book called "Language Implementation Patterns" [0] which introduces things on a level of "this kind of language motif maps to this kind of parsing code". [0] https://pragprog.com/book/tpdsl/language-implementation-patterns https://pragprog.com/book/tpdsl/language-implementation-patt...
- parrt 10y agoThanks for the ptr. :) I just wish I had time to rewrite that book in ANTLR 4 (it's in ANTLR 3).
- ftomassetti 10y agoI also loved that book! It is in my list of best books on building DSLs (https://tomassetti.me/domain-specific-languages#books https://tomassetti.me/domain-specific-languages#books)