2 ms·
This is my favorite parsing technique, but I found Crockford's presentation of it really difficult to wrap my head around. I think he muddles the technique with
by munificent 6y ago
This is my favorite parsing technique, but I found Crockford's presentation of it really difficult to wrap my head around. I think he muddles the technique with his own strong opinions around dynamic types and prototypes. In particular:
> Another explanation is that his technique is most effective when used in a dynamic, functional programming language. Its use in a static, procedural language would be considerably more difficult.
I've implemented Pratt parsers in Java, C#, C++, Dart, and C, and I've never found them difficult to express in any of those languages. If you'd like a different treatment of the technique, I wrote a blog post about them using Java:
http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/ http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-e...
And a chapter in my book using C:
http://craftinginterpreters.com/compiling-expressions.html http://craftinginterpreters.com/compiling-expressions.html
- fuzzybear3965 6y agoI read your article. It was really easy to follow. I'm not sure I'll feel the magic until I write it myself, though. You made it easy enough to follow. Plus, the magpie parser source looks clean. Thanks for sharing your work!
- brodo 6y agoThanks, I'll definitely check out your article. I'm currently writing a Pratt parser in Go and I don't have problems so far.