From fe2eac31d9dbec772796c3ea75be32e9cd01b810 Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Thu, 7 Jan 2021 12:44:06 +0000 Subject: Add first steps of AutoChomp --- autochomp/src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 autochomp/src/main.rs (limited to 'autochomp/src/main.rs') diff --git a/autochomp/src/main.rs b/autochomp/src/main.rs new file mode 100644 index 0000000..400cc2d --- /dev/null +++ b/autochomp/src/main.rs @@ -0,0 +1,23 @@ +use std::{error::Error, io::{self, Read, Write}, process::exit}; + +use chewed::Parse; + +mod nibble { + include!(concat!(env!("OUT_DIR"), "/nibble.rs")); +} + +fn main() { + let mut input = String::new(); + let res = io::stdin() + .read_to_string(&mut input) + .map_err(|e| Box::new(e) as Box) + .and_then(|_| nibble::Ast::parse(input.chars().peekable()).map_err(|e| Box::new(e) as Box)) + .and_then(|ast| { + write!(io::stdout(), "{:?}", ast).map_err(|e| Box::new(e) as Box) + }); + + if let Err(e) = res { + eprintln!("{}", e); + exit(1) + } +} -- cgit v1.2.3