diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index 0e7193e..0954074 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use std::{ use chomp::{ chomp::{ - ast::substitute::InlineCalls, + ast::substitute::Reduce, typed::{ context::Context, lower::{Backend, GenerateCode}, @@ -15,8 +15,12 @@ use chomp::{ visit::Visitable, }, lower::RustBackend, - nibble::File, + nibble::{ + convert::{self, Convert}, + Statement, + }, }; +use proc_macro2::Span; fn main() { let mut input = String::new(); @@ -24,12 +28,13 @@ fn main() { .read_to_string(&mut input) .map_err(|e| Box::new(e) as Box<dyn Error>) .and_then(|_| syn::parse_str(&input).map_err(|e| Box::new(e) as Box<dyn Error>)) - .and_then(|nibble: File| nibble.convert().map_err(|e| Box::new(e) as Box<dyn Error>)) - .and_then(|(funs, goal)| { - funs.into_iter() - .try_rfold(goal, |goal, function| { - goal.fold(&mut InlineCalls { function }) - }) + .and_then(|nibble: Statement| { + nibble + .convert(&mut convert::Context::default()) + .map_err(|e| Box::new(e) as Box<dyn Error>) + }) + .and_then(|expr| { + expr.fold(&mut Reduce) .map_err(|e| Box::new(e) as Box<dyn Error>) }) .and_then(|term| { @@ -37,12 +42,12 @@ fn main() { term.fold(&mut TypeInfer { context: &mut context, }) - .map_err(|e| Box::new(e) as Box<dyn Error>) + .map_err(|e| Box::new(e) as Box<dyn Error>) }) .map(|typed| { let mut backend = RustBackend::default(); let id = typed.gen(&mut backend); - backend.emit_code(None, None, id) + backend.emit_code(None, Span::call_site(), id) }) .and_then(|code| { write!(io::stdout(), "{:#}", code).map_err(|e| Box::new(e) as Box<dyn Error>) |