summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
Diffstat (limited to 'dhall')
-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
5 files changed, 7 insertions, 3 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)
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 >