feat: add error and builtin to term function
and add between parse
This commit is contained in:
parent
6b2601c40b
commit
bbc1b25ab7
|
@ -64,6 +64,8 @@ where
|
||||||
attempt(apply()),
|
attempt(apply()),
|
||||||
attempt(constant()),
|
attempt(constant()),
|
||||||
attempt(force()),
|
attempt(force()),
|
||||||
|
attempt(error()),
|
||||||
|
attempt(builtin()),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,12 +145,16 @@ where
|
||||||
Input: Stream<Token = char>,
|
Input: Stream<Token = char>,
|
||||||
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
|
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
|
||||||
{
|
{
|
||||||
|
between(
|
||||||
|
token('('),
|
||||||
|
token(')'),
|
||||||
string("builtin")
|
string("builtin")
|
||||||
.with(skip_many1(space()))
|
.with(skip_many1(space()))
|
||||||
.with(many1(alpha_num()))
|
.with(many1(alpha_num()))
|
||||||
.map(|builtin_name: String| {
|
.map(|builtin_name: String| {
|
||||||
Term::Builtin(DefaultFunction::from_str(&builtin_name).unwrap())
|
Term::Builtin(DefaultFunction::from_str(&builtin_name).unwrap())
|
||||||
})
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn error<Input>() -> impl Parser<Input, Output = Term>
|
pub fn error<Input>() -> impl Parser<Input, Output = Term>
|
||||||
|
@ -156,10 +162,14 @@ where
|
||||||
Input: Stream<Token = char>,
|
Input: Stream<Token = char>,
|
||||||
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
|
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
|
||||||
{
|
{
|
||||||
|
between(
|
||||||
|
token('('),
|
||||||
|
token(')'),
|
||||||
string("error")
|
string("error")
|
||||||
.with(skip_many1(space()))
|
.with(skip_many1(space()))
|
||||||
.with(term_())
|
.with(term_())
|
||||||
.map(|term| Term::Error(Box::new(term)))
|
.map(|term| Term::Error(Box::new(term))),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant<Input>() -> impl Parser<Input, Output = Term>
|
pub fn constant<Input>() -> impl Parser<Input, Output = Term>
|
||||||
|
|
Loading…
Reference in New Issue