summaryrefslogtreecommitdiff
path: root/dhall_syntax
diff options
context:
space:
mode:
authorNadrieril2019-05-08 17:16:59 +0200
committerNadrieril2019-05-08 17:16:59 +0200
commit1ea478858573045e5d3e3f8ccc3773021ea68ffa (patch)
tree63cf0504d11384415f4fb0351f3be66bdadd12aa /dhall_syntax
parent03de1d323107916b57def2a39238da14ba23291b (diff)
Implement normalization of missing builtins
Diffstat (limited to 'dhall_syntax')
-rw-r--r--dhall_syntax/src/printer.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs
index e3b180b..ebc9770 100644
--- a/dhall_syntax/src/printer.rs
+++ b/dhall_syntax/src/printer.rs
@@ -250,12 +250,23 @@ impl<SubExpr: Display + Clone> Display for InterpolatedText<SubExpr> {
match c {
'\\' => f.write_str("\\\\"),
'"' => f.write_str("\\\""),
- '$' => f.write_str("\\$"),
+ '$' => f.write_str("\\u0024"),
'\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{0000}'..='\u{001F}' => {
+ // Escape to an explicit "\u{XXXX}" form
+ let escaped: String =
+ c.escape_default().collect();
+ // Print as "\uXXXX"
+ write!(
+ f,
+ "\\u{:0>4}",
+ &escaped[3..escaped.len() - 1]
+ )
+ }
c => write!(f, "{}", c),
}?;
}