@willbooster/tree-sitter-kotlin 1.3.1 → 1.3.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 +13 -7
- package/package.json +1 -1
- package/src/node-types.json +75 -3
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -45,6 +45,7 @@ module.exports = grammar({
|
|
|
45
45
|
[$._loop_prefix, $.annotated_expression],
|
|
46
46
|
[$._loop_prefix, $.modifiers, $.type_modifiers, $.annotated_expression],
|
|
47
47
|
[$._loop_prefix, $.labeled_expression],
|
|
48
|
+
[$._loop_prefix, $.type_modifiers, $.annotated_expression],
|
|
48
49
|
[$.parameter_modifiers, $.type_modifiers],
|
|
49
50
|
[$.function_modifier, $.type_modifiers],
|
|
50
51
|
[$.function_modifier, $._reserved_identifier],
|
|
@@ -88,7 +89,7 @@ module.exports = grammar({
|
|
|
88
89
|
'$',
|
|
89
90
|
],
|
|
90
91
|
|
|
91
|
-
inline: ($) => [$._statements, $._identifier],
|
|
92
|
+
inline: ($) => [$._statements, $._identifier, $._control_structure_body],
|
|
92
93
|
|
|
93
94
|
precedences: ($) => [
|
|
94
95
|
[$.block, $.lambda_literal],
|
|
@@ -298,7 +299,7 @@ module.exports = grammar({
|
|
|
298
299
|
'in',
|
|
299
300
|
$.expression,
|
|
300
301
|
')',
|
|
301
|
-
optional(field('body',
|
|
302
|
+
optional(field('body', $._control_structure_body))
|
|
302
303
|
)
|
|
303
304
|
),
|
|
304
305
|
|
|
@@ -310,7 +311,7 @@ module.exports = grammar({
|
|
|
310
311
|
'(',
|
|
311
312
|
field('condition', $.expression),
|
|
312
313
|
')',
|
|
313
|
-
optional(choice(field('body',
|
|
314
|
+
optional(choice(field('body', $._control_structure_body), ';'))
|
|
314
315
|
)
|
|
315
316
|
),
|
|
316
317
|
|
|
@@ -319,7 +320,7 @@ module.exports = grammar({
|
|
|
319
320
|
seq(
|
|
320
321
|
optional($._loop_prefix),
|
|
321
322
|
'do',
|
|
322
|
-
optional(choice(field('body',
|
|
323
|
+
optional(choice(field('body', $._control_structure_body), ';')),
|
|
323
324
|
'while',
|
|
324
325
|
'(',
|
|
325
326
|
field('condition', $.expression),
|
|
@@ -598,18 +599,23 @@ module.exports = grammar({
|
|
|
598
599
|
field('condition', $.expression),
|
|
599
600
|
')',
|
|
600
601
|
choice(
|
|
601
|
-
field('consequence',
|
|
602
|
+
field('consequence', $._control_structure_body),
|
|
602
603
|
';',
|
|
603
604
|
seq(
|
|
604
|
-
optional(field('consequence',
|
|
605
|
+
optional(field('consequence', $._control_structure_body)),
|
|
605
606
|
optional(';'),
|
|
606
607
|
'else',
|
|
607
|
-
choice(field('alternative',
|
|
608
|
+
choice(field('alternative', $._control_structure_body), ';')
|
|
608
609
|
)
|
|
609
610
|
)
|
|
610
611
|
)
|
|
611
612
|
),
|
|
612
613
|
|
|
614
|
+
// Unlike Kotlin's grammar, this excludes declarations, which the compiler rejects here anyway: allowing them
|
|
615
|
+
// lets declarations nest in every expression context and exceeds tree-sitter's limit of 65535 parse states.
|
|
616
|
+
_control_structure_body: ($) =>
|
|
617
|
+
choice($.block, $.expression, $.assignment, $.for_statement, $.while_statement, $.do_while_statement),
|
|
618
|
+
|
|
613
619
|
parenthesized_expression: ($) => seq('(', $.expression, ')'),
|
|
614
620
|
|
|
615
621
|
collection_literal: ($) => seq('[', commaSep1($.expression), optional(','), ']'),
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -936,12 +936,28 @@
|
|
|
936
936
|
"multiple": false,
|
|
937
937
|
"required": false,
|
|
938
938
|
"types": [
|
|
939
|
+
{
|
|
940
|
+
"type": "assignment",
|
|
941
|
+
"named": true
|
|
942
|
+
},
|
|
939
943
|
{
|
|
940
944
|
"type": "block",
|
|
941
945
|
"named": true
|
|
942
946
|
},
|
|
943
947
|
{
|
|
944
|
-
"type": "
|
|
948
|
+
"type": "do_while_statement",
|
|
949
|
+
"named": true
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
"type": "expression",
|
|
953
|
+
"named": true
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
"type": "for_statement",
|
|
957
|
+
"named": true
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
"type": "while_statement",
|
|
945
961
|
"named": true
|
|
946
962
|
}
|
|
947
963
|
]
|
|
@@ -1079,12 +1095,28 @@
|
|
|
1079
1095
|
"multiple": false,
|
|
1080
1096
|
"required": false,
|
|
1081
1097
|
"types": [
|
|
1098
|
+
{
|
|
1099
|
+
"type": "assignment",
|
|
1100
|
+
"named": true
|
|
1101
|
+
},
|
|
1082
1102
|
{
|
|
1083
1103
|
"type": "block",
|
|
1084
1104
|
"named": true
|
|
1085
1105
|
},
|
|
1086
1106
|
{
|
|
1087
|
-
"type": "
|
|
1107
|
+
"type": "do_while_statement",
|
|
1108
|
+
"named": true
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
"type": "expression",
|
|
1112
|
+
"named": true
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
"type": "for_statement",
|
|
1116
|
+
"named": true
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
"type": "while_statement",
|
|
1088
1120
|
"named": true
|
|
1089
1121
|
}
|
|
1090
1122
|
]
|
|
@@ -1295,9 +1327,21 @@
|
|
|
1295
1327
|
"type": "block",
|
|
1296
1328
|
"named": true
|
|
1297
1329
|
},
|
|
1330
|
+
{
|
|
1331
|
+
"type": "do_while_statement",
|
|
1332
|
+
"named": true
|
|
1333
|
+
},
|
|
1298
1334
|
{
|
|
1299
1335
|
"type": "expression",
|
|
1300
1336
|
"named": true
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
"type": "for_statement",
|
|
1340
|
+
"named": true
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
"type": "while_statement",
|
|
1344
|
+
"named": true
|
|
1301
1345
|
}
|
|
1302
1346
|
]
|
|
1303
1347
|
},
|
|
@@ -1323,9 +1367,21 @@
|
|
|
1323
1367
|
"type": "block",
|
|
1324
1368
|
"named": true
|
|
1325
1369
|
},
|
|
1370
|
+
{
|
|
1371
|
+
"type": "do_while_statement",
|
|
1372
|
+
"named": true
|
|
1373
|
+
},
|
|
1326
1374
|
{
|
|
1327
1375
|
"type": "expression",
|
|
1328
1376
|
"named": true
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
"type": "for_statement",
|
|
1380
|
+
"named": true
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
"type": "while_statement",
|
|
1384
|
+
"named": true
|
|
1329
1385
|
}
|
|
1330
1386
|
]
|
|
1331
1387
|
}
|
|
@@ -2605,12 +2661,28 @@
|
|
|
2605
2661
|
"multiple": false,
|
|
2606
2662
|
"required": false,
|
|
2607
2663
|
"types": [
|
|
2664
|
+
{
|
|
2665
|
+
"type": "assignment",
|
|
2666
|
+
"named": true
|
|
2667
|
+
},
|
|
2608
2668
|
{
|
|
2609
2669
|
"type": "block",
|
|
2610
2670
|
"named": true
|
|
2611
2671
|
},
|
|
2612
2672
|
{
|
|
2613
|
-
"type": "
|
|
2673
|
+
"type": "do_while_statement",
|
|
2674
|
+
"named": true
|
|
2675
|
+
},
|
|
2676
|
+
{
|
|
2677
|
+
"type": "expression",
|
|
2678
|
+
"named": true
|
|
2679
|
+
},
|
|
2680
|
+
{
|
|
2681
|
+
"type": "for_statement",
|
|
2682
|
+
"named": true
|
|
2683
|
+
},
|
|
2684
|
+
{
|
|
2685
|
+
"type": "while_statement",
|
|
2614
2686
|
"named": true
|
|
2615
2687
|
}
|
|
2616
2688
|
]
|
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|