News for hackers. Stuff that matters.
Re:What the heck is a parser-combinator? by Mehdi2277 on Wednesday June 21, 2017 @05:19AM (#14602230)
Roughly, context sensitive can be covered by monadic parsers, while applicative parsers are context free. LR(k) also corresponds to context free parsers. So, at least for monadic combinators they are more powerful. I also think they're fairly modular. The primitive parsers are fairly easy to write and once you have a small library (or use an existing one like Parsec) of them it is fairly easy to put them together (in haskell do notation helps too). The only other kind of parsers I have personal experience coding is recursive descent which I had more trouble trying to keep track of.
Re:What the heck is a parser-combinator? by amelius on Wednesday June 21, 2017 @05:31AM (#14602292)
Ok, but what about the efficiency of LR(k) parsers implemented using monads?

Further, do monads warn the user when there is an ambiguity in the "grammar"?

Re:What the heck is a parser-combinator? by vorg on Wednesday June 21, 2017 @07:40AM (#14602803)
> monadic combinators are more powerful [than context free parsers]

Monadic parsers can do context-sensitive things that context free parsers can't, but they can't have unordered options which context free parsers can. So really monadic parsers have different powers to context-free.

> do monads warn the user when there is an ambiguity in the "grammar"?

You don't have ambiguity in the grammar because monadic parsers only provide ordered options.

Re:What the heck is a parser-combinator? by dozzie on Wednesday June 21, 2017 @08:46AM (#14603238)
> You don't have ambiguity in the grammar because monadic parsers only provide ordered options.

Oh, but you do have ambiguity in the grammar, except that parser returns one of the possible parse trees deterministically and thus doesn't warn you that the input could be parsed differently. This leads to the false impression that your grammar is unambiguous.

Re:What the heck is a parser-combinator? by marcosdumay on Wednesday June 21, 2017 @02:02PM (#14606322)
The parser implements an unambiguous grammar. But it may not be the grammar you were thinking it was.

Specifically, it makes it impossible for you to even write down that ambiguous grammar you wanted.

Re:What the heck is a parser-combinator? by fusiongyro on Wednesday June 21, 2017 @12:53PM (#14605529)
> Further, do monads warn the user when there is an ambiguity in the "grammar"?

I'm not aware of a parser combinator library that does this. The way you build parser combinators in Haskell doesn't exactly preclude it from being done but it wouldn't be totally trivial either.

Googling for it didn't turn up much that wasn't a veiled reference to this paper:

http://richard.myweb.cs.uwindsor.ca/PUBLICATIONS/PADL_08.pdf

Re:What the heck is a parser-combinator? by marcosdumay on Wednesday June 21, 2017 @01:57PM (#14606270)
If you mean big O efficiency, it doesn't make any difference if you are creating a monad, applicative, or an state machine. Complexity comes explicitly in the parser construction, so if you write a monadic parser using only LR(k) combinators, you will get an LR(k) parser. If you write some backtracking, you will get worse complexity.