@apple/tree-sitter-pkl 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.adoc +40 -0
  2. package/Cargo.lock +1 -1
  3. package/Cargo.toml +1 -1
  4. package/Package.swift +24 -0
  5. package/README.md +42 -0
  6. package/bindings/c/tree-sitter-pkl.h +16 -0
  7. package/bindings/swift/TreeSitterPkl/pkl.h +16 -0
  8. package/grammar.js +147 -63
  9. package/package.json +3 -4
  10. package/queries/highlights.scm +3 -8
  11. package/queries/injections.scm +3 -3
  12. package/src/grammar.json +750 -353
  13. package/src/node-types.json +1768 -1043
  14. package/src/parser.c +45772 -50670
  15. package/src/scanner.c +60 -28
  16. package/src/tree_sitter/alloc.h +54 -0
  17. package/src/tree_sitter/array.h +290 -0
  18. package/src/tree_sitter/parser.h +54 -13
  19. package/test/corpus/basic/annotation.txt +243 -0
  20. package/test/corpus/basic/comments.txt +41 -0
  21. package/test/corpus/basic/shebangComment.txt +15 -0
  22. package/test/corpus/basic/types.txt +232 -0
  23. package/test/corpus/class/constModifier.txt +24 -0
  24. package/test/corpus/class/fixedModifier.txt +24 -0
  25. package/test/corpus/expr/binary.txt +109 -0
  26. package/test/corpus/expr/functionLiteral.txt +23 -0
  27. package/test/corpus/expr/if.txt +15 -0
  28. package/test/corpus/expr/import.txt +20 -0
  29. package/test/corpus/expr/let.txt +17 -0
  30. package/test/corpus/expr/new.txt +36 -0
  31. package/test/corpus/expr/qualifiedAccess.txt +95 -0
  32. package/test/corpus/expr/read.txt +29 -0
  33. package/test/corpus/expr/throw.txt +14 -0
  34. package/test/corpus/expr/trace.txt +14 -0
  35. package/test/corpus/module/moduleHeader1.txt +23 -0
  36. package/test/corpus/module/moduleHeader2.txt +29 -0
  37. package/test/corpus/module/moduleHeader3.error.txt +23 -0
  38. package/test/corpus/module/moduleHeader4.txt +34 -0
  39. package/test/corpus/module/moduleHeader5.txt +16 -0
  40. package/test/corpus/module/moduleHeader6.txt +17 -0
  41. package/test/corpus/number/underscores.txt +99 -0
  42. package/test/corpus/object/objectAmendChain.txt +38 -0
  43. package/test/corpus/object/objectElementsWithParens.txt +51 -0
  44. package/test/corpus/object/objectGenerator.txt +53 -0
  45. package/test/corpus/object/objectMember.txt +129 -0
  46. package/test/corpus/object/objectMemberPredicate.txt +41 -0
  47. package/test/corpus/object/objectSpread.txt +51 -0
  48. package/test/corpus/object/objectWhenGenerator.txt +71 -0
  49. package/test/corpus/string/customStringDelimiters.txt +397 -0
  50. package/test/corpus/string/missingDelimiter.txt +28 -0
  51. package/test/corpus/string/multiline.txt +39 -0
  52. package/test/corpus/string/multilineInterpolation.txt +102 -0
  53. package/test/corpus/string/simple.txt +13 -0
  54. package/test/corpus/string/singleLineEscapes.txt +64 -0
  55. package/test/corpus/string/singleLineInterpolation.txt +94 -0
  56. package/test/corpus/string/stringWithTwoSlashes.txt +20 -0
  57. package/README.adoc +0 -61
  58. package/src/synctests.ts +0 -44
