Skip to content

Commit 7b107ba

Browse files
committed
sync with the recently upstreamed parser tests
1 parent 0d4fdd4 commit 7b107ba

File tree

16 files changed

+104
-107
lines changed

16 files changed

+104
-107
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
## Scope
66

7-
This parser is designed for syntax highlighting and does not strictly follow the Dhall language semantics. My goal is for all valid Dhall expressions to parse to something sensible. An invalid expression parsing is fine, except when it is obviously wrong. To help with this, the output of the parser is checked with hand-written [syntax trees](test/corpus/) for every Dhall [successful parse test](https://github.com/dhall-lang/dhall-lang/tree/master/tests/parser/success) (current with dhall-lang commit [4fecb49](https://github.com/dhall-lang/dhall-lang/commit/4fecb49a83caac4477d1e413fa6e4ee722b43b62)) except:
7+
This parser is designed for syntax highlighting and does not strictly follow the Dhall language semantics. My goal is for all valid Dhall expressions to parse to something sensible. An invalid expression parsing is fine, except when it is obviously wrong. To help with this, the output of the parser is checked with hand-written [syntax trees](test/corpus/) for every Dhall [successful parse test](https://github.com/dhall-lang/dhall-lang/tree/master/tests/parser/success) (current with dhall-lang commit [6d4c9d6](https://github.com/dhall-lang/dhall-lang/commit/6d4c9d6b8812ed3df1f45aabeca3deaf0615ba7b)) except:
88

99
- unit/ShebangA.dhall, unit/ShebangNixA.dhall: Handled by the text editor.
1010
- unit/TrailingLineCommentWithoutNewlineA.dhall: Unclear how to test with tree-sitter.
1111

12-
These tests also serve as a reference for what syntax trees various Dhall expressions produce. A shell script ([tests.sh](tests.sh)) is used to check that all tests are included. There may be extra test cases besides the Dhall ones. Ideally, those would eventually get upstreamed.
12+
Additionally, these tests serve as a reference for what syntax trees various Dhall expressions produce. A shell script ([tests.sh](tests.sh)) is provided to check that all tests, excluding a few intentionally non-compliant ones, are included.
1313

1414
## References
1515

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@
105105
dhall = fetchFromGitHub {
106106
owner = "dhall-lang";
107107
repo = "dhall-lang";
108-
rev = "4fecb49a83caac4477d1e413fa6e4ee722b43b62";
109-
hash = "sha256-VjOBG5kYY89njGpOxIpLFRK2mRP1UWr6QDOHtb7VMzE=";
108+
rev = "6d4c9d6b8812ed3df1f45aabeca3deaf0615ba7b";
109+
hash = "sha256-5cWQPqnTb59Z8Mov/t/ycaQ94jE+w2mol+0pbdRVbEI=";
110110
};
111111

112112
missing = [
113-
"builtinsA.dhall" # modified
114113
"unit/ShebangA.dhall"
115114
"unit/ShebangNixA.dhall"
116115
"unit/TrailingLineCommentWithoutNewlineA.dhall"
116+
"Unterminated block comment"
117+
"de Bruijn indices don't apply to builtins"
117118
];
118119

119120
in stdenvNoCC.mkDerivation {
@@ -122,7 +123,7 @@
122123

123124
buildPhase = ''
124125
${./tests.sh} -c ${test/corpus}\
125-
-i ${lib.strings.concatStringsSep "," missing}\
126+
-i "${lib.strings.concatStringsSep "," missing}"\
126127
${dhall}/tests/parser/success/
127128
'';
128129
installPhase = "touch $out";

test/corpus/builtins.txt

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,45 @@
22
All builtins (builtinsA.dhall*)
33
==================
44

5-
[ Natural/fold
6-
, Natural/build
7-
, Natural/isZero
8-
, Natural/even
9-
, Natural/odd
10-
, Natural/toInteger
11-
, Natural/show
12-
, Integer/toDouble
13-
, Integer/show
14-
, Integer/negate
15-
, Integer/clamp
16-
, Natural/subtract
5+
[ Date/show
176
, Double/show
7+
, Integer/clamp
8+
, Integer/negate
9+
, Integer/show
10+
, Integer/toDouble
1811
, List/build
1912
, List/fold
20-
, List/length
2113
, List/head
22-
, List/last
2314
, List/indexed
15+
, List/last
16+
, List/length
2417
, List/reverse
25-
, Text/show
18+
, Natural/build
19+
, Natural/even
20+
, Natural/fold
21+
, Natural/isZero
22+
, Natural/odd
23+
, Natural/show
24+
, Natural/subtract
25+
, Natural/toInteger
2626
, Text/replace
27-
, Date/show
27+
, Text/show
2828
, Time/show
2929
, TimeZone/show
3030
, Bool
31-
, True
31+
, Bytes
32+
, Date
33+
, Double
3234
, False
33-
, Optional
34-
, None
35-
, Natural
3635
, Integer
37-
, Double
36+
, List
37+
, Natural
38+
, None
39+
, Optional
3840
, Text
39-
, Bytes
40-
, Date
4141
, Time
4242
, TimeZone
43-
, List
44-
, Type
45-
, Kind
46-
, Sort
43+
, True
4744
]
4845

4946
---
@@ -76,13 +73,10 @@ All builtins (builtinsA.dhall*)
7673
(expression (primitive_expression (identifier (builtin))))
7774
(expression (primitive_expression (identifier (builtin))))
7875
(expression (primitive_expression (identifier (builtin))))
79-
(expression (primitive_expression (boolean_literal)))
80-
(expression (primitive_expression (boolean_literal)))
81-
(expression (primitive_expression (identifier (builtin))))
82-
(expression (primitive_expression (identifier (builtin))))
8376
(expression (primitive_expression (identifier (builtin))))
8477
(expression (primitive_expression (identifier (builtin))))
8578
(expression (primitive_expression (identifier (builtin))))
79+
(expression (primitive_expression (boolean_literal)))
8680
(expression (primitive_expression (identifier (builtin))))
8781
(expression (primitive_expression (identifier (builtin))))
8882
(expression (primitive_expression (identifier (builtin))))
@@ -91,7 +85,7 @@ All builtins (builtinsA.dhall*)
9185
(expression (primitive_expression (identifier (builtin))))
9286
(expression (primitive_expression (identifier (builtin))))
9387
(expression (primitive_expression (identifier (builtin))))
94-
(expression (primitive_expression (identifier (builtin)))))))
88+
(expression (primitive_expression (boolean_literal))))))
9589

