Most modern languages use a handwritten recursive descent parser anyway and the interesting part starts after you have the AST (code generation and register allocation).
Most modern languages use a handwritten recursive descent parser anyway and the interesting part starts after you have the AST (code generation and register allocation).
This is my strong opinion as well. Almost everyone fixates on parsing.
I've been working on an interpreter/compiler full time since 2013, so coming up for eight years. I think I've spent maybe three or four days working on the parser. It's a vanishingly small part of the job.
I wish compiler courses started with an AST, and then parsing was a separate course unrelated to compilers.
What I can really recommend (and me and others have recommended it already countless times) is TECS: The elements of computing systems (also know as "Nand2Tetris"). Although it also covers other parts like the hardware stuff it lets you implement
- an assembler
- a VM
- a compiler that compiles a simplified Java-like language to this VM
It takes a bottom-up approach, but if you go through all projects you get a really good view about the big picture. However as it does code generation via an intermediate VM language it doesn't really touch register architectures as a compilation target. Anyway I highly recommend that book.I'd go further and say that for most people, the first time you read or write a context-free grammar is when you're trying to write a parser. So the theory is motivating the practice.
By comparison, at Berkeley they recreate 61C Machine Structures every few years. Out goes the unimportant, in comes the new.
Lexing and parsing isn't even a vanishingly small part of the job. It's usually someone else's job. Someone who works on LLVM code generation for the XYZ processor is the wrong person to keep the Clang front end up to date with the latest C++ committee's standard iteration.
They should push DFAs and grammars into theory classes. That said, I do like the 2nd edition of the Dragon book, particularly the later chapters.
http://www-inst.eecs.berkeley.edu/~cs164/sp19/ https://web.stanford.edu/class/cs143/index2018.html https://suif.stanford.edu/~courses/cs243/
It depends on whether you are compiling C++ or not. ;-)
Bingo. We spent decades formalising and automating something... that was never that hard in the first place.
And what's more that kind of interplay is easier outside a parser framework!
Many languages are not very pure for parsing. If you're writing a parser using lex and bison this means bending over backwards to make it work.