[Haskell-cafe] Parsec beginners problem

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Apr 27 12:52:21 EDT 2007


Jim Burton <jim at sdf-eu.org> wrote:

> 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


More information about the Haskell-Cafe mailing list