tree-sitter-bynk 0.330.4 → 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
@@ -245,7 +245,14 @@ module.exports = grammar({
245
245
  ),
246
246
 
247
247
  _test_body_item: ($) =>
248
- 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
+ ),
249
256
 
250
257
  // -- Headers / clauses --
251
258
 
@@ -622,9 +629,16 @@ module.exports = grammar({
622
629
  seq(
623
630
  "capability",
624
631
  field("name", $.identifier),
625
- "{",
626
- repeat($.capability_op),
627
- "}",
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
+ ),
628
642
  ),
629
643
  capability_op: ($) =>
630
644
  seq(
@@ -1106,7 +1120,7 @@ module.exports = grammar({
1106
1120
  // The closed, compiler-known scheme set. `None`/`Internal` are zero-crypto;
1107
1121
  // `Bearer` (JWT/HS256), `Signature` (HMAC over the body), and `Oidc`
1108
1122
  // (JWKS/RS256+ES256) are compiler-generated verifiers.
1109
- scheme: () => choice("None", "Internal", "Bearer", "Signature", "Oidc"),
1123
+ scheme: () => choice("None", "Internal", "Bearer", "Signature", "Oidc", "Foreign"),
1110
1124
  // v0.51: the keyed-args scheme config — `(key = value, …)`. Values are
1111
1125
  // string or integer literals; the checker validates which keys each scheme
1112
1126
  // admits (Bearer: secret; Signature: secret/header/timestamp/tolerance).
@@ -1177,8 +1191,17 @@ module.exports = grammar({
1177
1191
  "fails",
1178
1192
  ),
1179
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
+
1180
1203
  // v0.118: an optional `as <tier>` classifier plus a body of leading
1181
- // `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
1182
1205
  // (`unit`/`integration`/`system`) are contextual, as on `suite_decl`.
1183
1206
  case: ($) =>
1184
1207
  seq(
@@ -1186,7 +1209,7 @@ module.exports = grammar({
1186
1209
  field("name", $.string_literal),
1187
1210
  optional(seq("as", field("tier", choice("unit", "integration", "system")))),
1188
1211
  "{",
1189
- repeat($.stub_clause),
1212
+ repeat(choice($.stub_clause, $.env_clause)),
1190
1213
  repeat($._statement),
1191
1214
  optional(field("tail", $._expression)),
1192
1215
  "}",
@@ -1232,9 +1255,11 @@ module.exports = grammar({
1232
1255
  choice(
1233
1256
  $.let_stmt,
1234
1257
  $.effect_let_stmt,
1258
+ $.let_else_stmt,
1235
1259
  $.effect_send_stmt,
1236
1260
  $.do_stmt,
1237
1261
  $.assign_stmt,
1262
+ $.advance_stmt,
1238
1263
  prec(1, $.expect_expr),
1239
1264
  ),
1240
1265
 
@@ -1259,6 +1284,52 @@ module.exports = grammar({
1259
1284
  // binder, and there is no actor sum.
1260
1285
  optional(field("principal", $.call_site_actor)),
1261
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), "}"),
1262
1333
  // v0.182 (#664): `by <Actor>` (unit identity) or `by <Actor>(<identity>)`.
1263
1334
  // `prec.right` so an immediately-following `(` is taken as the identity
1264
1335
  // argument rather than starting a fresh token sequence.
@@ -1278,6 +1349,16 @@ module.exports = grammar({
1278
1349
  // v0.81 (storage track): `name := expr` — a `Cell` store write.
1279
1350
  assign_stmt: ($) =>
1280
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
+ ),
1281
1362
 
1282
1363
  // A let/effect-let may bind the discard name `_`.
1283
1364
  _binding_name: ($) => choice($.identifier, alias("_", $.wildcard)),
@@ -1366,12 +1447,17 @@ module.exports = grammar({
1366
1447
 
1367
1448
  // v0.146 (ADR 0170): `else` is optional. A missing `else` defaults to a
1368
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`.)
1369
1453
  if_expr: ($) =>
1370
- seq(
1371
- "if",
1372
- field("cond", $._expression),
1373
- field("then", $.block),
1374
- 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
+ ),
1375
1461
  ),
1376
1462
 
1377
1463
  match_expr: ($) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-bynk",
3
- "version": "0.330.4",
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",
@@ -99,6 +99,9 @@
99
99
  "fails"
100
100
  ] @keyword.operator
101
101
 
102
+ ; #2134: the contextual `env` word heading a suite/case `env { … }` clause.
103
+ "env" @keyword
104
+
102
105
  ; #1706: the fault-claim word — contextual, like the observation words: the
103
106
  ; token exists only inside a `faults_expr`.
104
107
  "faults" @keyword.operator
@@ -146,6 +149,8 @@
146
149
  (call name: (identifier) @function)
147
150
  (method_call method: (identifier) @function.method)
148
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)
149
154
  (provider_op name: (identifier) @function.method)
150
155
  (call_handler method: (identifier) @function.method)
151
156