
Thankyou. Yes, I'd also noticed that "only end" could result in the "end" part being taken as an identifier. The language I'm parsing actually doesn't have reserved words though; so "end" and "only" are both possible valid identifiers. I should then probably replace my use of say, reserved "only", with string "only"; whiteSpace; for clarity. Still stuck though... P -----Original Message----- From: Brandon S. Allbery KF8NH [mailto:allbery@ece.cmu.edu] Sent: Tue 25/03/2008 19:58 To: Paul Keir; haskell-cafe@haskell.org Cafe Subject: Re: [Haskell-cafe] Parsec (Zero or One of) On Mar 25, 2008, at 12:43 , Paul Keir wrote:
Thanks. I can't find optionMaybe in my version 2.1 of Parsec, but in any case, defining my only_prod as
only_prod = do { reserved "only"; option [] identifier }
or
only_prod = do { reserved "only"; identifier <|> return [] }
gives the same error responses as before. I will anyway look closer at option.
The other problem here is that just using a given string in "reserved" doesn't prevent it from being parsed elsewhere by "identifier". (Note the character offset of the error was 9, i.e. just past "only end", and it was looking for "end" or more identifier characters.) Are you using the higher level parser facilities from Text.ParserCombinators.Parsec.Token, or rolling your own? If the latter, you will need to modify "identifier" to not accept keywords. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH