diff options
Diffstat (limited to 'autochomp/src/main.rs')
-rw-r--r-- | autochomp/src/main.rs | 23 |
1 files changed, 23 insertions, 0 deletions
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<dyn Error>) + .and_then(|_| nibble::Ast::parse(input.chars().peekable()).map_err(|e| Box::new(e) as Box<dyn Error>)) + .and_then(|ast| { + write!(io::stdout(), "{:?}", ast).map_err(|e| Box::new(e) as Box<dyn Error>) + }); + + if let Err(e) = res { + eprintln!("{}", e); + exit(1) + } +} |