Hets - the Heterogeneous Tool Set

Copyright(c) Christian Maeder, DFKI GmbH 2010
LicenseGPLv2 or higher, see LICENSE.txt
MaintainerChristian.Maeder@dfki.de
Stabilityprovisional
Portabilityportable
Safe HaskellSafe-Inferred

Common.Parsec

Contents

Description

frequently useful shortcuts mainly for character parsers

Synopsis

monad shortcuts

(<<) :: Monad m => m a -> m b -> m a infixl 1

forget :: Monad m => m a -> m ()

pair :: Monad m => m a -> m b -> m (a, b)

(<:>) :: Monad m => m a -> m [a] -> m [a] infixr 5

(<++>) :: Monad m => m [a] -> m [a] -> m [a] infixr 5

(>->) :: Monad m => m a -> (a -> b) -> m b infixl 4

single :: Monad m => m a -> m [a]

flat :: Monad m => m [[a]] -> m [a]

enclosedBy :: Monad m => m [a] -> m a -> m [a]

parsec shortcuts

optionL :: GenParser tok st [a] -> GenParser tok st [a]

parse an optional list

tryString :: String -> CharParser st String

shortcut for try . string

nestedComment :: String -> String -> CharParser st String

nested comments, open and closing strings must have at least one char

quotedLit :: Char -> CharParser st String

a literal enclosed in quotes and a backslash as escape character

stringLit :: CharParser st String

text in double quotes

sQuoted :: CharParser st String

text in single quotes

plainBlock :: String -> String -> CharParser st String

non-nested block

reserved :: [String] -> CharParser st String -> CharParser st String

reject keywords

sneakAhead :: CharParser st a -> CharParser st (Either ParseError a)

Similar to lookAhead, but runs the parser in an isolated sandbox. The function is monadic but in a read-only manner. Useful if lookAhead taints error messages.