fix: recursive term
This commit is contained in:
parent
6c31acbf5d
commit
6fdcd7012d
|
@ -1,3 +1,6 @@
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
pub mod cli;
|
pub mod cli;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate combine;
|
||||||
|
|
|
@ -52,7 +52,15 @@ 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(')'), constant()).skip(spaces())
|
between(token('('), token(')'), constant().or(delay())).skip(spaces())
|
||||||
|
}
|
||||||
|
|
||||||
|
parser! {
|
||||||
|
fn term_[I]()(I) -> Term
|
||||||
|
where [I: Stream<Token = char>]
|
||||||
|
{
|
||||||
|
term()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delay<Input>() -> impl Parser<Input, Output = Term>
|
pub fn delay<Input>() -> impl Parser<Input, Output = Term>
|
||||||
|
@ -62,7 +70,7 @@ where
|
||||||
{
|
{
|
||||||
string("delay")
|
string("delay")
|
||||||
.skip(spaces())
|
.skip(spaces())
|
||||||
.with(term())
|
.with(term_())
|
||||||
.map(|term| Term::Delay(Box::new(term)))
|
.map(|term| Term::Delay(Box::new(term)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue