From e4003cc25efcae79c1332e3481d7edfca1067c4f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 10 Sep 2019 15:04:26 +0200 Subject: Allows using match_inputs outside of a make_parser impl --- dhall_syntax/src/parser.rs | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'dhall_syntax') diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index a783f77..0d529bc 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -4,7 +4,8 @@ use pest::prec_climber as pcl; use pest::prec_climber::PrecClimber; use std::rc::Rc; -use dhall_generated_parser::{DhallParser, Rule}; +use dgp::Rule; +use dhall_generated_parser as dgp; use pest_consume::{make_parser, match_inputs, PestConsumer}; use crate::map::{DupTreeMap, DupTreeSet}; @@ -147,23 +148,10 @@ lazy_static::lazy_static! { }; } -struct Parsers; - -#[make_parser(DhallParser, Rule)] -impl Parsers { - #[entrypoint] - fn entrypoint(input_str: &str) -> ParseResult> { - let rc_input_str = input_str.to_string().into(); - let inputs = Self::parse_with_userdata( - Rule::final_expression, - input_str, - &rc_input_str, - )?; - Ok(match_inputs!(inputs; - [expression(e)] => e, - )) - } +struct DhallParser; +#[make_parser(dgp::DhallParser, dgp::Rule)] +impl DhallParser { fn EOI(_input: ParseInput) -> ParseResult<()> { Ok(()) } @@ -960,5 +948,13 @@ impl Parsers { } pub fn parse_expr(input_str: &str) -> ParseResult> { - Parsers::entrypoint(input_str) + let rc_input_str = input_str.to_string().into(); + let inputs = DhallParser::parse_with_userdata( + Rule::final_expression, + input_str, + &rc_input_str, + )?; + Ok(match_inputs!(; inputs; + [expression(e)] => e, + )) } -- cgit v1.2.3