~repos /plum
git clone https://pyrossh.dev/repos/plum.git
A statically typed, imperative programming language inspired by rust, python
5b848891
—
pyrossh 11 months ago
fix assign
tooling/tree-sitter-plum/grammar.js
CHANGED
|
@@ -64,7 +64,7 @@ module.exports = grammar({
|
|
|
64
64
|
seq(
|
|
65
65
|
optional(seq("module", $.module)),
|
|
66
66
|
repeat($.import),
|
|
67
|
-
repeat(choice($.class, $.trait, $.enum, $.fn)),
|
|
67
|
+
repeat(choice($.class, $.trait, $.enum, $.fn, $.assign)),
|
|
68
68
|
),
|
|
69
69
|
|
|
70
70
|
module: ($) => $.var_identifier,
|
tooling/tree-sitter-plum/src/grammar.json
CHANGED
|
Binary file
|
tooling/tree-sitter-plum/src/node-types.json
CHANGED
|
Binary file
|
tooling/tree-sitter-plum/src/parser.c
CHANGED
|
Binary file
|
tooling/tree-sitter-plum/test/corpus/assign.txt
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
assign - Expression
|
|
3
3
|
================================================================================
|
|
4
4
|
|
|
5
|
-
sum = 1 +
|
|
5
|
+
sum = 1 + {{2 * 3} / 4}
|
|
6
6
|
|
|
7
7
|
--------------------------------------------------------------------------------
|
|
8
8
|
|
|
9
9
|
(source
|
|
10
10
|
(assign
|
|
11
|
-
(
|
|
11
|
+
(var_identifier)
|
|
12
12
|
(expression
|
|
13
13
|
(primary_expression
|
|
14
14
|
(binary_operator
|
|
@@ -41,7 +41,7 @@ enabled = !False
|
|
|
41
41
|
|
|
42
42
|
(source
|
|
43
43
|
(assign
|
|
44
|
-
(
|
|
44
|
+
(var_identifier)
|
|
45
45
|
(expression
|
|
46
46
|
(not_operator
|
|
47
47
|
(expression
|
|
@@ -52,13 +52,13 @@ enabled = !False
|
|
|
52
52
|
assign - Boolean expression
|
|
53
53
|
================================================================================
|
|
54
54
|
|
|
55
|
-
open =
|
|
55
|
+
open = {count > 10} && {enabled == True} || {debug == False}
|
|
56
56
|
|
|
57
57
|
--------------------------------------------------------------------------------
|
|
58
58
|
|
|
59
59
|
(source
|
|
60
60
|
(assign
|
|
61
|
-
(
|
|
61
|
+
(var_identifier)
|
|
62
62
|
(expression
|
|
63
63
|
(boolean_operator
|
|
64
64
|
(expression
|
|
@@ -69,7 +69,7 @@ open = (count > 10) && (enabled == True) || (debug == False)
|
|
|
69
69
|
(expression
|
|
70
70
|
(comparison_operator
|
|
71
71
|
(primary_expression
|
|
72
|
-
(
|
|
72
|
+
(var_identifier))
|
|
73
73
|
(primary_expression
|
|
74
74
|
(integer)))))))
|
|
75
75
|
(expression
|
|
@@ -78,7 +78,7 @@ open = (count > 10) && (enabled == True) || (debug == False)
|
|
|
78
78
|
(expression
|
|
79
79
|
(comparison_operator
|
|
80
80
|
(primary_expression
|
|
81
|
-
(
|
|
81
|
+
(var_identifier))
|
|
82
82
|
(primary_expression
|
|
83
83
|
(type_identifier)))))))))
|
|
84
84
|
(expression
|
|
@@ -87,31 +87,27 @@ open = (count > 10) && (enabled == True) || (debug == False)
|
|
|
87
87
|
(expression
|
|
88
88
|
(comparison_operator
|
|
89
89
|
(primary_expression
|
|
90
|
-
(
|
|
90
|
+
(var_identifier))
|
|
91
91
|
(primary_expression
|
|
92
92
|
(type_identifier)))))))))))
|
|
93
93
|
|
|
94
94
|
================================================================================
|
|
95
|
-
assign -
|
|
95
|
+
assign - listOf
|
|
96
96
|
================================================================================
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
countries_list = listOf("US", "INDIA", "CANADA")
|
|
99
|
-
|
|
99
|
+
list_ints = listOf(1, 2, 3)
|
|
100
|
-
|
|
100
|
+
nested_list_ints = listOf(listOf(1), listOf(2), listOf(3))
|
|
101
|
-
c = list.of(1, 2, 3 * 4, 8, n)
|
|
102
|
-
d = "{name} {age}"
|
|
103
|
-
e = "Cat<{fullname()}, {age}>"
|
|
104
101
|
|
|
105
102
|
--------------------------------------------------------------------------------
|
|
106
103
|
|
|
107
104
|
(source
|
|
108
105
|
(assign
|
|
109
|
-
(
|
|
106
|
+
(var_identifier)
|
|
110
107
|
(expression
|
|
111
108
|
(primary_expression
|
|
112
|
-
(
|
|
109
|
+
(fn_call
|
|
113
|
-
(reference
|
|
114
|
-
|
|
110
|
+
(fn_identifier)
|
|
115
111
|
(argument_list
|
|
116
112
|
(expression
|
|
117
113
|
(primary_expression
|
|
@@ -132,13 +128,11 @@ e = "Cat<{fullname()}, {age}>"
|
|
|
132
128
|
(string_content)
|
|
133
129
|
(string_end)))))))))
|
|
134
130
|
(assign
|
|
135
|
-
(
|
|
131
|
+
(var_identifier)
|
|
136
132
|
(expression
|
|
137
133
|
(primary_expression
|
|
138
|
-
(
|
|
134
|
+
(fn_call
|
|
139
|
-
(reference
|
|
140
|
-
|
|
135
|
+
(fn_identifier)
|
|
141
|
-
(identifier))
|
|
142
136
|
(argument_list
|
|
143
137
|
(expression
|
|
144
138
|
(primary_expression
|
|
@@ -150,95 +144,58 @@ e = "Cat<{fullname()}, {age}>"
|
|
|
150
144
|
(primary_expression
|
|
151
145
|
(integer))))))))
|
|
152
146
|
(assign
|
|
153
|
-
(
|
|
147
|
+
(var_identifier)
|
|
154
148
|
(expression
|
|
155
149
|
(primary_expression
|
|
156
|
-
(
|
|
150
|
+
(fn_call
|
|
157
|
-
(reference
|
|
158
|
-
|
|
151
|
+
(fn_identifier)
|
|
159
|
-
(identifier))
|
|
160
152
|
(argument_list
|
|
161
153
|
(expression
|
|
162
154
|
(primary_expression
|
|
163
|
-
(
|
|
155
|
+
(fn_call
|
|
164
|
-
(reference
|
|
165
|
-
|
|
156
|
+
(fn_identifier)
|
|
166
|
-
(identifier))
|
|
167
157
|
(argument_list
|
|
168
158
|
(expression
|
|
169
159
|
(primary_expression
|
|
170
160
|
(integer)))))))
|
|
171
161
|
(expression
|
|
172
162
|
(primary_expression
|
|
173
|
-
(
|
|
163
|
+
(fn_call
|
|
174
|
-
(reference
|
|
175
|
-
|
|
164
|
+
(fn_identifier)
|
|
176
|
-
(identifier))
|
|
177
165
|
(argument_list
|
|
178
166
|
(expression
|
|
179
167
|
(primary_expression
|
|
180
168
|
(integer)))))))
|
|
181
169
|
(expression
|
|
182
170
|
(primary_expression
|
|
183
|
-
(
|
|
171
|
+
(fn_call
|
|
184
|
-
(reference
|
|
185
|
-
|
|
172
|
+
(fn_identifier)
|
|
186
|
-
(identifier))
|
|
187
173
|
(argument_list
|
|
188
174
|
(expression
|
|
189
175
|
(primary_expression
|
|
190
|
-
(integer))))))))))))
|
|
176
|
+
(integer)))))))))))))
|
|
191
|
-
(assign
|
|
192
|
-
(identifier)
|
|
193
|
-
(expression
|
|
194
|
-
(primary_expression
|
|
195
|
-
(call
|
|
196
|
-
(reference
|
|
197
|
-
(identifier)
|
|
198
|
-
(identifier))
|
|
199
|
-
(argument_list
|
|
200
|
-
(expression
|
|
201
|
-
(primary_expression
|
|
202
|
-
(integer)))
|
|
203
|
-
(expression
|
|
204
|
-
(primary_expression
|
|
205
|
-
(integer)))
|
|
206
|
-
(expression
|
|
207
|
-
(primary_expression
|
|
208
|
-
(binary_operator
|
|
209
|
-
(primary_expression
|
|
210
|
-
(integer))
|
|
211
|
-
(primary_expression
|
|
212
|
-
(integer)))))
|
|
213
|
-
(expression
|
|
214
|
-
(primary_expression
|
|
215
|
-
(integer)))
|
|
216
|
-
(expression
|
|
217
|
-
(primary_expression
|
|
218
|
-
(identifier)))))))))
|
|
219
177
|
|
|
220
178
|
================================================================================
|
|
221
|
-
assign -
|
|
179
|
+
assign - mapOf
|
|
222
180
|
================================================================================
|
|
223
181
|
|
|
224
|
-
|
|
182
|
+
country_codes = mapOf(
|
|
225
183
|
"in" => "INDIA",
|
|
226
184
|
"us" => "United States",
|
|
227
185
|
"ca" => "Canada"
|
|
228
186
|
)
|
|
229
|
-
|
|
187
|
+
map_ints = mapOf("a" => 1, "b" => 2)
|
|
230
|
-
|
|
188
|
+
nested_map_ints = mapOf("a" => 1, "b" => mapOf("c" => 3, "d" => 4))
|
|
231
189
|
|
|
232
190
|
--------------------------------------------------------------------------------
|
|
233
191
|
|
|
234
192
|
(source
|
|
235
193
|
(assign
|
|
236
|
-
(
|
|
194
|
+
(var_identifier)
|
|
237
195
|
(expression
|
|
238
196
|
(primary_expression
|
|
239
|
-
(
|
|
197
|
+
(fn_call
|
|
240
|
-
(reference
|
|
241
|
-
|
|
198
|
+
(fn_identifier)
|
|
242
199
|
(argument_list
|
|
243
200
|
(pair_argument
|
|
244
201
|
(string
|
|
@@ -274,12 +231,11 @@ b = Map("a" => 1, "b" => Map("c" => 3, "d" => 4))
|
|
|
274
231
|
(string_content)
|
|
275
232
|
(string_end))))))))))
|
|
276
233
|
(assign
|
|
277
|
-
(
|
|
234
|
+
(var_identifier)
|
|
278
235
|
(expression
|
|
279
236
|
(primary_expression
|
|
280
|
-
(
|
|
237
|
+
(fn_call
|
|
281
|
-
(reference
|
|
282
|
-
|
|
238
|
+
(fn_identifier)
|
|
283
239
|
(argument_list
|
|
284
240
|
(pair_argument
|
|
285
241
|
(string
|
|
@@ -298,12 +254,11 @@ b = Map("a" => 1, "b" => Map("c" => 3, "d" => 4))
|
|
|
298
254
|
(primary_expression
|
|
299
255
|
(integer)))))))))
|
|
300
256
|
(assign
|
|
301
|
-
(
|
|
257
|
+
(var_identifier)
|
|
302
258
|
(expression
|
|
303
259
|
(primary_expression
|
|
304
|
-
(
|
|
260
|
+
(fn_call
|
|
305
|
-
(reference
|
|
306
|
-
|
|
261
|
+
(fn_identifier)
|
|
307
262
|
(argument_list
|
|
308
263
|
(pair_argument
|
|
309
264
|
(string
|
|
@@ -320,10 +275,8 @@ b = Map("a" => 1, "b" => Map("c" => 3, "d" => 4))
|
|
|
320
275
|
(string_end))
|
|
321
276
|
(expression
|
|
322
277
|
(primary_expression
|
|
323
|
-
(
|
|
278
|
+
(fn_call
|
|
324
|
-
(reference
|
|
325
|
-
|
|
279
|
+
(fn_identifier)
|
|
326
|
-
(identifier))
|
|
327
280
|
(argument_list
|
|
328
281
|
(pair_argument
|
|
329
282
|
(string
|