diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2021-01-08 18:01:23 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2021-01-08 18:01:23 +0000 |
commit | eda4791472f5bf8daeba342efe97dc0977666613 (patch) | |
tree | cd10f6b19bd0657792dcba21af56dc9c497bd734 /autochomp/src/main.rs | |
parent | 0a837400e0ffa7fca1a1902b34f375d0dc5b5f6b (diff) |
Minor fix-ups to AutoChomp
Diffstat (limited to 'autochomp/src/main.rs')
-rw-r--r-- | autochomp/src/main.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/autochomp/src/main.rs b/autochomp/src/main.rs index 400cc2d..9b3b521 100644 --- a/autochomp/src/main.rs +++ b/autochomp/src/main.rs @@ -1,6 +1,11 @@ -use std::{error::Error, io::{self, Read, Write}, process::exit}; +use std::{ + error::Error, + fs, + io::{self, Read, Write}, + process::exit, +}; -use chewed::Parse; +use chewed::{IterWrapper, Parser}; mod nibble { include!(concat!(env!("OUT_DIR"), "/nibble.rs")); @@ -11,7 +16,11 @@ fn main() { 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(|_| { + IterWrapper::new(input.chars()) + .parse::<nibble::Ast>() + .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>) }); |