From e3813e7d4e3450704c1213fd6cdff7c801ccbc34 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 6 Mar 2019 23:48:32 +0100 Subject: Finally get rid of old parser --- dhall/src/main.rs | 30 ++---------------------------- dhall/tests/macros.rs | 9 ++------- 2 files changed, 4 insertions(+), 35 deletions(-) (limited to 'dhall') diff --git a/dhall/src/main.rs b/dhall/src/main.rs index 43d03ce..493f9be 100644 --- a/dhall/src/main.rs +++ b/dhall/src/main.rs @@ -57,36 +57,10 @@ fn print_error(message: &str, source: &str, start: usize, end: usize) { fn main() { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer).unwrap(); - let expr = match parser::parse_expr_lalrpop(&buffer) { + let expr = match parser::parse_expr(&buffer) { Ok(e) => e, - Err(lalrpop_util::ParseError::User { - error: lexer::LexicalError::Error(pos, e), - }) => { - print_error( - &format!("Unexpected token {:?}", e), - &buffer, - pos, - pos, - ); - return; - } - Err(lalrpop_util::ParseError::UnrecognizedToken { - token: Some((start, t, end)), - expected: e, - }) => { - print_error( - &format!("Unrecognized token {:?}", t), - &buffer, - start, - end, - ); - if !e.is_empty() { - println!("Expected {:?}", e); - } - return; - } Err(e) => { - print_error(&format!("Parser error {:?}", e), &buffer, 0, 0); + print_error(&format!("Parse error {}", e), &buffer, 0, 0); return; } }; diff --git a/dhall/tests/macros.rs b/dhall/tests/macros.rs index 777a2f6..28be70b 100644 --- a/dhall/tests/macros.rs +++ b/dhall/tests/macros.rs @@ -18,14 +18,9 @@ macro_rules! include_test_strs_ab { #[macro_export] macro_rules! parse_str { ($str:expr) => {{ - let pest_expr = parser::parse_expr_pest(&$str) + let pest_expr = parser::parse_expr(&$str) .map_err(|e| println!("{}", e)) .unwrap(); - // // Check with old parser - // match parser::parse_expr_lalrpop(&$str) { - // Ok(larlpop_expr) => assert_eq!(pest_expr, larlpop_expr), - // Err(_) => {}, - // }; // panic!("{:?}", pest_expr); pest_expr }}; @@ -78,7 +73,7 @@ macro_rules! run_spec_test { }; (parser_failure, $path:expr) => { let expr_str = include_test_str!($path); - parser::parse_expr_pest(&expr_str).unwrap_err(); + parser::parse_expr(&expr_str).unwrap_err(); }; } -- cgit v1.2.3