tree-sitter-bynk 0.508.4 → 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 +51 -16
- package/package.json +1 -1
- package/queries/highlights.scm +2 -0
- package/queries/injections.scm +13 -1
- package/src/grammar.json +140 -42
- package/src/node-types.json +66 -2
- package/src/parser.c +101812 -103746
- package/src/scanner.c +52 -27
package/grammar.js
CHANGED
|
@@ -39,7 +39,15 @@ const PREC = {
|
|
|
39
39
|
module.exports = grammar({
|
|
40
40
|
name: "bynk",
|
|
41
41
|
|
|
42
|
-
externals: ($) => [
|
|
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
|
|
|
@@ -2226,24 +2234,51 @@ module.exports = grammar({
|
|
|
2226
2234
|
'"',
|
|
2227
2235
|
),
|
|
2228
2236
|
// #2619: a multi-line string. The opening `"""` is followed by a
|
|
2229
|
-
// newline
|
|
2230
|
-
//
|
|
2231
|
-
// is a value rule, not a
|
|
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,
|
|
2232
2276
|
seq(
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
token.immediate(prec(1, /[^"\\]+/)),
|
|
2237
|
-
token.immediate(prec(1, /"{1,2}[^"\\]/)),
|
|
2238
|
-
$.escape_sequence,
|
|
2239
|
-
$.string_interpolation,
|
|
2240
|
-
),
|
|
2241
|
-
),
|
|
2277
|
+
$._raw_triple_open,
|
|
2278
|
+
$._multiline_opener_rest,
|
|
2279
|
+
optional($.raw_string_body),
|
|
2242
2280
|
'"""',
|
|
2243
2281
|
),
|
|
2244
|
-
// #2619: a raw string (`r"…"`, `r#"…"#`, `r"""…"""`): no escapes, no
|
|
2245
|
-
// interpolation. An external token — the `#` count is not regular.
|
|
2246
|
-
$.raw_string,
|
|
2247
2282
|
),
|
|
2248
2283
|
// `\n \t \r \0 \" \\` and `\u{1–6 hex digits}` (#2619). Whether a `\u{…}`
|
|
2249
2284
|
// names a scalar value (not a surrogate, at most 10FFFF) is the compiler's
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
|
@@ -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
|
package/queries/injections.scm
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
;
|
|
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
|
@@ -10614,49 +10614,24 @@
|
|
|
10614
10614
|
"type": "SEQ",
|
|
10615
10615
|
"members": [
|
|
10616
10616
|
{
|
|
10617
|
-
"type": "
|
|
10618
|
-
"
|
|
10619
|
-
"type": "PATTERN",
|
|
10620
|
-
"value": "\"\"\"\\r?\\n"
|
|
10621
|
-
}
|
|
10617
|
+
"type": "STRING",
|
|
10618
|
+
"value": "\"\"\""
|
|
10622
10619
|
},
|
|
10623
10620
|
{
|
|
10624
|
-
"type": "
|
|
10625
|
-
"
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
},
|
|
10639
|
-
{
|
|
10640
|
-
"type": "IMMEDIATE_TOKEN",
|
|
10641
|
-
"content": {
|
|
10642
|
-
"type": "PREC",
|
|
10643
|
-
"value": 1,
|
|
10644
|
-
"content": {
|
|
10645
|
-
"type": "PATTERN",
|
|
10646
|
-
"value": "\"{1,2}[^\"\\\\]"
|
|
10647
|
-
}
|
|
10648
|
-
}
|
|
10649
|
-
},
|
|
10650
|
-
{
|
|
10651
|
-
"type": "SYMBOL",
|
|
10652
|
-
"name": "escape_sequence"
|
|
10653
|
-
},
|
|
10654
|
-
{
|
|
10655
|
-
"type": "SYMBOL",
|
|
10656
|
-
"name": "string_interpolation"
|
|
10657
|
-
}
|
|
10658
|
-
]
|
|
10659
|
-
}
|
|
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
|
+
]
|
|
10660
10635
|
},
|
|
10661
10636
|
{
|
|
10662
10637
|
"type": "STRING",
|
|
@@ -10670,6 +10645,121 @@
|
|
|
10670
10645
|
}
|
|
10671
10646
|
]
|
|
10672
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
|
+
},
|
|
10673
10763
|
"escape_sequence": {
|
|
10674
10764
|
"type": "IMMEDIATE_TOKEN",
|
|
10675
10765
|
"content": {
|
|
@@ -10821,7 +10911,15 @@
|
|
|
10821
10911
|
},
|
|
10822
10912
|
{
|
|
10823
10913
|
"type": "SYMBOL",
|
|
10824
|
-
"name": "
|
|
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"
|
|
10825
10923
|
},
|
|
10826
10924
|
{
|
|
10827
10925
|
"type": "SYMBOL",
|
package/src/node-types.json
CHANGED
|
@@ -9392,6 +9392,32 @@
|
|
|
9392
9392
|
]
|
|
9393
9393
|
}
|
|
9394
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
|
+
},
|
|
9395
9421
|
{
|
|
9396
9422
|
"type": "record_construction",
|
|
9397
9423
|
"named": true,
|
|
@@ -11495,6 +11521,25 @@
|
|
|
11495
11521
|
]
|
|
11496
11522
|
}
|
|
11497
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
|
+
},
|
|
11498
11543
|
{
|
|
11499
11544
|
"type": "string_interpolation",
|
|
11500
11545
|
"named": true,
|
|
@@ -11637,7 +11682,18 @@
|
|
|
11637
11682
|
{
|
|
11638
11683
|
"type": "string_literal",
|
|
11639
11684
|
"named": true,
|
|
11640
|
-
"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
|
+
},
|
|
11641
11697
|
"children": {
|
|
11642
11698
|
"multiple": true,
|
|
11643
11699
|
"required": false,
|
|
@@ -11650,6 +11706,10 @@
|
|
|
11650
11706
|
"type": "raw_string",
|
|
11651
11707
|
"named": true
|
|
11652
11708
|
},
|
|
11709
|
+
{
|
|
11710
|
+
"type": "string_body",
|
|
11711
|
+
"named": true
|
|
11712
|
+
},
|
|
11653
11713
|
{
|
|
11654
11714
|
"type": "string_interpolation",
|
|
11655
11715
|
"named": true
|
|
@@ -14096,7 +14156,7 @@
|
|
|
14096
14156
|
"named": false
|
|
14097
14157
|
},
|
|
14098
14158
|
{
|
|
14099
|
-
"type": "
|
|
14159
|
+
"type": "raw_string_body",
|
|
14100
14160
|
"named": true
|
|
14101
14161
|
},
|
|
14102
14162
|
{
|
|
@@ -14147,6 +14207,10 @@
|
|
|
14147
14207
|
"type": "store",
|
|
14148
14208
|
"named": false
|
|
14149
14209
|
},
|
|
14210
|
+
{
|
|
14211
|
+
"type": "string_tag",
|
|
14212
|
+
"named": true
|
|
14213
|
+
},
|
|
14150
14214
|
{
|
|
14151
14215
|
"type": "stub",
|
|
14152
14216
|
"named": false
|