News for hackers. Stuff that matters.
Re:Combinator Parsing by Rusky on Monday May 05, 2014 @12:44PM (#7699530)
I've still never seen anything that can compete with recursive descent (with pratt parsing for expressions [0]) on error handling, simplicity of implementation, and performance.

The article claims recursive descent is tedious and error prone, but I've not found that to be the case. In fact, combinators like match, many, and opt map easily to either if/while or higher order functions.

I also think people tend to focus too much on LL vs LR vs whatever. Clang parses the entire family of C languages with a hand-written recursive descent parser + pratt parsing and it's well-known for its error messages, speed, and memory usage. I would also say it's very readable and pleasant to work with (for a C++ parser of course ;)

[0] http://javascript.crockford.com/tdop/tdop.html

Re:Combinator Parsing by dons on Monday May 05, 2014 @11:13AM (#7698991)
Amazing to think that parser combinator libraries are an almost 20 year old technique now.

And if you think these things are toys, consider e.g. http://hackage.haskell.org/package/FpMLv53 is used to process transactions worth billions.

Re:Combinator Parsing by hugofirth on Monday May 05, 2014 @09:57AM (#7698563)
Even though they have performance issues - I still love Scala's parser combinator libraries. I hadn't really dealt much with parsing prior to my use of them, and they made the process of parsing seem a lot more obvious and less "mystical" .
Re:Combinator Parsing by platz on Monday May 05, 2014 @11:08AM (#7698959)
I saw there was a port of attoparsec recently, but it still has to use trampolines.

Do you know of any benchmarks of different parsers, especially combinator libraries?

Re:Combinator Parsing by stephenjudkins on Monday May 05, 2014 @01:40PM (#7699925)
parboiled2 [https://github.com/sirthias/parboiled2] offers pretty much everything the built-in parser combinators do, but with fewer bugs and vastly improved performance. Since both use PEG grammars, it should be straightforward to port over. parboiled2 is fast because it generates fast, stateful parsers using macros while only exposing a purely functional interface.
Re:Combinator Parsing by phpnode on Monday May 05, 2014 @08:14AM (#7698066)
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
Re:Combinator Parsing by Ygg2 on Monday May 05, 2014 @09:21AM (#7698382)
What is the relationship between PEG parsers and Parser Combinators?
Re:Combinator Parsing by MarkCC on Monday May 05, 2014 @10:10AM (#7698625)
(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!

Re:Combinator Parsing by jerf on Monday May 05, 2014 @09:45AM (#7698499)
That'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.