parsec-3.1.16.1: Monadic parser combinators
Copyright(c) Daan Leijen 1999-2001 (c) Paolo Martini 2007
LicenseBSD-style (see the LICENSE file)
Maintainerderek.a.elkins@gmail.com
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Text.Parsec.Char

Description

Commonly used character parsers.

Synopsis

Documentation

oneOf :: forall s (m :: Type -> Type) u. Stream s m Char => [Char] -> ParsecT s u m Char Source #

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 :: forall s (m :: Type -> Type) u. Stream s m Char => [Char] -> ParsecT s u m Char Source #

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 :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m () Source #

Skips zero or more white space characters. See also skipMany.

space :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a white space character (any character which satisfies isSpace) Returns the parsed character.

newline :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a newline character ('\n'). Returns a newline character.

crlf :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a carriage return character ('\r') followed by a newline character ('\n'). Returns a newline character.

endOfLine :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a CRLF (see crlf) or LF (see newline) end-of-line. Returns a newline character ('\n').

endOfLine = newline <|> crlf

tab :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a tab character ('\t'). Returns a tab character.

upper :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses an upper case letter (according to isUpper). Returns the parsed character.

lower :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a lower case character (according to isLower). Returns the parsed character.

alphaNum :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a alphabetic or numeric Unicode characters according to isAlphaNum. Returns the parsed character.

Note that numeric digits outside the ASCII range (such as arabic-indic digits like e.g. "٤" or U+0664), as well as numeric characters which aren't digits, are parsed by this function but not by digit.

letter :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses an alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters according to isAlpha). Returns the parsed character.

digit :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses an ASCII digit. Returns the parsed character.

hexDigit :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses a hexadecimal digit (a digit or a letter between 'a' and 'f' or 'A' and 'F'). Returns the parsed character.

octDigit :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

Parses an octal digit (a character between '0' and '7'). Returns the parsed character.

char :: forall s (m :: Type -> Type) u. Stream s m Char => Char -> ParsecT s u m Char Source #

char c parses a single character c. Returns the parsed character (i.e. c).

 semiColon  = char ';'

anyChar :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Char Source #

This parser succeeds for any character. Returns the parsed character.

satisfy :: forall s (m :: Type -> Type) u. Stream s m Char => (Char -> Bool) -> ParsecT s u m Char Source #

The parser satisfy f succeeds for any character for which the supplied function f returns True. Returns the character that is actually parsed.

string :: forall s (m :: Type -> Type) u. Stream s m Char => String -> ParsecT s u m String Source #

string s parses a sequence of characters given by s. Returns the parsed string (i.e. s).

 divOrMod    =   string "div"
             <|> string "mod"

Consider using string'.

string' :: forall s (m :: Type -> Type) u. Stream s m Char => String -> ParsecT s u m String Source #

string' s parses a sequence of characters given by s. Doesn't consume matching prefix.

 carOrCdr    =   string' "car"
             <|> string' "cdr"

Since: parsec-3.1.16.0