tree-sitter-bynk 0.314.23 → 0.371.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)
4
4
 
5
5
  The [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar for the
6
- [Bynk](https://github.com/accuser/bynk) language — the source of truth for
6
+ [Bynk](https://github.com/bynk-lang/bynk) language — the source of truth for
7
7
  tree-sitter syntax highlighting (`queries/highlights.scm`), the playground's
8
8
  editor, and the Book's grammar reference (rendered from `src/grammar.json` by
9
9
  [`bynk-grammar`](https://crates.io/crates/bynk-grammar)).
@@ -45,5 +45,5 @@ test's dev-dependency edge is cycle-free.
45
45
 
46
46
  ## License
47
47
 
48
- Licensed under either of [Apache-2.0](https://github.com/accuser/bynk/blob/main/LICENSE-APACHE) or
49
- [MIT](https://github.com/accuser/bynk/blob/main/LICENSE-MIT) at your option.
48
+ Licensed under either of [Apache-2.0](https://github.com/bynk-lang/bynk/blob/main/LICENSE-APACHE) or
49
+ [MIT](https://github.com/bynk-lang/bynk/blob/main/LICENSE-MIT) at your option.
package/grammar.js CHANGED
@@ -41,7 +41,7 @@ module.exports = grammar({
41
41
 
42
42
  externals: ($) => [$.doc_block],
43
43
 
44
- extras: ($) => [/\s+/, $.line_comment, $.doc_block],
44
+ extras: ($) => [/\s+/, $.doc_line, $.line_comment, $.doc_block],
45
45
 
46
46
  // The DSL allows reserved words to be referenced inside specific rules via
47
47
  // tokens; we declare keywords so they take precedence over `identifier`.
@@ -201,6 +201,7 @@ module.exports = grammar({
201
201
  $.agent_decl,
202
202
  $.actor_decl,
203
203
  $.event_decl,
204
+ $.asset_decl,
204
205
  ),
205
206
 
206
207
  _context_body_item: ($) =>
@@ -217,6 +218,7 @@ module.exports = grammar({
217
218
  $.actor_decl,
218
219
  $.messages_decl,
219
220
  $.event_decl,
221
+ $.asset_decl,
220
222
  ),
221
223
 
222
224
  // v0.17: adapter items — a binding clause, capabilities, boundary types,
@@ -239,10 +241,18 @@ module.exports = grammar({
239
241
  $.actor_decl,
240
242
  $.messages_decl,
241
243
  $.event_decl,
244
+ $.asset_decl,
242
245
  ),
243
246
 
244
247
  _test_body_item: ($) =>
245
- choice($.uses_decl, $.consumes_decl, $.stub_clause, $.case, $.property_decl),
248
+ choice(
249
+ $.uses_decl,
250
+ $.consumes_decl,
251
+ $.env_clause,
252
+ $.stub_clause,
253
+ $.case,
254
+ $.property_decl,
255
+ ),
246
256
 
247
257
  // -- Headers / clauses --
248
258
 
@@ -368,6 +378,21 @@ module.exports = grammar({
368
378
  field("body", $.record_type),
369
379
  ),
370
380
 
381
+ // #1883 (static assets), slice 1a: `asset name = "path"` — one static
382
+ // file the platform serves. Admitted in every body (commons, context,
383
+ // adapter) like `event`; placement is a checker concern
384
+ // (`bynk.asset.outside_context_or_commons` rejects it in an adapter).
385
+ asset_decl: ($) =>
386
+ seq(
387
+ "asset",
388
+ field("name", $.identifier),
389
+ "=",
390
+ field("path", $.string_literal),
391
+ // #1883, slice 2: an optional fixed URL path. `at` is contextual,
392
+ // matched only here (the `word` rule keeps it an identifier elsewhere).
393
+ optional(seq("at", field("at", $.string_literal))),
394
+ ),
395
+
371
396
  // v0.154 (ADR 0178): a sum body may carry a trailing `embeds E as V, …`
372
397
  // clause declaring error embeddings the `?` operator auto-converts.
373
398
  // `embeds`/`as` are contextual — matched only in this position.
@@ -604,9 +629,16 @@ module.exports = grammar({
604
629
  seq(
605
630
  "capability",
606
631
  field("name", $.identifier),
607
- "{",
608
- repeat($.capability_op),
609
- "}",
632
+ choice(
633
+ seq("{", repeat($.capability_op), "}"),
634
+ // S4a (#1966): `capability Sessions = Kv @option(…)`, a derived
635
+ // capability: a distinct instance of a platform capability.
636
+ seq(
637
+ "=",
638
+ field("base", $.identifier),
639
+ repeat(field("annotation", $.store_annotation)),
640
+ ),
641
+ ),
610
642
  ),
611
643
  capability_op: ($) =>
612
644
  seq(
@@ -1088,7 +1120,7 @@ module.exports = grammar({
1088
1120
  // The closed, compiler-known scheme set. `None`/`Internal` are zero-crypto;
1089
1121
  // `Bearer` (JWT/HS256), `Signature` (HMAC over the body), and `Oidc`
1090
1122
  // (JWKS/RS256+ES256) are compiler-generated verifiers.
1091
- scheme: () => choice("None", "Internal", "Bearer", "Signature", "Oidc"),
1123
+ scheme: () => choice("None", "Internal", "Bearer", "Signature", "Oidc", "Foreign"),
1092
1124
  // v0.51: the keyed-args scheme config — `(key = value, …)`. Values are
1093
1125
  // string or integer literals; the checker validates which keys each scheme
1094
1126
  // admits (Bearer: secret; Signature: secret/header/timestamp/tolerance).
@@ -1159,8 +1191,17 @@ module.exports = grammar({
1159
1191
  "fails",
1160
1192
  ),
1161
1193
  ),
1194
+ // #2134: a suite- or case-scoped `env { NAME = "value" … }` clause — the
1195
+ // variables and secrets the suite's participants see. `env` is contextual:
1196
+ // a keyword only at the head of a suite or case body member. Values are
1197
+ // expressions here; the checker requires a `String` literal.
1198
+ env_clause: ($) =>
1199
+ seq("env", "{", repeat(seq($.env_entry, optional(","))), "}"),
1200
+ env_entry: ($) =>
1201
+ seq(field("name", $.identifier), "=", field("value", $._expression)),
1202
+
1162
1203
  // v0.118: an optional `as <tier>` classifier plus a body of leading
1163
- // `stub` clauses, then the ordinary statements and tail. The tier words
1204
+ // `stub` (and #2134 `env`) clauses, then the ordinary statements and tail. The tier words
1164
1205
  // (`unit`/`integration`/`system`) are contextual, as on `suite_decl`.
1165
1206
  case: ($) =>
1166
1207
  seq(
@@ -1168,7 +1209,7 @@ module.exports = grammar({
1168
1209
  field("name", $.string_literal),
1169
1210
  optional(seq("as", field("tier", choice("unit", "integration", "system")))),
1170
1211
  "{",
1171
- repeat($.stub_clause),
1212
+ repeat(choice($.stub_clause, $.env_clause)),
1172
1213
  repeat($._statement),
1173
1214
  optional(field("tail", $._expression)),
1174
1215
  "}",
@@ -1214,9 +1255,11 @@ module.exports = grammar({
1214
1255
  choice(
1215
1256
  $.let_stmt,
1216
1257
  $.effect_let_stmt,
1258
+ $.let_else_stmt,
1217
1259
  $.effect_send_stmt,
1218
1260
  $.do_stmt,
1219
1261
  $.assign_stmt,
1262
+ $.advance_stmt,
1220
1263
  prec(1, $.expect_expr),
1221
1264
  ),
1222
1265
 
@@ -1241,6 +1284,52 @@ module.exports = grammar({
1241
1284
  // binder, and there is no actor sum.
1242
1285
  optional(field("principal", $.call_site_actor)),
1243
1286
  ),
1287
+ // #2010: `let <pattern> (= | <-) <value> else <block>` or
1288
+ // `… else match { <arms> }`. The `else` is the value of the rest of the
1289
+ // enclosing block when the pattern does not match. The Rust parser reads a
1290
+ // bare name after `let` as a binding, never a pattern; this grammar is more
1291
+ // lenient (a bare-name `variant_pattern` is admitted) because the compiler,
1292
+ // not the highlighter, reports `bynk.parse.let_else_on_binding`.
1293
+ let_else_stmt: ($) =>
1294
+ seq(
1295
+ "let",
1296
+ field("pattern", choice($._let_pattern, alias($._let_or_pattern, $.or_pattern))),
1297
+ field("bind", choice("=", "<-")),
1298
+ field("value", $._expression),
1299
+ optional(field("principal", $.call_site_actor)),
1300
+ "else",
1301
+ field("else", choice($.block, $.let_else_match)),
1302
+ ),
1303
+ // #2010: the patterns that may open a `let … else`, mirroring the Rust
1304
+ // parser's `let_pattern_ahead`: a literal, a parenthesised pattern, or a
1305
+ // variant with a payload or a qualifier. A bare name stays a binding (and
1306
+ // a bare `_` a discard), so `let x = …` is never ambiguous here.
1307
+ _let_pattern: ($) =>
1308
+ choice(
1309
+ $.literal_pattern,
1310
+ $.paren_pattern,
1311
+ alias($._let_variant_pattern, $.variant_pattern),
1312
+ ),
1313
+ // `let Ok(x) | Err(x) = …`: an or-chain whose first alternative opens a
1314
+ // pattern; the rest are any patterns.
1315
+ _let_or_pattern: ($) => prec.left(1, seq($._let_pattern, "|", $._pattern)),
1316
+ _let_variant_pattern: ($) => {
1317
+ const payload = seq("(", optional(sep1($._pattern_binding, ",")), optional(","), ")");
1318
+ return prec.right(
1319
+ choice(
1320
+ seq(
1321
+ field("type", $.identifier),
1322
+ ".",
1323
+ field("variant", $.identifier),
1324
+ optional(payload),
1325
+ ),
1326
+ seq(field("variant", $.identifier), payload),
1327
+ ),
1328
+ );
1329
+ },
1330
+ // #2010: the `else match { <arms> }` form, whose arms cover the values the
1331
+ // `let` pattern does not.
1332
+ let_else_match: ($) => seq("match", "{", repeat($.match_arm), "}"),
1244
1333
  // v0.182 (#664): `by <Actor>` (unit identity) or `by <Actor>(<identity>)`.
1245
1334
  // `prec.right` so an immediately-following `(` is taken as the identity
1246
1335
  // argument rather than starting a fresh token sequence.
@@ -1260,6 +1349,16 @@ module.exports = grammar({
1260
1349
  // v0.81 (storage track): `name := expr` — a `Cell` store write.
1261
1350
  assign_stmt: ($) =>
1262
1351
  seq(field("target", $.identifier), ":=", field("value", $._expression)),
1352
+ // #2137: `advance Clock by <Duration>` — move the test harness's clock. The
1353
+ // compiler admits it only in a `case` body and only on `Clock`; `advance`
1354
+ // is contextual.
1355
+ advance_stmt: ($) =>
1356
+ seq(
1357
+ "advance",
1358
+ field("capability", $.identifier),
1359
+ "by",
1360
+ field("amount", $._expression),
1361
+ ),
1263
1362
 
1264
1363
  // A let/effect-let may bind the discard name `_`.
1265
1364
  _binding_name: ($) => choice($.identifier, alias("_", $.wildcard)),
@@ -1295,7 +1394,14 @@ module.exports = grammar({
1295
1394
  // call throws. `faults` is contextual (an ordinary identifier elsewhere),
1296
1395
  // mirroring the compiler's trailing-word parse; an expression is never
1297
1396
  // followed by a bare identifier, so the word alone decides.
1298
- faults_expr: ($) => seq(field("call", $._expression), "faults"),
1397
+ // #1812: an optional call-site actor sits between the call and `faults`,
1398
+ // in the same position as on an effect-let (`by User("bob")`).
1399
+ faults_expr: ($) =>
1400
+ seq(
1401
+ field("call", $._expression),
1402
+ optional(field("principal", $.call_site_actor)),
1403
+ "faults",
1404
+ ),
1299
1405
 
1300
1406
  // v0.117: an observation — a `Cap.op` seam reference followed by one of the
1301
1407
  // sugar matchers. `called` / `never` / `once` / `times` / `with` / `before`
@@ -1341,12 +1447,17 @@ module.exports = grammar({
1341
1447
 
1342
1448
  // v0.146 (ADR 0170): `else` is optional. A missing `else` defaults to a
1343
1449
  // unit branch (legal only for a unit then-branch, enforced by the checker).
1450
+ // #2010: `prec.right` settles the dangling `else` in
1451
+ // `let P = if c { … } else …` the way the Rust parser does: the `if`
1452
+ // takes the `else`. (No other rule could follow an `if` with `else`.)
1344
1453
  if_expr: ($) =>
1345
- seq(
1346
- "if",
1347
- field("cond", $._expression),
1348
- field("then", $.block),
1349
- optional(seq("else", field("else", choice($.if_expr, $.block)))),
1454
+ prec.right(
1455
+ seq(
1456
+ "if",
1457
+ field("cond", $._expression),
1458
+ field("then", $.block),
1459
+ optional(seq("else", field("else", choice($.if_expr, $.block)))),
1460
+ ),
1350
1461
  ),
1351
1462
 
1352
1463
  match_expr: ($) =>
@@ -1686,6 +1797,13 @@ module.exports = grammar({
1686
1797
  // dash sequence that's already been gobbled by the external scanner).
1687
1798
  line_comment: () => token(seq("--", /[^\n]*/)),
1688
1799
 
1800
+ // #1888: a `--|` one-line doc. Both it and `line_comment` match a
1801
+ // `--|` line to its end, so the higher lexical precedence makes it a
1802
+ // doc. The compiler takes `--|` as a doc only when it is the first thing
1803
+ // on its line; an extras token cannot see that, so a `--|` after code on
1804
+ // the same line highlights as a doc here though it compiles as a comment.
1805
+ doc_line: () => token(prec(1, seq("--|", /[^\n]*/))),
1806
+
1689
1807
  // `doc_block` is provided by the external scanner — see src/scanner.c.
1690
1808
  // The grammar references it via the `externals` array above.
1691
1809
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-bynk",
3
- "version": "0.314.23",
3
+ "version": "0.371.3",
4
4
  "description": "Tree-sitter grammar for the Bynk language.",
5
5
  "main": "bindings/node",
6
6
  "types": "bindings/node",
@@ -13,12 +13,12 @@
13
13
  "license": "MIT OR Apache-2.0",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+https://github.com/accuser/bynk.git",
16
+ "url": "git+https://github.com/bynk-lang/bynk.git",
17
17
  "directory": "tree-sitter-bynk"
18
18
  },
19
- "homepage": "https://github.com/accuser/bynk/tree/main/tree-sitter-bynk",
19
+ "homepage": "https://github.com/bynk-lang/bynk/tree/main/tree-sitter-bynk",
20
20
  "bugs": {
21
- "url": "https://github.com/accuser/bynk/issues"
21
+ "url": "https://github.com/bynk-lang/bynk/issues"
22
22
  },
23
23
  "scripts": {
24
24
  "install": "node-gyp-build",
@@ -57,6 +57,7 @@
57
57
  "ensures"
58
58
  "messages"
59
59
  "event"
60
+ "asset"
60
61
  ] @keyword.declaration
61
62
 
62
63
  [
@@ -98,6 +99,9 @@
98
99
  "fails"
99
100
  ] @keyword.operator
100
101
 
102
+ ; #2134: the contextual `env` word heading a suite/case `env { … }` clause.
103
+ "env" @keyword
104
+
101
105
  ; #1706: the fault-claim word — contextual, like the observation words: the
102
106
  ; token exists only inside a `faults_expr`.
103
107
  "faults" @keyword.operator
@@ -145,6 +149,8 @@
145
149
  (call name: (identifier) @function)
146
150
  (method_call method: (identifier) @function.method)
147
151
  (capability_op name: (identifier) @function.method)
152
+ ; S4a (#1966): the base of a derived capability (`capability Sessions = Kv`).
153
+ (capability_decl base: (identifier) @type)
148
154
  (provider_op name: (identifier) @function.method)
149
155
  (call_handler method: (identifier) @function.method)
150
156
 
@@ -240,6 +246,7 @@
240
246
 
241
247
  (line_comment) @comment
242
248
  (doc_block) @comment.documentation
249
+ (doc_line) @comment.documentation
243
250
 
244
251
  ; -- Errors (tree-sitter recovery) --
245
252