4 ms·
Top Down Operator Precedence (2007)
- munificent 6y agoThis 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.
- lioeters 6y agoA fairly recent take on the technique, with an accompanying TypeScript implementation: How Desmos uses Pratt Parsers - https://engineering.desmos.com/articles/pratt-parser/ https://engineering.desmos.com/articles/pratt-parser/ (Dec 2018) https://github.com/desmosinc/pratt-parser-blog-code 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.
- JadeNB 6y ago> 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 https://news.ycombinator.com/item?id=25448594 .