
I was just wondering, is there a way to use parsec get all valid parses of an ambiguous language? A quick google said no, but I may have missed something. If not, is there another, similar library which does? If not, why not? -- Alex R

Hello Alex Choice in Parsec is left-biased - the alternative combinator (<|>) will return the fist successful parse. For reasons see the paper [1] - in a nutshell error reporting is hard for ambiguous parsers and space leaks become a problem. Happy has some support for GLR parsing, but it might not working in the current release. If your interest is via natural language processing you might want to search for Peter Ljunglof's (umlauts on o) thesis - "Pure Functional Parsing an advanced tutorial". It covers Chart parsing (extending Earley parsing) and GLR parsing. All source is within the paper. [1] Daan Leijen & Erik Meijer Parsec: Direct Style Monadic Parser Combinators For The Real World
participants (2)
-
Alex Rozenshteyn
-
Stephen Tetley