From 6fdcd7012d0513e12e2b4c87a58d8228f9507710 Mon Sep 17 00:00:00 2001 From: rvcas Date: Thu, 5 May 2022 23:51:35 -0400 Subject: [PATCH] fix: recursive term --- src/lib.rs | 3 +++ src/parser.rs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5fdd7584..7378cc9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ pub mod ast; pub mod cli; pub mod parser; + +#[macro_use] +extern crate combine; diff --git a/src/parser.rs b/src/parser.rs index d5943dad..23327212 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -52,7 +52,15 @@ where Input: Stream, Input::Error: ParseError, { - between(token('('), token(')'), constant()).skip(spaces()) + between(token('('), token(')'), constant().or(delay())).skip(spaces()) +} + +parser! { + fn term_[I]()(I) -> Term + where [I: Stream] + { + term() + } } pub fn delay() -> impl Parser @@ -62,7 +70,7 @@ where { string("delay") .skip(spaces()) - .with(term()) + .with(term_()) .map(|term| Term::Delay(Box::new(term))) }