diff options
author | Nadrieril | 2019-05-08 17:16:59 +0200 |
---|---|---|
committer | Nadrieril | 2019-05-08 17:16:59 +0200 |
commit | 1ea478858573045e5d3e3f8ccc3773021ea68ffa (patch) | |
tree | 63cf0504d11384415f4fb0351f3be66bdadd12aa /dhall_syntax/src | |
parent | 03de1d323107916b57def2a39238da14ba23291b (diff) |
Implement normalization of missing builtins
Diffstat (limited to 'dhall_syntax/src')
-rw-r--r-- | dhall_syntax/src/printer.rs | 13 |
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), }?; } |