summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
m---------dhall-lang0
-rw-r--r--dhall/src/syntax/text/dhall.abnf20
-rw-r--r--dhall/src/syntax/text/dhall.pest.visibility8
-rw-r--r--dhall/src/syntax/text/parser.rs37
-rw-r--r--dhall/tests/parser/failure/spacing/RecordTypeNoSpace.txt2
5 files changed, 22 insertions, 45 deletions
diff --git a/dhall-lang b/dhall-lang
-Subproject eb2e9df445f8fd2036863813c3ad32a89e7778e
+Subproject f08384ee5d4a9f1fbd63befb3938b4035f7b5d9
diff --git a/dhall/src/syntax/text/dhall.abnf b/dhall/src/syntax/text/dhall.abnf
index 05d76e6..362a436 100644
--- a/dhall/src/syntax/text/dhall.abnf
+++ b/dhall/src/syntax/text/dhall.abnf
@@ -896,11 +896,9 @@ primitive-expression =
record-type-or-literal =
empty-record-literal
- / non-empty-record-type-or-literal
- / empty-record-type
+ / [non-empty-record-type-or-literal]
empty-record-literal = "="
-empty-record-type = ""
non-empty-record-type-or-literal =
(non-empty-record-type / non-empty-record-literal)
@@ -913,22 +911,18 @@ record-type-entry = any-label-or-some whsp ":" whsp1 expression
non-empty-record-literal =
record-literal-entry *(whsp "," whsp record-literal-entry)
+; If the `record-literal-normal-entry` is absent, that represents a punned
+; record entry, such as in `{ x }`, which is a short-hand for `{ x = x }`
record-literal-entry =
- any-label-or-some (record-literal-normal-entry / record-literal-punned-entry)
+ any-label-or-some [record-literal-normal-entry]
record-literal-normal-entry =
*(whsp "." whsp any-label-or-some) whsp "=" whsp expression
-record-literal-punned-entry = ""
-
+; If the `union-type-entry` is absent, that represents an empty union
+; alternative, such as in `< Heads | Tails >`
union-type =
- non-empty-union-type
- / empty-union-type
-
-empty-union-type = ""
-
-non-empty-union-type =
- union-type-entry *(whsp "|" whsp union-type-entry)
+ [union-type-entry *(whsp "|" whsp union-type-entry)]
; x : Natural
; x
diff --git a/dhall/src/syntax/text/dhall.pest.visibility b/dhall/src/syntax/text/dhall.pest.visibility
index b2114ce..2fee160 100644
--- a/dhall/src/syntax/text/dhall.pest.visibility
+++ b/dhall/src/syntax/text/dhall.pest.visibility
@@ -178,19 +178,15 @@ selector
labels
# type_selector
primitive_expression
-# record_type_or_literal
+record_type_or_literal
empty_record_literal
-empty_record_type
-non_empty_record_type_or_literal
+# non_empty_record_type_or_literal
non_empty_record_type
record_type_entry
non_empty_record_literal
record_literal_entry
-# record_literal_punned_entry
# record_literal_normal_entry
union_type
-empty_union_type
-# non_empty_union_type
union_type_entry
non_empty_list_literal
# complete_expression
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs
index e870db3..1c51ca2 100644
--- a/dhall/src/syntax/text/parser.rs
+++ b/dhall/src/syntax/text/parser.rs
@@ -909,26 +909,19 @@ impl DhallParser {
))
}
- #[alias(record_type_or_literal)]
- fn empty_record_literal(input: ParseInput) -> ParseResult<UnspannedExpr> {
- Ok(RecordLit(Default::default()))
- }
-
- #[alias(record_type_or_literal)]
- fn empty_record_type(input: ParseInput) -> ParseResult<UnspannedExpr> {
- Ok(RecordType(Default::default()))
- }
-
- #[alias(record_type_or_literal)]
- fn non_empty_record_type_or_literal(
- input: ParseInput,
- ) -> ParseResult<UnspannedExpr> {
+ fn record_type_or_literal(input: ParseInput) -> ParseResult<UnspannedExpr> {
Ok(match_nodes!(input.children();
+ [empty_record_literal(_)] => RecordLit(Default::default()),
[non_empty_record_type(map)] => RecordType(map),
[non_empty_record_literal(map)] => RecordLit(map),
+ [] => RecordType(Default::default()),
))
}
+ fn empty_record_literal(input: ParseInput) -> ParseResult<()> {
+ Ok(())
+ }
+
fn non_empty_record_type(
input: ParseInput,
) -> ParseResult<BTreeMap<Label, Expr>> {
@@ -997,8 +990,7 @@ impl DhallParser {
}
fn union_type(input: ParseInput) -> ParseResult<UnspannedExpr> {
- let map = match_nodes!(input.children();
- [empty_union_type(_)] => Default::default(),
+ Ok(match_nodes!(input.children();
[union_type_entry(entries)..] => {
let mut map = BTreeMap::default();
for (l, t) in entries {
@@ -1015,14 +1007,9 @@ impl DhallParser {
}
}
}
- map
+ UnionType(map)
},
- );
- Ok(UnionType(map))
- }
-
- fn empty_union_type(_input: ParseInput) -> ParseResult<()> {
- Ok(())
+ ))
}
fn union_type_entry(
@@ -1065,7 +1052,7 @@ pub fn parse_expr(input_str: &str) -> ParseResult<Expr> {
}
#[test]
-#[ignore]
+#[cfg_attr(windows, ignore)]
// Check that the local copy of the grammar file is in sync with the one from dhall-lang.
fn test_grammar_files_in_sync() {
use std::process::Command;
@@ -1079,8 +1066,8 @@ fn test_grammar_files_in_sync() {
.arg("--ignore-space-change")
.arg("--color")
.arg("--")
- .arg(spec_abnf_path)
.arg(local_abnf_path)
+ .arg(spec_abnf_path)
.output()
.expect("failed to run `git diff` command");
diff --git a/dhall/tests/parser/failure/spacing/RecordTypeNoSpace.txt b/dhall/tests/parser/failure/spacing/RecordTypeNoSpace.txt
index 0e1a879..051ff49 100644
--- a/dhall/tests/parser/failure/spacing/RecordTypeNoSpace.txt
+++ b/dhall/tests/parser/failure/spacing/RecordTypeNoSpace.txt
@@ -3,4 +3,4 @@
1 | { x :T }␊
| ^---
|
- = expected missing, if_, merge, NaN, Some_, toMap, assert, forall, empty_record_literal, or record_type_entry
+ = expected missing, record_type_entry, if_, merge, NaN, Some_, toMap, assert, forall, or empty_record_literal