Making a Pratt Parser Generator
robertjacobson.dev
robertjacobson.dev
http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-e...
Years ago when I was at Mozilla we built PrattParser utils in JS: https://github.com/taskcluster/json-e/blob/386ae415d807eb066...
It probably had short comings, because it's been rewritten since (I haven't kept up).
But with a few rules and simple functions a pratt parser is rather intuitive, and easy to write and port to other languages.
I'd be very curious to see the next article :)
Maybe it’s just me but it seems there’s a lot of language design coming out recently. E.g. Bob Nystrom has “Crafting Interpreters.” It really like that language design and parsing gets more attention, which is great because it’s fascinating stuff.
https://matklad.github.io/2020/04/13/simple-but-powerful-pra...
http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm
http://www.engr.mun.ca/~theo/Misc/pratt_parsing.htm
Matklad's stuff is really great. I wish he had cited Norvell, though.
I am going to go meditate on the subjectivity of my reality. If I am wrong about this, what else am I wrong about?
Personally, at some point, I'd like to write a Pratt Parser in C99. I'd like to explore the one sentiment you had that OOP has a negative effect on understanding Pratt Parsers.
I hear you though, there are many that (overly) use passive-aggressive and/or aggressive language in the form of acronyms like STFU, GTFO, RTFA, IDC, WTH, WTF etc. Not my intent. I sometimes use TFA as a reference to the linked article. I'll reconsider next time.
Natural languages are highly ambiguous. Using a naive approach like Early's algorithm can lead to thousands of parse trees for a single sentence. Probabilistic grammar parsing algorithms attempt to discover the "most likely" parse tree with respect to a particular statistical model of the language grammar. As with parsing algorithms for formal languages, different algorithms make different trade-offs. "Best" only makes sense with respect to a particular metric: "Best" in what sense?
I personally don't know much about this area beyond what I just said.