[Haskell-cafe] How to use notFollowedBy function in Parsec

Christian Maeder maeder at tzi.de
Mon Nov 21 07:02:33 EST 2005


Sara Kenedy wrote:
> import qualified ParsecToken as P

the proper hierarchical module name is:
Text.ParserCombinators.Parsec.Token

> str1 :: Parser String
> str1 = do {str <- many anyToken; notFollowedBy semi; return str}

simply try:

str <- many anyToken; notFollowedBy (char ';'); return str

"semi" only skips additional white spaces (that you are not interested in)

(I find it easier not to use the Parsec.Token und Parsec.Language 
wrappers and remain Haskell 98 conform)

Christian


More information about the Haskell-Cafe mailing list