@apple/tree-sitter-pkl 0.18.0 → 0.19.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.
- package/CHANGELOG.adoc +18 -4
- package/CMakeLists.txt +1 -1
- package/Cargo.lock +21 -21
- package/Cargo.toml +1 -1
- package/MAINTAINERS.adoc +1 -0
- package/Makefile +1 -1
- package/SECURITY.adoc +1 -1
- package/go.mod +2 -0
- package/go.sum +36 -0
- package/grammar.js +16 -16
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/src/grammar.json +114 -31
- package/src/parser.c +29116 -25595
- package/src/scanner.c +1 -1
- package/test/corpus/expr/typeTest.txt +11 -0
- package/test/corpus/object/objectBodyParams.txt +30 -7
- package/test/corpus/snippetTests/classes/class5.txt +131 -0
- package/test/corpus/snippetTests/classes/constraints15.txt +26 -0
- package/test/corpus/snippetTests/classes/functions5.txt +141 -0
- package/tree-sitter.json +4 -1
package/src/scanner.c
CHANGED
|
@@ -4,6 +4,8 @@ typeTest
|
|
|
4
4
|
foo = bar is Int(this < 0)
|
|
5
5
|
|
|
6
6
|
qux = bar as Float
|
|
7
|
+
|
|
8
|
+
corge = bar as foo.Bar
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
(module
|
|
@@ -26,4 +28,13 @@ qux = bar as Float
|
|
|
26
28
|
(identifier))
|
|
27
29
|
(declaredType
|
|
28
30
|
(qualifiedIdentifier
|
|
31
|
+
(identifier)))))
|
|
32
|
+
(classProperty
|
|
33
|
+
(identifier)
|
|
34
|
+
(typeCastExpr
|
|
35
|
+
(unqualifiedAccessExpr
|
|
36
|
+
(identifier))
|
|
37
|
+
(declaredType
|
|
38
|
+
(qualifiedIdentifier
|
|
39
|
+
(identifier)
|
|
29
40
|
(identifier))))))
|
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
objectBodyParams
|
|
3
3
|
===
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
root {
|
|
6
|
+
foo { bar ->
|
|
7
|
+
res = bar
|
|
8
|
+
}
|
|
9
|
+
zig { zag, zing, ->
|
|
10
|
+
pop = zag + zing
|
|
11
|
+
}
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
---
|
|
@@ -12,10 +17,28 @@ foo { bar ->
|
|
|
12
17
|
(classProperty
|
|
13
18
|
(identifier)
|
|
14
19
|
(objectBody
|
|
15
|
-
(objectBodyParameters
|
|
16
|
-
(typedIdentifier
|
|
17
|
-
(identifier)))
|
|
18
20
|
(objectProperty
|
|
19
21
|
(identifier)
|
|
20
|
-
(
|
|
21
|
-
(
|
|
22
|
+
(objectBody
|
|
23
|
+
(objectBodyParameters
|
|
24
|
+
(typedIdentifier
|
|
25
|
+
(identifier)))
|
|
26
|
+
(objectProperty
|
|
27
|
+
(identifier)
|
|
28
|
+
(unqualifiedAccessExpr
|
|
29
|
+
(identifier)))))
|
|
30
|
+
(objectProperty
|
|
31
|
+
(identifier)
|
|
32
|
+
(objectBody
|
|
33
|
+
(objectBodyParameters
|
|
34
|
+
(typedIdentifier
|
|
35
|
+
(identifier))
|
|
36
|
+
(typedIdentifier
|
|
37
|
+
(identifier)))
|
|
38
|
+
(objectProperty
|
|
39
|
+
(identifier)
|
|
40
|
+
(additiveExpr
|
|
41
|
+
(unqualifiedAccessExpr
|
|
42
|
+
(identifier))
|
|
43
|
+
(unqualifiedAccessExpr
|
|
44
|
+
(identifier)))))))))
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
===
|
|
2
|
+
classes/class5.pkl
|
|
3
|
+
===
|
|
4
|
+
|
|
5
|
+
class A<T, U,>
|
|
6
|
+
class B<
|
|
7
|
+
T,
|
|
8
|
+
U,
|
|
9
|
+
> {
|
|
10
|
+
function foo<V, W,>(x: V, y: W) = x.toString() + y.toString()
|
|
11
|
+
function bar<
|
|
12
|
+
V,
|
|
13
|
+
W,
|
|
14
|
+
>(x: V, y: W) = x.toString() + y.toString()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
a: A<String, String,>
|
|
18
|
+
b: B<
|
|
19
|
+
Int,
|
|
20
|
+
Int,
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
(module
|
|
27
|
+
(clazz
|
|
28
|
+
(identifier)
|
|
29
|
+
(typeParameterList
|
|
30
|
+
(typeParameter
|
|
31
|
+
(identifier))
|
|
32
|
+
(typeParameter
|
|
33
|
+
(identifier))))
|
|
34
|
+
(clazz
|
|
35
|
+
(identifier)
|
|
36
|
+
(typeParameterList
|
|
37
|
+
(typeParameter
|
|
38
|
+
(identifier))
|
|
39
|
+
(typeParameter
|
|
40
|
+
(identifier)))
|
|
41
|
+
(classBody
|
|
42
|
+
(classMethod
|
|
43
|
+
(methodHeader
|
|
44
|
+
(identifier)
|
|
45
|
+
(typeParameterList
|
|
46
|
+
(typeParameter
|
|
47
|
+
(identifier))
|
|
48
|
+
(typeParameter
|
|
49
|
+
(identifier)))
|
|
50
|
+
(parameterList
|
|
51
|
+
(typedIdentifier
|
|
52
|
+
(identifier)
|
|
53
|
+
(typeAnnotation
|
|
54
|
+
(declaredType
|
|
55
|
+
(qualifiedIdentifier
|
|
56
|
+
(identifier)))))
|
|
57
|
+
(typedIdentifier
|
|
58
|
+
(identifier)
|
|
59
|
+
(typeAnnotation
|
|
60
|
+
(declaredType
|
|
61
|
+
(qualifiedIdentifier
|
|
62
|
+
(identifier)))))))
|
|
63
|
+
(additiveExpr
|
|
64
|
+
(qualifiedAccessExpr
|
|
65
|
+
(unqualifiedAccessExpr
|
|
66
|
+
(identifier))
|
|
67
|
+
(identifier)
|
|
68
|
+
(argumentList))
|
|
69
|
+
(qualifiedAccessExpr
|
|
70
|
+
(unqualifiedAccessExpr
|
|
71
|
+
(identifier))
|
|
72
|
+
(identifier)
|
|
73
|
+
(argumentList))))
|
|
74
|
+
(classMethod
|
|
75
|
+
(methodHeader
|
|
76
|
+
(identifier)
|
|
77
|
+
(typeParameterList
|
|
78
|
+
(typeParameter
|
|
79
|
+
(identifier))
|
|
80
|
+
(typeParameter
|
|
81
|
+
(identifier)))
|
|
82
|
+
(parameterList
|
|
83
|
+
(typedIdentifier
|
|
84
|
+
(identifier)
|
|
85
|
+
(typeAnnotation
|
|
86
|
+
(declaredType
|
|
87
|
+
(qualifiedIdentifier
|
|
88
|
+
(identifier)))))
|
|
89
|
+
(typedIdentifier
|
|
90
|
+
(identifier)
|
|
91
|
+
(typeAnnotation
|
|
92
|
+
(declaredType
|
|
93
|
+
(qualifiedIdentifier
|
|
94
|
+
(identifier)))))))
|
|
95
|
+
(additiveExpr
|
|
96
|
+
(qualifiedAccessExpr
|
|
97
|
+
(unqualifiedAccessExpr
|
|
98
|
+
(identifier))
|
|
99
|
+
(identifier)
|
|
100
|
+
(argumentList))
|
|
101
|
+
(qualifiedAccessExpr
|
|
102
|
+
(unqualifiedAccessExpr
|
|
103
|
+
(identifier))
|
|
104
|
+
(identifier)
|
|
105
|
+
(argumentList))))))
|
|
106
|
+
(classProperty
|
|
107
|
+
(identifier)
|
|
108
|
+
(typeAnnotation
|
|
109
|
+
(declaredType
|
|
110
|
+
(qualifiedIdentifier
|
|
111
|
+
(identifier))
|
|
112
|
+
(typeArgumentList
|
|
113
|
+
(declaredType
|
|
114
|
+
(qualifiedIdentifier
|
|
115
|
+
(identifier)))
|
|
116
|
+
(declaredType
|
|
117
|
+
(qualifiedIdentifier
|
|
118
|
+
(identifier)))))))
|
|
119
|
+
(classProperty
|
|
120
|
+
(identifier)
|
|
121
|
+
(typeAnnotation
|
|
122
|
+
(declaredType
|
|
123
|
+
(qualifiedIdentifier
|
|
124
|
+
(identifier))
|
|
125
|
+
(typeArgumentList
|
|
126
|
+
(declaredType
|
|
127
|
+
(qualifiedIdentifier
|
|
128
|
+
(identifier)))
|
|
129
|
+
(declaredType
|
|
130
|
+
(qualifiedIdentifier
|
|
131
|
+
(identifier))))))))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
===
|
|
2
|
+
classes/constraints15.pkl
|
|
3
|
+
===
|
|
4
|
+
|
|
5
|
+
res1: String(length >= 3, length <= 5) = "abcd"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
(module
|
|
10
|
+
(classProperty
|
|
11
|
+
(identifier)
|
|
12
|
+
(typeAnnotation
|
|
13
|
+
(constrainedType
|
|
14
|
+
(declaredType
|
|
15
|
+
(qualifiedIdentifier
|
|
16
|
+
(identifier)))
|
|
17
|
+
(comparisonExpr
|
|
18
|
+
(unqualifiedAccessExpr
|
|
19
|
+
(identifier))
|
|
20
|
+
(intLiteralExpr))
|
|
21
|
+
(comparisonExpr
|
|
22
|
+
(unqualifiedAccessExpr
|
|
23
|
+
(identifier))
|
|
24
|
+
(intLiteralExpr))))
|
|
25
|
+
(slStringLiteralExpr
|
|
26
|
+
(slStringLiteralPart))))
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
===
|
|
2
|
+
classes/functions5.pkl
|
|
3
|
+
===
|
|
4
|
+
|
|
5
|
+
function a(x, y,) = 2 * x * y
|
|
6
|
+
function b(x: Int, y: Int,) = 2 * x * y
|
|
7
|
+
function c(
|
|
8
|
+
x: Int,
|
|
9
|
+
y: Int,
|
|
10
|
+
) = 2 * x * y
|
|
11
|
+
local d: (Int, Int,) -> Int = (x, y,) -> 2 * x * y
|
|
12
|
+
|
|
13
|
+
res1 = a(3, 4,)
|
|
14
|
+
res2 = b(3, 4,)
|
|
15
|
+
res3 = c(
|
|
16
|
+
3,
|
|
17
|
+
4,
|
|
18
|
+
)
|
|
19
|
+
res4 = d.apply(3, 4,)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
(module
|
|
24
|
+
(classMethod
|
|
25
|
+
(methodHeader
|
|
26
|
+
(identifier)
|
|
27
|
+
(parameterList
|
|
28
|
+
(typedIdentifier
|
|
29
|
+
(identifier))
|
|
30
|
+
(typedIdentifier
|
|
31
|
+
(identifier))))
|
|
32
|
+
(multiplicativeExpr
|
|
33
|
+
(multiplicativeExpr
|
|
34
|
+
(intLiteralExpr)
|
|
35
|
+
(unqualifiedAccessExpr
|
|
36
|
+
(identifier)))
|
|
37
|
+
(unqualifiedAccessExpr
|
|
38
|
+
(identifier))))
|
|
39
|
+
(classMethod
|
|
40
|
+
(methodHeader
|
|
41
|
+
(identifier)
|
|
42
|
+
(parameterList
|
|
43
|
+
(typedIdentifier
|
|
44
|
+
(identifier)
|
|
45
|
+
(typeAnnotation
|
|
46
|
+
(declaredType
|
|
47
|
+
(qualifiedIdentifier
|
|
48
|
+
(identifier)))))
|
|
49
|
+
(typedIdentifier
|
|
50
|
+
(identifier)
|
|
51
|
+
(typeAnnotation
|
|
52
|
+
(declaredType
|
|
53
|
+
(qualifiedIdentifier
|
|
54
|
+
(identifier)))))))
|
|
55
|
+
(multiplicativeExpr
|
|
56
|
+
(multiplicativeExpr
|
|
57
|
+
(intLiteralExpr)
|
|
58
|
+
(unqualifiedAccessExpr
|
|
59
|
+
(identifier)))
|
|
60
|
+
(unqualifiedAccessExpr
|
|
61
|
+
(identifier))))
|
|
62
|
+
(classMethod
|
|
63
|
+
(methodHeader
|
|
64
|
+
(identifier)
|
|
65
|
+
(parameterList
|
|
66
|
+
(typedIdentifier
|
|
67
|
+
(identifier)
|
|
68
|
+
(typeAnnotation
|
|
69
|
+
(declaredType
|
|
70
|
+
(qualifiedIdentifier
|
|
71
|
+
(identifier)))))
|
|
72
|
+
(typedIdentifier
|
|
73
|
+
(identifier)
|
|
74
|
+
(typeAnnotation
|
|
75
|
+
(declaredType
|
|
76
|
+
(qualifiedIdentifier
|
|
77
|
+
(identifier)))))))
|
|
78
|
+
(multiplicativeExpr
|
|
79
|
+
(multiplicativeExpr
|
|
80
|
+
(intLiteralExpr)
|
|
81
|
+
(unqualifiedAccessExpr
|
|
82
|
+
(identifier)))
|
|
83
|
+
(unqualifiedAccessExpr
|
|
84
|
+
(identifier))))
|
|
85
|
+
(classProperty
|
|
86
|
+
(modifier)
|
|
87
|
+
(identifier)
|
|
88
|
+
(typeAnnotation
|
|
89
|
+
(functionLiteralType
|
|
90
|
+
(declaredType
|
|
91
|
+
(qualifiedIdentifier
|
|
92
|
+
(identifier)))
|
|
93
|
+
(declaredType
|
|
94
|
+
(qualifiedIdentifier
|
|
95
|
+
(identifier)))
|
|
96
|
+
(declaredType
|
|
97
|
+
(qualifiedIdentifier
|
|
98
|
+
(identifier)))))
|
|
99
|
+
(functionLiteralExpr
|
|
100
|
+
(parameterList
|
|
101
|
+
(typedIdentifier
|
|
102
|
+
(identifier))
|
|
103
|
+
(typedIdentifier
|
|
104
|
+
(identifier)))
|
|
105
|
+
(multiplicativeExpr
|
|
106
|
+
(multiplicativeExpr
|
|
107
|
+
(intLiteralExpr)
|
|
108
|
+
(unqualifiedAccessExpr
|
|
109
|
+
(identifier)))
|
|
110
|
+
(unqualifiedAccessExpr
|
|
111
|
+
(identifier)))))
|
|
112
|
+
(classProperty
|
|
113
|
+
(identifier)
|
|
114
|
+
(unqualifiedAccessExpr
|
|
115
|
+
(identifier)
|
|
116
|
+
(argumentList
|
|
117
|
+
(intLiteralExpr)
|
|
118
|
+
(intLiteralExpr))))
|
|
119
|
+
(classProperty
|
|
120
|
+
(identifier)
|
|
121
|
+
(unqualifiedAccessExpr
|
|
122
|
+
(identifier)
|
|
123
|
+
(argumentList
|
|
124
|
+
(intLiteralExpr)
|
|
125
|
+
(intLiteralExpr))))
|
|
126
|
+
(classProperty
|
|
127
|
+
(identifier)
|
|
128
|
+
(unqualifiedAccessExpr
|
|
129
|
+
(identifier)
|
|
130
|
+
(argumentList
|
|
131
|
+
(intLiteralExpr)
|
|
132
|
+
(intLiteralExpr))))
|
|
133
|
+
(classProperty
|
|
134
|
+
(identifier)
|
|
135
|
+
(qualifiedAccessExpr
|
|
136
|
+
(unqualifiedAccessExpr
|
|
137
|
+
(identifier))
|
|
138
|
+
(identifier)
|
|
139
|
+
(argumentList
|
|
140
|
+
(intLiteralExpr)
|
|
141
|
+
(intLiteralExpr)))))
|
package/tree-sitter.json
CHANGED
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
"pkl"
|
|
12
12
|
],
|
|
13
13
|
"injection-regex": "^pkl$",
|
|
14
|
+
"highlights": "queries/highlights.scm",
|
|
15
|
+
"injections": "queries/injections.scm",
|
|
16
|
+
"locals": "queries/locals.scm",
|
|
14
17
|
"class-name": "TreeSitterPkl"
|
|
15
18
|
}
|
|
16
19
|
],
|
|
17
20
|
"metadata": {
|
|
18
|
-
"version": "0.
|
|
21
|
+
"version": "0.19.0",
|
|
19
22
|
"license": "Apache-2.0",
|
|
20
23
|
"description": "Parser for Pkl programming language",
|
|
21
24
|
"authors": [
|