diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2021-01-14 11:42:55 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2021-01-14 11:42:55 +0000 |
commit | aac3549a72663c523a456b2f5d7c3b77f509cdd6 (patch) | |
tree | 562824f3cfa5feca791715c733f7749197bb7e7a /src/main.rs | |
parent | 0d01692c97ea8ca6fc4b229e5b9678cb252bceda (diff) |
Add labelled expressions.
Restructure project (again).
Convert `Cat` and `Alt` from binary to n+2-ary.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs index a255590..100bb68 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,15 +5,7 @@ use std::{ process::exit, }; -use chomp::{ - chomp::{ - check::{InlineCalls, TypeCheck}, - context::Context, - visit::Visitable, - }, - lower::{rust::RustBackend, Backend, GenerateCode}, - nibble::cst::File, -}; +use chomp::{chomp::{ast::substitute::InlineCalls, typed::{TypeInfer, context::Context, lower::{Backend, GenerateCode}}, visit::Visitable}, lower::RustBackend, nibble::cst::File}; #[derive(Debug)] struct UndecVar; @@ -31,17 +23,17 @@ 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().ok_or(Box::new(UndecVar) 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::new(function)) + goal.fold(&mut InlineCalls { function }) }) .map_err(|e| Box::new(e) as Box<dyn Error>) }) .and_then(|term| { let mut context = Context::default(); - term.fold(&mut TypeCheck { + term.fold(&mut TypeInfer { context: &mut context, }) .map_err(|e| Box::new(e) as Box<dyn Error>) @@ -49,7 +41,7 @@ fn main() { .map(|typed| { let mut backend = RustBackend::default(); let id = typed.gen(&mut backend); - backend.emit_code(id) + backend.emit_code(None, None, id) }) .and_then(|code| { write!(io::stdout(), "{:#}", code).map_err(|e| Box::new(e) as Box<dyn Error>) |