diff options
author | Nadrieril | 2020-06-25 13:55:49 +0100 |
---|---|---|
committer | Nadrieril | 2020-06-25 15:12:09 +0100 |
commit | 2cb647a1af179662832fb978b90f0b1df6e3dc18 (patch) | |
tree | eac1912c7b9fb905ad150ecc895e766560b38337 /dhall/src/syntax/text | |
parent | 8ca63c1cd953f2f480b25d63727a30da7a3c43df (diff) |
spec: allow quoted labels to be empty
Diffstat (limited to '')
-rw-r--r-- | dhall/src/syntax/text/dhall.abnf | 2 | ||||
-rw-r--r-- | dhall/src/syntax/text/printer.rs | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/dhall/src/syntax/text/dhall.abnf b/dhall/src/syntax/text/dhall.abnf index 861f7b3..05d76e6 100644 --- a/dhall/src/syntax/text/dhall.abnf +++ b/dhall/src/syntax/text/dhall.abnf @@ -206,7 +206,7 @@ quoted-label-char = ; %x60 = '`'
/ %x61-7E
-quoted-label = 1*quoted-label-char
+quoted-label = *quoted-label-char
; NOTE: Dhall does not support Unicode labels, mainly to minimize the potential
; for code obfuscation
diff --git a/dhall/src/syntax/text/printer.rs b/dhall/src/syntax/text/printer.rs index ccba385..8815d69 100644 --- a/dhall/src/syntax/text/printer.rs +++ b/dhall/src/syntax/text/printer.rs @@ -154,7 +154,9 @@ fn fmt_label(label: &Label, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { | "True" | "False" | "Some" => true, _ => Builtin::parse(&s).is_some(), }; - if !is_reserved && s.chars().all(|c| c.is_ascii_alphanumeric()) { + if s.is_empty() { + write!(f, "``") + } else if !is_reserved && s.chars().all(|c| c.is_ascii_alphanumeric()) { write!(f, "{}", s) } else { write!(f, "`{}`", s) |