@willbooster/tree-sitter-c-sharp 15.0.1 → 15.0.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 +117 -10
- package/package.json +1 -1
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +4 -1
package/grammar.js
CHANGED
|
@@ -53,6 +53,9 @@ module.exports = grammar({
|
|
|
53
53
|
name: 'c_sharp',
|
|
54
54
|
|
|
55
55
|
conflicts: ($) => [
|
|
56
|
+
[$._stackalloc_array_type, $.array_type],
|
|
57
|
+
[$._stackalloc_array_type, $._array_base_type],
|
|
58
|
+
[$._stackalloc_nullable_type, $.nullable_type],
|
|
56
59
|
[$._simple_name, $._expression_simple_name, $._pattern_simple_identifier_name, $._ambiguous_cast_qualified_name],
|
|
57
60
|
[$._expression_simple_name, $._ambiguous_cast_qualified_name],
|
|
58
61
|
[$._simple_name, $._expression_simple_name, $._ambiguous_cast_qualified_name],
|
|
@@ -185,6 +188,13 @@ module.exports = grammar({
|
|
|
185
188
|
[$._pattern_identifier, $.from_clause, $._reserved_identifier],
|
|
186
189
|
[$.scoped_type, $._pattern_identifier, $._reserved_identifier],
|
|
187
190
|
[$._pattern_identifier, $._lambda_expression_init, $.anonymous_method_expression, $._reserved_identifier],
|
|
191
|
+
[
|
|
192
|
+
$._pattern_identifier,
|
|
193
|
+
$._lambda_expression_init,
|
|
194
|
+
$._typed_lambda_expression_init,
|
|
195
|
+
$.anonymous_method_expression,
|
|
196
|
+
$._reserved_identifier,
|
|
197
|
+
],
|
|
188
198
|
[$._pattern_identifier, $.identifier],
|
|
189
199
|
[$.implicit_type, $._pattern_identifier, $._reserved_identifier],
|
|
190
200
|
[$._pattern_primary_expression, $._conditional_access_receiver],
|
|
@@ -251,11 +261,23 @@ module.exports = grammar({
|
|
|
251
261
|
[$._reserved_identifier, $.modifier],
|
|
252
262
|
[$._reserved_identifier],
|
|
253
263
|
[$._lambda_expression_init, $.anonymous_method_expression, $._reserved_identifier],
|
|
264
|
+
[$._lambda_expression_init, $._typed_lambda_expression_init, $.anonymous_method_expression, $._reserved_identifier],
|
|
254
265
|
[$._lambda_expression_init, $._reserved_identifier],
|
|
266
|
+
[$._lambda_expression_init, $._typed_lambda_expression_init, $._reserved_identifier],
|
|
255
267
|
[$.modifier, $._lambda_expression_init, $.anonymous_method_expression],
|
|
268
|
+
[$.modifier, $._lambda_expression_init, $._typed_lambda_expression_init, $.anonymous_method_expression],
|
|
256
269
|
[$.modifier, $._lambda_expression_init],
|
|
270
|
+
[$.modifier, $._lambda_expression_init, $._typed_lambda_expression_init],
|
|
257
271
|
[$.modifier, $._lambda_expression_init, $._reserved_identifier],
|
|
272
|
+
[$.modifier, $._lambda_expression_init, $._typed_lambda_expression_init, $._reserved_identifier],
|
|
258
273
|
[$.modifier, $._lambda_expression_init, $.anonymous_method_expression, $._reserved_identifier],
|
|
274
|
+
[
|
|
275
|
+
$.modifier,
|
|
276
|
+
$._lambda_expression_init,
|
|
277
|
+
$._typed_lambda_expression_init,
|
|
278
|
+
$.anonymous_method_expression,
|
|
279
|
+
$._reserved_identifier,
|
|
280
|
+
],
|
|
259
281
|
[$._reserved_identifier, $.scoped_type],
|
|
260
282
|
[$._reserved_identifier, $.implicit_type],
|
|
261
283
|
[$._reserved_identifier, $.from_clause],
|
|
@@ -359,6 +381,9 @@ module.exports = grammar({
|
|
|
359
381
|
sym('_expression_generic_end'),
|
|
360
382
|
sym('_definite_expression_generic_end'),
|
|
361
383
|
sym('_if_alternative_directive'),
|
|
384
|
+
sym('_conditional_consequence_start'),
|
|
385
|
+
sym('_expression_generic_start'),
|
|
386
|
+
sym('_stackalloc_context'),
|
|
362
387
|
],
|
|
363
388
|
|
|
364
389
|
extras: ($) => [
|
|
@@ -632,7 +657,7 @@ module.exports = grammar({
|
|
|
632
657
|
|
|
633
658
|
type_parameter_list: ($) =>
|
|
634
659
|
seq(
|
|
635
|
-
|
|
660
|
+
genericStart(),
|
|
636
661
|
commaSep1($.type_parameter),
|
|
637
662
|
choice('>', alias(sym('_expression_generic_end'), '>'), alias(sym('_definite_expression_generic_end'), '>'))
|
|
638
663
|
),
|
|
@@ -1055,7 +1080,7 @@ module.exports = grammar({
|
|
|
1055
1080
|
|
|
1056
1081
|
type_argument_list: ($) =>
|
|
1057
1082
|
seq(
|
|
1058
|
-
|
|
1083
|
+
genericStart(),
|
|
1059
1084
|
choice(repeat(','), commaSep1($.type)),
|
|
1060
1085
|
choice('>', alias(sym('_expression_generic_end'), '>'), alias(sym('_definite_expression_generic_end'), '>'))
|
|
1061
1086
|
),
|
|
@@ -1067,7 +1092,7 @@ module.exports = grammar({
|
|
|
1067
1092
|
|
|
1068
1093
|
_expression_type_argument_list: ($) =>
|
|
1069
1094
|
seq(
|
|
1070
|
-
|
|
1095
|
+
genericStart(),
|
|
1071
1096
|
choice(
|
|
1072
1097
|
seq(choice(repeat(','), commaSep1($.type)), alias(sym('_expression_generic_end'), '>')),
|
|
1073
1098
|
seq(repeat(','), alias(sym('_definite_expression_generic_end'), '>')),
|
|
@@ -1129,7 +1154,7 @@ module.exports = grammar({
|
|
|
1129
1154
|
|
|
1130
1155
|
_ambiguous_expression_arguments: ($) =>
|
|
1131
1156
|
seq(
|
|
1132
|
-
|
|
1157
|
+
genericStart(),
|
|
1133
1158
|
commaSep1(alias($._nongeneric_expression_type_argument, $.type)),
|
|
1134
1159
|
choice('>', alias(sym('_expression_generic_end'), '>'), alias(sym('_definite_expression_generic_end'), '>'))
|
|
1135
1160
|
),
|
|
@@ -1162,7 +1187,7 @@ module.exports = grammar({
|
|
|
1162
1187
|
|
|
1163
1188
|
_method_expression_arguments: ($) =>
|
|
1164
1189
|
seq(
|
|
1165
|
-
|
|
1190
|
+
genericStart(),
|
|
1166
1191
|
choice(
|
|
1167
1192
|
repeat(','),
|
|
1168
1193
|
seq(
|
|
@@ -1250,6 +1275,32 @@ module.exports = grammar({
|
|
|
1250
1275
|
|
|
1251
1276
|
array_type: ($) => seq(field('type', $._array_base_type), field('rank', $.array_rank_specifier)),
|
|
1252
1277
|
|
|
1278
|
+
_stackalloc_array_type: ($) =>
|
|
1279
|
+
prec.dynamic(
|
|
1280
|
+
1,
|
|
1281
|
+
seq(
|
|
1282
|
+
field(
|
|
1283
|
+
'type',
|
|
1284
|
+
choice(
|
|
1285
|
+
alias($._stackalloc_array_type, $.array_type),
|
|
1286
|
+
$._name,
|
|
1287
|
+
alias($._stackalloc_nullable_type, $.nullable_type),
|
|
1288
|
+
$.pointer_type,
|
|
1289
|
+
$.function_pointer_type,
|
|
1290
|
+
$.predefined_type,
|
|
1291
|
+
$.tuple_type
|
|
1292
|
+
)
|
|
1293
|
+
),
|
|
1294
|
+
field('rank', $.array_rank_specifier)
|
|
1295
|
+
)
|
|
1296
|
+
),
|
|
1297
|
+
|
|
1298
|
+
_stackalloc_nullable_type: ($) =>
|
|
1299
|
+
seq(
|
|
1300
|
+
field('type', choice(alias($._stackalloc_array_type, $.array_type), $._name, $.predefined_type, $.tuple_type)),
|
|
1301
|
+
nullableQuestion()
|
|
1302
|
+
),
|
|
1303
|
+
|
|
1253
1304
|
_array_base_type: ($) =>
|
|
1254
1305
|
choice(
|
|
1255
1306
|
$.array_type,
|
|
@@ -1277,7 +1328,7 @@ module.exports = grammar({
|
|
|
1277
1328
|
'delegate',
|
|
1278
1329
|
'*',
|
|
1279
1330
|
optional($.calling_convention),
|
|
1280
|
-
|
|
1331
|
+
genericStart(),
|
|
1281
1332
|
repeat(seq($.function_pointer_parameter, ',')),
|
|
1282
1333
|
field('returns', $.type),
|
|
1283
1334
|
'>'
|
|
@@ -1960,6 +2011,24 @@ module.exports = grammar({
|
|
|
1960
2011
|
prec.right(
|
|
1961
2012
|
PREC.COALESCING,
|
|
1962
2013
|
seq(field('left', $.expression), field('operator', '??'), field('right', $.expression))
|
|
2014
|
+
),
|
|
2015
|
+
...binaryOperators().map(([operator, precedence]) =>
|
|
2016
|
+
prec.left(
|
|
2017
|
+
precedence,
|
|
2018
|
+
seq(
|
|
2019
|
+
field('left', $.expression),
|
|
2020
|
+
field('operator', operator),
|
|
2021
|
+
field('right', alias($._binary_typed_lambda_expression, $.lambda_expression))
|
|
2022
|
+
)
|
|
2023
|
+
)
|
|
2024
|
+
),
|
|
2025
|
+
prec.right(
|
|
2026
|
+
PREC.COALESCING,
|
|
2027
|
+
seq(
|
|
2028
|
+
field('left', $.expression),
|
|
2029
|
+
field('operator', '??'),
|
|
2030
|
+
field('right', alias($._binary_typed_lambda_expression, $.lambda_expression))
|
|
2031
|
+
)
|
|
1963
2032
|
)
|
|
1964
2033
|
),
|
|
1965
2034
|
|
|
@@ -2008,6 +2077,7 @@ module.exports = grammar({
|
|
|
2008
2077
|
seq(
|
|
2009
2078
|
field('condition', $.expression),
|
|
2010
2079
|
ternaryQuestion(),
|
|
2080
|
+
sym('_conditional_consequence_start'),
|
|
2011
2081
|
field('consequence', $.expression),
|
|
2012
2082
|
':',
|
|
2013
2083
|
sym('_conditional_alternative_start'),
|
|
@@ -2456,7 +2526,19 @@ module.exports = grammar({
|
|
|
2456
2526
|
parenthesized_expression: ($) => seq('(', $.expression, ')'),
|
|
2457
2527
|
|
|
2458
2528
|
lambda_expression: ($) =>
|
|
2459
|
-
prec(
|
|
2529
|
+
prec(
|
|
2530
|
+
-1,
|
|
2531
|
+
choice(
|
|
2532
|
+
seq($._lambda_expression_init, '=>', field('body', choice($.block, $.expression))),
|
|
2533
|
+
seq($._typed_lambda_expression_init, '=>', field('body', choice($.block, $.expression)))
|
|
2534
|
+
)
|
|
2535
|
+
),
|
|
2536
|
+
|
|
2537
|
+
_binary_typed_lambda_expression: ($) =>
|
|
2538
|
+
prec(
|
|
2539
|
+
1,
|
|
2540
|
+
prec.dynamic(-1, seq($._typed_lambda_expression_init, '=>', field('body', choice($.block, $.expression))))
|
|
2541
|
+
),
|
|
2460
2542
|
|
|
2461
2543
|
_lambda_expression_init: ($) =>
|
|
2462
2544
|
prec(
|
|
@@ -2466,11 +2548,23 @@ module.exports = grammar({
|
|
|
2466
2548
|
repeat(prec.dynamic(1, alias(choice('static', 'async'), $.modifier))),
|
|
2467
2549
|
choice(
|
|
2468
2550
|
field('parameters', prec(-1, alias($.identifier, sym('implicit_parameter')))),
|
|
2469
|
-
seq(
|
|
2551
|
+
prec(1, prec.dynamic(1, seq(field('type', $.ref_type), field('parameters', $._lambda_parameters)))),
|
|
2552
|
+
field('parameters', $._lambda_parameters)
|
|
2470
2553
|
)
|
|
2471
2554
|
)
|
|
2472
2555
|
),
|
|
2473
2556
|
|
|
2557
|
+
_typed_lambda_expression_init: ($) =>
|
|
2558
|
+
prec(
|
|
2559
|
+
-1,
|
|
2560
|
+
seq(
|
|
2561
|
+
repeat($._attribute_list),
|
|
2562
|
+
repeat(prec.dynamic(1, alias(choice('static', 'async'), $.modifier))),
|
|
2563
|
+
field('type', $.type),
|
|
2564
|
+
field('parameters', $._lambda_parameters)
|
|
2565
|
+
)
|
|
2566
|
+
),
|
|
2567
|
+
|
|
2474
2568
|
_lambda_parameters: ($) =>
|
|
2475
2569
|
prec(
|
|
2476
2570
|
-1,
|
|
@@ -3362,12 +3456,21 @@ function arrayCreationExpression($, initializer) {
|
|
|
3362
3456
|
}
|
|
3363
3457
|
|
|
3364
3458
|
/**
|
|
3365
|
-
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'type'>} $
|
|
3459
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'_stackalloc_array_type' | 'array_type' | 'type'>} $
|
|
3366
3460
|
* @param {import('@willbooster/web-tree-sitter/dsl').Rule} initializer
|
|
3367
3461
|
* @returns {import('@willbooster/web-tree-sitter/dsl').Rule}
|
|
3368
3462
|
*/
|
|
3369
3463
|
function stackallocExpression($, initializer) {
|
|
3370
|
-
return
|
|
3464
|
+
return choice(
|
|
3465
|
+
prec.left(seq('stackalloc', field('type', $.type), initializer)),
|
|
3466
|
+
prec.right(
|
|
3467
|
+
seq(
|
|
3468
|
+
alias(sym('_stackalloc_context'), 'stackalloc'),
|
|
3469
|
+
field('type', alias($._stackalloc_array_type, $.array_type)),
|
|
3470
|
+
initializer
|
|
3471
|
+
)
|
|
3472
|
+
)
|
|
3473
|
+
);
|
|
3371
3474
|
}
|
|
3372
3475
|
|
|
3373
3476
|
/**
|
|
@@ -3791,3 +3894,7 @@ function blockEnd() {
|
|
|
3791
3894
|
function ampersandOperator() {
|
|
3792
3895
|
return alias(sym('_ampersand_operator'), '&');
|
|
3793
3896
|
}
|
|
3897
|
+
|
|
3898
|
+
function genericStart() {
|
|
3899
|
+
return choice('<', alias(sym('_expression_generic_start'), '<'));
|
|
3900
|
+
}
|
package/package.json
CHANGED
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|
package/tree-sitter.json
CHANGED
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"src/nullableTypes.h",
|
|
25
25
|
"src/questionContext.h",
|
|
26
26
|
"src/questionLiterals.h",
|
|
27
|
+
"src/questionOperands.h",
|
|
28
|
+
"src/questionState.h",
|
|
29
|
+
"src/questionSuffix.h",
|
|
27
30
|
"src/tree_sitter/alloc.h",
|
|
28
31
|
"src/tree_sitter/array.h",
|
|
29
32
|
"src/tree_sitter/parser.h"
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
}
|
|
32
35
|
],
|
|
33
36
|
"metadata": {
|
|
34
|
-
"version": "15.0.
|
|
37
|
+
"version": "15.0.2",
|
|
35
38
|
"license": "MIT",
|
|
36
39
|
"description": "C# grammar for tree-sitter",
|
|
37
40
|
"authors": [
|