Module Parser

Library with functional logic parser combinators.

Adapted from: Rafael Caballero and Francisco J. Lopez-Fraguas: A Functional Logic Perspective of Parsing. In Proc. FLOPS'99, Springer LNCS 1722, pp. 85-99, 1999

Author: Michael Hanus

Version: December 2012

Summary of exported operations:

(<|>) :: ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]   
Combines two parsers without representation in an alternative manner.
(<||>) :: (a -> [b] -> [b]) -> (a -> [b] -> [b]) -> a -> [b] -> [b]   
Combines two parsers with representation in an alternative manner.
(<*>) :: ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]   
Combines two parsers (with or without representation) in a sequential manner.
(>>>) :: ([a] -> [a]) -> b -> b -> [a] -> [a]   
Attaches a representation to a parser without representation.
empty :: [a] -> [a]   
The empty parser which recognizes the empty word.
terminal :: a -> [a] -> [a]   
A parser recognizing a particular terminal symbol.
satisfy :: (a -> Bool) -> a -> [a] -> [a]   
A parser (with representation) recognizing a terminal satisfying a given predicate.
star :: (a -> [b] -> [b]) -> [a] -> [b] -> [b]   
A star combinator for parsers.
some :: (a -> [b] -> [b]) -> [a] -> [b] -> [b]   
A some combinator for parsers.

Exported datatypes:


Parser

Type synonym: Parser a = [a] -> [a]


ParserRep

Type synonym: ParserRep a b = a -> Parser b


Exported operations:

(<|>) :: ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]   

Combines two parsers without representation in an alternative manner.

Further infos:
  • defined as right-associative infix operator with precedence 2

(<||>) :: (a -> [b] -> [b]) -> (a -> [b] -> [b]) -> a -> [b] -> [b]   

Combines two parsers with representation in an alternative manner.

Further infos:
  • defined as right-associative infix operator with precedence 2

(<*>) :: ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]   

Combines two parsers (with or without representation) in a sequential manner.

Further infos:
  • defined as right-associative infix operator with precedence 4

(>>>) :: ([a] -> [a]) -> b -> b -> [a] -> [a]   

Attaches a representation to a parser without representation.

Further infos:
  • defined as right-associative infix operator with precedence 3

empty :: [a] -> [a]   

The empty parser which recognizes the empty word.

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

terminal :: a -> [a] -> [a]   

A parser recognizing a particular terminal symbol.

Further infos:
  • partially defined

satisfy :: (a -> Bool) -> a -> [a] -> [a]   

A parser (with representation) recognizing a terminal satisfying a given predicate.

Further infos:
  • partially defined

star :: (a -> [b] -> [b]) -> [a] -> [b] -> [b]   

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

some :: (a -> [b] -> [b]) -> [a] -> [b] -> [b]   

A some combinator for parsers. The returned parser repeats the argument parser (with representation) at least once.