summaryrefslogtreecommitdiff
path: root/autochomp/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'autochomp/src/main.rs')
-rw-r--r--autochomp/src/main.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/autochomp/src/main.rs b/autochomp/src/main.rs
index cbc0646..d8a78e1 100644
--- a/autochomp/src/main.rs
+++ b/autochomp/src/main.rs
@@ -7,7 +7,7 @@ use std::{
use chewed::{IterWrapper, Parser};
use chomp::{
chomp::{
- ast::substitute::InlineCalls,
+ ast::substitute::Reduce,
typed::{
context::Context,
lower::{Backend, GenerateCode},
@@ -16,7 +16,9 @@ use chomp::{
visit::Visitable,
},
lower::RustBackend,
+ nibble::convert::{self, Convert},
};
+use proc_macro2::Span;
fn main() {
let mut input = String::new();
@@ -28,12 +30,12 @@ fn main() {
.parse::<autochomp::Ast>()
.map_err(|e| Box::new(e) as Box<dyn Error>)
})
- .and_then(|ast| ast.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(|ast| {
+ ast.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| {
@@ -46,7 +48,7 @@ fn main() {
.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>)