From aac3549a72663c523a456b2f5d7c3b77f509cdd6 Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Thu, 14 Jan 2021 11:42:55 +0000 Subject: Add labelled expressions. Restructure project (again). Convert `Cat` and `Alt` from binary to n+2-ary. --- src/main.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/main.rs') 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) .and_then(|_| syn::parse_str(&input).map_err(|e| Box::new(e) as Box)) - .and_then(|nibble: File| nibble.convert().ok_or(Box::new(UndecVar) as Box)) + .and_then(|nibble: File| nibble.convert().map_err(|e| Box::new(e) as Box)) .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) }) .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) @@ -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) -- cgit v1.2.3