From 9f41dc5a4680cba3697c64da28855c8d4f437191 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 10 Sep 2019 14:51:37 +0200 Subject: Implement parsing in PestConsumer --- dhall_syntax/src/parser.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'dhall_syntax') diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index a83b8d0..a783f77 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -2,11 +2,10 @@ use itertools::Itertools; use pest::iterators::Pair; use pest::prec_climber as pcl; use pest::prec_climber::PrecClimber; -use pest::Parser; use std::rc::Rc; use dhall_generated_parser::{DhallParser, Rule}; -use pest_consume::{make_parser, match_inputs}; +use pest_consume::{make_parser, match_inputs, PestConsumer}; use crate::map::{DupTreeMap, DupTreeSet}; use crate::ExprF::*; @@ -21,8 +20,6 @@ type ParsedText = InterpolatedText>; type ParsedTextContents = InterpolatedTextContents>; type ParseInput<'input, 'data> = pest_consume::ParseInput<'input, 'data, Rule, Rc>; -type ParseInputs<'input, 'data> = - pest_consume::ParseInputs<'input, 'data, Rule, Rc>; pub type ParseError = pest::error::Error; pub type ParseResult = Result; @@ -152,13 +149,16 @@ lazy_static::lazy_static! { struct Parsers; -#[make_parser(Rule)] +#[make_parser(DhallParser, Rule)] impl Parsers { #[entrypoint] fn entrypoint(input_str: &str) -> ParseResult> { - let pairs = DhallParser::parse(Rule::final_expression, input_str)?; let rc_input_str = input_str.to_string().into(); - let inputs = ParseInputs::new(input_str, pairs, &rc_input_str); + let inputs = Self::parse_with_userdata( + Rule::final_expression, + input_str, + &rc_input_str, + )?; Ok(match_inputs!(inputs; [expression(e)] => e, )) -- cgit v1.2.3