From 7b30677613bb8687649473361ce1a826509742a0 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 28 Feb 2019 21:00:00 +0100 Subject: Auto-generate pest file from spec abnf --- src/parser.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index a0281f4..057fce2 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -13,13 +13,9 @@ pub fn parse_expr(s: &str) -> Result { use pest::Parser; use pest::error::Error; -use pest_derive::*; - -#[derive(Parser)] -#[grammar = "dhall.pest"] -struct DhallParser; - use pest::iterators::Pair; +use crate::generated_parser::{DhallParser, Rule}; + fn debug_pair(pair: Pair) { fn aux(indent: usize, pair: Pair) { let indent_str = "| ".repeat(indent); @@ -61,11 +57,11 @@ pub fn parse_expr_pest(s: &str) -> Result> { fn test_parse() { use crate::core::Expr::*; let expr = "((22 + 3) * 10)"; + println!("{:?}", parse_expr(expr)); match parse_expr_pest(expr) { Err(e) => println!("{}", e), ok => println!("{:?}", ok), } - println!("{:?}", parse_expr(expr)); assert_eq!(parse_expr_pest(expr).unwrap(), parse_expr(expr).unwrap()); assert!(false); -- cgit v1.2.3