summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------dhall-lang0
-rw-r--r--dhall/src/typecheck.rs1
-rw-r--r--dhall_core/src/parser.rs23
-rw-r--r--dhall_core/src/printer.rs28
-rw-r--r--dhall_generated_parser/src/dhall.pest.visibility2
5 files changed, 48 insertions, 6 deletions
diff --git a/dhall-lang b/dhall-lang
-Subproject 64e1ff6b6e27eb5633e2e803fe8f9d2c6e7c624
+Subproject 4f7c41dac1f79afba3df1d3aa8e181e12298d19
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index 13ffb48..c6f3645 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -1496,6 +1496,7 @@ mod spec_tests {
ti_success!(ti_success_unit_True, "unit/True");
ti_success!(ti_success_unit_Type, "unit/Type");
ti_success!(ti_success_unit_TypeAnnotation, "unit/TypeAnnotation");
+ ti_success!(ti_success_unit_TypeAnnotationSort, "unit/TypeAnnotationSort");
ti_success!(ti_success_unit_UnionConstructorField, "unit/UnionConstructorField");
ti_success!(ti_success_unit_UnionOne, "unit/UnionOne");
ti_success!(ti_success_unit_UnionTypeEmpty, "unit/UnionTypeEmpty");
diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs
index fcf85bd..12383d4 100644
--- a/dhall_core/src/parser.rs
+++ b/dhall_core/src/parser.rs
@@ -2,6 +2,7 @@ use itertools::Itertools;
use pest::iterators::Pair;
use pest::Parser;
pub use pest::Span;
+use std::borrow::Cow;
use std::collections::BTreeMap;
use std::path::PathBuf;
@@ -567,7 +568,27 @@ make_parser! {
[posix_environment_variable(s)] => s,
));
rule!(bash_environment_variable<String>; captured_str!(s) => s.to_owned());
- rule!(posix_environment_variable<String>; captured_str!(s) => s.to_owned());
+ rule!(posix_environment_variable<String>; children!(
+ [posix_environment_variable_character(chars)..] => {
+ chars.collect()
+ },
+ ));
+ rule!(posix_environment_variable_character<Cow<'a, str>>;
+ captured_str!(s) => {
+ match s {
+ "\\\"" => Cow::Owned("\"".to_owned()),
+ "\\\\" => Cow::Owned("\\".to_owned()),
+ "\\a" => Cow::Owned("\u{0007}".to_owned()),
+ "\\b" => Cow::Owned("\u{0008}".to_owned()),
+ "\\f" => Cow::Owned("\u{000C}".to_owned()),
+ "\\n" => Cow::Owned("\n".to_owned()),
+ "\\r" => Cow::Owned("\r".to_owned()),
+ "\\t" => Cow::Owned("\t".to_owned()),
+ "\\v" => Cow::Owned("\u{000B}".to_owned()),
+ _ => Cow::Borrowed(s)
+ }
+ }
+ );
token_rule!(missing<()>);
diff --git a/dhall_core/src/printer.rs b/dhall_core/src/printer.rs
index 8b37b0f..704000a 100644
--- a/dhall_core/src/printer.rs
+++ b/dhall_core/src/printer.rs
@@ -351,7 +351,7 @@ impl Display for ImportHashed {
use std::path::PathBuf;
use FilePrefix::*;
use ImportLocation::*;
- let quoted = |s: &str| -> String {
+ let quoted_path_component = |s: &str| -> String {
if s.chars().all(|c| c.is_ascii_alphanumeric()) {
s.to_owned()
} else {
@@ -361,7 +361,7 @@ impl Display for ImportHashed {
let fmt_path = |f: &mut fmt::Formatter, p: &PathBuf| {
let res: String = p
.iter()
- .map(|c| quoted(c.to_string_lossy().as_ref()))
+ .map(|c| quoted_path_component(c.to_string_lossy().as_ref()))
.join("/");
f.write_str(&res)
};
@@ -387,8 +387,28 @@ impl Display for ImportHashed {
write!(f, " using ({})", h)?
}
}
- Env(e) => {
- write!(f, "env:{}", quoted(e))?;
+ Env(s) => {
+ write!(f, "env:")?;
+ if s.chars().all(|c| c.is_ascii_alphanumeric()) {
+ write!(f, "{}", s)?;
+ } else {
+ write!(f, "\"")?;
+ for c in s.chars() {
+ match c {
+ '"' => f.write_str("\\\"")?,
+ '\\' => f.write_str("\\\\")?,
+ '\u{0007}' => f.write_str("\\a")?,
+ '\u{0008}' => f.write_str("\\b")?,
+ '\u{000C}' => f.write_str("\\f")?,
+ '\n' => f.write_str("\\n")?,
+ '\r' => f.write_str("\\r")?,
+ '\t' => f.write_str("\\t")?,
+ '\u{000B}' => f.write_str("\\v")?,
+ _ => write!(f, "{}", c)?,
+ }
+ }
+ write!(f, "\"")?;
+ }
}
Missing => {
write!(f, "missing")?;
diff --git a/dhall_generated_parser/src/dhall.pest.visibility b/dhall_generated_parser/src/dhall.pest.visibility
index e9236d4..6e83052 100644
--- a/dhall_generated_parser/src/dhall.pest.visibility
+++ b/dhall_generated_parser/src/dhall.pest.visibility
@@ -126,7 +126,7 @@ http
env
bash_environment_variable
posix_environment_variable
-# posix_environment_variable_character
+posix_environment_variable_character
import_type
hash
import_hashed