summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
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
7 files changed, 8 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 436b02c..959f0a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
#### [Unreleased]
+- Allow quoted labels to be empty
- Support Dhall v16.0.0
- Fix running tests on Windows. Developing on this lib should now be possible on Windows.
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 >