9690
==================
9791
Bool (unit/BoolA.dhall)

test/corpus/comments.txt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ Line comment ending in CLRF (lineCommentCRLFA.dhall)
2626
(line_comment (line_comment_prefix) (line_comment_content))
2727
(primitive_expression (numeric_literal (natural_literal))))
2828

29-
==================
30-
Trailing line comments terminate without newline (unit/TrailingLineCommentWithoutNewlineA.dhall)
31-
==================
32-
33-
-- This test verifies that a trailing line comment does not require a newline
34-
1--
35-
36-
---
37-
38-
(expression
39-
(line_comment (line_comment_prefix) (line_comment_content))
40-
(primitive_expression (numeric_literal (natural_literal)))
41-
(line_comment (line_comment_prefix) (line_comment_content)))
42-
4329
==================
4430
Block comment (blockCommentA.dhall)
4531
==================
@@ -75,12 +61,13 @@ Nested block comments (nestedBlockCommentA.dhall)
7561
(primitive_expression (numeric_literal (natural_literal))))
7662

7763
==================
78-
Mixed comments
64+
Mixed comments (mixedBlockLineCommentA.dhall)
7965
==================
8066

8167
{- foo -}
8268
-- bar
8369
{- --baz -}
70+
-- {- qux -}
8471

8572
1
8673

@@ -96,6 +83,7 @@ Mixed comments
9683
(block_comment_open)
9784
(block_comment_content)
9885
(block_comment_close))
86+
(line_comment (line_comment_prefix) (line_comment_content))
9987
(primitive_expression (numeric_literal (natural_literal))))
10088

10189
==================

test/corpus/functions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ toMap { foo= 1, bar= 4, baz= 9 }
242242
(numeric_literal (natural_literal)))))))))
243243

244244
==================
245-
showConstructor statement
245+
showConstructor statement (unit/ShowConstructorA.dhall)
246246
==================
247247

248248
showConstructor <A>.A
@@ -257,7 +257,7 @@ showConstructor <A>.A
257257
(selector (selector_dot) (label)))))
258258

259259
==================
260-
showConstructor statement with a value
260+
showConstructor statement with a value (unit/ShowConstructorWithValueA.dhall)
261261
==================
262262

263263
showConstructor (<A : Bool>.A False)

test/corpus/identifiers.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ missingFoo
145145
(primitive_expression (identifier (label))))
146146

147147
==================
148-
de Bruijn indices
148+
de Bruijn indices (unit/DeBruijnIndexA.dhall)
149149
==================
150150

151151
x == x@0

test/corpus/lambda.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ forall(x: T) -> x
113113
expression: (expression (primitive_expression (identifier (label))))))
114114

115115
==================
116-
Unicode forall expression
116+
Unicode forall expression (unit/ForallUnicodeA.dhall)
117117
==================
118118

119119
∀(x : T) -> y

test/corpus/lists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Annotated non-empty list (unit/ListLitNonEmptyAnnotatedA.dhall)
3131
(primitive_expression (identifier (label))))))
3232

3333
==================
34-
Multi-line lists
34+
Multi-line lists (unit/ListWithNewlineA.dhall)
3535
==================
3636

3737
[ [
@@ -68,7 +68,7 @@ Multi-line lists
6868
(numeric_literal (natural_literal))))))))))
6969

7070
==================
71-
Comments in lists
71+
Comments in lists (listWithCommentA.dhall)
7272
==================
7373

7474
[

test/corpus/numbers.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ NaN
192192
(primitive_expression (numeric_literal (double_literal))))
193193

194194
==================
195-
Integer-valued double literal (unit/DoubleLitSecretelyIntA.dhall)
195+
Integer-valued double literal (unit/DoubleLitSecretlyIntA.dhall)
196196
==================
197197

198198
{-

0 commit comments

Comments
 (0)