[Haskell-cafe] Re: Proving my point
Achim Schneider
barsoap at web.de
Fri May 16 15:33:47 EDT 2008
Andrew Coppin <andrewcoppin at btinternet.com> wrote:
> Wait... "unexpected end of input; expecting [...] end of input [...]"
>
> That's just *wrong*...! ;-)
>
> But don't despaire - show us your parser and what it's supposed to
> parse, and I'm sure somebody [maybe even me] will be able to tell you
> what's up.
This is what I came up with while simplifying the parser:
import Text.Parsec
identifier = do
whiteSpace
s <- many1 letter
whiteSpace
return s
whiteSpace = do
eof <|> ((many $ choice [ char ' ', newline ]) >> return ())
main = do
let syn = runParser (do
char '\\'
many1 identifier
char ':'
whiteSpace
identifier
whiteSpace
) () "" "\\a b"
print syn
Admittedly, this is a quite degenerate case crouching in at least 10
corners simultaneously. Anyway, I get
% ./test
Left (line 1, column 5):
unexpected end of input
expecting end of input, letter or ":"
and if I change it to
whiteSpace = do
(many eof >> return ())
<|> ((many $ choice [ char ' ', newline ]) >> return ())
Left (line 1, column 3):
unexpected " "
expecting letter, end of input or ":"
Please, please don't ask me for the rationale of using eof like this,
you would get the same answer as if you'd ask me why I cast a stone into
the sea.
--
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited.
More information about the Haskell-Cafe
mailing list