diff options
author | Nadrieril | 2020-06-25 18:48:43 +0100 |
---|---|---|
committer | Nadrieril | 2020-06-25 18:48:43 +0100 |
commit | 51389702f26d25eb78f9e848f478cf2640544a29 (patch) | |
tree | 42cbcc2e0d7bc09ada7de3a38c94288aa321527c | |
parent | d2d8ab436021cee48fc61d4d2bb04d2e09159ec6 (diff) |
spec: allow trailing delimiters
Diffstat (limited to '')
27 files changed, 52 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a63eb7..d9fa944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ #### [Unreleased] +- Allow trailing delimiters in records, lists, etc. - BREAKING CHANGE: Support Dhall v17.0.0 See https://github.com/dhall-lang/dhall-lang/releases/tag/v16.0.0 and diff --git a/dhall-lang b/dhall-lang -Subproject f035ea1947d9392bcedbe7f8c563f33559370ef +Subproject 0c899ab31fdb857f535fe9f5b37f981271824a6 diff --git a/dhall/src/syntax/text/dhall.abnf b/dhall/src/syntax/text/dhall.abnf index 37ec43b..2d487f5 100644 --- a/dhall/src/syntax/text/dhall.abnf +++ b/dhall/src/syntax/text/dhall.abnf @@ -853,7 +853,8 @@ selector-expression = primitive-expression *(whsp "." whsp selector) selector = any-label / labels / type-selector
-labels = "{" whsp [ any-label-or-some whsp *("," whsp any-label-or-some whsp) ] "}"
+labels =
+ "{" whsp [ "," whsp ] [ any-label-or-some whsp *("," whsp any-label-or-some whsp) [ "," whsp ] ] "}"
type-selector = "(" whsp expression whsp ")"
; NOTE: Backtrack when parsing the first three alternatives (i.e. the numeric
@@ -894,18 +895,18 @@ record-type-or-literal = empty-record-literal
/ [non-empty-record-type-or-literal]
-empty-record-literal = "="
+empty-record-literal = "=" [ whsp "," ]
non-empty-record-type-or-literal =
(non-empty-record-type / non-empty-record-literal)
non-empty-record-type =
- record-type-entry *(whsp "," whsp record-type-entry)
+ record-type-entry *(whsp "," whsp record-type-entry) [ whsp "," ]
record-type-entry = any-label-or-some whsp ":" whsp1 expression
non-empty-record-literal =
- record-literal-entry *(whsp "," whsp record-literal-entry)
+ record-literal-entry *(whsp "," whsp record-literal-entry) [ whsp "," ]
; 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 }`
@@ -918,7 +919,7 @@ record-literal-normal-entry = ; If the `union-type-entry` is absent, that represents an empty union
; alternative, such as in `< Heads | Tails >`
union-type =
- [union-type-entry *(whsp "|" whsp union-type-entry)]
+ [union-type-entry *(whsp "|" whsp union-type-entry) [ whsp "|" ]]
; x : Natural
; x
@@ -926,7 +927,7 @@ union-type-entry = any-label-or-some [ whsp ":" whsp1 expression ] non-empty-list-literal =
- "[" whsp [ "," whsp ] expression whsp *("," whsp expression whsp) "]"
+ "[" whsp [ "," whsp ] expression whsp *("," whsp expression whsp) [ "," whsp ] "]"
; This just adds surrounding whitespace for the top-level of the program
complete-expression = whsp expression whsp
diff --git a/dhall/tests/parser/failure/unit/ListLitTwoCommas.txt b/dhall/tests/parser/failure/unit/ListLitTwoCommas.txt new file mode 100644 index 0000000..1cdfed5 --- /dev/null +++ b/dhall/tests/parser/failure/unit/ListLitTwoCommas.txt @@ -0,0 +1,6 @@ + --> 1:4 + | +1 | [ ,, ]␊ + | ^--- + | + = expected expression diff --git a/dhall/tests/parser/failure/unit/ProjectionTwoCommas.txt b/dhall/tests/parser/failure/unit/ProjectionTwoCommas.txt new file mode 100644 index 0000000..1585703 --- /dev/null +++ b/dhall/tests/parser/failure/unit/ProjectionTwoCommas.txt @@ -0,0 +1,6 @@ + --> 1:8 + | +1 | foo.{ ,, }␊ + | ^--- + | + = expected any_label_or_some diff --git a/dhall/tests/parser/failure/unit/RecordTwoCommas.txt b/dhall/tests/parser/failure/unit/RecordTwoCommas.txt new file mode 100644 index 0000000..3828d4b --- /dev/null +++ b/dhall/tests/parser/failure/unit/RecordTwoCommas.txt @@ -0,0 +1,6 @@ + --> 1:4 + | +1 | { ,, }␊ + | ^--- + | + = expected any_label_or_some or empty_record_literal diff --git a/dhall/tests/parser/failure/unit/UnionTypeTwoDelims.txt b/dhall/tests/parser/failure/unit/UnionTypeTwoDelims.txt new file mode 100644 index 0000000..c4fa37e --- /dev/null +++ b/dhall/tests/parser/failure/unit/UnionTypeTwoDelims.txt @@ -0,0 +1,6 @@ + --> 1:4 + | +1 | < || >␊ + | ^--- + | + = expected any_label_or_some diff --git a/dhall/tests/parser/success/unit/ListLitEmptyCommaB.txt b/dhall/tests/parser/success/unit/ListLitEmptyCommaB.txt new file mode 100644 index 0000000..3b99552 --- /dev/null +++ b/dhall/tests/parser/success/unit/ListLitEmptyCommaB.txt @@ -0,0 +1 @@ +[] : List Bool diff --git a/dhall/tests/parser/success/unit/ListLitLeadingCommaB.txt b/dhall/tests/parser/success/unit/ListLitLeadingCommaB.txt new file mode 100644 index 0000000..5ed6f26 --- /dev/null +++ b/dhall/tests/parser/success/unit/ListLitLeadingCommaB.txt @@ -0,0 +1 @@ +[x, y] diff --git a/dhall/tests/parser/success/unit/ListLitTrailingAndLeadingCommasB.txt b/dhall/tests/parser/success/unit/ListLitTrailingAndLeadingCommasB.txt new file mode 100644 index 0000000..5ed6f26 --- /dev/null +++ b/dhall/tests/parser/success/unit/ListLitTrailingAndLeadingCommasB.txt @@ -0,0 +1 @@ +[x, y] diff --git a/dhall/tests/parser/success/unit/ListLitTrailingCommaB.txt b/dhall/tests/parser/success/unit/ListLitTrailingCommaB.txt new file mode 100644 index 0000000..5ed6f26 --- /dev/null +++ b/dhall/tests/parser/success/unit/ListLitTrailingCommaB.txt @@ -0,0 +1 @@ +[x, y] diff --git a/dhall/tests/parser/success/unit/ProjectionLeadingCommaB.txt b/dhall/tests/parser/success/unit/ProjectionLeadingCommaB.txt new file mode 100644 index 0000000..519da8c --- /dev/null +++ b/dhall/tests/parser/success/unit/ProjectionLeadingCommaB.txt @@ -0,0 +1 @@ +foo.{ x, y } diff --git a/dhall/tests/parser/success/unit/ProjectionTrailingAndLeadingCommasB.txt b/dhall/tests/parser/success/unit/ProjectionTrailingAndLeadingCommasB.txt new file mode 100644 index 0000000..519da8c --- /dev/null +++ b/dhall/tests/parser/success/unit/ProjectionTrailingAndLeadingCommasB.txt @@ -0,0 +1 @@ +foo.{ x, y } diff --git a/dhall/tests/parser/success/unit/ProjectionTrailingCommaB.txt b/dhall/tests/parser/success/unit/ProjectionTrailingCommaB.txt new file mode 100644 index 0000000..519da8c --- /dev/null +++ b/dhall/tests/parser/success/unit/ProjectionTrailingCommaB.txt @@ -0,0 +1 @@ +foo.{ x, y } diff --git a/dhall/tests/parser/success/unit/RecordLitEmptyLeadingCommaB.txt b/dhall/tests/parser/success/unit/RecordLitEmptyLeadingCommaB.txt new file mode 100644 index 0000000..339130f --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordLitEmptyLeadingCommaB.txt @@ -0,0 +1 @@ +{=} diff --git a/dhall/tests/parser/success/unit/RecordLitEmptyTrailingCommaB.txt b/dhall/tests/parser/success/unit/RecordLitEmptyTrailingCommaB.txt new file mode 100644 index 0000000..339130f --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordLitEmptyTrailingCommaB.txt @@ -0,0 +1 @@ +{=} diff --git a/dhall/tests/parser/success/unit/RecordLitLeadingCommaB.txt b/dhall/tests/parser/success/unit/RecordLitLeadingCommaB.txt new file mode 100644 index 0000000..325db4f --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordLitLeadingCommaB.txt @@ -0,0 +1 @@ +{ x = 0, y = 1 } diff --git a/dhall/tests/parser/success/unit/RecordLitTrailingAndLeadingCommasB.txt b/dhall/tests/parser/success/unit/RecordLitTrailingAndLeadingCommasB.txt new file mode 100644 index 0000000..325db4f --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordLitTrailingAndLeadingCommasB.txt @@ -0,0 +1 @@ +{ x = 0, y = 1 } diff --git a/dhall/tests/parser/success/unit/RecordLitTrailingCommaB.txt b/dhall/tests/parser/success/unit/RecordLitTrailingCommaB.txt new file mode 100644 index 0000000..325db4f --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordLitTrailingCommaB.txt @@ -0,0 +1 @@ +{ x = 0, y = 1 } diff --git a/dhall/tests/parser/success/unit/RecordTypeEmptyCommaB.txt b/dhall/tests/parser/success/unit/RecordTypeEmptyCommaB.txt new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordTypeEmptyCommaB.txt @@ -0,0 +1 @@ +{} diff --git a/dhall/tests/parser/success/unit/RecordTypeLeadingCommaB.txt b/dhall/tests/parser/success/unit/RecordTypeLeadingCommaB.txt new file mode 100644 index 0000000..b88d0ae --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordTypeLeadingCommaB.txt @@ -0,0 +1 @@ +{ x : T, y : U } diff --git a/dhall/tests/parser/success/unit/RecordTypeTrailingAndLeadingCommasB.txt b/dhall/tests/parser/success/unit/RecordTypeTrailingAndLeadingCommasB.txt new file mode 100644 index 0000000..b88d0ae --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordTypeTrailingAndLeadingCommasB.txt @@ -0,0 +1 @@ +{ x : T, y : U } diff --git a/dhall/tests/parser/success/unit/RecordTypeTrailingCommaB.txt b/dhall/tests/parser/success/unit/RecordTypeTrailingCommaB.txt new file mode 100644 index 0000000..b88d0ae --- /dev/null +++ b/dhall/tests/parser/success/unit/RecordTypeTrailingCommaB.txt @@ -0,0 +1 @@ +{ x : T, y : U } diff --git a/dhall/tests/parser/success/unit/UnionTypeEmptyDelimB.txt b/dhall/tests/parser/success/unit/UnionTypeEmptyDelimB.txt new file mode 100644 index 0000000..c677118 --- /dev/null +++ b/dhall/tests/parser/success/unit/UnionTypeEmptyDelimB.txt @@ -0,0 +1 @@ +< > diff --git a/dhall/tests/parser/success/unit/UnionTypeLeadingDelimB.txt b/dhall/tests/parser/success/unit/UnionTypeLeadingDelimB.txt new file mode 100644 index 0000000..0f942c8 --- /dev/null +++ b/dhall/tests/parser/success/unit/UnionTypeLeadingDelimB.txt @@ -0,0 +1 @@ +< x: T | y: U > diff --git a/dhall/tests/parser/success/unit/UnionTypeTrailingAndLeadingDelimsB.txt b/dhall/tests/parser/success/unit/UnionTypeTrailingAndLeadingDelimsB.txt new file mode 100644 index 0000000..0f942c8 --- /dev/null +++ b/dhall/tests/parser/success/unit/UnionTypeTrailingAndLeadingDelimsB.txt @@ -0,0 +1 @@ +< x: T | y: U > diff --git a/dhall/tests/parser/success/unit/UnionTypeTrailingDelimB.txt b/dhall/tests/parser/success/unit/UnionTypeTrailingDelimB.txt new file mode 100644 index 0000000..0f942c8 --- /dev/null +++ b/dhall/tests/parser/success/unit/UnionTypeTrailingDelimB.txt @@ -0,0 +1 @@ +< x: T | y: U > |