Module XFD.Parser

This module implements some deterministic parsing combinators.

Summary of exported operations:

(<*) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],b)   
Combine parsers with resulting representation of first one.
(*>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],c)   
Combine parsers with resulting representation of second one.
(<*>) :: ([a] -> Either String ([a],b -> c)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],c)   
(<|>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],b)   
Combines two parsers in an alternative manner.
(<$>) :: (a -> b) -> ([c] -> Either String ([c],a)) -> [c] -> Either String ([c],b)   
Apply unary function f to result of parser p
liftP2 :: (a -> b -> c) -> ([d] -> Either String ([d],a)) -> ([d] -> Either String ([d],b)) -> [d] -> Either String ([d],c)   
Apply binary function f to results of parsers p1 and p2
yield :: a -> [b] -> Either String ([b],a)   
A parser with x as representation while consuming no tokens.
terminal :: a -> [a] -> Either String ([a],())   
A parser recognizing a particular terminal symbol.
eof :: [a] -> Either String ([a],b)   
Returns parse error about unexpected end-of-file
unexpected :: a -> [a] -> Either String ([a],b)   
Returns parse error about unexpected token t
star :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])   
A star combinator for parsers.
some :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])   
A some combinator for parsers.

Exported datatypes:


Parser

Type synonym: Parser a b = [a] -> Either ParseError ([a],b)


ParseError

Type synonym: ParseError = String


Exported operations:

(<*) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],b)   

Combine parsers with resulting representation of first one.

(*>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],c)) -> [a] -> Either String ([a],c)   

Combine parsers with resulting representation of second one.

(<*>) :: ([a] -> Either String ([a],b -> c)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],c)   

(<|>) :: ([a] -> Either String ([a],b)) -> ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],b)   

Combines two parsers in an alternative manner.

(<$>) :: (a -> b) -> ([c] -> Either String ([c],a)) -> [c] -> Either String ([c],b)   

Apply unary function f to result of parser p

liftP2 :: (a -> b -> c) -> ([d] -> Either String ([d],a)) -> ([d] -> Either String ([d],b)) -> [d] -> Either String ([d],c)   

Apply binary function f to results of parsers p1 and p2

yield :: a -> [b] -> Either String ([b],a)   

A parser with x as representation while consuming no tokens.

Further infos:
  • solution complete, i.e., able to compute all solutions

terminal :: a -> [a] -> Either String ([a],())   

A parser recognizing a particular terminal symbol.

eof :: [a] -> Either String ([a],b)   

Returns parse error about unexpected end-of-file

Further infos:
  • solution complete, i.e., able to compute all solutions

unexpected :: a -> [a] -> Either String ([a],b)   

Returns parse error about unexpected token t

star :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])   

A star combinator for parsers. The returned parser repeats zero or more times a parser p and returns the representation of all parsers in a list.

some :: ([a] -> Either String ([a],b)) -> [a] -> Either String ([a],[b])   

A some combinator for parsers. The returned parser repeats the argument parser at least once.