Library with deterministic logic parser combinators.
Author: Jonas Oberschweiber
Version: August 2018
parse
:: (String -> [(a,String)]) -> String -> Maybe a
Applies a parser to a string. |
failure
:: String -> [(a,String)]
A parser that always fails. |
yield
:: a -> String -> [(a,String)]
A parser that consumes no input and results in the given value. |
empty
:: String -> [((),String)]
A parser that consumes no input and results in the unit value. |
anyChar
:: String -> [(Char,String)]
A parser that consumes an arbitrary single character. |
check
:: (a -> Bool) -> (String -> [(a,String)]) -> String -> [(a,String)]
Builds a parser that succeeds if the predicate holds on the result of the original parser. |
char
:: Char -> String -> [((),String)]
Builds a parser that consumes a specific character and results in the unit value. |
word
:: String -> String -> [((),String)]
Builds a parser that consumes the given string and results in the unit value. |
(<|>)
:: (String -> [(a,String)]) -> (String -> [(a,String)]) -> String -> [(a,String)]
Builds a parser that tries both its argument parsers and results in the result of the first one to succeed. |
(<!>)
:: (String -> [(a,String)]) -> (String -> [(a,String)]) -> String -> [(a,String)]
Builds a parser that tries its first argument parser and alternatively, if the first one does not succeed, its second argument parser. |
(<$>)
:: (a -> b) -> (String -> [(a,String)]) -> String -> [(b,String)]
Builds a parser that applies a function to the result of the original parser. |
(<*>)
:: (String -> [(a -> b,String)]) -> (String -> [(a,String)]) -> String -> [(b,String)]
Applies the function returned by the first parser to the result of the second parser. |
(<*)
:: (String -> [(a,String)]) -> (String -> [(b,String)]) -> String -> [(a,String)]
Builds a parser that applies both parsers in order and returns the result of the first one. |
(*>)
:: (String -> [(a,String)]) -> (String -> [(b,String)]) -> String -> [(b,String)]
Builds a parser that applies both parsers in order and returns the result of the second one. |
(*>=)
:: (String -> [(a,String)]) -> (a -> String -> [(b,String)]) -> String -> [(b,String)]
|
many
:: (String -> [(a,String)]) -> String -> [([a],String)]
Builds a parser that will apply the original parser arbitrarily many times. |
some
:: (String -> [(a,String)]) -> String -> [([a],String)]
Builds a parser that will apply the original parser at least once. |
A parser
Type synonym: Parser a = String -> [(a,String)]
Applies a parser to a string. If it succeeds, returns the result of the
parser. Returns |
A parser that always fails.
|
A parser that consumes no input and results in the given value.
|
A parser that consumes no input and results in the unit value.
|
A parser that consumes an arbitrary single character. |
Builds a parser that succeeds if the predicate holds on the result of the original parser. |
Builds a parser that consumes a specific character and results in the unit value. |
Builds a parser that consumes the given string and results in the unit value. |
Builds a parser that tries both its argument parsers and results in the result of the first one to succeed.
|
Builds a parser that tries its first argument parser and alternatively, if
the first one does not succeed, its second argument parser. In contrast to
|
Builds a parser that applies a function to the result of the original parser.
|
Applies the function returned by the first parser to the result of the second parser. Applies the parsers in order.
|
Builds a parser that applies both parsers in order and returns the result of the first one.
|
Builds a parser that applies both parsers in order and returns the result of the second one.
|
|
Builds a parser that will apply the original parser arbitrarily many times. |
Builds a parser that will apply the original parser at least once. |