parsley-1.0.0.2: A fast parser combinator library backed by Typed Template Haskell
LicenseBSD-3-Clause
MaintainerJamie Willis
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

Parsley.Combinator

Description

This module contains the classic parser combinator operations specific to parsers themselves. This means any combinators that deal with input consumption at a primitive level.

Since: 0.1.0.0

Synopsis

Documentation

satisfy #

Arguments

:: ParserOps rep 
=> rep (Char -> Bool)

The predicate that a character must satisfy to be parsed

-> Parser Char

A parser that matches a single character matching the predicate

Attempts to read a single character matching the provided predicate. If it succeeds, the character will be returned and consumed, otherwise the parser will fail having consumed no input.

Since: parsley-core-0.1.0.0

char :: Char -> Parser Char Source #

This combinator will attempt to match a given character. If that character is the next input token, the parser succeeds and the character is returned. Otherwise, the combinator will fail having not consumed any input.

Since: 0.1.0.0

item :: Parser Char Source #

Reads any single character. This combinator will only fail if there is no more input remaining. The parsed character is returned.

Since: 0.1.0.0

string :: String -> Parser String Source #

This combinator will attempt match a given string. If the parser fails midway through, this combinator will fail having consumed input. On success, the string itself is returned and input will be consumed.

Since: 0.1.0.0

token :: String -> Parser String Source #

Like string, excepts parses the given string atomically using try. Never consumes input on failure.

Since: 0.1.0.0

oneOf :: [Char] -> Parser Char Source #

This combinator will attempt to match any one of the provided list of characters. If one of those characters is found, it will be returned and the input consumed. If not, the combinator will fail having consumed no input.

Since: 0.1.0.0

noneOf :: [Char] -> Parser Char Source #

This combinator will attempt to not match any one of the provided list of characters. If one of those characters is found, the combinator will fail having consumed no input. If not, it will return the character that was not an element of the provided list.

Since: 0.1.0.0

eof :: Parser () Source #

This parser succeeds only if there is no input left to consume, and fails without consuming input otherwise.

Since: 0.1.0.0

more :: Parser () Source #

This parser succeeds if there is still input left to consume, and fails otherwise.

Since: 0.1.0.0

someTill :: Parser a -> Parser b -> Parser [a] Source #

The combinator someTill p end will try and parse p as many times as possible (but at least once) so long as end cannot be successfully parsed. It will return the results from the successful parses of p.

Since: 0.1.0.0

try :: Parser a -> Parser a #

This combinator allows a parser to backtrack on failure, which is to say that it will not have consumed any input if it were to fail. This is important since parsec semantics demand that the second branch of (<|>) can only be taken if the first did not consume input on failure.

Excessive use of try will reduce the efficiency of the parser and effect the generated error messages. It should only be used in one of two circumstances:

  • When two branches of a parser share a common leading prefix (in which case, it is often better to try and factor this out).
  • When a parser needs to be executed atomically (for example, tokens).

Since: parsley-core-0.1.0.0

lookAhead :: Parser a -> Parser a #

This combinator will attempt to parse a given parser. If it succeeds, the result is returned without having consumed any input. If it fails, however, any consumed input remains consumed.

Since: parsley-core-0.1.0.0

notFollowedBy :: Parser a -> Parser () #

This combinator will ensure that a given parser fails. If the parser does fail, a () is returned and no input is consumed. If the parser succeeded, then this combinator will fail, however it will not consume any input.

Since: parsley-core-0.1.0.0