From 903d6c0bba36a6696eb337ae84b962f4cc48b5b5 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 4 Mar 2020 21:26:01 +0000 Subject: Implement remote imports and cleanup import chaining --- dhall/src/syntax/text/parser.rs | 18 +++++++++--------- dhall/src/syntax/text/printer.rs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'dhall/src/syntax/text') diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index ba64a75..7140332 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -10,7 +10,7 @@ use crate::syntax::map::{DupTreeMap, DupTreeSet}; use crate::syntax::ExprKind::*; use crate::syntax::LitKind::*; use crate::syntax::{ - Double, Expr, FilePath, FilePrefix, Hash, ImportLocation, ImportMode, + Double, Expr, FilePath, FilePrefix, Hash, ImportMode, ImportTarget, Integer, InterpolatedText, InterpolatedTextContents, Label, NaiveDouble, Natural, Scheme, Span, UnspannedExpr, URL, V, }; @@ -483,9 +483,9 @@ impl DhallParser { } #[alias(import_type)] - fn local(input: ParseInput) -> ParseResult> { + fn local(input: ParseInput) -> ParseResult> { Ok(match_nodes!(input.into_children(); - [local_path((prefix, p))] => ImportLocation::Local(prefix, p), + [local_path((prefix, p))] => ImportTarget::Local(prefix, p), )) } @@ -550,17 +550,17 @@ impl DhallParser { } #[alias(import_type)] - fn http(input: ParseInput) -> ParseResult> { - Ok(ImportLocation::Remote(match_nodes!(input.into_children(); + fn http(input: ParseInput) -> ParseResult> { + Ok(ImportTarget::Remote(match_nodes!(input.into_children(); [http_raw(url)] => url, [http_raw(url), expression(e)] => URL { headers: Some(e), ..url }, ))) } #[alias(import_type)] - fn env(input: ParseInput) -> ParseResult> { + fn env(input: ParseInput) -> ParseResult> { Ok(match_nodes!(input.into_children(); - [environment_variable(v)] => ImportLocation::Env(v), + [environment_variable(v)] => ImportTarget::Env(v), )) } #[alias(environment_variable)] @@ -593,8 +593,8 @@ impl DhallParser { } #[alias(import_type)] - fn missing(_input: ParseInput) -> ParseResult> { - Ok(ImportLocation::Missing) + fn missing(_input: ParseInput) -> ParseResult> { + Ok(ImportTarget::Missing) } fn hash(input: ParseInput) -> ParseResult { diff --git a/dhall/src/syntax/text/printer.rs b/dhall/src/syntax/text/printer.rs index 53f2c8f..5bb987b 100644 --- a/dhall/src/syntax/text/printer.rs +++ b/dhall/src/syntax/text/printer.rs @@ -379,8 +379,8 @@ impl Display for Hash { impl Display for Import { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { use FilePrefix::*; - use ImportLocation::*; use ImportMode::*; + use ImportTarget::*; let quote_if_needed = |s: &str| -> String { if s.chars().all(|c| c.is_ascii_alphanumeric()) { s.to_string() -- cgit v1.2.3