@willbooster/tree-sitter-c-sharp 9.0.0 → 10.0.0
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 +255 -28
- package/package.json +1 -1
- package/queries/highlights.scm +6 -4
- package/queries/tags.scm +1 -3
- package/src/node-types.json +186 -46
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const { alias, choice, field, grammar, optional, prec, repeat, repeat1, seq, sym, token } =
|
|
12
12
|
/** @type {typeof globalThis & import('@willbooster/web-tree-sitter/dsl').DSL} */ (globalThis);
|
|
13
13
|
|
|
14
|
-
/** @typedef {'_preproc_expression' | '_top_level_item_no_statement' | 'attribute_list' | 'declaration' | 'enum_member_declaration' | 'expression' | 'method_signature' | 'statement'} PreprocContentRule */
|
|
14
|
+
/** @typedef {'_preproc_expression' | '_top_level_item_no_statement' | '_base_list_mixed_type' | '_base_list_mixed_suffix' | '_base_list_trivia' | '_base_list' | '_base_list_type' | '_base_list_suffix' | '_base_list_prefix' | '_base_list_separator' | '_base_list_separator_path' | '_enum_base_clause' | '_enum_base_type' | 'attribute_list' | 'declaration' | 'enum_member_declaration' | 'expression' | 'method_signature' | 'statement'} PreprocContentRule */
|
|
15
15
|
|
|
16
16
|
const PREC = {
|
|
17
17
|
GENERIC: 19,
|
|
@@ -226,11 +226,36 @@ module.exports = grammar({
|
|
|
226
226
|
[$.parameter, $.declaration_expression],
|
|
227
227
|
[$.parameter, $.tuple_element],
|
|
228
228
|
[$.event_declaration, $.variable_declarator],
|
|
229
|
-
[$.base_list],
|
|
230
229
|
[$.using_directive, $.modifier],
|
|
231
230
|
[$.using_directive],
|
|
232
231
|
[$._constructor_declaration_initializer, $._simple_name],
|
|
233
232
|
[$.receiver_parameter, $.scoped_type, $._reserved_identifier],
|
|
233
|
+
[$._base_list_type, $._conditional_base_list_head, $._base_list_prefix],
|
|
234
|
+
[$._base_list_type, $._base_list_prefix],
|
|
235
|
+
[$._base_list_separator_path, $._base_list_suffix],
|
|
236
|
+
[sym('preproc_if_in_base_list'), sym('preproc_if_in_base_list_suffix')],
|
|
237
|
+
[sym('preproc_elif_in_base_list'), sym('preproc_elif_in_base_list_suffix')],
|
|
238
|
+
[sym('preproc_else_in_base_list'), sym('preproc_else_in_base_list_suffix')],
|
|
239
|
+
[sym('preproc_if_in_empty_base'), sym('preproc_if_in_base_list_prefix'), sym('preproc_if_in_base_list_suffix')],
|
|
240
|
+
[
|
|
241
|
+
sym('preproc_elif_in_empty_base'),
|
|
242
|
+
sym('preproc_elif_in_base_list_prefix'),
|
|
243
|
+
sym('preproc_elif_in_base_list_suffix'),
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
sym('preproc_else_in_empty_base'),
|
|
247
|
+
sym('preproc_else_in_base_list_prefix'),
|
|
248
|
+
sym('preproc_else_in_base_list_suffix'),
|
|
249
|
+
],
|
|
250
|
+
[sym('preproc_if_in_empty_base'), sym('preproc_if_in_base_list_prefix')],
|
|
251
|
+
[sym('preproc_elif_in_empty_base'), sym('preproc_elif_in_base_list_prefix')],
|
|
252
|
+
[sym('preproc_else_in_empty_base'), sym('preproc_else_in_base_list_prefix')],
|
|
253
|
+
[sym('preproc_if_in_empty_base'), sym('preproc_if_in_base_list_suffix')],
|
|
254
|
+
[sym('preproc_elif_in_empty_base'), sym('preproc_elif_in_base_list_suffix')],
|
|
255
|
+
[sym('preproc_else_in_empty_base'), sym('preproc_else_in_base_list_suffix')],
|
|
256
|
+
[sym('preproc_if_in_base_list_prefix'), sym('preproc_if_in_base_list_suffix')],
|
|
257
|
+
[sym('preproc_elif_in_base_list_prefix'), sym('preproc_elif_in_base_list_suffix')],
|
|
258
|
+
[sym('preproc_else_in_base_list_prefix'), sym('preproc_else_in_base_list_suffix')],
|
|
234
259
|
],
|
|
235
260
|
|
|
236
261
|
externals: () => [
|
|
@@ -307,6 +332,11 @@ module.exports = grammar({
|
|
|
307
332
|
],
|
|
308
333
|
|
|
309
334
|
inline: ($) => [
|
|
335
|
+
$._base_list,
|
|
336
|
+
$._base_list_head,
|
|
337
|
+
$._base_list_separator,
|
|
338
|
+
$._enum_base_clause,
|
|
339
|
+
$._enum_base_type,
|
|
310
340
|
$._postfix_receiver,
|
|
311
341
|
$._namespace_member_declaration,
|
|
312
342
|
$._object_creation_type,
|
|
@@ -414,7 +444,9 @@ module.exports = grammar({
|
|
|
414
444
|
repeat($.modifier),
|
|
415
445
|
'class',
|
|
416
446
|
field('name', $.identifier),
|
|
417
|
-
|
|
447
|
+
optional($.type_parameter_list),
|
|
448
|
+
optional($.parameter_list),
|
|
449
|
+
optional($._base_list),
|
|
418
450
|
repeat($.type_parameter_constraints_clause)
|
|
419
451
|
),
|
|
420
452
|
|
|
@@ -427,7 +459,9 @@ module.exports = grammar({
|
|
|
427
459
|
optional(seq('ref', optional(alias('partial', $.modifier)))),
|
|
428
460
|
'struct',
|
|
429
461
|
field('name', $.identifier),
|
|
430
|
-
|
|
462
|
+
optional($.type_parameter_list),
|
|
463
|
+
optional($.parameter_list),
|
|
464
|
+
optional($._base_list),
|
|
431
465
|
repeat($.type_parameter_constraints_clause)
|
|
432
466
|
),
|
|
433
467
|
|
|
@@ -438,7 +472,13 @@ module.exports = grammar({
|
|
|
438
472
|
),
|
|
439
473
|
|
|
440
474
|
_enum_declaration_initializer: ($) =>
|
|
441
|
-
seq(
|
|
475
|
+
seq(
|
|
476
|
+
repeat($._attribute_list),
|
|
477
|
+
repeat($.modifier),
|
|
478
|
+
'enum',
|
|
479
|
+
field('name', $.identifier),
|
|
480
|
+
optional($._enum_base_clause)
|
|
481
|
+
),
|
|
442
482
|
|
|
443
483
|
enum_member_declaration_list: ($) =>
|
|
444
484
|
seq(
|
|
@@ -462,7 +502,7 @@ module.exports = grammar({
|
|
|
462
502
|
'interface',
|
|
463
503
|
field('name', $.identifier),
|
|
464
504
|
field('type_parameters', optional($.type_parameter_list)),
|
|
465
|
-
optional($.
|
|
505
|
+
optional($._base_list),
|
|
466
506
|
repeat($.type_parameter_constraints_clause)
|
|
467
507
|
),
|
|
468
508
|
|
|
@@ -489,22 +529,15 @@ module.exports = grammar({
|
|
|
489
529
|
'record',
|
|
490
530
|
optional(choice('class', 'struct')),
|
|
491
531
|
field('name', $.identifier),
|
|
492
|
-
|
|
493
|
-
optional(
|
|
532
|
+
optional($.type_parameter_list),
|
|
533
|
+
optional($.parameter_list),
|
|
534
|
+
optional($._base_list),
|
|
494
535
|
repeat($.type_parameter_constraints_clause)
|
|
495
536
|
),
|
|
496
537
|
|
|
497
|
-
record_base: ($) =>
|
|
498
|
-
choice(
|
|
499
|
-
seq(':', commaSep1($._name)),
|
|
500
|
-
seq(':', $.primary_constructor_base_type, optional(seq(',', commaSep1($._name))))
|
|
501
|
-
),
|
|
502
|
-
|
|
503
538
|
_declaration_list_body: ($) =>
|
|
504
539
|
choice(seq(field('body', $.declaration_list), sym('_optional_semi')), statementEnd()),
|
|
505
540
|
|
|
506
|
-
primary_constructor_base_type: ($) => seq(field('type', $._name), $.argument_list),
|
|
507
|
-
|
|
508
541
|
modifier: () =>
|
|
509
542
|
prec.right(
|
|
510
543
|
choice(
|
|
@@ -537,7 +570,88 @@ module.exports = grammar({
|
|
|
537
570
|
|
|
538
571
|
type_parameter: ($) => seq(repeat($._attribute_list), optional(choice('in', 'out')), field('name', $.identifier)),
|
|
539
572
|
|
|
540
|
-
|
|
573
|
+
_enum_base_clause: ($) => choice(alias($._enum_base_list, $.base_list), $._conditional_enum_base_clause),
|
|
574
|
+
|
|
575
|
+
_conditional_enum_base_clause: ($) =>
|
|
576
|
+
seq(alias(sym('preproc_if_in_enum_base_clause'), sym('preproc_if')), optional($._enum_base_clause)),
|
|
577
|
+
|
|
578
|
+
_enum_base_list: ($) => seq(':', $._enum_base_type),
|
|
579
|
+
|
|
580
|
+
_enum_base_type: ($) =>
|
|
581
|
+
seq(
|
|
582
|
+
repeat($._base_list_trivia),
|
|
583
|
+
choice(field('underlying_type', $.type), $._conditional_enum_base_type),
|
|
584
|
+
repeat($._base_list_trivia)
|
|
585
|
+
),
|
|
586
|
+
|
|
587
|
+
_conditional_enum_base_type: ($) =>
|
|
588
|
+
choice(
|
|
589
|
+
alias(sym('preproc_if_in_enum_base_type'), sym('preproc_if')),
|
|
590
|
+
seq(
|
|
591
|
+
$._conditional_enum_base_type,
|
|
592
|
+
repeat($._base_list_trivia),
|
|
593
|
+
alias(sym('preproc_if_in_enum_base_type'), sym('preproc_if'))
|
|
594
|
+
)
|
|
595
|
+
),
|
|
596
|
+
|
|
597
|
+
_base_list_trivia: () => alias(sym('preproc_if_in_empty_base'), sym('preproc_if')),
|
|
598
|
+
|
|
599
|
+
_base_list: ($) => choice($.base_list, $._conditional_base_list),
|
|
600
|
+
|
|
601
|
+
_conditional_base_list: ($) =>
|
|
602
|
+
seq(
|
|
603
|
+
alias(sym('preproc_if_in_base_list'), sym('preproc_if')),
|
|
604
|
+
optional(choice($._base_list_suffix, $._base_list))
|
|
605
|
+
),
|
|
606
|
+
|
|
607
|
+
base_list: ($) => seq(':', $._base_list_type),
|
|
608
|
+
|
|
609
|
+
_base_list_type: ($) =>
|
|
610
|
+
choice(
|
|
611
|
+
seq($._base_list_mixed_type, choice($._base_list_type, $._base_list_suffix)),
|
|
612
|
+
seq(alias(sym('preproc_if_in_base_list_prefix'), sym('preproc_if')), $._base_list_type),
|
|
613
|
+
seq($._base_list_head, optional($._base_list_suffix))
|
|
614
|
+
),
|
|
615
|
+
|
|
616
|
+
_base_list_head: ($) =>
|
|
617
|
+
choice(seq(field('base', $.type), optional($.argument_list)), $._conditional_base_list_head),
|
|
618
|
+
|
|
619
|
+
_conditional_base_list_head: ($) =>
|
|
620
|
+
choice(
|
|
621
|
+
alias(sym('preproc_if_in_base_list_type'), sym('preproc_if')),
|
|
622
|
+
seq(
|
|
623
|
+
$._conditional_base_list_head,
|
|
624
|
+
repeat($._base_list_trivia),
|
|
625
|
+
alias(sym('preproc_if_in_base_list_type'), sym('preproc_if'))
|
|
626
|
+
)
|
|
627
|
+
),
|
|
628
|
+
|
|
629
|
+
_base_list_mixed_type: () => alias(sym('preproc_if_in_mixed_base_type'), sym('preproc_if')),
|
|
630
|
+
|
|
631
|
+
_base_list_mixed_suffix: () => alias(sym('preproc_if_in_mixed_base_suffix'), sym('preproc_if')),
|
|
632
|
+
|
|
633
|
+
_base_list_prefix: ($) =>
|
|
634
|
+
choice(
|
|
635
|
+
seq($._base_list_mixed_type, choice($._base_list_prefix, $._base_list_separator_path)),
|
|
636
|
+
seq(alias(sym('preproc_if_in_base_list_prefix'), sym('preproc_if')), optional($._base_list_prefix)),
|
|
637
|
+
seq($._base_list_head, $._base_list_separator_path)
|
|
638
|
+
),
|
|
639
|
+
|
|
640
|
+
_base_list_separator: () => choice(',', alias(sym('preproc_if_in_base_list_separator'), sym('preproc_if'))),
|
|
641
|
+
|
|
642
|
+
_base_list_separator_path: ($) =>
|
|
643
|
+
choice(
|
|
644
|
+
seq($._base_list_mixed_suffix, choice($._base_list_prefix, $._base_list_separator_path)),
|
|
645
|
+
seq(alias(sym('preproc_if_in_base_list_suffix'), sym('preproc_if')), $._base_list_separator_path),
|
|
646
|
+
seq($._base_list_separator, optional($._base_list_prefix))
|
|
647
|
+
),
|
|
648
|
+
|
|
649
|
+
_base_list_suffix: ($) =>
|
|
650
|
+
choice(
|
|
651
|
+
seq($._base_list_mixed_suffix, choice($._base_list_type, $._base_list_suffix)),
|
|
652
|
+
seq(alias(sym('preproc_if_in_base_list_suffix'), sym('preproc_if')), optional($._base_list_suffix)),
|
|
653
|
+
seq($._base_list_separator, $._base_list_type)
|
|
654
|
+
),
|
|
541
655
|
|
|
542
656
|
type_parameter_constraints_clause: ($) => seq('where', $.identifier, ':', commaSep1($.type_parameter_constraint)),
|
|
543
657
|
|
|
@@ -2336,6 +2450,36 @@ module.exports = grammar({
|
|
|
2336
2450
|
false,
|
|
2337
2451
|
true
|
|
2338
2452
|
),
|
|
2453
|
+
...preprocIfWithMixedContent(
|
|
2454
|
+
'_in_mixed_base_type',
|
|
2455
|
+
($) => $._base_list_type,
|
|
2456
|
+
($) => $._base_list_prefix,
|
|
2457
|
+
($) =>
|
|
2458
|
+
choice(
|
|
2459
|
+
$._base_list_mixed_type,
|
|
2460
|
+
seq($._base_list_prefix, $._base_list_mixed_type),
|
|
2461
|
+
seq($._base_list_type, $._base_list_mixed_suffix)
|
|
2462
|
+
)
|
|
2463
|
+
),
|
|
2464
|
+
...preprocIfWithMixedContent(
|
|
2465
|
+
'_in_mixed_base_suffix',
|
|
2466
|
+
($) => $._base_list_suffix,
|
|
2467
|
+
($) => $._base_list_separator_path,
|
|
2468
|
+
($) =>
|
|
2469
|
+
choice(
|
|
2470
|
+
$._base_list_mixed_suffix,
|
|
2471
|
+
seq($._base_list_suffix, $._base_list_mixed_suffix),
|
|
2472
|
+
seq($._base_list_separator_path, $._base_list_mixed_type)
|
|
2473
|
+
)
|
|
2474
|
+
),
|
|
2475
|
+
...preprocIf('_in_empty_base', ($) => $._base_list_trivia),
|
|
2476
|
+
...preprocIf('_in_enum_base_clause', ($) => $._enum_base_clause, 0, false),
|
|
2477
|
+
...preprocIfWithContent('_in_enum_base_type', ($) => $._enum_base_type),
|
|
2478
|
+
...preprocIf('_in_base_list', ($) => $._base_list, 0, false),
|
|
2479
|
+
...preprocIfWithContent('_in_base_list_type', ($) => $._base_list_type),
|
|
2480
|
+
...preprocIf('_in_base_list_prefix', ($) => $._base_list_prefix, 0, false),
|
|
2481
|
+
...preprocIf('_in_base_list_separator', ($) => $._base_list_separator_path, 0, false, true),
|
|
2482
|
+
...preprocIf('_in_base_list_suffix', ($) => $._base_list_suffix, 0, false),
|
|
2339
2483
|
...preprocIf('', ($) => $.declaration),
|
|
2340
2484
|
...preprocIf('_in_top_level', ($) => choice($._top_level_item_no_statement, $.statement)),
|
|
2341
2485
|
...preprocIf('_in_expression', ($) => $.expression, -2, false),
|
|
@@ -2612,6 +2756,87 @@ function preprocessor(command) {
|
|
|
2612
2756
|
return alias(new RegExp('#[ \t]*' + command), '#' + command);
|
|
2613
2757
|
}
|
|
2614
2758
|
|
|
2759
|
+
/**
|
|
2760
|
+
* @param {string} suffix
|
|
2761
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} complete
|
|
2762
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} prefix
|
|
2763
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} mixed
|
|
2764
|
+
* @returns {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>}
|
|
2765
|
+
*/
|
|
2766
|
+
function preprocIfWithMixedContent(suffix, complete, prefix, mixed) {
|
|
2767
|
+
const contents = [undefined, complete, prefix, mixed];
|
|
2768
|
+
/** @param {number} mask */
|
|
2769
|
+
function alternativeBlock(mask) {
|
|
2770
|
+
return choice(
|
|
2771
|
+
alias(sym('preproc_else' + suffix + mask), sym('preproc_else')),
|
|
2772
|
+
alias(sym('preproc_elif' + suffix + mask), sym('preproc_elif'))
|
|
2773
|
+
);
|
|
2774
|
+
}
|
|
2775
|
+
/**
|
|
2776
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
|
2777
|
+
* @param {number} mask
|
|
2778
|
+
*/
|
|
2779
|
+
function contentOrAlternative($, mask) {
|
|
2780
|
+
return choice(
|
|
2781
|
+
...contents.map((content, provided) => {
|
|
2782
|
+
const remaining = mask & ~provided;
|
|
2783
|
+
const alternative = field(
|
|
2784
|
+
'alternative',
|
|
2785
|
+
remaining ? alternativeBlock(remaining) : optional(alternativeBlock(0))
|
|
2786
|
+
);
|
|
2787
|
+
return content ? seq(content($), alternative) : alternative;
|
|
2788
|
+
})
|
|
2789
|
+
);
|
|
2790
|
+
}
|
|
2791
|
+
/** @type {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>} */
|
|
2792
|
+
const rules = {
|
|
2793
|
+
['preproc_if' + suffix]: ($) => conditionalDirective('if', $, contentOrAlternative($, 3), preprocessor('endif')),
|
|
2794
|
+
};
|
|
2795
|
+
for (const mask of [0, 1, 2, 3]) {
|
|
2796
|
+
rules['preproc_elif' + suffix + mask] = ($) => conditionalDirective('elif', $, contentOrAlternative($, mask));
|
|
2797
|
+
rules['preproc_else' + suffix + mask] = ($) =>
|
|
2798
|
+
seq(
|
|
2799
|
+
preprocessor('else'),
|
|
2800
|
+
choice(
|
|
2801
|
+
...contents.flatMap((content, provided) => (content && (provided & mask) === mask ? [content($)] : [])),
|
|
2802
|
+
...(mask === 0 ? [optional($._base_list_trivia)] : [])
|
|
2803
|
+
)
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
return rules;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
/**
|
|
2810
|
+
* @param {string} suffix
|
|
2811
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} content
|
|
2812
|
+
* @returns {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>}
|
|
2813
|
+
*/
|
|
2814
|
+
function preprocIfWithContent(suffix, content) {
|
|
2815
|
+
/** @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $ */
|
|
2816
|
+
function contentOrAlternative($) {
|
|
2817
|
+
return choice(
|
|
2818
|
+
seq(content($), field('alternative', optional(alternativeBlock(false)))),
|
|
2819
|
+
seq(repeat($._base_list_trivia), field('alternative', alternativeBlock(true)))
|
|
2820
|
+
);
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
/** @param {boolean} required */
|
|
2824
|
+
function alternativeBlock(required) {
|
|
2825
|
+
const alternativeSuffix = suffix + (required ? '_with_content' : '');
|
|
2826
|
+
return choice(
|
|
2827
|
+
alias(sym('preproc_else' + alternativeSuffix), sym('preproc_else')),
|
|
2828
|
+
alias(sym('preproc_elif' + alternativeSuffix), sym('preproc_elif'))
|
|
2829
|
+
);
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
return {
|
|
2833
|
+
...preprocIf(suffix, ($) => choice(content($), repeat1($._base_list_trivia)), 0, false),
|
|
2834
|
+
['preproc_if' + suffix]: ($) => conditionalDirective('if', $, contentOrAlternative($), preprocessor('endif')),
|
|
2835
|
+
['preproc_else' + suffix + '_with_content']: ($) => seq(preprocessor('else'), content($)),
|
|
2836
|
+
['preproc_elif' + suffix + '_with_content']: ($) => conditionalDirective('elif', $, contentOrAlternative($)),
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2615
2840
|
/**
|
|
2616
2841
|
*
|
|
2617
2842
|
* @param {string} suffix
|
|
@@ -2648,10 +2873,9 @@ function preprocIf(suffix, content, precedence = 0, rep = true, required = false
|
|
|
2648
2873
|
['preproc_if' + suffix]: ($) =>
|
|
2649
2874
|
prec(
|
|
2650
2875
|
precedence,
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
directiveNewLine(),
|
|
2876
|
+
conditionalDirective(
|
|
2877
|
+
'if',
|
|
2878
|
+
$,
|
|
2655
2879
|
contentRule($),
|
|
2656
2880
|
field('alternative', optional(alternativeBlock())),
|
|
2657
2881
|
preprocessor('endif')
|
|
@@ -2663,17 +2887,20 @@ function preprocIf(suffix, content, precedence = 0, rep = true, required = false
|
|
|
2663
2887
|
['preproc_elif' + suffix]: ($) =>
|
|
2664
2888
|
prec(
|
|
2665
2889
|
precedence,
|
|
2666
|
-
|
|
2667
|
-
preprocessor('elif'),
|
|
2668
|
-
field('condition', $._preproc_expression),
|
|
2669
|
-
directiveNewLine(),
|
|
2670
|
-
contentRule($),
|
|
2671
|
-
field('alternative', optional(alternativeBlock()))
|
|
2672
|
-
)
|
|
2890
|
+
conditionalDirective('elif', $, contentRule($), field('alternative', optional(alternativeBlock())))
|
|
2673
2891
|
),
|
|
2674
2892
|
};
|
|
2675
2893
|
}
|
|
2676
2894
|
|
|
2895
|
+
/**
|
|
2896
|
+
* @param {'if' | 'elif'} command
|
|
2897
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
|
2898
|
+
* @param {...import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} content
|
|
2899
|
+
*/
|
|
2900
|
+
function conditionalDirective(command, $, ...content) {
|
|
2901
|
+
return seq(preprocessor(command), field('condition', $._preproc_expression), directiveNewLine(), ...content);
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2677
2904
|
/**
|
|
2678
2905
|
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'_simple_name'>} $
|
|
2679
2906
|
* @param {import('@willbooster/web-tree-sitter/dsl').Rule} receiver
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
(interface_declaration name: (identifier) @type)
|
|
12
12
|
(class_declaration name: (identifier) @type)
|
|
13
13
|
(enum_declaration name: (identifier) @type)
|
|
14
|
-
(struct_declaration (identifier) @type)
|
|
15
|
-
(record_declaration (identifier) @type)
|
|
14
|
+
(struct_declaration name: (identifier) @type)
|
|
15
|
+
(record_declaration name: (identifier) @type)
|
|
16
16
|
(namespace_declaration name: (identifier) @module)
|
|
17
17
|
|
|
18
18
|
(generic_name (identifier) @type)
|
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
(_ type: (identifier) @type)
|
|
29
29
|
|
|
30
|
-
(base_list (identifier) @type)
|
|
31
|
-
|
|
32
30
|
(predefined_type) @type.builtin
|
|
33
31
|
|
|
34
32
|
;; Enum
|
|
@@ -219,3 +217,7 @@
|
|
|
219
217
|
(file_directive_value) @string
|
|
220
218
|
|
|
221
219
|
(file_directive_kind) @keyword.directive
|
|
220
|
+
|
|
221
|
+
(_ base: (identifier) @type)
|
|
222
|
+
|
|
223
|
+
(_ underlying_type: (identifier) @type)
|
package/queries/tags.scm
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
(class_declaration name: (identifier) @name) @definition.class
|
|
2
2
|
|
|
3
|
-
(
|
|
3
|
+
(_ base: (_) @name @reference.class)
|
|
4
4
|
|
|
5
5
|
(interface_declaration name: (identifier) @name) @definition.interface
|
|
6
6
|
|
|
7
|
-
(interface_declaration (base_list (_) @name)) @reference.interface
|
|
8
|
-
|
|
9
7
|
(method_declaration name: (identifier) @name) @definition.method
|
|
10
8
|
|
|
11
9
|
(method_signature name: (identifier) @name) @definition.method
|
package/src/node-types.json
CHANGED
|
@@ -1427,21 +1427,38 @@
|
|
|
1427
1427
|
{
|
|
1428
1428
|
"type": "base_list",
|
|
1429
1429
|
"named": true,
|
|
1430
|
-
"fields": {
|
|
1430
|
+
"fields": {
|
|
1431
|
+
"base": {
|
|
1432
|
+
"multiple": true,
|
|
1433
|
+
"required": false,
|
|
1434
|
+
"types": [
|
|
1435
|
+
{
|
|
1436
|
+
"type": "type",
|
|
1437
|
+
"named": true
|
|
1438
|
+
}
|
|
1439
|
+
]
|
|
1440
|
+
},
|
|
1441
|
+
"underlying_type": {
|
|
1442
|
+
"multiple": false,
|
|
1443
|
+
"required": false,
|
|
1444
|
+
"types": [
|
|
1445
|
+
{
|
|
1446
|
+
"type": "type",
|
|
1447
|
+
"named": true
|
|
1448
|
+
}
|
|
1449
|
+
]
|
|
1450
|
+
}
|
|
1451
|
+
},
|
|
1431
1452
|
"children": {
|
|
1432
1453
|
"multiple": true,
|
|
1433
|
-
"required":
|
|
1454
|
+
"required": false,
|
|
1434
1455
|
"types": [
|
|
1435
1456
|
{
|
|
1436
1457
|
"type": "argument_list",
|
|
1437
1458
|
"named": true
|
|
1438
1459
|
},
|
|
1439
1460
|
{
|
|
1440
|
-
"type": "
|
|
1441
|
-
"named": true
|
|
1442
|
-
},
|
|
1443
|
-
{
|
|
1444
|
-
"type": "type",
|
|
1461
|
+
"type": "preproc_if",
|
|
1445
1462
|
"named": true
|
|
1446
1463
|
}
|
|
1447
1464
|
]
|
|
@@ -1952,6 +1969,16 @@
|
|
|
1952
1969
|
"type": "class_declaration",
|
|
1953
1970
|
"named": true,
|
|
1954
1971
|
"fields": {
|
|
1972
|
+
"base": {
|
|
1973
|
+
"multiple": true,
|
|
1974
|
+
"required": false,
|
|
1975
|
+
"types": [
|
|
1976
|
+
{
|
|
1977
|
+
"type": "type",
|
|
1978
|
+
"named": true
|
|
1979
|
+
}
|
|
1980
|
+
]
|
|
1981
|
+
},
|
|
1955
1982
|
"body": {
|
|
1956
1983
|
"multiple": false,
|
|
1957
1984
|
"required": false,
|
|
@@ -1977,6 +2004,10 @@
|
|
|
1977
2004
|
"multiple": true,
|
|
1978
2005
|
"required": false,
|
|
1979
2006
|
"types": [
|
|
2007
|
+
{
|
|
2008
|
+
"type": "argument_list",
|
|
2009
|
+
"named": true
|
|
2010
|
+
},
|
|
1980
2011
|
{
|
|
1981
2012
|
"type": "attribute_list",
|
|
1982
2013
|
"named": true
|
|
@@ -1993,6 +2024,10 @@
|
|
|
1993
2024
|
"type": "parameter_list",
|
|
1994
2025
|
"named": true
|
|
1995
2026
|
},
|
|
2027
|
+
{
|
|
2028
|
+
"type": "preproc_if",
|
|
2029
|
+
"named": true
|
|
2030
|
+
},
|
|
1996
2031
|
{
|
|
1997
2032
|
"type": "preproc_if_in_attribute_list",
|
|
1998
2033
|
"named": true
|
|
@@ -3123,6 +3158,10 @@
|
|
|
3123
3158
|
"type": "modifier",
|
|
3124
3159
|
"named": true
|
|
3125
3160
|
},
|
|
3161
|
+
{
|
|
3162
|
+
"type": "preproc_if",
|
|
3163
|
+
"named": true
|
|
3164
|
+
},
|
|
3126
3165
|
{
|
|
3127
3166
|
"type": "preproc_if_in_attribute_list",
|
|
3128
3167
|
"named": true
|
|
@@ -4199,6 +4238,16 @@
|
|
|
4199
4238
|
"type": "interface_declaration",
|
|
4200
4239
|
"named": true,
|
|
4201
4240
|
"fields": {
|
|
4241
|
+
"base": {
|
|
4242
|
+
"multiple": true,
|
|
4243
|
+
"required": false,
|
|
4244
|
+
"types": [
|
|
4245
|
+
{
|
|
4246
|
+
"type": "type",
|
|
4247
|
+
"named": true
|
|
4248
|
+
}
|
|
4249
|
+
]
|
|
4250
|
+
},
|
|
4202
4251
|
"body": {
|
|
4203
4252
|
"multiple": false,
|
|
4204
4253
|
"required": false,
|
|
@@ -4234,6 +4283,10 @@
|
|
|
4234
4283
|
"multiple": true,
|
|
4235
4284
|
"required": false,
|
|
4236
4285
|
"types": [
|
|
4286
|
+
{
|
|
4287
|
+
"type": "argument_list",
|
|
4288
|
+
"named": true
|
|
4289
|
+
},
|
|
4237
4290
|
{
|
|
4238
4291
|
"type": "attribute_list",
|
|
4239
4292
|
"named": true
|
|
@@ -4246,6 +4299,10 @@
|
|
|
4246
4299
|
"type": "modifier",
|
|
4247
4300
|
"named": true
|
|
4248
4301
|
},
|
|
4302
|
+
{
|
|
4303
|
+
"type": "preproc_if",
|
|
4304
|
+
"named": true
|
|
4305
|
+
},
|
|
4249
4306
|
{
|
|
4250
4307
|
"type": "preproc_if_in_attribute_list",
|
|
4251
4308
|
"named": true
|
|
@@ -6138,6 +6195,16 @@
|
|
|
6138
6195
|
}
|
|
6139
6196
|
]
|
|
6140
6197
|
},
|
|
6198
|
+
"base": {
|
|
6199
|
+
"multiple": true,
|
|
6200
|
+
"required": false,
|
|
6201
|
+
"types": [
|
|
6202
|
+
{
|
|
6203
|
+
"type": "type",
|
|
6204
|
+
"named": true
|
|
6205
|
+
}
|
|
6206
|
+
]
|
|
6207
|
+
},
|
|
6141
6208
|
"condition": {
|
|
6142
6209
|
"multiple": false,
|
|
6143
6210
|
"required": true,
|
|
@@ -6171,16 +6238,34 @@
|
|
|
6171
6238
|
"named": true
|
|
6172
6239
|
}
|
|
6173
6240
|
]
|
|
6241
|
+
},
|
|
6242
|
+
"underlying_type": {
|
|
6243
|
+
"multiple": false,
|
|
6244
|
+
"required": false,
|
|
6245
|
+
"types": [
|
|
6246
|
+
{
|
|
6247
|
+
"type": "type",
|
|
6248
|
+
"named": true
|
|
6249
|
+
}
|
|
6250
|
+
]
|
|
6174
6251
|
}
|
|
6175
6252
|
},
|
|
6176
6253
|
"children": {
|
|
6177
6254
|
"multiple": true,
|
|
6178
6255
|
"required": false,
|
|
6179
6256
|
"types": [
|
|
6257
|
+
{
|
|
6258
|
+
"type": "argument_list",
|
|
6259
|
+
"named": true
|
|
6260
|
+
},
|
|
6180
6261
|
{
|
|
6181
6262
|
"type": "attribute_list",
|
|
6182
6263
|
"named": true
|
|
6183
6264
|
},
|
|
6265
|
+
{
|
|
6266
|
+
"type": "base_list",
|
|
6267
|
+
"named": true
|
|
6268
|
+
},
|
|
6184
6269
|
{
|
|
6185
6270
|
"type": "declaration",
|
|
6186
6271
|
"named": true
|
|
@@ -6223,15 +6308,44 @@
|
|
|
6223
6308
|
{
|
|
6224
6309
|
"type": "preproc_else",
|
|
6225
6310
|
"named": true,
|
|
6226
|
-
"fields": {
|
|
6311
|
+
"fields": {
|
|
6312
|
+
"base": {
|
|
6313
|
+
"multiple": true,
|
|
6314
|
+
"required": false,
|
|
6315
|
+
"types": [
|
|
6316
|
+
{
|
|
6317
|
+
"type": "type",
|
|
6318
|
+
"named": true
|
|
6319
|
+
}
|
|
6320
|
+
]
|
|
6321
|
+
},
|
|
6322
|
+
"underlying_type": {
|
|
6323
|
+
"multiple": false,
|
|
6324
|
+
"required": false,
|
|
6325
|
+
"types": [
|
|
6326
|
+
{
|
|
6327
|
+
"type": "type",
|
|
6328
|
+
"named": true
|
|
6329
|
+
}
|
|
6330
|
+
]
|
|
6331
|
+
}
|
|
6332
|
+
},
|
|
6227
6333
|
"children": {
|
|
6228
6334
|
"multiple": true,
|
|
6229
6335
|
"required": false,
|
|
6230
6336
|
"types": [
|
|
6337
|
+
{
|
|
6338
|
+
"type": "argument_list",
|
|
6339
|
+
"named": true
|
|
6340
|
+
},
|
|
6231
6341
|
{
|
|
6232
6342
|
"type": "attribute_list",
|
|
6233
6343
|
"named": true
|
|
6234
6344
|
},
|
|
6345
|
+
{
|
|
6346
|
+
"type": "base_list",
|
|
6347
|
+
"named": true
|
|
6348
|
+
},
|
|
6235
6349
|
{
|
|
6236
6350
|
"type": "declaration",
|
|
6237
6351
|
"named": true
|
|
@@ -6322,6 +6436,16 @@
|
|
|
6322
6436
|
}
|
|
6323
6437
|
]
|
|
6324
6438
|
},
|
|
6439
|
+
"base": {
|
|
6440
|
+
"multiple": true,
|
|
6441
|
+
"required": false,
|
|
6442
|
+
"types": [
|
|
6443
|
+
{
|
|
6444
|
+
"type": "type",
|
|
6445
|
+
"named": true
|
|
6446
|
+
}
|
|
6447
|
+
]
|
|
6448
|
+
},
|
|
6325
6449
|
"condition": {
|
|
6326
6450
|
"multiple": false,
|
|
6327
6451
|
"required": true,
|
|
@@ -6355,12 +6479,30 @@
|
|
|
6355
6479
|
"named": true
|
|
6356
6480
|
}
|
|
6357
6481
|
]
|
|
6482
|
+
},
|
|
6483
|
+
"underlying_type": {
|
|
6484
|
+
"multiple": false,
|
|
6485
|
+
"required": false,
|
|
6486
|
+
"types": [
|
|
6487
|
+
{
|
|
6488
|
+
"type": "type",
|
|
6489
|
+
"named": true
|
|
6490
|
+
}
|
|
6491
|
+
]
|
|
6358
6492
|
}
|
|
6359
6493
|
},
|
|
6360
6494
|
"children": {
|
|
6361
6495
|
"multiple": true,
|
|
6362
6496
|
"required": false,
|
|
6363
6497
|
"types": [
|
|
6498
|
+
{
|
|
6499
|
+
"type": "argument_list",
|
|
6500
|
+
"named": true
|
|
6501
|
+
},
|
|
6502
|
+
{
|
|
6503
|
+
"type": "base_list",
|
|
6504
|
+
"named": true
|
|
6505
|
+
},
|
|
6364
6506
|
{
|
|
6365
6507
|
"type": "declaration",
|
|
6366
6508
|
"named": true
|
|
@@ -6567,44 +6709,6 @@
|
|
|
6567
6709
|
]
|
|
6568
6710
|
}
|
|
6569
6711
|
},
|
|
6570
|
-
{
|
|
6571
|
-
"type": "primary_constructor_base_type",
|
|
6572
|
-
"named": true,
|
|
6573
|
-
"fields": {
|
|
6574
|
-
"type": {
|
|
6575
|
-
"multiple": false,
|
|
6576
|
-
"required": true,
|
|
6577
|
-
"types": [
|
|
6578
|
-
{
|
|
6579
|
-
"type": "alias_qualified_name",
|
|
6580
|
-
"named": true
|
|
6581
|
-
},
|
|
6582
|
-
{
|
|
6583
|
-
"type": "generic_name",
|
|
6584
|
-
"named": true
|
|
6585
|
-
},
|
|
6586
|
-
{
|
|
6587
|
-
"type": "identifier",
|
|
6588
|
-
"named": true
|
|
6589
|
-
},
|
|
6590
|
-
{
|
|
6591
|
-
"type": "qualified_name",
|
|
6592
|
-
"named": true
|
|
6593
|
-
}
|
|
6594
|
-
]
|
|
6595
|
-
}
|
|
6596
|
-
},
|
|
6597
|
-
"children": {
|
|
6598
|
-
"multiple": false,
|
|
6599
|
-
"required": true,
|
|
6600
|
-
"types": [
|
|
6601
|
-
{
|
|
6602
|
-
"type": "argument_list",
|
|
6603
|
-
"named": true
|
|
6604
|
-
}
|
|
6605
|
-
]
|
|
6606
|
-
}
|
|
6607
|
-
},
|
|
6608
6712
|
{
|
|
6609
6713
|
"type": "property_declaration",
|
|
6610
6714
|
"named": true,
|
|
@@ -6863,6 +6967,16 @@
|
|
|
6863
6967
|
"type": "record_declaration",
|
|
6864
6968
|
"named": true,
|
|
6865
6969
|
"fields": {
|
|
6970
|
+
"base": {
|
|
6971
|
+
"multiple": true,
|
|
6972
|
+
"required": false,
|
|
6973
|
+
"types": [
|
|
6974
|
+
{
|
|
6975
|
+
"type": "type",
|
|
6976
|
+
"named": true
|
|
6977
|
+
}
|
|
6978
|
+
]
|
|
6979
|
+
},
|
|
6866
6980
|
"body": {
|
|
6867
6981
|
"multiple": false,
|
|
6868
6982
|
"required": false,
|
|
@@ -6888,6 +7002,10 @@
|
|
|
6888
7002
|
"multiple": true,
|
|
6889
7003
|
"required": false,
|
|
6890
7004
|
"types": [
|
|
7005
|
+
{
|
|
7006
|
+
"type": "argument_list",
|
|
7007
|
+
"named": true
|
|
7008
|
+
},
|
|
6891
7009
|
{
|
|
6892
7010
|
"type": "attribute_list",
|
|
6893
7011
|
"named": true
|
|
@@ -6904,6 +7022,10 @@
|
|
|
6904
7022
|
"type": "parameter_list",
|
|
6905
7023
|
"named": true
|
|
6906
7024
|
},
|
|
7025
|
+
{
|
|
7026
|
+
"type": "preproc_if",
|
|
7027
|
+
"named": true
|
|
7028
|
+
},
|
|
6907
7029
|
{
|
|
6908
7030
|
"type": "preproc_if_in_attribute_list",
|
|
6909
7031
|
"named": true
|
|
@@ -7255,6 +7377,16 @@
|
|
|
7255
7377
|
"type": "struct_declaration",
|
|
7256
7378
|
"named": true,
|
|
7257
7379
|
"fields": {
|
|
7380
|
+
"base": {
|
|
7381
|
+
"multiple": true,
|
|
7382
|
+
"required": false,
|
|
7383
|
+
"types": [
|
|
7384
|
+
{
|
|
7385
|
+
"type": "type",
|
|
7386
|
+
"named": true
|
|
7387
|
+
}
|
|
7388
|
+
]
|
|
7389
|
+
},
|
|
7258
7390
|
"body": {
|
|
7259
7391
|
"multiple": false,
|
|
7260
7392
|
"required": false,
|
|
@@ -7280,6 +7412,10 @@
|
|
|
7280
7412
|
"multiple": true,
|
|
7281
7413
|
"required": false,
|
|
7282
7414
|
"types": [
|
|
7415
|
+
{
|
|
7416
|
+
"type": "argument_list",
|
|
7417
|
+
"named": true
|
|
7418
|
+
},
|
|
7283
7419
|
{
|
|
7284
7420
|
"type": "attribute_list",
|
|
7285
7421
|
"named": true
|
|
@@ -7296,6 +7432,10 @@
|
|
|
7296
7432
|
"type": "parameter_list",
|
|
7297
7433
|
"named": true
|
|
7298
7434
|
},
|
|
7435
|
+
{
|
|
7436
|
+
"type": "preproc_if",
|
|
7437
|
+
"named": true
|
|
7438
|
+
},
|
|
7299
7439
|
{
|
|
7300
7440
|
"type": "preproc_if_in_attribute_list",
|
|
7301
7441
|
"named": true
|
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|