[Haskell-cafe] An irritating Parsec problem
Andrew Coppin
andrewcoppin at btinternet.com
Thu Oct 16 13:10:49 EDT 2008
Andrew Coppin wrote:
> Philippa Cowderoy wrote:
>> On Wed, 15 Oct 2008, Andrew Coppin wrote:
>>
>>
>>> Philippa Cowderoy wrote:
>>>
>>>> expressions = do es <- many1 expression
>>>> eof
>>>> return es
>>>>
>>> Ah - so "eof" fails if it isn't the end of the input?
>>>
>>>
>>
>> eof = notFollowedBy anyChar
>>
>> (assuming I've got the identifiers right, that's the actual
>> definition too)
>>
>
> OK, well that'll make it fail alright. Now I just gotta figure out how
> to get a sane error message out of it! ;-)
>
> (The example I showed is very simple; real parsers generally aren't.)
Actually, I added this to my real parser, and it actually seems to do
exactly what I want. Give it an invalid expression and it immediately
pinpoints exactly where the problem is, why it's a problem, and what you
should be doing instead. Neat!
More information about the Haskell-Cafe
mailing list