summaryrefslogtreecommitdiff
path: root/autochomp/src/main.rs
diff options
context:
space:
mode:
authorGreg Brown <gmb60@cam.ac.uk>2021-05-11 13:53:56 +0100
committerGreg Brown <gmb60@cam.ac.uk>2021-05-11 13:53:56 +0100
commit387959675cd53b3c75ad9b6215b07843f8c8f1d8 (patch)
treebc972c31a0b48f8fd8c9240465c8bd83e16f5258 /autochomp/src/main.rs
parentdfc08ff2c6580bbeb3951b223e0332546ba3b0d9 (diff)
Rename autochomp to autonibble.
Diffstat (limited to 'autochomp/src/main.rs')
-rw-r--r--autochomp/src/main.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/autochomp/src/main.rs b/autochomp/src/main.rs
deleted file mode 100644
index d8a78e1..0000000
--- a/autochomp/src/main.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-use std::{
- error::Error,
- io::{self, Read, Write},
- process::exit,
-};
-
-use chewed::{IterWrapper, Parser};
-use chomp::{
- chomp::{
- ast::substitute::Reduce,
- typed::{
- context::Context,
- lower::{Backend, GenerateCode},
- TypeInfer,
- },
- visit::Visitable,
- },
- lower::RustBackend,
- nibble::convert::{self, Convert},
-};
-use proc_macro2::Span;
-
-fn main() {
- let mut input = String::new();
- let res = io::stdin()
- .read_to_string(&mut input)
- .map_err(|e| Box::new(e) as Box<dyn Error>)
- .and_then(|_| {
- IterWrapper::new(input.chars())
- .parse::<autochomp::Ast>()
- .map_err(|e| Box::new(e) as Box<dyn Error>)
- })
- .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| {
- let mut context = Context::default();
- term.fold(&mut TypeInfer {
- context: &mut context,
- })
- .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, Span::call_site(), id)
- })
- .and_then(|code| {
- write!(io::stdout(), "{:#}", code).map_err(|e| Box::new(e) as Box<dyn Error>)
- });
-
- if let Err(e) = res {
- eprintln!("{}", e);
- exit(1)
- }
-}