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.Combinators

Description

A collection of predefined combinators. Use these to combine other parsers into more complex ones.

Synopsis

Documentation

choice :: (Monad m, Stream s t) => [ParcomT s t m a] -> ParcomT s t m a Source

Walk a list of options, return the first one that succeeds.

namedChoice :: (Monad m, Stream s t) => [(String, ParcomT s t m a)] -> ParcomT s t m a Source

Like choice, but each choice tagged with a human-readable name for better error reporting.

before :: (Monad m, Stream s t) => ParcomT s t m a -> ParcomT s t m b -> ParcomT s t m a Source

Match two consecutive parser, return the first parser's result iff both succeed.

between :: (Monad m, Stream s t) => ParcomT s t m a -> ParcomT s t m l -> ParcomT s t m r -> ParcomT s t m a Source

Match three consecutive parsers, return the middle parser's result iff all three match. Parsers are given in the order inner, left, right.

many :: (Monad m, Stream s t) => ParcomT s t m a -> ParcomT s t m [a] Source

Match zero or more occurrences of a parser

many1 :: (Monad m, Stream s t) => ParcomT s t m a -> ParcomT s t m [a] Source

Match one or more occurrences of a parser

manySepBy :: (Monad m, Stream s t) => ParcomT s t m a -> ParcomT s t m b -> ParcomT s t m [a] Source

Given an item parser and a separator parser, keep parsing until the separator or the item fails.

times :: (Monad m, Stream s t) => Int -> ParcomT s t m a -> ParcomT s t m [a] Source

Run the given parser n times, returning all the results as a list.

skip :: Monad m => ParcomT s t m a -> ParcomT s t m () Source

Ignore the result of a parser.

possibly :: Monad m => ParcomT s t m a -> ParcomT s t m (Maybe a) Source

Optional parsing to Maybe

optional :: Monad m => a -> ParcomT s t m a -> ParcomT s t m a Source

Optional parsing with default

option :: Monad m => ParcomT s t m a -> ParcomT s t m () Source

Optional parsing, ignoring (but consuming) result