summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/text
diff options
context:
space:
mode:
authorNadrieril2020-03-04 21:26:01 +0000
committerNadrieril2020-03-05 15:58:54 +0000
commit903d6c0bba36a6696eb337ae84b962f4cc48b5b5 (patch)
tree63cb58b2b566fb5532e59b1455fffc82fa89ce0d /dhall/src/syntax/text
parent5a9a5859eec0cf7deebf7fa07fe99f8dc8722ec8 (diff)
Implement remote imports and cleanup import chaining
Diffstat (limited to 'dhall/src/syntax/text')
-rw-r--r--dhall/src/syntax/text/parser.rs18
-rw-r--r--dhall/src/syntax/text/printer.rs2
2 files changed, 10 insertions, 10 deletions
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<ImportLocation<Expr>> {
+ fn local(input: ParseInput) -> ParseResult<ImportTarget<Expr>> {
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<ImportLocation<Expr>> {
- Ok(ImportLocation::Remote(match_nodes!(input.into_children();
+ fn http(input: ParseInput) -> ParseResult<ImportTarget<Expr>> {
+ 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<ImportLocation<Expr>> {
+ fn env(input: ParseInput) -> ParseResult<ImportTarget<Expr>> {
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<ImportLocation<Expr>> {
- Ok(ImportLocation::Missing)
+ fn missing(_input: ParseInput) -> ParseResult<ImportTarget<Expr>> {
+ Ok(ImportTarget::Missing)
}
fn hash(input: ParseInput) -> ParseResult<Hash> {
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<SubExpr: Display> Display for Import<SubExpr> {
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()