I was reading a lot about Haskell Parser Combinators and found a lot of topics like:
- Parsec vs Yacc/Bison/Antlr: Why and when to use Parsec?
- Which Haskell parsing technology is most pleasant to use, and why?
- Parsec or happy (with alex) or uu-parsinglib
- Choosing a Haskell parser
- What is the advantage of using a parser generator like happy as opposed to using parser combinators?
But all these topics compare Parser Combinators
with Parser Generators
.
I want to ask you which of Parser Combinator
suits best the following conditions:
- I want to have good control about the errors (including error recovery) and messages for user
- I want to be able to fed the parser with small parts of text (not whole file at once)
- I want to be able to redesign nicely the grammar (I'm currently developing the grammar, so "nice waf of working" is important"
- The final parser should be fast (the performance is important, but not as much as points 1-3).
I've found out, that the most popular parser combinators are:
attoparsec
so I don't know first hand about Parsec. attoparsec has a reputation for being extremely fast but not so great on the error messages front. It's targeted at back end parsing needs that a front end user should never see error messages from. – GoldyText
which is awesome. – Becnelattoparsec
error messages are completely unusable, but it is very fast. – Submergeduu-parsinglib
is, to my understanding, well equipped for 1, 2, and 3 all the way to the point of suggesting the correct syntax to the user (and even inputing it automatically, though that can be annoying). The documentation is best gotten by reading "Combinator Parsing: A Short Tutorial". – Tussahparsers
andtrifecta
. – Tussahparsers
ortrifecta
? Could you elaborate a little bit more why they could be better thanParsec
oruu-parsinglib
? – Magnetoelectricityparsers
/trifecta
for a little bit. I'm not certain that they're significantly better that uu-parsinglib though. As far as I've seen, familiarity should be the major decision factor. Though, if you're seen one parsing combinator library you've pretty much seen them all. – Tussahuu-parsinglib
- could you please tell me (if it is possible) - doesuu-parsinglib
has more advanced / better features thanparsec
? I understand, that if it can suggest the syntax, I do not have to use tools likeAlex
with it? – Magnetoelectricityuu-parsinglib
does somewhat more thanParsec
"out of the box". The best way to get an appreciation of the differences is to read that tutorial I linked above. – Tussahparse
, which is rather simple. It's pretty straightforward to implement anotherP
type though it's a bit of work---the source of Core has examples for future parsers, history parsers, recognizers, partial parsers, and defaults---but it sadly doesn't export theT
type which contains them and theparse
andparse_h
types are oversimplified—what you want to do is replace theeval :: Steps a -> a
function. – Tussaheval
Fail
branch andget_cheapest
calls are what do the rewriting. – Tussahlexer + parser
be done inuu-parsinglib
: #18214679 – Magnetoelectricity