
27 Apr
2007
27 Apr
'07
12:52 p.m.
Jim Burton
After posting I realised the difference between parsing "(a)" <|> "(b)" and parsing "a" <|> "aa" ... so Parsec doesn't do the latter well or at all?
Exactly. Parsec is designed to avoid backtracking altogether, and to give only one answer, so it is the wrong tool for the job. You could look into alternative parser combinators like the Hutton Meijer ones from way back - they are non-deterministic and backtracking, and can explicitly represent all possible parses as a list, which I think is what you want. You can find them in the polyparse package: http://www.cs.york.ac.uk/fp/polyparse Regards, Malcolm