parsec1-1.0.0.2: Portable monadic parser combinators

Portabilityportable
Stabilityprovisional
MaintainerAntoine Latter <aslatter@gmail.com>

Text.ParserCombinators.Parsec.Char

Description

Commonly used character parsers.

Synopsis

Documentation

spaces :: CharParser st ()Source

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

space :: CharParser st CharSource

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

newline :: CharParser st CharSource

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

tab :: CharParser st CharSource

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

upper :: CharParser st CharSource

Parses an upper case letter (a character between 'A' and 'Z'). Returns the parsed character.

lower :: CharParser st CharSource

Parses a lower case character (a character between 'a' and 'z'). Returns the parsed character.

alphaNum :: CharParser st CharSource

Parses a letter or digit (a character between '0' and '9'). Returns the parsed character.

letter :: CharParser st CharSource

Parses a letter (an upper case or lower case character). Returns the parsed character.

digit :: CharParser st CharSource

Parses a digit. Returns the parsed character.

hexDigit :: CharParser st CharSource

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

octDigit :: CharParser st CharSource

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

char :: Char -> CharParser st CharSource

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

  semiColon  = char ';'

string :: String -> CharParser st StringSource

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

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

anyChar :: CharParser st CharSource

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

oneOf :: [Char] -> CharParser st 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 :: [Char] -> CharParser st 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"

satisfy :: (Char -> Bool) -> CharParser st CharSource

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

  digit     = satisfy isDigit
  oneOf cs  = satisfy (\c -> c `elem` cs)