3 ms·
I vividly remember learning about recursive descent parsing in my compilers class and thinking, "Wow, I can use this everywhere!" Of course in addition to exec
by ChuckMcM 9y ago
I vividly remember learning about recursive descent parsing in my compilers class and thinking, "Wow, I can use this everywhere!"
Of course in addition to executing an AST you can also generate CODE for it...
- seanmcdirmid 9y agoRecursive descent is still a great way to implement parsers.
- dozzie 9y ago"Recursive descent" is an ancient African expression meaning "I can't write grammars".
- seanmcdirmid 9y agoMost production compilers still depend on recursive descent because (a) it isn't that much harder compared to the generative approach, and (b) it is the best way to work in real error recovery or to support IDE services.
- munificent 9y ago> Of course in addition to executing an AST you can also generate CODE for it... Yes! In the third part of the book [1], we'll do exactly that. The C interpreter's parser generates bytecode as it parses. I haven't written the text yet (that's the hard part...) but you can see the code for it here [2]. [1]: http://www.craftinginterpreters.com/a-bytecode-virtual-machine.html http://www.craftinginterpreters.com/a-bytecode-virtual-machi... [2]: https://github.com/munificent/craftinginterpreters/blob/master/c/compiler.c https://github.com/munificent/craftinginterpreters/blob/mast...
- ChuckMcM 9y agoThat will be awesome.