diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index e5238dc..e60a893 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,8 +14,14 @@ use std::io::{self, Read}; fn main() { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer).unwrap(); - let r = parser::parse_expr(&buffer); - println!("{:?}", r); + match parser::parse_expr(&buffer) { + Ok(e) => println!("{:?}", e), + Err(lalrpop_util::ParseError::User { error: lexer::LexicalError::Error(pos, e) }) => { + let context = &buffer[pos..::std::cmp::min(buffer.len(), pos + 20)]; + println!("Unexpected token in {:?}: {:?}...", e, context); + } + Err(e) => println!("{:?}", e), + } /* expr <- case exprFromText (Directed "(stdin)" 0 0 0 0) inText of |