summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorGreg Brown <gmb60@cam.ac.uk>2021-05-06 19:40:59 +0100
committerGreg Brown <gmb60@cam.ac.uk>2021-05-06 19:40:59 +0100
commitdfc08ff2c6580bbeb3951b223e0332546ba3b0d9 (patch)
tree60597dd9492b9c2dfa10ea610289f143dd3e41b7 /src/main.rs
parentef485d6f3e4df6e1a424ba3797388fa0bba6eb2e (diff)
Introduce lambda expressions.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs25
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>)