From 0388d9858627693bab2433f134eb4ed1d6e9b164 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 6 Sep 2019 18:17:36 +0200 Subject: Make ParseInput independent from dhall-specific types --- dhall_proc_macros/src/make_parser.rs | 8 ++++---- dhall_proc_macros/src/parse_children.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'dhall_proc_macros/src') diff --git a/dhall_proc_macros/src/make_parser.rs b/dhall_proc_macros/src/make_parser.rs index a17ab61..c0594a5 100644 --- a/dhall_proc_macros/src/make_parser.rs +++ b/dhall_proc_macros/src/make_parser.rs @@ -179,7 +179,7 @@ fn apply_special_attrs(f: &mut ParsedFn, rule_enum: &Ident) -> Result<()> { #function #climber.climb( - #input_arg.pair.clone().into_inner(), + #input_arg.as_pair().clone().into_inner(), |p| Self::#child_rule(#input_arg.with_pair(p)), |l, op, r| { #fn_name(#input_arg.clone(), l?, op, r?) @@ -207,9 +207,9 @@ fn apply_special_attrs(f: &mut ParsedFn, rule_enum: &Ident) -> Result<()> { let mut #input_arg = #input_arg; // While the current rule allows shortcutting, and there is a single child, and the // child can still be parsed by the current function, then skip to that child. - while ::allows_shortcut(#input_arg.as_rule()) { + while ::allows_shortcut(#input_arg.as_rule()) { if let Some(child) = #input_arg.single_child() { - if &::rule_alias(child.as_rule()) + if &::rule_alias(child.as_rule()) == stringify!(#fn_name) { #input_arg = child; continue; @@ -313,7 +313,7 @@ pub fn make_parser( let ty = &imp.self_ty; let (impl_generics, _, where_clause) = imp.generics.split_for_impl(); Ok(quote!( - impl #impl_generics PestConsumer for #ty #where_clause { + impl #impl_generics pest_consume::PestConsumer for #ty #where_clause { type Rule = #rule_enum; fn rule_alias(rule: Self::Rule) -> String { match rule { diff --git a/dhall_proc_macros/src/parse_children.rs b/dhall_proc_macros/src/parse_children.rs index a35c03f..d6474a7 100644 --- a/dhall_proc_macros/src/parse_children.rs +++ b/dhall_proc_macros/src/parse_children.rs @@ -186,11 +186,11 @@ pub fn parse_children( .collect::>>()?; Ok(quote!({ - let #i_children_rules: Vec<_> = #input_expr.pair + let #i_children_rules: Vec<_> = #input_expr.as_pair() .clone() .into_inner() .map(|p| p.as_rule()) - .map(::rule_alias) + .map(::rule_alias) .collect(); let #i_children_rules: Vec<&str> = #i_children_rules .iter() @@ -199,7 +199,7 @@ pub fn parse_children( #[allow(unused_mut)] let mut #i_inputs = #input_expr - .pair + .as_pair() .clone() .into_inner() .map(|p| #input_expr.with_pair(p)); -- cgit v1.2.3