@@ -0,0 +1,129 @@
1
+ ================================================================================
2
+ objectMember
3
+ ================================================================================
4
+
5
+ res1 { 1 2 3 }
6
+ res2 { 1; 2; 3 }
7
+ res3 {
8
+ 1
9
+ 2
10
+ 3
11
+ }
12
+ res4 {1;2;3;}
13
+ res5{1}
14
+ res6{1;2}
15
+ res7{foo = 1}
16
+ res8{foo = 1; bar = 2}
17
+ res9{nested{1}}
18
+ res10{["foo"] = 1; ["bar"] = 2}
19
+ res11 { new {}; new {}; new {} }
20
+ res12 {1.2;.3;.4;.5}
21
+
22
+ --------------------------------------------------------------------------------
23
+
24
+ (module
25
+ (classProperty
26
+ (identifier)
27
+ (objectBody
28
+ (objectElement
29
+ (intLiteral))
30
+ (objectElement
31
+ (intLiteral))
32
+ (objectElement
33
+ (intLiteral))))
34
+ (classProperty
35
+ (identifier)
36
+ (objectBody
37
+ (objectElement
38
+ (intLiteral))
39
+ (objectElement
40
+ (intLiteral))
41
+ (objectElement
42
+ (intLiteral))))
43
+ (classProperty
44
+ (identifier)
45
+ (objectBody
46
+ (objectElement
47
+ (intLiteral))
48
+ (objectElement
49
+ (intLiteral))
50
+ (objectElement
51
+ (intLiteral))))
52
+ (classProperty
53
+ (identifier)
54
+ (objectBody
55
+ (objectElement
56
+ (intLiteral))
57
+ (objectElement
58
+ (intLiteral))
59
+ (objectElement
60
+ (intLiteral))))
61
+ (classProperty
62
+ (identifier)
63
+ (objectBody
64
+ (objectElement
65
+ (intLiteral))))
66
+ (classProperty
67
+ (identifier)
68
+ (objectBody
69
+ (objectElement
70
+ (intLiteral))
71
+ (objectElement
72
+ (intLiteral))))
73
+ (classProperty
74
+ (identifier)
75
+ (objectBody
76
+ (objectProperty
77
+ (identifier)
78
+ (intLiteral))))
79
+ (classProperty
80
+ (identifier)
81
+ (objectBody
82
+ (objectProperty
83
+ (identifier)
84
+ (intLiteral))
85
+ (objectProperty
86
+ (identifier)
87
+ (intLiteral))))
88
+ (classProperty
89
+ (identifier)
90
+ (objectBody
91
+ (objectProperty
92
+ (identifier)
93
+ (objectBody
94
+ (objectElement
95
+ (intLiteral))))))
96
+ (classProperty
97
+ (identifier)
98
+ (objectBody
99
+ (objectEntry
100
+ (slStringLiteral
101
+ (slStringLiteralPart))
102
+ (intLiteral))
103
+ (objectEntry
104
+ (slStringLiteral
105
+ (slStringLiteralPart))
106
+ (intLiteral))))
107
+ (classProperty
108
+ (identifier)
109
+ (objectBody
110
+ (objectElement
111
+ (newExpr
112
+ (objectBody)))
113
+ (objectElement
114
+ (newExpr
115
+ (objectBody)))
116
+ (objectElement
117
+ (newExpr
118
+ (objectBody)))))
119
+ (classProperty
120
+ (identifier)
121
+ (objectBody
122
+ (objectElement
123
+ (floatLiteral))
124
+ (objectElement
125
+ (floatLiteral))
126
+ (objectElement
127
+ (floatLiteral))
128
+ (objectElement
129
+ (floatLiteral)))))
@@ -0,0 +1,41 @@
1
+ ===
2
+ objectMemberPredicate
3
+ ===
4
+
5
+ foo {
6
+ [[fuzz == 15]] {
7
+ foo = 1
8
+ }
9
+
10
+ [[fuzz == 15]] = 15
11
+
12
+ [[foo[bar]]] = true
13
+ }
14
+ ---
15
+
16
+ (module
17
+ (classProperty
18
+ (identifier)
19
+ (objectBody
20
+ (objectPredicate
21
+ (binaryExpr
22
+ (variableExpr
23
+ (identifier))
24
+ (intLiteral))
25
+ (objectBody
26
+ (objectProperty
27
+ (identifier)
28
+ (intLiteral))))
29
+ (objectPredicate
30
+ (binaryExpr
31
+ (variableExpr
32
+ (identifier))
33
+ (intLiteral))
34
+ (intLiteral))
35
+ (objectPredicate
36
+ (subscriptExpr
37
+ (variableExpr
38
+ (identifier))
39
+ (variableExpr
40
+ (identifier)))
41
+ (trueLiteral)))))
@@ -0,0 +1,51 @@
1
+ ================================================================================
2
+ objectSpread
3
+ ================================================================================
4
+
5
+ res {
6
+ ...person1
7
+ ...person2
8
+ ...?person3
9
+ ...?person4
10
+ for (elem in iterable) {
11
+ ...elem
12
+ }
13
+ when (cond) {
14
+ ...elem
15
+ }
16
+ }
17
+
18
+ --------------------------------------------------------------------------------
19
+
20
+ (module
21
+ (classProperty
22
+ (identifier)
23
+ (objectBody
24
+ (objectSpread
25
+ (variableExpr
26
+ (identifier)))
27
+ (objectSpread
28
+ (variableExpr
29
+ (identifier)))
30
+ (objectSpread
31
+ (variableExpr
32
+ (identifier)))
33
+ (objectSpread
34
+ (variableExpr
35
+ (identifier)))
36
+ (forGenerator
37
+ (typedIdentifier
38
+ (identifier))
39
+ (variableExpr
40
+ (identifier))
41
+ (objectBody
42
+ (objectSpread
43
+ (variableExpr
44
+ (identifier)))))
45
+ (whenGenerator
46
+ (variableExpr
47
+ (identifier))
48
+ (objectBody
49
+ (objectSpread
50
+ (variableExpr
51
+ (identifier))))))))
@@ -0,0 +1,71 @@
1
+ ===
2
+ objectWhenGenerator
3
+ ===
4
+
5
+ res1 {
6
+ when (bar) {
7
+ 1
8
+ }
9
+ }
10
+
11
+ res2 {
12
+ when (baz) {
13
+ 1
14
+ } else {
15
+ 2
16
+ }
17
+ }
18
+
19
+ res3 {
20
+ when (bar) { 1 }
21
+ }
22
+
23
+ res4 {
24
+ when (bar) { 1 } else { 2 }
25
+ }
26
+
27
+ ---
28
+
29
+ (module
30
+ (classProperty
31
+ (identifier)
32
+ (objectBody
33
+ (whenGenerator
34
+ (variableExpr
35
+ (identifier))
36
+ (objectBody
37
+ (objectElement
38
+ (intLiteral))))))
39
+ (classProperty
40
+ (identifier)
41
+ (objectBody
42
+ (whenGenerator
43
+ (variableExpr
44
+ (identifier))
45
+ (objectBody
46
+ (objectElement
47
+ (intLiteral)))
48
+ (objectBody
49
+ (objectElement
50
+ (intLiteral))))))
51
+ (classProperty
52
+ (identifier)
53
+ (objectBody
54
+ (whenGenerator
55
+ (variableExpr
56
+ (identifier))
57
+ (objectBody
58
+ (objectElement
59
+ (intLiteral))))))
60
+ (classProperty
61
+ (identifier)
62
+ (objectBody
63
+ (whenGenerator
64
+ (variableExpr
65
+ (identifier))
66
+ (objectBody
67
+ (objectElement
68
+ (intLiteral)))
69
+ (objectBody
70
+ (objectElement
71
+ (intLiteral)))))))
@@ -0,0 +1,397 @@
1
+ ===
2
+ customStringDelimiters
3
+ ===
4
+
5
+ res1 = #"\r\n\t\\"#
6
+ res2 = #"$foo"#
7
+ res3 = #"\(3 * 4)"#
8
+
9
+ res4 = #"""
10
+ \r\n\t\\
11
+ """#
12
+
13
+ res5 = #"""
14
+ $foo
15
+ """#
16
+
17
+ res6 = #"""
18
+ \(3 * 4)
19
+ """#
20
+
21
+ res7 = #"""
22
+ \r\n\t\\
23
+ $foo
24
+ \(3 * 4)
25
+ """#
26
+
27
+ res9 = #"""
28
+ leading and trailing newline trimmed
29
+ """#
30
+
31
+ res10 = #"""
32
+
33
+ leading newline not trimmed
34
+ """#
35
+
36
+ res11 = #"""
37
+
38
+
39
+
40
+ leading newlines not trimmed
41
+ """#
42
+
43
+ res13 = #"""
44
+ trailing newline not trimmed
45
+
46
+ """#
47
+
48
+ res14 = #"""
49
+ trailing newlines not trimmed
50
+
51
+
52
+
53
+ """#
54
+
55
+ res16 = #"""
56
+ leading
57
+ whitespace
58
+ trimmed
59
+ """#
60
+
61
+ res17 = #"""
62
+ leading
63
+ whitespace
64
+ partially
65
+ trimmed
66
+ """#
67
+
68
+ res18 = #"""
69
+ leading
70
+ whitespace
71
+ partially
72
+ trimmed
73
+ """#
74
+
75
+ res19 = #"""
76
+ "AS IS"
77
+ """#
78
+
79
+ res20 = #"""
80
+ ""AS IS""
81
+ """#
82
+
83
+ res21 = #"""
84
+ """""AS IS"""""
85
+ """#
86
+
87
+ local body = "AS IS"
88
+
89
+ res22 = #"""
90
+ "\#(body)"
91
+ """#
92
+
93
+ res23 = #"""
94
+ ""\#(body)""
95
+ """#
96
+
97
+ res24 = #"""
98
+ """""\#(body)"""""
99
+ """#
100
+
101
+ res25 = ##"# ## ### " "" """ \ \#"##
102
+
103
+ res26 = ###"# ## ### #### " "" """ """" \ \# \##"###
104
+
105
+ res27 = #####"# ## ### #### ##### ###### " "" """ """" """"" \ \# \## \### \####"#####
106
+
107
+ res28 = #"one\#(###"two\###("three")two"###)one\#(##"two"##)"#
108
+
109
+ res29 = #"\#t \#(###"\###t\###t \###("\t\t\t") \###t\###t"###) \#t \#(##"\##t\##t"##)"#
110
+
111
+ res30 = #"\#u{61} \#u{1F920} \#(##"\##u{1dd}"##)"#
112
+
113
+ res31 = ###"\###u{61} \###u{1F920} \###(#"\#u{1dd}"#)"###
114
+
115
+ res32 = ##"""
116
+ # ## ### " "" """ \ \#
117
+ """##
118
+
119
+ res33 = ###"""
120
+ # ## ### #### " "" """ """" \ \# \##
121
+ """###
122
+
123
+ res34 = #####"""
124
+ # ## ### #### ##### ###### " "" """ """" """"" \ \# \## \### \####
125
+ """#####
126
+
127
+ res35 = #"""
128
+ one\#(###"two\###("three")two"###)one\#(##"two"##)
129
+ """#
130
+
131
+ res36 = #"""
132
+ \#t \#(###"\###t\###t \###("\t\t\t") \###t\###t"###) \#t \#(##"\##t\##t"##)
133
+ """#
134
+
135
+ res37 = #"""
136
+ \#u{61} \#u{1F920} \#(##"\##u{1dd}"##)
137
+ """#
138
+
139
+ res38 = ###"""
140
+ \###u{61} \###u{1F920} \###(#"\#u{1dd}"#)
141
+ """###
142
+
143
+ ---
144
+
145
+ (module
146
+ (classProperty
147
+ (identifier)
148
+ (slStringLiteral
149
+ (slStringLiteralPart)))
150
+ (classProperty
151
+ (identifier)
152
+ (slStringLiteral
153
+ (slStringLiteralPart)))
154
+ (classProperty
155
+ (identifier)
156
+ (slStringLiteral
157
+ (slStringLiteralPart)))
158
+ (classProperty
159
+ (identifier)
160
+ (mlStringLiteral
161
+ (mlStringLiteralPart)))
162
+ (classProperty
163
+ (identifier)
164
+ (mlStringLiteral
165
+ (mlStringLiteralPart)))
166
+ (classProperty
167
+ (identifier)
168
+ (mlStringLiteral
169
+ (mlStringLiteralPart)))
170
+ (classProperty
171
+ (identifier)
172
+ (mlStringLiteral
173
+ (mlStringLiteralPart)))
174
+ (classProperty
175
+ (identifier)
176
+ (mlStringLiteral
177
+ (mlStringLiteralPart)))
178
+ (classProperty
179
+ (identifier)
180
+ (mlStringLiteral
181
+ (mlStringLiteralPart)))
182
+ (classProperty
183
+ (identifier)
184
+ (mlStringLiteral
185
+ (mlStringLiteralPart)))
186
+ (classProperty
187
+ (identifier)
188
+ (mlStringLiteral
189
+ (mlStringLiteralPart)))
190
+ (classProperty
191
+ (identifier)
192
+ (mlStringLiteral
193
+ (mlStringLiteralPart)))
194
+ (classProperty
195
+ (identifier)
196
+ (mlStringLiteral
197
+ (mlStringLiteralPart)))
198
+ (classProperty
199
+ (identifier)
200
+ (mlStringLiteral
201
+ (mlStringLiteralPart)))
202
+ (classProperty
203
+ (identifier)
204
+ (mlStringLiteral
205
+ (mlStringLiteralPart)))
206
+ (classProperty
207
+ (identifier)
208
+ (mlStringLiteral
209
+ (mlStringLiteralPart)))
210
+ (classProperty
211
+ (identifier)
212
+ (mlStringLiteral
213
+ (mlStringLiteralPart)))
214
+ (classProperty
215
+ (identifier)
216
+ (mlStringLiteral
217
+ (mlStringLiteralPart)))
218
+ (classProperty
219
+ (modifier)
220
+ (identifier)
221
+ (slStringLiteral
222
+ (slStringLiteralPart)))
223
+ (classProperty
224
+ (identifier)
225
+ (mlStringLiteral
226
+ (mlStringLiteralPart)
227
+ (interpolationExpr
228
+ (variableExpr
229
+ (identifier)))
230
+ (mlStringLiteralPart)))
231
+ (classProperty
232
+ (identifier)
233
+ (mlStringLiteral
234
+ (mlStringLiteralPart)
235
+ (interpolationExpr
236
+ (variableExpr
237
+ (identifier)))
238
+ (mlStringLiteralPart)))
239
+ (classProperty
240
+ (identifier)
241
+ (mlStringLiteral
242
+ (mlStringLiteralPart)
243
+ (interpolationExpr
244
+ (variableExpr
245
+ (identifier)))
246
+ (mlStringLiteralPart)))
247
+ (classProperty
248
+ (identifier)
249
+ (slStringLiteral
250
+ (slStringLiteralPart)))
251
+ (classProperty
252
+ (identifier)
253
+ (slStringLiteral
254
+ (slStringLiteralPart)))
255
+ (classProperty
256
+ (identifier)
257
+ (slStringLiteral
258
+ (slStringLiteralPart)))
259
+ (classProperty
260
+ (identifier)
261
+ (slStringLiteral
262
+ (slStringLiteralPart)
263
+ (interpolationExpr
264
+ (slStringLiteral
265
+ (slStringLiteralPart)
266
+ (interpolationExpr
267
+ (slStringLiteral
268
+ (slStringLiteralPart)))
269
+ (slStringLiteralPart)))
270
+ (slStringLiteralPart)
271
+ (interpolationExpr
272
+ (slStringLiteral
273
+ (slStringLiteralPart)))))
274
+ (classProperty
275
+ (identifier)
276
+ (slStringLiteral
277
+ (escapeSequence)
278
+ (slStringLiteralPart)
279
+ (interpolationExpr
280
+ (slStringLiteral
281
+ (escapeSequence)
282
+ (escapeSequence)
283
+ (slStringLiteralPart)
284
+ (interpolationExpr
285
+ (slStringLiteral
286
+ (escapeSequence)
287
+ (escapeSequence)
288
+ (escapeSequence)))
289
+ (slStringLiteralPart)
290
+ (escapeSequence)
291
+ (escapeSequence)))
292
+ (slStringLiteralPart)
293
+ (escapeSequence)
294
+ (slStringLiteralPart)
295
+ (interpolationExpr
296
+ (slStringLiteral
297
+ (escapeSequence)
298
+ (escapeSequence)))))
299
+ (classProperty
300
+ (identifier)
301
+ (slStringLiteral
302
+ (escapeSequence)
303
+ (slStringLiteralPart)
304
+ (escapeSequence)
305
+ (slStringLiteralPart)
306
+ (interpolationExpr
307
+ (slStringLiteral
308
+ (escapeSequence)))))
309
+ (classProperty
310
+ (identifier)
311
+ (slStringLiteral
312
+ (escapeSequence)
313
+ (slStringLiteralPart)
314
+ (escapeSequence)
315
+ (slStringLiteralPart)
316
+ (interpolationExpr
317
+ (slStringLiteral
318
+ (escapeSequence)))))
319
+ (classProperty
320
+ (identifier)
321
+ (mlStringLiteral
322
+ (mlStringLiteralPart)))
323
+ (classProperty
324
+ (identifier)
325
+ (mlStringLiteral
326
+ (mlStringLiteralPart)))
327
+ (classProperty
328
+ (identifier)
329
+ (mlStringLiteral
330
+ (mlStringLiteralPart)))
331
+ (classProperty
332
+ (identifier)
333
+ (mlStringLiteral
334
+ (mlStringLiteralPart)
335
+ (interpolationExpr
336
+ (slStringLiteral
337
+ (slStringLiteralPart)
338
+ (interpolationExpr
339
+ (slStringLiteral
340
+ (slStringLiteralPart)))
341
+ (slStringLiteralPart)))
342
+ (mlStringLiteralPart)
343
+ (interpolationExpr
344
+ (slStringLiteral
345
+ (slStringLiteralPart)))
346
+ (mlStringLiteralPart)))
347
+ (classProperty
348
+ (identifier)
349
+ (mlStringLiteral
350
+ (mlStringLiteralPart)
351
+ (escapeSequence)
352
+ (mlStringLiteralPart)
353
+ (interpolationExpr
354
+ (slStringLiteral
355
+ (escapeSequence)
356
+ (escapeSequence)
357
+ (slStringLiteralPart)
358
+ (interpolationExpr
359
+ (slStringLiteral
360
+ (escapeSequence)
361
+ (escapeSequence)
362
+ (escapeSequence)))
363
+ (slStringLiteralPart)
364
+ (escapeSequence)
365
+ (escapeSequence)))
366
+ (mlStringLiteralPart)
367
+ (escapeSequence)
368
+ (mlStringLiteralPart)
369
+ (interpolationExpr
370
+ (slStringLiteral
371
+ (escapeSequence)
372
+ (escapeSequence)))
373
+ (mlStringLiteralPart)))
374
+ (classProperty
375
+ (identifier)
376
+ (mlStringLiteral
377
+ (mlStringLiteralPart)
378
+ (escapeSequence)
379
+ (mlStringLiteralPart)
380
+ (escapeSequence)
381
+ (mlStringLiteralPart)
382
+ (interpolationExpr
383
+ (slStringLiteral
384
+ (escapeSequence)))
385
+ (mlStringLiteralPart)))
386
+ (classProperty
387
+ (identifier)
388
+ (mlStringLiteral
389
+ (mlStringLiteralPart)
390
+ (escapeSequence)
391
+ (mlStringLiteralPart)
392
+ (escapeSequence)
393
+ (mlStringLiteralPart)
394
+ (interpolationExpr
395
+ (slStringLiteral
396
+ (escapeSequence)))
397
+ (mlStringLiteralPart))))
@@ -0,0 +1,28 @@
1
+ ================================================================================
2
+ missingDelimiter
3
+ ================================================================================
4
+
5
+ res1 = "Hello
6
+
7
+ res2 = #"Hello there"
8
+
9
+ res3 = ##"Hello there"#
10
+
11
+ --------------------------------------------------------------------------------
12
+
13
+ (module
14
+ (classProperty
15
+ (identifier)
16
+ (slStringLiteral
17
+ (slStringLiteralPart)
18
+ (MISSING """)))
19
+ (classProperty
20
+ (identifier)
21
+ (slStringLiteral
22
+ (slStringLiteralPart)
23
+ (MISSING ""#")))
24
+ (classProperty
25
+ (identifier)
26
+ (slStringLiteral
27
+ (slStringLiteralPart)
28
+ (MISSING ""##"))))