tree-sitter-bynk 0.377.2 → 0.403.3

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/grammar.js CHANGED
@@ -74,6 +74,11 @@ module.exports = grammar({
74
74
  // whether a matcher (`called`/`never`/`before`) or an ordinary continuation
75
75
  // (`(`, an operator, …) follows.
76
76
  [$.observation_expr, $._primary],
77
+ // `trace` is contextual: `trace (` opens either the `trace(Cap.op)`
78
+ // builtin or an ordinary call to a function named `trace` (the compiler
79
+ // picks the builtin only on the exact `trace ( Ident . Ident )` shape). GLR
80
+ // keeps both; `trace_expr`'s dynamic precedence wins when both complete.
81
+ [$.trace_expr, $._contextual_identifier],
77
82
  // v0.140: inside `agent_decl`, a `store` field's own trailing
78
83
  // `@annotation`s are the same rule as the handler-position annotation
79
84
  // prefix that can immediately follow the last store field — one token of
@@ -202,6 +207,7 @@ module.exports = grammar({
202
207
  $.actor_decl,
203
208
  $.event_decl,
204
209
  $.asset_decl,
210
+ $.embed_decl,
205
211
  ),
206
212
 
207
213
  _context_body_item: ($) =>
@@ -219,6 +225,8 @@ module.exports = grammar({
219
225
  $.messages_decl,
220
226
  $.event_decl,
221
227
  $.asset_decl,
228
+ $.embed_decl,
229
+ $.removed_agent_decl,
222
230
  ),
223
231
 
224
232
  // v0.17: adapter items — a binding clause, capabilities, boundary types,
@@ -242,6 +250,7 @@ module.exports = grammar({
242
250
  $.messages_decl,
243
251
  $.event_decl,
244
252
  $.asset_decl,
253
+ $.embed_decl,
245
254
  ),
246
255
 
247
256
  _test_body_item: ($) =>
@@ -281,6 +290,17 @@ module.exports = grammar({
281
290
  seq(
282
291
  "binding",
283
292
  field("module", $.string_literal),
293
+ // #2321: `includes` is contextual (an identifier elsewhere), so it is a
294
+ // token only here.
295
+ optional(
296
+ seq(
297
+ alias("includes", $.includes_keyword),
298
+ "[",
299
+ optional(sep1(field("include", $.string_literal), ",")),
300
+ optional(","),
301
+ "]",
302
+ ),
303
+ ),
284
304
  optional(
285
305
  seq(
286
306
  "requires",
@@ -393,6 +413,18 @@ module.exports = grammar({
393
413
  optional(seq("at", field("at", $.string_literal))),
394
414
  ),
395
415
 
416
+ // #2387 (embedded text), slice 1: `embed name = "path"` — one project
417
+ // file's text as a `String` constant. Admitted in every body like `asset`;
418
+ // placement is a checker concern (`bynk.embed.outside_context_or_commons`
419
+ // rejects it in an adapter).
420
+ embed_decl: ($) =>
421
+ seq(
422
+ "embed",
423
+ field("name", $.identifier),
424
+ "=",
425
+ field("path", $.string_literal),
426
+ ),
427
+
396
428
  // v0.154 (ADR 0178): a sum body may carry a trailing `embeds E as V, …`
397
429
  // clause declaring error embeddings the `?` operator auto-converts.
398
430
  // `embeds`/`as` are contextual — matched only in this position.
@@ -867,11 +899,14 @@ module.exports = grammar({
867
899
  seq(
868
900
  "agent",
869
901
  field("name", $.identifier),
902
+ // State-migrations S3 (#2248): `agent New replaces Old` — a class
903
+ // rename, its stored data moving with it. `replaces` is contextual.
904
+ optional(seq("replaces", field("replaces", $.identifier))),
870
905
  "{",
871
906
  field("key", $.key_decl),
872
907
  // v0.81 (storage track): the agent's `store` fields (ADR 0108).
873
908
  repeat($.store_field),
874
- repeat(choice($.invariant_decl, $.transition_decl)),
909
+ repeat(choice($.invariant_decl, $.transition_decl, $.migrate_decl)),
875
910
  // v0.140 (ADR 0163): handler-position annotations parse uniformly on
876
911
  // agent handlers too; the checker (not the grammar) restricts which
877
912
  // annotations apply to a non-HTTP handler. Only `on call` is a valid
@@ -901,6 +936,32 @@ module.exports = grammar({
901
936
  ":",
902
937
  field("predicate", $._expression),
903
938
  ),
939
+ // State-migrations S2 (#2224): `migrate from N [(old: T)] { … }` — a step
940
+ // carrying a stored record from schema version N to the current shape.
941
+ // `migrate` and `drop` are contextual keywords, like `store`.
942
+ migrate_decl: ($) =>
943
+ seq(
944
+ "migrate",
945
+ "from",
946
+ field("from", $.number_literal),
947
+ optional(
948
+ seq(
949
+ "(",
950
+ field("old", $.identifier),
951
+ ":",
952
+ field("old_type", $._type_ref),
953
+ ")",
954
+ ),
955
+ ),
956
+ "{",
957
+ repeat(choice($.let_stmt, $.assign_stmt, $.migrate_drop)),
958
+ "}",
959
+ ),
960
+ migrate_drop: ($) => seq("drop", field("field", $.identifier)),
961
+ // State-migrations S3 (#2248): `removed agent Old` — the class is gone and
962
+ // its stored data deleted. `removed` is contextual.
963
+ removed_agent_decl: ($) =>
964
+ seq("removed", "agent", field("name", $.identifier)),
904
965
  key_decl: ($) =>
905
966
  seq("key", field("name", $.identifier), ":", field("type", $._type_ref)),
906
967
  // v0.81 (storage track): `store <name>: <Kind>[…] [= init]`. `store` is a
@@ -954,6 +1015,26 @@ module.exports = grammar({
954
1015
  // Events track, slice 0 (spine #936): a `from Events(E)` service's
955
1016
  // one handler.
956
1017
  $.event_handler,
1018
+ // #2341 (L4, decision C): a `from http` service's rendering of the
1019
+ // router's own rejections.
1020
+ $.rejected_handler,
1021
+ ),
1022
+ // #2341 (L4, decision C): `on rejected(why: BoundaryRejection) ->
1023
+ // HttpResult[()] { … }`. The generic handler shape; the checker refuses a
1024
+ // `by`/`given` and checks the parameter and return type.
1025
+ rejected_handler: ($) =>
1026
+ seq(
1027
+ "on",
1028
+ "rejected",
1029
+ "(",
1030
+ optional(sep1($.param, ",")),
1031
+ optional(","),
1032
+ ")",
1033
+ "->",
1034
+ field("return_type", $._type_ref),
1035
+ optional(field("by", $.by_clause)),
1036
+ optional(field("given", $.given_clause)),
1037
+ field("body", $.block),
957
1038
  ),
958
1039
  // Events track, slice 0 (spine #936): `on event(e: E) -> Effect[()] { … }`
959
1040
  // — a `from Events(E)` subscriber's one handler. Same generic shape as
@@ -1330,7 +1411,8 @@ module.exports = grammar({
1330
1411
  // #2010: the `else match { <arms> }` form, whose arms cover the values the
1331
1412
  // `let` pattern does not.
1332
1413
  let_else_match: ($) => seq("match", "{", repeat($.match_arm), "}"),
1333
- // v0.182 (#664): `by <Actor>` (unit identity) or `by <Actor>(<identity>)`.
1414
+ // v0.182 (#664): `by <Actor>` (unit identity) or `by <Actor>(<identity>)`;
1415
+ // #2380: `by <Actor>(<identity>, <claims>)` for an `Oidc` actor.
1334
1416
  // `prec.right` so an immediately-following `(` is taken as the identity
1335
1417
  // argument rather than starting a fresh token sequence.
1336
1418
  call_site_actor: ($) =>
@@ -1338,7 +1420,15 @@ module.exports = grammar({
1338
1420
  seq(
1339
1421
  "by",
1340
1422
  field("actor", $.identifier),
1341
- optional(seq("(", field("identity", $._expression), ")")),
1423
+ // #2380 (L5): an `Oidc` principal may pass its token's claims second.
1424
+ optional(
1425
+ seq(
1426
+ "(",
1427
+ field("identity", $._expression),
1428
+ optional(seq(",", field("claims", $._expression))),
1429
+ ")",
1430
+ ),
1431
+ ),
1342
1432
  ),
1343
1433
  ),
1344
1434
  // v0.79: `~> expr` — an asynchronous fire-and-forget send (no binder).
@@ -1348,7 +1438,11 @@ module.exports = grammar({
1348
1438
  do_stmt: ($) => seq("do", field("value", $._expression)),
1349
1439
  // v0.81 (storage track): `name := expr` — a `Cell` store write.
1350
1440
  assign_stmt: ($) =>
1351
- seq(field("target", $.identifier), ":=", field("value", $._expression)),
1441
+ seq(
1442
+ field("target", choice($.identifier, $._contextual_identifier)),
1443
+ ":=",
1444
+ field("value", $._expression),
1445
+ ),
1352
1446
  // #2137: `advance Clock by <Duration>` — move the test harness's clock. The
1353
1447
  // compiler admits it only in a `case` body and only on `Clock`; `advance`
1354
1448
  // is contextual.
@@ -1433,8 +1527,8 @@ module.exports = grammar({
1433
1527
  // `List` of per-op records. A test-only builtin recognised by its
1434
1528
  // `trace ( Ident . Ident )` shape.
1435
1529
  trace_expr: ($) =>
1436
- prec(
1437
- PREC.postfix + 1,
1530
+ prec.dynamic(
1531
+ 1,
1438
1532
  seq(
1439
1533
  "trace",
1440
1534
  "(",
@@ -1618,8 +1712,19 @@ module.exports = grammar({
1618
1712
  $.unit_literal,
1619
1713
  $.self_expr,
1620
1714
  $.identifier,
1715
+ $._contextual_identifier,
1621
1716
  ),
1622
1717
 
1718
+ // `trace` and `advance` are contextual in the compiler — ordinary
1719
+ // identifiers outside `trace(Cap.op)` / `advance Clock by …`. Here, as
1720
+ // `word`-shaped literals, they are extracted as keyword tokens, and where an
1721
+ // identifier and the keyword are both valid (an expression or statement
1722
+ // head) the keyword always wins the lex. Re-admit the keyword token as an
1723
+ // `identifier` in exactly those positions. The next tokens decide: `advance`
1724
+ // followed by an identifier can only open an `advance_stmt`, and `trace (`
1725
+ // is a declared conflict that `trace_expr`'s dynamic precedence settles.
1726
+ _contextual_identifier: ($) => alias(choice("trace", "advance"), $.identifier),
1727
+
1623
1728
  // v0.20a: a lambda — `(params) => expr | block`. Conflicts with
1624
1729
  // paren_expr/unit_literal until the `=>` disambiguates (GLR conflict
1625
1730
  // declared below).
@@ -1633,7 +1738,10 @@ module.exports = grammar({
1633
1738
  ),
1634
1739
 
1635
1740
  lambda_param: ($) =>
1636
- seq(field("name", $.identifier), optional(seq(":", field("type", $._type_ref)))),
1741
+ seq(
1742
+ field("name", choice($.identifier, $._contextual_identifier)),
1743
+ optional(seq(":", field("type", $._type_ref))),
1744
+ ),
1637
1745
 
1638
1746
  paren_expr: ($) => seq("(", $._expression, ")"),
1639
1747
 
@@ -1668,7 +1776,7 @@ module.exports = grammar({
1668
1776
  prec.left(
1669
1777
  PREC.postfix,
1670
1778
  seq(
1671
- field("name", $.identifier),
1779
+ field("name", choice($.identifier, $._contextual_identifier)),
1672
1780
  // v0.20a: optional explicit type arguments — `name[T, U](…)`.
1673
1781
  optional(seq("[", sep1(field("type_arg", $._type_ref), ","), "]")),
1674
1782
  "(",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-bynk",
3
- "version": "0.377.2",
3
+ "version": "0.403.3",
4
4
  "description": "Tree-sitter grammar for the Bynk language.",
5
5
  "main": "bindings/node",
6
6
  "types": "bindings/node",
@@ -53,11 +53,17 @@
53
53
  "property"
54
54
  "invariant"
55
55
  "transition"
56
+ "migrate"
57
+ "drop"
58
+ "replaces"
59
+ "removed"
56
60
  "requires"
57
61
  "ensures"
58
62
  "messages"
59
63
  "event"
64
+ "rejected"
60
65
  "asset"
66
+ "embed"
61
67
  ] @keyword.declaration
62
68
 
63
69
  [
@@ -251,3 +257,6 @@
251
257
  ; -- Errors (tree-sitter recovery) --
252
258
 
253
259
  (ERROR) @error
260
+
261
+ ; #2321: `includes` is contextual (an identifier elsewhere), so it is its own node.
262
+ (includes_keyword) @keyword.declaration