
Hello,
I run as follows:
simple::Parser String
simple = do manyTill anyToken (semi <|> eof)
run:: Show a => Parser a -> String -> IO()
run p input
= case (parse p "" input) of
Left err -> do {putStr "parse error at " ;print err}
Right x -> print x
ParsecLanguage> :load Test.hs
Type checking
ERROR "Test.hs":21 - Type error in application
*** Expression : semi <|> eof
*** Term : semi
*** Type : GenParser Char () String
*** Does not match : GenParser a b ()
Do you know what happens? Thank you.
On 11/22/05, Daniel Fischer
Am Dienstag, 22. November 2005 14:51 schrieben Sie:
Am Montag, 21. November 2005 03:27 schrieb Sara Kenedy:
May I suggest
endBy anyToken semi ? -- optionally replace semi by "char ';'", if you ^^^^^^^^
Oops, I confused endBy and manyTill !! Also below. And since maybe there isn't any semicolon, I'd say
manyTill anyToken (semi {- try semi, perhaps -} <|> eof)
don't want to skip whitespace
I think this is what you want --- stop at the first semicolon.
If you want to ignore just a final semicolon, you might use
endBy anyToken (optional semi >> eof),
if you want to stop at the last semicolon, whatever comes thereafter, you have a problem, you'd need long lookahead.
Cheers again, Daniel