summaryrefslogtreecommitdiff
path: root/dhall_syntax
diff options
context:
space:
mode:
authorNadrieril2019-09-11 21:11:39 +0200
committerNadrieril2019-09-11 21:11:39 +0200
commitf4f83af7831c309923feaf453069a6a75e181084 (patch)
tree86d770b9ccb0e17b75ae5c4a999286d39c59232d /dhall_syntax
parent810a3d8066c2efed3f7c74cfb171d17988168080 (diff)
Rename match_inputs to match_nodes to reflect new terminology
Diffstat (limited to 'dhall_syntax')
-rw-r--r--dhall_syntax/src/parser.rs76
1 files changed, 38 insertions, 38 deletions
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<E: Clone>(
input: ParseInput,
) -> ParseResult<ParsedText<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<ParsedTextContents<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<ParsedText<E>> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[single_quote_continue(lines)] => {
let newline: ParsedText<E> = "\n".to_string().into();
@@ -303,7 +303,7 @@ impl DhallParser {
fn single_quote_continue<E: Clone>(
input: ParseInput,
) -> ParseResult<Vec<Vec<ParsedTextContents<E>>>> {
- 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<E: Clone>(input: ParseInput) -> ParseResult<Expr<E>> {
- 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<V<Label>> {
- 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<Vec<String>> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[path_component(components)..] => {
components.collect()
}
@@ -450,7 +450,7 @@ impl DhallParser {
fn local<E: Clone>(
input: ParseInput,
) -> ParseResult<ImportLocation<Expr<E>>> {
- 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<String>)> {
- 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<String>)> {
- 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<String>)> {
- 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<String>)> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[path(p)] => (FilePrefix::Absolute, p)
))
}
@@ -493,7 +493,7 @@ impl DhallParser {
}
fn http_raw<E: Clone>(input: ParseInput) -> ParseResult<URL<Expr<E>>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<ImportLocation<Expr<E>>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<ImportLocation<Expr<E>>> {
- 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<String> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[posix_environment_variable_character(chars)..] => {
chars.collect()
},
@@ -588,7 +588,7 @@ impl DhallParser {
) -> ParseResult<crate::Import<Expr<E>>> {
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<E: Clone>(input: ParseInput) -> ParseResult<Expr<E>> {
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<E: Clone>(input: ParseInput) -> ParseResult<Expr<E>> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[expression(e)] => spanned(input, EmptyListLit(e)),
))
}
fn expression<E: Clone>(input: ParseInput) -> ParseResult<Expr<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<(Label, Option<Expr<E>>, Expr<E>, 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<E: Clone>(
input: ParseInput,
) -> ParseResult<Expr<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<Expr<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<Expr<E>> {
- 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<Label, DupTreeSet<Label>>, 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<DupTreeSet<Label>> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[label(ls)..] => ls.collect(),
))
}
@@ -823,7 +823,7 @@ impl DhallParser {
fn primitive_expression<E: Clone>(
input: ParseInput,
) -> ParseResult<Expr<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<Expr<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<(Expr<E>, DupTreeMap<Label, Expr<E>>)> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<(Label, Expr<E>)> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<(Expr<E>, DupTreeMap<Label, Expr<E>>)> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<(Label, Expr<E>)> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[label(name), expression(expr)] => (name, expr)
))
}
#[alias(expression)]
fn union_type<E: Clone>(input: ParseInput) -> ParseResult<Expr<E>> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<(Label, Option<Expr<E>>)> {
- 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<E: Clone>(
input: ParseInput,
) -> ParseResult<Expr<E>> {
- 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<E: Clone>(input: ParseInput) -> ParseResult<Expr<E>> {
- Ok(match_inputs!(input.children();
+ Ok(match_nodes!(input.children();
[expression(e), EOI(_)] => e
))
}
@@ -949,7 +949,7 @@ pub fn parse_expr<E: Clone>(input_str: &str) -> ParseResult<Expr<E>> {
input_str,
rc_input_str,
)?;
- Ok(match_inputs!(<DhallParser>; inputs;
+ Ok(match_nodes!(<DhallParser>; inputs;
[expression(e)] => e,
))
}