4 ms·
isn't there a good PEG available for python? Compare the source code in the post to the equivalent PEG.js grammar - http://pegjs.majda.cz/online http://pegjs.ma
by phpnode 12y ago
isn't there a good PEG available for python? Compare the source code in the post to the equivalent PEG.js grammar - http://pegjs.majda.cz/online http://pegjs.majda.cz/online
- Ygg2 12y agoWhat is the relationship between PEG parsers and Parser Combinators?
- MarkCC 12y ago(Original blogpost author here.) They're pretty much orthogonal. PEG is a particular parsing technique. Combinators are a technique for implementing parsers. You can write a parser combinator library which uses PEG or packrat algorithms underneath. In this blog post, the library that I'm using is basically building LL parse generators, not PEG. But you could easily implement a PEG-based combinator system. I didn't do that, because I didn't want to get bogged down with explaining too much about parsing algorithms. The LL/recursive descent approach is pretty easy to understand when you see the grammar code. For PEG, I would have needed to spend more time explaining the algorithms, and the post was already too long!
- jerf 12y agoThat's not quite equivalent; the JS doesn't do division or subtraction. The Python syntax is a bit klunky. The Haskell equivalent is on par with the PEG. I don't know how they compare as the grammars become non-trivial.