[Haskell-cafe] Troubles understanding Parsec Error Handling

Matthias Hörmann mhoermann at gmail.com
Thu May 31 10:40:31 CEST 2012


Hello

Thanks for the quick help with this. I thought about the idea that
lookAhead might be the cause of the
positioning bug but then discarded that idea because I thought lookAhead
should never lead to an error
past wherever the input position is now considering it doesn't consume any
input.

I am aware of the issue with the error message position and the output, I
was still working on improving
that when I was puzzled by the fact that the error message I specified
wasn't even returned to me.

As for try, I believe I need it to make sure the input I consume one
character at the time, before I know
if I will reach another valid match (or any at all) does not stay consumed
when my parser fails.

I am still very much in the experimental phase as far as writing Parsec
combinators beyond very simple
stuff is concerned so I am open for suggestions on how to improve it in a
way that doesn't need "try".

Thanks again for all the help and especially for the patch. After applying
it I do get the error message I
specified.

I noticed there are still some other problems in the code. In particular it
doesn't work as intended in cases
like this one:

parseTest (do; r1 <- anyOf ["Hello", "Hallo", "Foo", "HallofFame"]; r2 <-
string "fbla"; return (r1, r2)) "Hallofbla"

where it should (according to my goal) return no parse error but instead
accept "Hallo" and allow the string parser
to consume the rejected suffix but I will try to fix that.

Matthias Hoermann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120531/b2d01145/attachment.htm>


More information about the Haskell-Cafe mailing list