pears
Types
pub type ParseError(i) {
ParseError(input: Input(i), expected: List(String))
}
Constructors
-
ParseError(input: Input(i), expected: List(String))
pub type ParseResult(i, a) =
Result(Parsed(i, a), ParseError(i))
pub type Parsed(i, a) {
Parsed(input: Input(i), value: a)
}
Constructors
-
Parsed(input: Input(i), value: a)
Functions
pub fn alt(
parser_1: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
parser_2: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, b), ParseError(a))
pub fn between(
open: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
close: fn(List(a)) -> Result(Parsed(a, c), ParseError(a)),
parser: fn(List(a)) -> Result(Parsed(a, d), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, d), ParseError(a))
pub fn char(
c: String,
) -> fn(List(String)) ->
Result(Parsed(String, String), ParseError(String))
pub fn lazy(
f: fn() -> fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, b), ParseError(a))
Lazily evaluates the given parser allowing for recursive parsers
pub fn left(
parser_1 p1: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
parser_2 p2: fn(List(a)) -> Result(Parsed(a, c), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, b), ParseError(a))
pub fn many0(
parser: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, List(b)), ParseError(a))
Parses zero or more occurrences of the given parser
pub fn many1(
parser: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, List(b)), ParseError(a))
Parses one or more occurrences of the given parser
pub fn map(
p: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
fun: fn(b) -> c,
) -> fn(List(a)) -> Result(Parsed(a, c), ParseError(a))
Maps the result of a parser to a new value using a mapper function
pub fn pair(
parser_1 p1: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
parser_2 p2: fn(List(a)) -> Result(Parsed(a, c), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, #(b, c)), ParseError(a))
pub fn parse(
parser: fn(List(String)) ->
Result(Parsed(String, a), ParseError(String)),
input: String,
) -> Result(Parsed(String, a), ParseError(String))
pub fn right(
parser_1 p1: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
parser_2 p2: fn(List(a)) -> Result(Parsed(a, c), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, c), ParseError(a))
pub fn satisfying(
f: fn(a) -> Bool,
) -> fn(List(a)) -> Result(Parsed(a, a), ParseError(a))
pub fn string(
str: String,
) -> fn(List(String)) ->
Result(Parsed(String, String), ParseError(String))
pub fn then(
parser_a: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
parser_b: fn(List(a)) -> Result(Parsed(a, c), ParseError(a)),
) -> fn(List(a)) -> Result(Parsed(a, c), ParseError(a))
pub fn to(
parser: fn(List(a)) -> Result(Parsed(a, b), ParseError(a)),
value: c,
) -> fn(List(a)) -> Result(Parsed(a, c), ParseError(a))
Maps the result of a parser to a constant value
pub fn whitespace() -> fn(List(String)) ->
Result(Parsed(String, String), ParseError(String))
pub fn whitespace0() -> fn(List(String)) ->
Result(Parsed(String, List(String)), ParseError(String))
pub fn whitespace1() -> fn(List(String)) ->
Result(Parsed(String, List(String)), ParseError(String))