plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


391c8e4Peter John 2026-07-23T18:41:41+05:30
feat(tree-sitter-plum): add field_target rule for obj.field = value assignment
tooling/tree-sitter-plum/grammar.js CHANGED
@@ -199,9 +199,16 @@ module.exports = grammar({
199
199
  $.expression,
200
200
  ),
201
201
 
202
+ field_target: ($) =>
203
+ seq(
204
+ field("object", $.primary_expression),
205
+ ".",
206
+ field("member", $.fn_identifier),
207
+ ),
208
+
202
209
  assign: ($) =>
203
210
  seq(
204
- commaSep1($.var_identifier),
211
+ commaSep1(choice($.var_identifier, $.field_target)),
205
212
  "=",
206
213
  commaSep1($.expression),
207
214
  ),
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
@@ -262,3 +262,50 @@ main() =
262
262
  (expression
263
263
  (primary_expression
264
264
  (integer)))))))))))))))))
265
+
266
+ ================================================================================
267
+ field assignment target
268
+ ================================================================================
269
+
270
+ main() =
271
+ self.head = value
272
+ self.head.value = x
273
+ a, self.field = 1, 2
274
+
275
+ --------------------------------------------------------------------------------
276
+
277
+ (source
278
+ (fn
279
+ (fn_identifier)
280
+ (body
281
+ (assign
282
+ (field_target
283
+ (primary_expression
284
+ (self))
285
+ (fn_identifier))
286
+ (expression
287
+ (primary_expression
288
+ (var_identifier))))
289
+ (assign
290
+ (field_target
291
+ (primary_expression
292
+ (attribute
293
+ (primary_expression
294
+ (self))
295
+ (fn_identifier)))
296
+ (fn_identifier))
297
+ (expression
298
+ (primary_expression
299
+ (var_identifier))))
300
+ (assign
301
+ (var_identifier)
302
+ (field_target
303
+ (primary_expression
304
+ (self))
305
+ (fn_identifier))
306
+ (expression
307
+ (primary_expression
308
+ (integer)))
309
+ (expression
310
+ (primary_expression
311
+ (integer)))))))