tree-sitter-bynk 0.504.3 → 0.510.2

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
@@ -39,7 +39,15 @@ const PREC = {
39
39
  module.exports = grammar({
40
40
  name: "bynk",
41
41
 
42
- externals: ($) => [$.doc_block, $.doc_line, $.raw_string, $._type_app_open, $._error_sentinel],
42
+ externals: ($) => [
43
+ $.doc_block,
44
+ $.doc_line,
45
+ $._raw_string_line,
46
+ $._raw_triple_open,
47
+ $.raw_string_body,
48
+ $._type_app_open,
49
+ $._error_sentinel,
50
+ ],
43
51
 
44
52
  extras: ($) => [/\s+/, $.doc_line, $.line_comment, $.doc_block],
45
53
 
@@ -288,9 +296,12 @@ module.exports = grammar({
288
296
  // v0.6: `consumes a.b as Alias`.
289
297
  seq("as", field("alias", $.identifier)),
290
298
  // v0.17: `consumes a.b { Cap, … }` — selected capabilities.
299
+ // #2887: an exported type may be renamed, `T as Alias`.
291
300
  seq(
292
301
  "{",
293
- optional(sep1(field("capability", $.identifier), ",")),
302
+ optional(
303
+ sep1($.consumes_item, ","),
304
+ ),
294
305
  optional(","),
295
306
  "}",
296
307
  ),
@@ -298,6 +309,14 @@ module.exports = grammar({
298
309
  ),
299
310
  ),
300
311
 
312
+ // #2890: one braced item of a selective `consumes`: a name, optionally
313
+ // renamed with `as`.
314
+ consumes_item: ($) =>
315
+ seq(
316
+ field("name", $.identifier),
317
+ optional(seq("as", field("alias", $.identifier))),
318
+ ),
319
+
301
320
  // v0.17: an adapter's binding module + optional npm dependency map.
302
321
  binding_decl: ($) =>
303
322
  seq(
@@ -2004,7 +2023,10 @@ module.exports = grammar({
2004
2023
  lambda_param: ($) =>
2005
2024
  choice(
2006
2025
  seq(
2007
- field("name", choice($.identifier, $._contextual_identifier)),
2026
+ field(
2027
+ "name",
2028
+ choice($.identifier, $._contextual_identifier, alias("_", $.wildcard)),
2029
+ ),
2008
2030
  optional(seq(":", field("type", $._type_ref))),
2009
2031
  ),
2010
2032
  field("pattern", alias($._lambda_record_pattern, $.record_pattern)),
@@ -2212,24 +2234,51 @@ module.exports = grammar({
2212
2234
  '"',
2213
2235
  ),
2214
2236
  // #2619: a multi-line string. The opening `"""` is followed by a
2215
- // newline; the body may hold lone or doubled quotes; escapes and
2216
- // interpolation are those of an ordinary string. (Indentation stripping
2217
- // is a value rule, not a shape: the compiler checks it.)
2237
+ // newline, or (#2958) by a language tag and a newline; the body may
2238
+ // hold lone or doubled quotes; escapes and interpolation are those of
2239
+ // an ordinary string. (Indentation stripping is a value rule, not a
2240
+ // shape: the compiler checks it.)
2241
+ seq('"""', $._multiline_opener_rest, optional($.string_body), '"""'),
2242
+ // #2619: a raw string (`r"…"`, `r#"…"#`, `r"""…"""`): no escapes, no
2243
+ // interpolation.
2244
+ $.raw_string,
2245
+ ),
2246
+ // #2958: the rest of a multi-line string's opening line: a newline, or a
2247
+ // language tag, optional spaces or tabs, and a newline. No space may come
2248
+ // between the `"""` and the tag.
2249
+ _multiline_opener_rest: ($) =>
2250
+ choice(
2251
+ token.immediate(/\r?\n/),
2252
+ seq(field("tag", $.string_tag), token.immediate(/[ \t]*\r?\n/)),
2253
+ ),
2254
+ // #2958: a multi-line string's language tag (`sql` in `"""sql`): editor
2255
+ // metadata naming the language of the body, for `injections.scm`. It is
2256
+ // not part of the value.
2257
+ string_tag: () => token.immediate(/[a-z][a-z0-9_-]*/),
2258
+ // #2958: a multi-line string's body, a node of its own so an injection
2259
+ // can name it. Interpolation holes and escapes are its children.
2260
+ string_body: ($) =>
2261
+ repeat1(
2262
+ choice(
2263
+ token.immediate(prec(1, /[^"\\]+/)),
2264
+ token.immediate(prec(1, /"{1,2}[^"\\]/)),
2265
+ $.escape_sequence,
2266
+ $.string_interpolation,
2267
+ ),
2268
+ ),
2269
+ // #2619: a raw string. Single-line forms are one external token (the `#`
2270
+ // count is not regular); the multi-line form (#2958) is an external
2271
+ // opener `r"""`, the opening line's rest, an external opaque body, and
2272
+ // the closing `"""`, so the tag and body are nodes of their own.
2273
+ raw_string: ($) =>
2274
+ choice(
2275
+ $._raw_string_line,
2218
2276
  seq(
2219
- token(/"""\r?\n/),
2220
- repeat(
2221
- choice(
2222
- token.immediate(prec(1, /[^"\\]+/)),
2223
- token.immediate(prec(1, /"{1,2}[^"\\]/)),
2224
- $.escape_sequence,
2225
- $.string_interpolation,
2226
- ),
2227
- ),
2277
+ $._raw_triple_open,
2278
+ $._multiline_opener_rest,
2279
+ optional($.raw_string_body),
2228
2280
  '"""',
2229
2281
  ),
2230
- // #2619: a raw string (`r"…"`, `r#"…"#`, `r"""…"""`): no escapes, no
2231
- // interpolation. An external token — the `#` count is not regular.
2232
- $.raw_string,
2233
2282
  ),
2234
2283
  // `\n \t \r \0 \" \\` and `\u{1–6 hex digits}` (#2619). Whether a `\u{…}`
2235
2284
  // names a scalar value (not a surrogate, at most 10FFFF) is the compiler's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-bynk",
3
- "version": "0.504.3",
3
+ "version": "0.510.2",
4
4
  "description": "Tree-sitter grammar for the Bynk language.",
5
5
  "main": "bindings/node",
6
6
  "types": "bindings/node",
@@ -237,6 +237,8 @@
237
237
  (string_literal) @string
238
238
  ; #2619: an escape inside a string; a raw string has none.
239
239
  (escape_sequence) @string.escape
240
+ ; #2958: a multi-line string's language tag is metadata, not string text.
241
+ (string_tag) @attribute
240
242
  (number_literal) @number
241
243
  (float_literal) @number
242
244
  (decimal_literal) @number
@@ -251,6 +253,8 @@
251
253
  (qualified_name (identifier) @module)
252
254
  (uses_decl target: (qualified_name) @module)
253
255
  (consumes_decl target: (qualified_name) @module)
256
+ ; #2890: the name a `consumes U { T as Alias }` item introduces is a type.
257
+ (consumes_item alias: (identifier) @type)
254
258
  (suite_decl target: (qualified_name) @module)
255
259
 
256
260
  ; -- Operators & punctuation --
@@ -1 +1,13 @@
1
- ; No language injections currently; doc-block contents are plain text.
1
+ ; #2958: a multi-line string's language tag (`"""sql`, `r"""regex`) names the
2
+ ; language of its body. The body is injected as that language; interpolation
3
+ ; holes and escapes are children of the body, so they are left out of the
4
+ ; injected text. A tag no editor knows is a plain string.
5
+ ; Doc-block contents are plain text.
6
+
7
+ ((string_literal
8
+ (string_tag) @injection.language
9
+ (string_body) @injection.content))
10
+
11
+ ((raw_string
12
+ (string_tag) @injection.language
13
+ (raw_string_body) @injection.content))
package/src/grammar.json CHANGED
@@ -669,12 +669,8 @@
669
669
  "type": "SEQ",
670
670
  "members": [
671
671
  {
672
- "type": "FIELD",
673
- "name": "capability",
674
- "content": {
675
- "type": "SYMBOL",
676
- "name": "identifier"
677
- }
672
+ "type": "SYMBOL",
673
+ "name": "consumes_item"
678
674
  },
679
675
  {
680
676
  "type": "REPEAT",
@@ -686,12 +682,8 @@
686
682
  "value": ","
687
683
  },
688
684
  {
689
- "type": "FIELD",
690
- "name": "capability",
691
- "content": {
692
- "type": "SYMBOL",
693
- "name": "identifier"
694
- }
685
+ "type": "SYMBOL",
686
+ "name": "consumes_item"
695
687
  }
696
688
  ]
697
689
  }
@@ -730,6 +722,44 @@
730
722
  }
731
723
  ]
732
724
  },
725
+ "consumes_item": {
726
+ "type": "SEQ",
727
+ "members": [
728
+ {
729
+ "type": "FIELD",
730
+ "name": "name",
731
+ "content": {
732
+ "type": "SYMBOL",
733
+ "name": "identifier"
734
+ }
735
+ },
736
+ {
737
+ "type": "CHOICE",
738
+ "members": [
739
+ {
740
+ "type": "SEQ",
741
+ "members": [
742
+ {
743
+ "type": "STRING",
744
+ "value": "as"
745
+ },
746
+ {
747
+ "type": "FIELD",
748
+ "name": "alias",
749
+ "content": {
750
+ "type": "SYMBOL",
751
+ "name": "identifier"
752
+ }
753
+ }
754
+ ]
755
+ },
756
+ {
757
+ "type": "BLANK"
758
+ }
759
+ ]
760
+ }
761
+ ]
762
+ },
733
763
  "binding_decl": {
734
764
  "type": "SEQ",
735
765
  "members": [
@@ -9334,6 +9364,15 @@
9334
9364
  {
9335
9365
  "type": "SYMBOL",
9336
9366
  "name": "_contextual_identifier"
9367
+ },
9368
+ {
9369
+ "type": "ALIAS",
9370
+ "content": {
9371
+ "type": "STRING",
9372
+ "value": "_"
9373
+ },
9374
+ "named": true,
9375
+ "value": "wildcard"
9337
9376
  }
9338
9377
  ]
9339
9378
  }
@@ -10575,49 +10614,24 @@
10575
10614
  "type": "SEQ",
10576
10615
  "members": [
10577
10616
  {
10578
- "type": "TOKEN",
10579
- "content": {
10580
- "type": "PATTERN",
10581
- "value": "\"\"\"\\r?\\n"
10582
- }
10617
+ "type": "STRING",
10618
+ "value": "\"\"\""
10583
10619
  },
10584
10620
  {
10585
- "type": "REPEAT",
10586
- "content": {
10587
- "type": "CHOICE",
10588
- "members": [
10589
- {
10590
- "type": "IMMEDIATE_TOKEN",
10591
- "content": {
10592
- "type": "PREC",
10593
- "value": 1,
10594
- "content": {
10595
- "type": "PATTERN",
10596
- "value": "[^\"\\\\]+"
10597
- }
10598
- }
10599
- },
10600
- {
10601
- "type": "IMMEDIATE_TOKEN",
10602
- "content": {
10603
- "type": "PREC",
10604
- "value": 1,
10605
- "content": {
10606
- "type": "PATTERN",
10607
- "value": "\"{1,2}[^\"\\\\]"
10608
- }
10609
- }
10610
- },
10611
- {
10612
- "type": "SYMBOL",
10613
- "name": "escape_sequence"
10614
- },
10615
- {
10616
- "type": "SYMBOL",
10617
- "name": "string_interpolation"
10618
- }
10619
- ]
10620
- }
10621
+ "type": "SYMBOL",
10622
+ "name": "_multiline_opener_rest"
10623
+ },
10624
+ {
10625
+ "type": "CHOICE",
10626
+ "members": [
10627
+ {
10628
+ "type": "SYMBOL",
10629
+ "name": "string_body"
10630
+ },
10631
+ {
10632
+ "type": "BLANK"
10633
+ }
10634
+ ]
10621
10635
  },
10622
10636
  {
10623
10637
  "type": "STRING",
@@ -10631,6 +10645,121 @@
10631
10645
  }
10632
10646
  ]
10633
10647
  },
10648
+ "_multiline_opener_rest": {
10649
+ "type": "CHOICE",
10650
+ "members": [
10651
+ {
10652
+ "type": "IMMEDIATE_TOKEN",
10653
+ "content": {
10654
+ "type": "PATTERN",
10655
+ "value": "\\r?\\n"
10656
+ }
10657
+ },
10658
+ {
10659
+ "type": "SEQ",
10660
+ "members": [
10661
+ {
10662
+ "type": "FIELD",
10663
+ "name": "tag",
10664
+ "content": {
10665
+ "type": "SYMBOL",
10666
+ "name": "string_tag"
10667
+ }
10668
+ },
10669
+ {
10670
+ "type": "IMMEDIATE_TOKEN",
10671
+ "content": {
10672
+ "type": "PATTERN",
10673
+ "value": "[ \\t]*\\r?\\n"
10674
+ }
10675
+ }
10676
+ ]
10677
+ }
10678
+ ]
10679
+ },
10680
+ "string_tag": {
10681
+ "type": "IMMEDIATE_TOKEN",
10682
+ "content": {
10683
+ "type": "PATTERN",
10684
+ "value": "[a-z][a-z0-9_-]*"
10685
+ }
10686
+ },
10687
+ "string_body": {
10688
+ "type": "REPEAT1",
10689
+ "content": {
10690
+ "type": "CHOICE",
10691
+ "members": [
10692
+ {
10693
+ "type": "IMMEDIATE_TOKEN",
10694
+ "content": {
10695
+ "type": "PREC",
10696
+ "value": 1,
10697
+ "content": {
10698
+ "type": "PATTERN",
10699
+ "value": "[^\"\\\\]+"
10700
+ }
10701
+ }
10702
+ },
10703
+ {
10704
+ "type": "IMMEDIATE_TOKEN",
10705
+ "content": {
10706
+ "type": "PREC",
10707
+ "value": 1,
10708
+ "content": {
10709
+ "type": "PATTERN",
10710
+ "value": "\"{1,2}[^\"\\\\]"
10711
+ }
10712
+ }
10713
+ },
10714
+ {
10715
+ "type": "SYMBOL",
10716
+ "name": "escape_sequence"
10717
+ },
10718
+ {
10719
+ "type": "SYMBOL",
10720
+ "name": "string_interpolation"
10721
+ }
10722
+ ]
10723
+ }
10724
+ },
10725
+ "raw_string": {
10726
+ "type": "CHOICE",
10727
+ "members": [
10728
+ {
10729
+ "type": "SYMBOL",
10730
+ "name": "_raw_string_line"
10731
+ },
10732
+ {
10733
+ "type": "SEQ",
10734
+ "members": [
10735
+ {
10736
+ "type": "SYMBOL",
10737
+ "name": "_raw_triple_open"
10738
+ },
10739
+ {
10740
+ "type": "SYMBOL",
10741
+ "name": "_multiline_opener_rest"
10742
+ },
10743
+ {
10744
+ "type": "CHOICE",
10745
+ "members": [
10746
+ {
10747
+ "type": "SYMBOL",
10748
+ "name": "raw_string_body"
10749
+ },
10750
+ {
10751
+ "type": "BLANK"
10752
+ }
10753
+ ]
10754
+ },
10755
+ {
10756
+ "type": "STRING",
10757
+ "value": "\"\"\""
10758
+ }
10759
+ ]
10760
+ }
10761
+ ]
10762
+ },
10634
10763
  "escape_sequence": {
10635
10764
  "type": "IMMEDIATE_TOKEN",
10636
10765
  "content": {
@@ -10782,7 +10911,15 @@
10782
10911
  },
10783
10912
  {
10784
10913
  "type": "SYMBOL",
10785
- "name": "raw_string"
10914
+ "name": "_raw_string_line"
10915
+ },
10916
+ {
10917
+ "type": "SYMBOL",
10918
+ "name": "_raw_triple_open"
10919
+ },
10920
+ {
10921
+ "type": "SYMBOL",
10922
+ "name": "raw_string_body"
10786
10923
  },
10787
10924
  {
10788
10925
  "type": "SYMBOL",
@@ -2529,8 +2529,34 @@
2529
2529
  }
2530
2530
  ]
2531
2531
  },
2532
- "capability": {
2533
- "multiple": true,
2532
+ "target": {
2533
+ "multiple": false,
2534
+ "required": true,
2535
+ "types": [
2536
+ {
2537
+ "type": "qualified_name",
2538
+ "named": true
2539
+ }
2540
+ ]
2541
+ }
2542
+ },
2543
+ "children": {
2544
+ "multiple": true,
2545
+ "required": false,
2546
+ "types": [
2547
+ {
2548
+ "type": "consumes_item",
2549
+ "named": true
2550
+ }
2551
+ ]
2552
+ }
2553
+ },
2554
+ {
2555
+ "type": "consumes_item",
2556
+ "named": true,
2557
+ "fields": {
2558
+ "alias": {
2559
+ "multiple": false,
2534
2560
  "required": false,
2535
2561
  "types": [
2536
2562
  {
@@ -2539,12 +2565,12 @@
2539
2565
  }
2540
2566
  ]
2541
2567
  },
2542
- "target": {
2568
+ "name": {
2543
2569
  "multiple": false,
2544
2570
  "required": true,
2545
2571
  "types": [
2546
2572
  {
2547
- "type": "qualified_name",
2573
+ "type": "identifier",
2548
2574
  "named": true
2549
2575
  }
2550
2576
  ]
@@ -6389,6 +6415,10 @@
6389
6415
  {
6390
6416
  "type": "identifier",
6391
6417
  "named": true
6418
+ },
6419
+ {
6420
+ "type": "wildcard",
6421
+ "named": true
6392
6422
  }
6393
6423
  ]
6394
6424
  },
@@ -9362,6 +9392,32 @@
9362
9392
  ]
9363
9393
  }
9364
9394
  },
9395
+ {
9396
+ "type": "raw_string",
9397
+ "named": true,
9398
+ "fields": {
9399
+ "tag": {
9400
+ "multiple": false,
9401
+ "required": false,
9402
+ "types": [
9403
+ {
9404
+ "type": "string_tag",
9405
+ "named": true
9406
+ }
9407
+ ]
9408
+ }
9409
+ },
9410
+ "children": {
9411
+ "multiple": false,
9412
+ "required": false,
9413
+ "types": [
9414
+ {
9415
+ "type": "raw_string_body",
9416
+ "named": true
9417
+ }
9418
+ ]
9419
+ }
9420
+ },
9365
9421
  {
9366
9422
  "type": "record_construction",
9367
9423
  "named": true,
@@ -11465,6 +11521,25 @@
11465
11521
  ]
11466
11522
  }
11467
11523
  },
11524
+ {
11525
+ "type": "string_body",
11526
+ "named": true,
11527
+ "fields": {},
11528
+ "children": {
11529
+ "multiple": true,
11530
+ "required": false,
11531
+ "types": [
11532
+ {
11533
+ "type": "escape_sequence",
11534
+ "named": true
11535
+ },
11536
+ {
11537
+ "type": "string_interpolation",
11538
+ "named": true
11539
+ }
11540
+ ]
11541
+ }
11542
+ },
11468
11543
  {
11469
11544
  "type": "string_interpolation",
11470
11545
  "named": true,
@@ -11607,7 +11682,18 @@
11607
11682
  {
11608
11683
  "type": "string_literal",
11609
11684
  "named": true,
11610
- "fields": {},
11685
+ "fields": {
11686
+ "tag": {
11687
+ "multiple": false,
11688
+ "required": false,
11689
+ "types": [
11690
+ {
11691
+ "type": "string_tag",
11692
+ "named": true
11693
+ }
11694
+ ]
11695
+ }
11696
+ },
11611
11697
  "children": {
11612
11698
  "multiple": true,
11613
11699
  "required": false,
@@ -11620,6 +11706,10 @@
11620
11706
  "type": "raw_string",
11621
11707
  "named": true
11622
11708
  },
11709
+ {
11710
+ "type": "string_body",
11711
+ "named": true
11712
+ },
11623
11713
  {
11624
11714
  "type": "string_interpolation",
11625
11715
  "named": true
@@ -14066,7 +14156,7 @@
14066
14156
  "named": false
14067
14157
  },
14068
14158
  {
14069
- "type": "raw_string",
14159
+ "type": "raw_string_body",
14070
14160
  "named": true
14071
14161
  },
14072
14162
  {
@@ -14117,6 +14207,10 @@
14117
14207
  "type": "store",
14118
14208
  "named": false
14119
14209
  },
14210
+ {
14211
+ "type": "string_tag",
14212
+ "named": true
14213
+ },
14120
14214
  {
14121
14215
  "type": "stub",
14122
14216
  "named": false