diff options
author | Nadrieril | 2019-09-10 15:04:26 +0200 |
---|---|---|
committer | Nadrieril | 2019-09-10 15:04:26 +0200 |
commit | e4003cc25efcae79c1332e3481d7edfca1067c4f (patch) | |
tree | b6fc119338bc6c17649356969acfbedde9482314 /dhall_syntax | |
parent | 9f41dc5a4680cba3697c64da28855c8d4f437191 (diff) |
Allows using match_inputs outside of a make_parser impl
Diffstat (limited to 'dhall_syntax')
-rw-r--r-- | dhall_syntax/src/parser.rs | 32 |
1 files changed, 14 insertions, 18 deletions
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<E: Clone>(input_str: &str) -> ParseResult<Expr<E>> { - 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<E: Clone>(input_str: &str) -> ParseResult<Expr<E>> { - 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!(<DhallParser>; inputs; + [expression(e)] => e, + )) } |