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:
I 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!
At the bottom of the article, they mention a number of articles including the posted one by Doug Crockford, as well as the (excellent) article mentioned in a sibling comment, by @munificent.
> At the bottom of the article, they mention a number of articles including the posted one by Doug Crockford, as well as the (excellent) article mentioned in a sibling comment, by @munificent.
5 comments
[ 3.2 ms ] story [ 14.1 ms ] thread> 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-e...
And a chapter in my book using C:
http://craftinginterpreters.com/compiling-expressions.html
How Desmos uses Pratt Parsers - https://engineering.desmos.com/articles/pratt-parser/ (Dec 2018)
https://github.com/desmosinc/pratt-parser-blog-code
At the bottom of the article, they mention a number of articles including the posted one by Doug Crockford, as well as the (excellent) article mentioned in a sibling comment, by @munificent.
The sibling comment: https://news.ycombinator.com/item?id=25448594 .