parcom-lib-0.8.0.3: A simple parser-combinator library, a bit like Parsec but without the frills

Safe HaskellSafe-Inferred
LanguageHaskell98

Text.Parcom.Prim

Description

Primitive parsers.

Regarding consuming input, unless states otherwise, all of these behave as follows:

  • If a parser succeeds, it consumes the input it matches
  • If a parser fails, it does not consume any input at all

Synopsis

Documentation

anyToken :: (Monad m, Stream s t, Token t) => ParcomT s t m t Source

Gets the next token from the stream

oneOf :: (Monad m, Stream s t, Token t, Show t, Eq t) => [t] -> ParcomT s t m t Source

Matches one token against a list of possible tokens; returns the matching token or fails.

noneOf :: (Monad m, Stream s t, Token t, Show t, Eq t) => [t] -> ParcomT s t m t Source

Matches one token against a list of prohibited tokens; returns the non-matching token or fails.

eof :: (Monad m, Stream s t, Token t) => ParcomT s t m () Source

Succeeds iff end-of-input has been reached

satisfy :: (Monad m, Stream s t, Token t) => (t -> Bool) -> ParcomT s t m t Source

Succeeds if the given predicate is met for the next token.

token :: (Monad m, Stream s t, Token t, Show t, Eq t) => t -> ParcomT s t m t Source

Exactly match one particular token

tokens :: (Monad m, Stream s t, Token t, Eq t, Show t) => [t] -> ParcomT s t m [t] Source

Match a series of tokens exactly

prefix :: (Monad m, Stream s t, Token t, Eq t, Show t, Listish s t) => s -> ParcomT s t m s Source

Match a series of tokens exactly. Unlike tokens, this parser accepts the target sequence by the stream's type instead of list-of-tokens. Depending on the stream's Listish implementation, this may be more efficient than matching and consuming the tokens one-by-one, as tokens does.