fix: recursive term

This commit is contained in:
rvcas 2022-05-05 23:51:35 -04:00
parent 6c31acbf5d
commit 6fdcd7012d
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,6 @@
pub mod ast;
pub mod cli;
pub mod parser;
#[macro_use]
extern crate combine;

View File

@ -52,7 +52,15 @@ where
Input: Stream<Token = char>,
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>
@ -62,7 +70,7 @@ where
{
string("delay")
.skip(spaces())
.with(term())
.with(term_())
.map(|term| Term::Delay(Box::new(term)))
}