uu-tc-2009.2.2: Haskell 98 parser combintors for INFOB3TC at Utrecht University

ParseLib.Parallel.Core

Contents

Synopsis

The type of parsers

data Parser s r Source

The parser is a CPS version of Parser'

Elementary parsers

anySymbol :: Parser s sSource

Parses any single symbol.

satisfy :: (s -> Bool) -> Parser s sSource

Takes a predicate and returns a parser that parses a single symbol satisfying that predicate.

empty :: Alternative f => forall a. f a

The identity of <|>

failp :: Parser s aSource

Same as empty; provided for compatibility with the lecture notes.

succeed :: a -> Parser s aSource

Parser that always succeeds, i.e., for epsilon.

pure :: Applicative f => forall a. a -> f a

Lift a value.

Parser combinators

(<|>) :: Alternative f => forall a. f a -> f a -> f a

An associative binary operation

(<<|>) :: Parser s a -> Parser s a -> Parser s aSource

Biased choice. Not implemented by the parallel parser combinators. Just maps to parallel choice.

(<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b

Sequential application.

(<$>) :: Functor f => (a -> b) -> f a -> f b

An infix synonym for fmap.

(>>=) :: Monad m => forall a b. m a -> (a -> m b) -> m b

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

Lookahead

look :: Parser s [s]Source

Returns the rest of the input without consuming anything.

Running parsers

parse :: Parser s a -> [s] -> [(a, [s])]Source

Runs a parser to a given string.