From f4f83af7831c309923feaf453069a6a75e181084 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 11 Sep 2019 21:11:39 +0200 Subject: Rename match_inputs to match_nodes to reflect new terminology --- dhall_syntax/src/parser.rs | 76 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'dhall_syntax/src/parser.rs') diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index d945435..c0b9712 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -6,7 +6,7 @@ use std::rc::Rc; use dgp::Rule; use dhall_generated_parser as dgp; -use pest_consume::{match_inputs, Parser}; +use pest_consume::{match_nodes, Parser}; use crate::map::{DupTreeMap, DupTreeSet}; use crate::ExprF::*; @@ -167,7 +167,7 @@ impl DhallParser { fn double_quote_literal( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [double_quote_chunk(chunks)..] => { chunks.collect() } @@ -177,7 +177,7 @@ impl DhallParser { fn double_quote_chunk( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(e)] => { InterpolatedTextContents::Expr(e) }, @@ -264,7 +264,7 @@ impl DhallParser { fn single_quote_literal( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [single_quote_continue(lines)] => { let newline: ParsedText = "\n".to_string().into(); @@ -303,7 +303,7 @@ impl DhallParser { fn single_quote_continue( input: ParseInput, ) -> ParseResult>>> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(e), single_quote_continue(lines)] => { let c = InterpolatedTextContents::Expr(e); let mut lines = lines; @@ -388,7 +388,7 @@ impl DhallParser { #[alias(expression, shortcut = true)] fn identifier(input: ParseInput) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [variable(v)] => { spanned(input, Var(v)) }, @@ -397,7 +397,7 @@ impl DhallParser { } fn variable(input: ParseInput) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [label(l), natural_literal(idx)] => { V(l, idx) }, @@ -439,7 +439,7 @@ impl DhallParser { .collect()) } fn path(input: ParseInput) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [path_component(components)..] => { components.collect() } @@ -450,7 +450,7 @@ impl DhallParser { fn local( input: ParseInput, ) -> ParseResult>> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [local_path((prefix, p))] => ImportLocation::Local(prefix, p), )) } @@ -459,19 +459,19 @@ impl DhallParser { fn parent_path( input: ParseInput, ) -> ParseResult<(FilePrefix, Vec)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [path(p)] => (FilePrefix::Parent, p) )) } #[alias(local_path)] fn here_path(input: ParseInput) -> ParseResult<(FilePrefix, Vec)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [path(p)] => (FilePrefix::Here, p) )) } #[alias(local_path)] fn home_path(input: ParseInput) -> ParseResult<(FilePrefix, Vec)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [path(p)] => (FilePrefix::Home, p) )) } @@ -479,7 +479,7 @@ impl DhallParser { fn absolute_path( input: ParseInput, ) -> ParseResult<(FilePrefix, Vec)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [path(p)] => (FilePrefix::Absolute, p) )) } @@ -493,7 +493,7 @@ impl DhallParser { } fn http_raw(input: ParseInput) -> ParseResult>> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [scheme(sch), authority(auth), path(p)] => URL { scheme: sch, authority: auth, @@ -523,7 +523,7 @@ impl DhallParser { fn http( input: ParseInput, ) -> ParseResult>> { - Ok(ImportLocation::Remote(match_inputs!(input.children(); + Ok(ImportLocation::Remote(match_nodes!(input.children(); [http_raw(url)] => url, [http_raw(url), expression(e)] => URL { headers: Some(e), ..url }, ))) @@ -533,7 +533,7 @@ impl DhallParser { fn env( input: ParseInput, ) -> ParseResult>> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [environment_variable(v)] => ImportLocation::Env(v), )) } @@ -543,7 +543,7 @@ impl DhallParser { } #[alias(environment_variable)] fn posix_environment_variable(input: ParseInput) -> ParseResult { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [posix_environment_variable_character(chars)..] => { chars.collect() }, @@ -588,7 +588,7 @@ impl DhallParser { ) -> ParseResult>> { use crate::Import; let mode = ImportMode::Code; - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [import_type(location)] => Import { mode, location, hash: None }, [import_type(location), hash(h)] => Import { mode, location, hash: Some(h) }, )) @@ -606,7 +606,7 @@ impl DhallParser { #[alias(expression)] fn import(input: ParseInput) -> ParseResult> { use crate::Import; - let import = match_inputs!(input.children(); + let import = match_nodes!(input.children(); [import_hashed(imp)] => { Import { mode: ImportMode::Code, ..imp } }, @@ -641,13 +641,13 @@ impl DhallParser { #[alias(expression)] fn empty_list_literal(input: ParseInput) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(e)] => spanned(input, EmptyListLit(e)), )) } fn expression(input: ParseInput) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [lambda(()), label(l), expression(typ), arrow(()), expression(body)] => { spanned(input, Lam(l, typ, body)) @@ -694,7 +694,7 @@ impl DhallParser { fn let_binding( input: ParseInput, ) -> ParseResult<(Label, Option>, Expr, Span)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [label(name), expression(annot), expression(expr)] => (name, Some(annot), expr, input_to_span(input)), [label(name), expression(expr)] => @@ -744,7 +744,7 @@ impl DhallParser { fn application_expression( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(e)] => e, [expression(first), expression(rest)..] => { rest.fold( @@ -765,7 +765,7 @@ impl DhallParser { fn first_application_expression( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [Some_(()), expression(e)] => { spanned(input, SomeLit(e)) }, @@ -783,7 +783,7 @@ impl DhallParser { fn selector_expression( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(e)] => e, [expression(first), selector(rest)..] => { rest.fold( @@ -806,7 +806,7 @@ impl DhallParser { fn selector( input: ParseInput, ) -> ParseResult<(Either>, Span)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [label(l)] => (Either::Left(l), input_to_span(input)), [labels(ls)] => (Either::Right(ls), input_to_span(input)), // [expression(_e)] => unimplemented!("selection by expression"), // TODO @@ -814,7 +814,7 @@ impl DhallParser { } fn labels(input: ParseInput) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [label(ls)..] => ls.collect(), )) } @@ -823,7 +823,7 @@ impl DhallParser { fn primitive_expression( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [double_literal(n)] => spanned(input, DoubleLit(n)), [natural_literal(n)] => spanned(input, NaturalLit(n)), [integer_literal(n)] => spanned(input, IntegerLit(n)), @@ -849,7 +849,7 @@ impl DhallParser { fn non_empty_record_type_or_literal( input: ParseInput, ) -> ParseResult> { - let e = match_inputs!(input.children(); + let e = match_nodes!(input.children(); [label(first_label), non_empty_record_type(rest)] => { let (first_expr, mut map) = rest; map.insert(first_label, first_expr); @@ -867,7 +867,7 @@ impl DhallParser { fn non_empty_record_type( input: ParseInput, ) -> ParseResult<(Expr, DupTreeMap>)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(expr), record_type_entry(entries)..] => { (expr, entries.collect()) } @@ -877,7 +877,7 @@ impl DhallParser { fn record_type_entry( input: ParseInput, ) -> ParseResult<(Label, Expr)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [label(name), expression(expr)] => (name, expr) )) } @@ -885,7 +885,7 @@ impl DhallParser { fn non_empty_record_literal( input: ParseInput, ) -> ParseResult<(Expr, DupTreeMap>)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(expr), record_literal_entry(entries)..] => { (expr, entries.collect()) } @@ -895,14 +895,14 @@ impl DhallParser { fn record_literal_entry( input: ParseInput, ) -> ParseResult<(Label, Expr)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [label(name), expression(expr)] => (name, expr) )) } #[alias(expression)] fn union_type(input: ParseInput) -> ParseResult> { - let map = match_inputs!(input.children(); + let map = match_nodes!(input.children(); [empty_union_type(_)] => Default::default(), [union_type_entry(entries)..] => entries.collect(), ); @@ -916,7 +916,7 @@ impl DhallParser { fn union_type_entry( input: ParseInput, ) -> ParseResult<(Label, Option>)> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [label(name), expression(expr)] => (name, Some(expr)), [label(name)] => (name, None), )) @@ -926,7 +926,7 @@ impl DhallParser { fn non_empty_list_literal( input: ParseInput, ) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(items)..] => spanned( input, NEListLit(items.collect()) @@ -936,7 +936,7 @@ impl DhallParser { #[alias(expression)] fn final_expression(input: ParseInput) -> ParseResult> { - Ok(match_inputs!(input.children(); + Ok(match_nodes!(input.children(); [expression(e), EOI(_)] => e )) } @@ -949,7 +949,7 @@ pub fn parse_expr(input_str: &str) -> ParseResult> { input_str, rc_input_str, )?; - Ok(match_inputs!(; inputs; + Ok(match_nodes!(; inputs; [expression(e)] => e, )) } -- cgit v1.2.3