Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | ekmett@gmail.com |
Safe Haskell | None |
Parsers for character streams
- oneOf :: CharParsing m => [Char] -> m Char
- noneOf :: CharParsing m => [Char] -> m Char
- oneOfSet :: CharParsing m => CharSet -> m Char
- noneOfSet :: CharParsing m => CharSet -> m Char
- spaces :: CharParsing m => m ()
- space :: CharParsing m => m Char
- newline :: CharParsing m => m Char
- tab :: CharParsing m => m Char
- upper :: CharParsing m => m Char
- lower :: CharParsing m => m Char
- alphaNum :: CharParsing m => m Char
- letter :: CharParsing m => m Char
- digit :: CharParsing m => m Char
- hexDigit :: CharParsing m => m Char
- octDigit :: CharParsing m => m Char
- satisfyRange :: CharParsing m => Char -> Char -> m Char
- class Parsing m => CharParsing m where
Combinators
oneOf :: CharParsing m => [Char] -> m CharSource
oneOf cs
succeeds if the current character is in the supplied
list of characters cs
. Returns the parsed character. See also
satisfy
.
vowel = oneOf "aeiou"
noneOf :: CharParsing m => [Char] -> m CharSource
As the dual of oneOf
, noneOf cs
succeeds if the current
character not in the supplied list of characters cs
. Returns the
parsed character.
consonant = noneOf "aeiou"
oneOfSet :: CharParsing m => CharSet -> m CharSource
oneOfSet cs
succeeds if the current character is in the supplied
set of characters cs
. Returns the parsed character. See also
satisfy
.
vowel = oneOf "aeiou"
noneOfSet :: CharParsing m => CharSet -> m CharSource
As the dual of oneOf
, noneOf cs
succeeds if the current
character not in the supplied list of characters cs
. Returns the
parsed character.
consonant = noneOf "aeiou"
spaces :: CharParsing m => m ()Source
Skips zero or more white space characters. See also skipMany
.
space :: CharParsing m => m CharSource
Parses a white space character (any character which satisfies isSpace
)
Returns the parsed character.
newline :: CharParsing m => m CharSource
Parses a newline character ('\n'). Returns a newline character.
tab :: CharParsing m => m CharSource
Parses a tab character ('\t'). Returns a tab character.
upper :: CharParsing m => m CharSource
Parses an upper case letter. Returns the parsed character.
lower :: CharParsing m => m CharSource
Parses a lower case character. Returns the parsed character.
alphaNum :: CharParsing m => m CharSource
Parses a letter or digit. Returns the parsed character.
letter :: CharParsing m => m CharSource
Parses a letter (an upper case or lower case character). Returns the parsed character.
digit :: CharParsing m => m CharSource
Parses a digit. Returns the parsed character.
hexDigit :: CharParsing m => m CharSource
Parses a hexadecimal digit (a digit or a letter between 'a' and 'f' or 'A' and 'F'). Returns the parsed character.
octDigit :: CharParsing m => m CharSource
Parses an octal digit (a character between '0' and '7'). Returns the parsed character.
satisfyRange :: CharParsing m => Char -> Char -> m CharSource
Class
class Parsing m => CharParsing m whereSource
Additional functionality needed to parse character streams.
satisfy :: (Char -> Bool) -> m CharSource
Parse a single character of the input, with UTF-8 decoding
char c
parses a single character c
. Returns the parsed
character (i.e. c
).
e.g.
semiColon = char
';'
notChar :: Char -> m CharSource
notChar c
parses any single character other than c
. Returns the parsed
character.
This parser succeeds for any character. Returns the parsed character.
string :: String -> m StringSource
string s
parses a sequence of characters given by s
. Returns
the parsed string (i.e. s
).
divOrMod = string "div" <|> string "mod"
text t
parses a sequence of characters determined by the text t
Returns
the parsed text fragment (i.e. t
).
Using OverloadedStrings
:
divOrMod = text "div" <|> text "mod"
CharParsing ReadP | |
Chunk t => CharParsing (Parser t) | |
(CharParsing m, MonadPlus m) => CharParsing (IdentityT m) | |
CharParsing m => CharParsing (Unlined m) | |
CharParsing m => CharParsing (Unspaced m) | |
CharParsing m => CharParsing (Unhighlighted m) | |
(CharParsing m, MonadPlus m) => CharParsing (ReaderT e m) | |
(CharParsing m, MonadPlus m) => CharParsing (StateT s m) | |
(CharParsing m, MonadPlus m) => CharParsing (StateT s m) | |
(CharParsing m, MonadPlus m, Monoid w) => CharParsing (WriterT w m) | |
(CharParsing m, MonadPlus m, Monoid w) => CharParsing (WriterT w m) | |
Stream s m Char => CharParsing (ParsecT s u m) | |
(CharParsing m, MonadPlus m, Monoid w) => CharParsing (RWST r w s m) | |
(CharParsing m, MonadPlus m, Monoid w) => CharParsing (RWST r w s m) |