summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2020-06-25 13:55:49 +0100
committerNadrieril2020-06-25 15:12:09 +0100
commit2cb647a1af179662832fb978b90f0b1df6e3dc18 (patch)
treeeac1912c7b9fb905ad150ecc895e766560b38337 /dhall
parent8ca63c1cd953f2f480b25d63727a30da7a3c43df (diff)
spec: allow quoted labels to be empty
Diffstat (limited to '')
m---------dhall-lang0
-rw-r--r--dhall/src/syntax/text/dhall.abnf2
-rw-r--r--dhall/src/syntax/text/printer.rs4
-rw-r--r--dhall/tests/parser/success/quotedLabelB.txt2
-rw-r--r--dhall/tests/parser/success/quotedRecordLabelB.txt1
-rw-r--r--dhall/tests/parser/success/quotedUnionLabelB.txt1
6 files changed, 7 insertions, 3 deletions
diff --git a/dhall-lang b/dhall-lang
-Subproject 4d7c8e403202d7e8c64429bc23da41e33475d4e
+Subproject eb2e9df445f8fd2036863813c3ad32a89e7778e
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)
diff --git a/dhall/tests/parser/success/quotedLabelB.txt b/dhall/tests/parser/success/quotedLabelB.txt
index 861ae0b..f8175de 100644
--- a/dhall/tests/parser/success/quotedLabelB.txt
+++ b/dhall/tests/parser/success/quotedLabelB.txt
@@ -1 +1 @@
-{ example1 = let `let` = 1 in `let`, example2 = let `:.` = 1 in `:.`, example3 = let `$ref` = 1 in `$ref` }
+{ example1 = let `let` = 1 in `let`, example2 = let `:.` = 1 in `:.`, example3 = let `$ref` = 1 in `$ref`, example4 = let `` = 1 in `` }
diff --git a/dhall/tests/parser/success/quotedRecordLabelB.txt b/dhall/tests/parser/success/quotedRecordLabelB.txt
new file mode 100644
index 0000000..6e5a76b
--- /dev/null
+++ b/dhall/tests/parser/success/quotedRecordLabelB.txt
@@ -0,0 +1 @@
+{ `` = 2, ` ` = 3, foo = 1 }
diff --git a/dhall/tests/parser/success/quotedUnionLabelB.txt b/dhall/tests/parser/success/quotedUnionLabelB.txt
new file mode 100644
index 0000000..1974ec2
--- /dev/null
+++ b/dhall/tests/parser/success/quotedUnionLabelB.txt
@@ -0,0 +1 @@
+< ``: Natural | ` `: Natural | foo: Natural >