Module Parse

Functional implementation of parser combinators.

Author: Sebastian Fischer

Summary of exported operations:

(<|>) :: ([a] -> [(b,[a])]) -> ([a] -> [(b,[a])]) -> [a] -> [(b,[a])]   
Combines two parsers in an alternative manner.
(<*>) :: ([a] -> [(b,[a])]) -> (b -> [a] -> [(c,[a])]) -> [a] -> [(c,[a])]   
Combines two parsers in a sequential manner.
update :: (a -> b) -> ([c] -> [(a,[c])]) -> [c] -> [(b,[c])]   
Updates all parsed values of a parser
(<.>) :: ([a] -> [(b,[a])]) -> ([a] -> [(c,[a])]) -> [a] -> [(b,[a])]   
Combines two parsers in a sequential manner.
(<:>) :: ([a] -> [(b,[a])]) -> ([a] -> [(c,[a])]) -> [a] -> [(c,[a])]   
Combines two parser in a sequential manner.
empty :: a -> [b] -> [(a,[b])]   
The empty parser which recognizes the empty word.
satisfy :: (a -> Bool) -> [a] -> [(a,[a])]   
A parser recognizing a terminal satisfying a given predicate.
terminal :: Eq a => a -> [a] -> [(a,[a])]   
A parser recognizing a particular terminal symbol.
star :: ([a] -> [(b,[a])]) -> [a] -> [([b],[a])]   
A star combinator for parsers.
some :: ([a] -> [(b,[a])]) -> [a] -> [([b],[a])]   
A some combinator for parsers.

Exported datatypes:


Parser

A parser maps a list of tokens into parsed values with remaining tokens.

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


Exported operations:

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

Combines two parsers in an alternative manner.

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

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

Combines two parsers in a sequential manner.

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

update :: (a -> b) -> ([c] -> [(a,[c])]) -> [c] -> [(b,[c])]   

Updates all parsed values of a parser

(<.>) :: ([a] -> [(b,[a])]) -> ([a] -> [(c,[a])]) -> [a] -> [(b,[a])]   

Combines two parsers in a sequential manner. Ignores the result of the second parser.

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

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

Combines two parser in a sequential manner. Ignores the result of the first parser.

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

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

The empty parser which recognizes the empty word.

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

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

A parser recognizing a terminal satisfying a given predicate.

terminal :: Eq a => a -> [a] -> [(a,[a])]   

A parser recognizing a particular terminal symbol.

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

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

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

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