Hacker News new | ask | show | jobs
by markus_zhang 1116 days ago
What is a good book just for recursive descend parsing? I dabbed into some compiler books but found BNF difficult.

Just some clarification, it is not difficult to understand but difficult to build from scratch. I'm thinking maybe a book that asks me to build up BNF expressions for a series of grammars of gradually increasing complexity would be nice.

3 comments

Not a book, but a nice way to start with the task is to build up a simple JSON parser using recursive descent;

This [1] is a great tutorial to start with. Personally, I followed up with a standards compliant JSON parser of my own, in Python [2], and later ported it into a larger golang codebase. Practically building up multiple JSON parsers taught me to build my own DSL, using recursive descent parsing. My path admittedly is quite non-standard and idiosyncratic, but was way more fun than going through a textbook :)

[1]: https://www.booleanworld.com/building-recursive-descent-pars...

[2]: https://github.com/HexmosTech/json-rd

Crafting Interpreters was fun to read and easy to follow, even as someone with a mechanical engineering degree :)
You might want to checkout Parsing Techniques: A Practical Guide by Dick Grune et.al.

Came across it on HN but I have not read it though.