[Haskell-cafe] An irritating Parsec problem

Philippa Cowderoy flippa at flippac.org
Wed Oct 15 15:27:44 EDT 2008

On Wed, 15 Oct 2008, Andrew Coppin wrote:

> Suppose this is the top-level parser for my language.


> Does anybody know how to fix this irratiting quirk? I can see why it happens,
> but not how to fix it.

One of:

expressions = many1 (try expression <|> myFail)
  where myFail = {- eat your way to the next expression -}

or do a prepass splitting your input up into expressions and feed the 
individual expressions into Parsec.

Parsec's not designed to do error recovery as such, so it's something you 
need to work out how to handle if you need it.

flippa at flippac.org

'In Ankh-Morpork even the shit have a street to itself...
 Truly this is a land of opportunity.' - Detritus, Men at Arms

More information about the Haskell-Cafe mailing list