diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2021-01-07 12:44:06 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2021-01-07 12:44:06 +0000 |
commit | fe2eac31d9dbec772796c3ea75be32e9cd01b810 (patch) | |
tree | ad0c0ad42ce986d3dd915512de8c18968194c15a /autochomp/src/main.rs | |
parent | eb280a903f8f20d0b0c0ef5acae955a20929d100 (diff) |
Add first steps of AutoChomp
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) + } +} |