@willbooster/tree-sitter-c-sharp 9.0.0 → 10.0.1
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 +270 -29
- package/package.json +1 -1
- package/queries/highlights.scm +6 -4
- package/queries/tags.scm +1 -3
- package/src/node-types.json +190 -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' | '_namespace_body_item' | '_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,
|
|
@@ -391,7 +421,20 @@ module.exports = grammar({
|
|
|
391
421
|
_namespace_member_declaration: ($) => choice($.namespace_declaration, $.type_declaration),
|
|
392
422
|
|
|
393
423
|
namespace_declaration: ($) =>
|
|
394
|
-
seq(
|
|
424
|
+
seq(
|
|
425
|
+
'namespace',
|
|
426
|
+
field('name', $._name),
|
|
427
|
+
field('body', alias($._namespace_body, $.declaration_list)),
|
|
428
|
+
sym('_optional_semi')
|
|
429
|
+
),
|
|
430
|
+
|
|
431
|
+
_namespace_body: ($) => seq('{', repeat($._namespace_body_item), blockEnd()),
|
|
432
|
+
|
|
433
|
+
_namespace_body_item: ($) =>
|
|
434
|
+
prec(
|
|
435
|
+
1,
|
|
436
|
+
choice($.extern_alias_directive, $.declaration, alias(sym('preproc_if_in_namespace'), sym('preproc_if')))
|
|
437
|
+
),
|
|
395
438
|
|
|
396
439
|
file_scoped_namespace_declaration: ($) =>
|
|
397
440
|
prec.right(seq('namespace', field('name', $._name), statementEnd(), repeat($._top_level_item_no_statement))),
|
|
@@ -414,7 +457,9 @@ module.exports = grammar({
|
|
|
414
457
|
repeat($.modifier),
|
|
415
458
|
'class',
|
|
416
459
|
field('name', $.identifier),
|
|
417
|
-
|
|
460
|
+
optional($.type_parameter_list),
|
|
461
|
+
optional($.parameter_list),
|
|
462
|
+
optional($._base_list),
|
|
418
463
|
repeat($.type_parameter_constraints_clause)
|
|
419
464
|
),
|
|
420
465
|
|
|
@@ -427,7 +472,9 @@ module.exports = grammar({
|
|
|
427
472
|
optional(seq('ref', optional(alias('partial', $.modifier)))),
|
|
428
473
|
'struct',
|
|
429
474
|
field('name', $.identifier),
|
|
430
|
-
|
|
475
|
+
optional($.type_parameter_list),
|
|
476
|
+
optional($.parameter_list),
|
|
477
|
+
optional($._base_list),
|
|
431
478
|
repeat($.type_parameter_constraints_clause)
|
|
432
479
|
),
|
|
433
480
|
|
|
@@ -438,7 +485,13 @@ module.exports = grammar({
|
|
|
438
485
|
),
|
|
439
486
|
|
|
440
487
|
_enum_declaration_initializer: ($) =>
|
|
441
|
-
seq(
|
|
488
|
+
seq(
|
|
489
|
+
repeat($._attribute_list),
|
|
490
|
+
repeat($.modifier),
|
|
491
|
+
'enum',
|
|
492
|
+
field('name', $.identifier),
|
|
493
|
+
optional($._enum_base_clause)
|
|
494
|
+
),
|
|
442
495
|
|
|
443
496
|
enum_member_declaration_list: ($) =>
|
|
444
497
|
seq(
|
|
@@ -462,7 +515,7 @@ module.exports = grammar({
|
|
|
462
515
|
'interface',
|
|
463
516
|
field('name', $.identifier),
|
|
464
517
|
field('type_parameters', optional($.type_parameter_list)),
|
|
465
|
-
optional($.
|
|
518
|
+
optional($._base_list),
|
|
466
519
|
repeat($.type_parameter_constraints_clause)
|
|
467
520
|
),
|
|
468
521
|
|
|
@@ -489,22 +542,15 @@ module.exports = grammar({
|
|
|
489
542
|
'record',
|
|
490
543
|
optional(choice('class', 'struct')),
|
|
491
544
|
field('name', $.identifier),
|
|
492
|
-
|
|
493
|
-
optional(
|
|
545
|
+
optional($.type_parameter_list),
|
|
546
|
+
optional($.parameter_list),
|
|
547
|
+
optional($._base_list),
|
|
494
548
|
repeat($.type_parameter_constraints_clause)
|
|
495
549
|
),
|
|
496
550
|
|
|
497
|
-
record_base: ($) =>
|
|
498
|
-
choice(
|
|
499
|
-
seq(':', commaSep1($._name)),
|
|
500
|
-
seq(':', $.primary_constructor_base_type, optional(seq(',', commaSep1($._name))))
|
|
501
|
-
),
|
|
502
|
-
|
|
503
551
|
_declaration_list_body: ($) =>
|
|
504
552
|
choice(seq(field('body', $.declaration_list), sym('_optional_semi')), statementEnd()),
|
|
505
553
|
|
|
506
|
-
primary_constructor_base_type: ($) => seq(field('type', $._name), $.argument_list),
|
|
507
|
-
|
|
508
554
|
modifier: () =>
|
|
509
555
|
prec.right(
|
|
510
556
|
choice(
|
|
@@ -537,7 +583,88 @@ module.exports = grammar({
|
|
|
537
583
|
|
|
538
584
|
type_parameter: ($) => seq(repeat($._attribute_list), optional(choice('in', 'out')), field('name', $.identifier)),
|
|
539
585
|
|
|
540
|
-
|
|
586
|
+
_enum_base_clause: ($) => choice(alias($._enum_base_list, $.base_list), $._conditional_enum_base_clause),
|
|
587
|
+
|
|
588
|
+
_conditional_enum_base_clause: ($) =>
|
|
589
|
+
seq(alias(sym('preproc_if_in_enum_base_clause'), sym('preproc_if')), optional($._enum_base_clause)),
|
|
590
|
+
|
|
591
|
+
_enum_base_list: ($) => seq(':', $._enum_base_type),
|
|
592
|
+
|
|
593
|
+
_enum_base_type: ($) =>
|
|
594
|
+
seq(
|
|
595
|
+
repeat($._base_list_trivia),
|
|
596
|
+
choice(field('underlying_type', $.type), $._conditional_enum_base_type),
|
|
597
|
+
repeat($._base_list_trivia)
|
|
598
|
+
),
|
|
599
|
+
|
|
600
|
+
_conditional_enum_base_type: ($) =>
|
|
601
|
+
choice(
|
|
602
|
+
alias(sym('preproc_if_in_enum_base_type'), sym('preproc_if')),
|
|
603
|
+
seq(
|
|
604
|
+
$._conditional_enum_base_type,
|
|
605
|
+
repeat($._base_list_trivia),
|
|
606
|
+
alias(sym('preproc_if_in_enum_base_type'), sym('preproc_if'))
|
|
607
|
+
)
|
|
608
|
+
),
|
|
609
|
+
|
|
610
|
+
_base_list_trivia: () => alias(sym('preproc_if_in_empty_base'), sym('preproc_if')),
|
|
611
|
+
|
|
612
|
+
_base_list: ($) => choice($.base_list, $._conditional_base_list),
|
|
613
|
+
|
|
614
|
+
_conditional_base_list: ($) =>
|
|
615
|
+
seq(
|
|
616
|
+
alias(sym('preproc_if_in_base_list'), sym('preproc_if')),
|
|
617
|
+
optional(choice($._base_list_suffix, $._base_list))
|
|
618
|
+
),
|
|
619
|
+
|
|
620
|
+
base_list: ($) => seq(':', $._base_list_type),
|
|
621
|
+
|
|
622
|
+
_base_list_type: ($) =>
|
|
623
|
+
choice(
|
|
624
|
+
seq($._base_list_mixed_type, choice($._base_list_type, $._base_list_suffix)),
|
|
625
|
+
seq(alias(sym('preproc_if_in_base_list_prefix'), sym('preproc_if')), $._base_list_type),
|
|
626
|
+
seq($._base_list_head, optional($._base_list_suffix))
|
|
627
|
+
),
|
|
628
|
+
|
|
629
|
+
_base_list_head: ($) =>
|
|
630
|
+
choice(seq(field('base', $.type), optional($.argument_list)), $._conditional_base_list_head),
|
|
631
|
+
|
|
632
|
+
_conditional_base_list_head: ($) =>
|
|
633
|
+
choice(
|
|
634
|
+
alias(sym('preproc_if_in_base_list_type'), sym('preproc_if')),
|
|
635
|
+
seq(
|
|
636
|
+
$._conditional_base_list_head,
|
|
637
|
+
repeat($._base_list_trivia),
|
|
638
|
+
alias(sym('preproc_if_in_base_list_type'), sym('preproc_if'))
|
|
639
|
+
)
|
|
640
|
+
),
|
|
641
|
+
|
|
642
|
+
_base_list_mixed_type: () => alias(sym('preproc_if_in_mixed_base_type'), sym('preproc_if')),
|
|
643
|
+
|
|
644
|
+
_base_list_mixed_suffix: () => alias(sym('preproc_if_in_mixed_base_suffix'), sym('preproc_if')),
|
|
645
|
+
|
|
646
|
+
_base_list_prefix: ($) =>
|
|
647
|
+
choice(
|
|
648
|
+
seq($._base_list_mixed_type, choice($._base_list_prefix, $._base_list_separator_path)),
|
|
649
|
+
seq(alias(sym('preproc_if_in_base_list_prefix'), sym('preproc_if')), optional($._base_list_prefix)),
|
|
650
|
+
seq($._base_list_head, $._base_list_separator_path)
|
|
651
|
+
),
|
|
652
|
+
|
|
653
|
+
_base_list_separator: () => choice(',', alias(sym('preproc_if_in_base_list_separator'), sym('preproc_if'))),
|
|
654
|
+
|
|
655
|
+
_base_list_separator_path: ($) =>
|
|
656
|
+
choice(
|
|
657
|
+
seq($._base_list_mixed_suffix, choice($._base_list_prefix, $._base_list_separator_path)),
|
|
658
|
+
seq(alias(sym('preproc_if_in_base_list_suffix'), sym('preproc_if')), $._base_list_separator_path),
|
|
659
|
+
seq($._base_list_separator, optional($._base_list_prefix))
|
|
660
|
+
),
|
|
661
|
+
|
|
662
|
+
_base_list_suffix: ($) =>
|
|
663
|
+
choice(
|
|
664
|
+
seq($._base_list_mixed_suffix, choice($._base_list_type, $._base_list_suffix)),
|
|
665
|
+
seq(alias(sym('preproc_if_in_base_list_suffix'), sym('preproc_if')), optional($._base_list_suffix)),
|
|
666
|
+
seq($._base_list_separator, $._base_list_type)
|
|
667
|
+
),
|
|
541
668
|
|
|
542
669
|
type_parameter_constraints_clause: ($) => seq('where', $.identifier, ':', commaSep1($.type_parameter_constraint)),
|
|
543
670
|
|
|
@@ -2336,6 +2463,37 @@ module.exports = grammar({
|
|
|
2336
2463
|
false,
|
|
2337
2464
|
true
|
|
2338
2465
|
),
|
|
2466
|
+
...preprocIf('_in_namespace', ($) => $._namespace_body_item, 1),
|
|
2467
|
+
...preprocIfWithMixedContent(
|
|
2468
|
+
'_in_mixed_base_type',
|
|
2469
|
+
($) => $._base_list_type,
|
|
2470
|
+
($) => $._base_list_prefix,
|
|
2471
|
+
($) =>
|
|
2472
|
+
choice(
|
|
2473
|
+
$._base_list_mixed_type,
|
|
2474
|
+
seq($._base_list_prefix, $._base_list_mixed_type),
|
|
2475
|
+
seq($._base_list_type, $._base_list_mixed_suffix)
|
|
2476
|
+
)
|
|
2477
|
+
),
|
|
2478
|
+
...preprocIfWithMixedContent(
|
|
2479
|
+
'_in_mixed_base_suffix',
|
|
2480
|
+
($) => $._base_list_suffix,
|
|
2481
|
+
($) => $._base_list_separator_path,
|
|
2482
|
+
($) =>
|
|
2483
|
+
choice(
|
|
2484
|
+
$._base_list_mixed_suffix,
|
|
2485
|
+
seq($._base_list_suffix, $._base_list_mixed_suffix),
|
|
2486
|
+
seq($._base_list_separator_path, $._base_list_mixed_type)
|
|
2487
|
+
)
|
|
2488
|
+
),
|
|
2489
|
+
...preprocIf('_in_empty_base', ($) => $._base_list_trivia),
|
|
2490
|
+
...preprocIf('_in_enum_base_clause', ($) => $._enum_base_clause, 0, false),
|
|
2491
|
+
...preprocIfWithContent('_in_enum_base_type', ($) => $._enum_base_type),
|
|
2492
|
+
...preprocIf('_in_base_list', ($) => $._base_list, 0, false),
|
|
2493
|
+
...preprocIfWithContent('_in_base_list_type', ($) => $._base_list_type),
|
|
2494
|
+
...preprocIf('_in_base_list_prefix', ($) => $._base_list_prefix, 0, false),
|
|
2495
|
+
...preprocIf('_in_base_list_separator', ($) => $._base_list_separator_path, 0, false, true),
|
|
2496
|
+
...preprocIf('_in_base_list_suffix', ($) => $._base_list_suffix, 0, false),
|
|
2339
2497
|
...preprocIf('', ($) => $.declaration),
|
|
2340
2498
|
...preprocIf('_in_top_level', ($) => choice($._top_level_item_no_statement, $.statement)),
|
|
2341
2499
|
...preprocIf('_in_expression', ($) => $.expression, -2, false),
|
|
@@ -2612,6 +2770,87 @@ function preprocessor(command) {
|
|
|
2612
2770
|
return alias(new RegExp('#[ \t]*' + command), '#' + command);
|
|
2613
2771
|
}
|
|
2614
2772
|
|
|
2773
|
+
/**
|
|
2774
|
+
* @param {string} suffix
|
|
2775
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} complete
|
|
2776
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} prefix
|
|
2777
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} mixed
|
|
2778
|
+
* @returns {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>}
|
|
2779
|
+
*/
|
|
2780
|
+
function preprocIfWithMixedContent(suffix, complete, prefix, mixed) {
|
|
2781
|
+
const contents = [undefined, complete, prefix, mixed];
|
|
2782
|
+
/** @param {number} mask */
|
|
2783
|
+
function alternativeBlock(mask) {
|
|
2784
|
+
return choice(
|
|
2785
|
+
alias(sym('preproc_else' + suffix + mask), sym('preproc_else')),
|
|
2786
|
+
alias(sym('preproc_elif' + suffix + mask), sym('preproc_elif'))
|
|
2787
|
+
);
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
|
2791
|
+
* @param {number} mask
|
|
2792
|
+
*/
|
|
2793
|
+
function contentOrAlternative($, mask) {
|
|
2794
|
+
return choice(
|
|
2795
|
+
...contents.map((content, provided) => {
|
|
2796
|
+
const remaining = mask & ~provided;
|
|
2797
|
+
const alternative = field(
|
|
2798
|
+
'alternative',
|
|
2799
|
+
remaining ? alternativeBlock(remaining) : optional(alternativeBlock(0))
|
|
2800
|
+
);
|
|
2801
|
+
return content ? seq(content($), alternative) : alternative;
|
|
2802
|
+
})
|
|
2803
|
+
);
|
|
2804
|
+
}
|
|
2805
|
+
/** @type {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>} */
|
|
2806
|
+
const rules = {
|
|
2807
|
+
['preproc_if' + suffix]: ($) => conditionalDirective('if', $, contentOrAlternative($, 3), preprocessor('endif')),
|
|
2808
|
+
};
|
|
2809
|
+
for (const mask of [0, 1, 2, 3]) {
|
|
2810
|
+
rules['preproc_elif' + suffix + mask] = ($) => conditionalDirective('elif', $, contentOrAlternative($, mask));
|
|
2811
|
+
rules['preproc_else' + suffix + mask] = ($) =>
|
|
2812
|
+
seq(
|
|
2813
|
+
preprocessor('else'),
|
|
2814
|
+
choice(
|
|
2815
|
+
...contents.flatMap((content, provided) => (content && (provided & mask) === mask ? [content($)] : [])),
|
|
2816
|
+
...(mask === 0 ? [optional($._base_list_trivia)] : [])
|
|
2817
|
+
)
|
|
2818
|
+
);
|
|
2819
|
+
}
|
|
2820
|
+
return rules;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
/**
|
|
2824
|
+
* @param {string} suffix
|
|
2825
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} content
|
|
2826
|
+
* @returns {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>}
|
|
2827
|
+
*/
|
|
2828
|
+
function preprocIfWithContent(suffix, content) {
|
|
2829
|
+
/** @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $ */
|
|
2830
|
+
function contentOrAlternative($) {
|
|
2831
|
+
return choice(
|
|
2832
|
+
seq(content($), field('alternative', optional(alternativeBlock(false)))),
|
|
2833
|
+
seq(repeat($._base_list_trivia), field('alternative', alternativeBlock(true)))
|
|
2834
|
+
);
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
/** @param {boolean} required */
|
|
2838
|
+
function alternativeBlock(required) {
|
|
2839
|
+
const alternativeSuffix = suffix + (required ? '_with_content' : '');
|
|
2840
|
+
return choice(
|
|
2841
|
+
alias(sym('preproc_else' + alternativeSuffix), sym('preproc_else')),
|
|
2842
|
+
alias(sym('preproc_elif' + alternativeSuffix), sym('preproc_elif'))
|
|
2843
|
+
);
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
return {
|
|
2847
|
+
...preprocIf(suffix, ($) => choice(content($), repeat1($._base_list_trivia)), 0, false),
|
|
2848
|
+
['preproc_if' + suffix]: ($) => conditionalDirective('if', $, contentOrAlternative($), preprocessor('endif')),
|
|
2849
|
+
['preproc_else' + suffix + '_with_content']: ($) => seq(preprocessor('else'), content($)),
|
|
2850
|
+
['preproc_elif' + suffix + '_with_content']: ($) => conditionalDirective('elif', $, contentOrAlternative($)),
|
|
2851
|
+
};
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2615
2854
|
/**
|
|
2616
2855
|
*
|
|
2617
2856
|
* @param {string} suffix
|
|
@@ -2648,10 +2887,9 @@ function preprocIf(suffix, content, precedence = 0, rep = true, required = false
|
|
|
2648
2887
|
['preproc_if' + suffix]: ($) =>
|
|
2649
2888
|
prec(
|
|
2650
2889
|
precedence,
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
directiveNewLine(),
|
|
2890
|
+
conditionalDirective(
|
|
2891
|
+
'if',
|
|
2892
|
+
$,
|
|
2655
2893
|
contentRule($),
|
|
2656
2894
|
field('alternative', optional(alternativeBlock())),
|
|
2657
2895
|
preprocessor('endif')
|
|
@@ -2663,17 +2901,20 @@ function preprocIf(suffix, content, precedence = 0, rep = true, required = false
|
|
|
2663
2901
|
['preproc_elif' + suffix]: ($) =>
|
|
2664
2902
|
prec(
|
|
2665
2903
|
precedence,
|
|
2666
|
-
|
|
2667
|
-
preprocessor('elif'),
|
|
2668
|
-
field('condition', $._preproc_expression),
|
|
2669
|
-
directiveNewLine(),
|
|
2670
|
-
contentRule($),
|
|
2671
|
-
field('alternative', optional(alternativeBlock()))
|
|
2672
|
-
)
|
|
2904
|
+
conditionalDirective('elif', $, contentRule($), field('alternative', optional(alternativeBlock())))
|
|
2673
2905
|
),
|
|
2674
2906
|
};
|
|
2675
2907
|
}
|
|
2676
2908
|
|
|
2909
|
+
/**
|
|
2910
|
+
* @param {'if' | 'elif'} command
|
|
2911
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
|
2912
|
+
* @param {...import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} content
|
|
2913
|
+
*/
|
|
2914
|
+
function conditionalDirective(command, $, ...content) {
|
|
2915
|
+
return seq(preprocessor(command), field('condition', $._preproc_expression), directiveNewLine(), ...content);
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2677
2918
|
/**
|
|
2678
2919
|
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'_simple_name'>} $
|
|
2679
2920
|
* @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
|
|
@@ -2663,6 +2698,10 @@
|
|
|
2663
2698
|
{
|
|
2664
2699
|
"type": "declaration",
|
|
2665
2700
|
"named": true
|
|
2701
|
+
},
|
|
2702
|
+
{
|
|
2703
|
+
"type": "extern_alias_directive",
|
|
2704
|
+
"named": true
|
|
2666
2705
|
}
|
|
2667
2706
|
]
|
|
2668
2707
|
}
|
|
@@ -3123,6 +3162,10 @@
|
|
|
3123
3162
|
"type": "modifier",
|
|
3124
3163
|
"named": true
|
|
3125
3164
|
},
|
|
3165
|
+
{
|
|
3166
|
+
"type": "preproc_if",
|
|
3167
|
+
"named": true
|
|
3168
|
+
},
|
|
3126
3169
|
{
|
|
3127
3170
|
"type": "preproc_if_in_attribute_list",
|
|
3128
3171
|
"named": true
|
|
@@ -4199,6 +4242,16 @@
|
|
|
4199
4242
|
"type": "interface_declaration",
|
|
4200
4243
|
"named": true,
|
|
4201
4244
|
"fields": {
|
|
4245
|
+
"base": {
|
|
4246
|
+
"multiple": true,
|
|
4247
|
+
"required": false,
|
|
4248
|
+
"types": [
|
|
4249
|
+
{
|
|
4250
|
+
"type": "type",
|
|
4251
|
+
"named": true
|
|
4252
|
+
}
|
|
4253
|
+
]
|
|
4254
|
+
},
|
|
4202
4255
|
"body": {
|
|
4203
4256
|
"multiple": false,
|
|
4204
4257
|
"required": false,
|
|
@@ -4234,6 +4287,10 @@
|
|
|
4234
4287
|
"multiple": true,
|
|
4235
4288
|
"required": false,
|
|
4236
4289
|
"types": [
|
|
4290
|
+
{
|
|
4291
|
+
"type": "argument_list",
|
|
4292
|
+
"named": true
|
|
4293
|
+
},
|
|
4237
4294
|
{
|
|
4238
4295
|
"type": "attribute_list",
|
|
4239
4296
|
"named": true
|
|
@@ -4246,6 +4303,10 @@
|
|
|
4246
4303
|
"type": "modifier",
|
|
4247
4304
|
"named": true
|
|
4248
4305
|
},
|
|
4306
|
+
{
|
|
4307
|
+
"type": "preproc_if",
|
|
4308
|
+
"named": true
|
|
4309
|
+
},
|
|
4249
4310
|
{
|
|
4250
4311
|
"type": "preproc_if_in_attribute_list",
|
|
4251
4312
|
"named": true
|
|
@@ -6138,6 +6199,16 @@
|
|
|
6138
6199
|
}
|
|
6139
6200
|
]
|
|
6140
6201
|
},
|
|
6202
|
+
"base": {
|
|
6203
|
+
"multiple": true,
|
|
6204
|
+
"required": false,
|
|
6205
|
+
"types": [
|
|
6206
|
+
{
|
|
6207
|
+
"type": "type",
|
|
6208
|
+
"named": true
|
|
6209
|
+
}
|
|
6210
|
+
]
|
|
6211
|
+
},
|
|
6141
6212
|
"condition": {
|
|
6142
6213
|
"multiple": false,
|
|
6143
6214
|
"required": true,
|
|
@@ -6171,16 +6242,34 @@
|
|
|
6171
6242
|
"named": true
|
|
6172
6243
|
}
|
|
6173
6244
|
]
|
|
6245
|
+
},
|
|
6246
|
+
"underlying_type": {
|
|
6247
|
+
"multiple": false,
|
|
6248
|
+
"required": false,
|
|
6249
|
+
"types": [
|
|
6250
|
+
{
|
|
6251
|
+
"type": "type",
|
|
6252
|
+
"named": true
|
|
6253
|
+
}
|
|
6254
|
+
]
|
|
6174
6255
|
}
|
|
6175
6256
|
},
|
|
6176
6257
|
"children": {
|
|
6177
6258
|
"multiple": true,
|
|
6178
6259
|
"required": false,
|
|
6179
6260
|
"types": [
|
|
6261
|
+
{
|
|
6262
|
+
"type": "argument_list",
|
|
6263
|
+
"named": true
|
|
6264
|
+
},
|
|
6180
6265
|
{
|
|
6181
6266
|
"type": "attribute_list",
|
|
6182
6267
|
"named": true
|
|
6183
6268
|
},
|
|
6269
|
+
{
|
|
6270
|
+
"type": "base_list",
|
|
6271
|
+
"named": true
|
|
6272
|
+
},
|
|
6184
6273
|
{
|
|
6185
6274
|
"type": "declaration",
|
|
6186
6275
|
"named": true
|
|
@@ -6223,15 +6312,44 @@
|
|
|
6223
6312
|
{
|
|
6224
6313
|
"type": "preproc_else",
|
|
6225
6314
|
"named": true,
|
|
6226
|
-
"fields": {
|
|
6315
|
+
"fields": {
|
|
6316
|
+
"base": {
|
|
6317
|
+
"multiple": true,
|
|
6318
|
+
"required": false,
|
|
6319
|
+
"types": [
|
|
6320
|
+
{
|
|
6321
|
+
"type": "type",
|
|
6322
|
+
"named": true
|
|
6323
|
+
}
|
|
6324
|
+
]
|
|
6325
|
+
},
|
|
6326
|
+
"underlying_type": {
|
|
6327
|
+
"multiple": false,
|
|
6328
|
+
"required": false,
|
|
6329
|
+
"types": [
|
|
6330
|
+
{
|
|
6331
|
+
"type": "type",
|
|
6332
|
+
"named": true
|
|
6333
|
+
}
|
|
6334
|
+
]
|
|
6335
|
+
}
|
|
6336
|
+
},
|
|
6227
6337
|
"children": {
|
|
6228
6338
|
"multiple": true,
|
|
6229
6339
|
"required": false,
|
|
6230
6340
|
"types": [
|
|
6341
|
+
{
|
|
6342
|
+
"type": "argument_list",
|
|
6343
|
+
"named": true
|
|
6344
|
+
},
|
|
6231
6345
|
{
|
|
6232
6346
|
"type": "attribute_list",
|
|
6233
6347
|
"named": true
|
|
6234
6348
|
},
|
|
6349
|
+
{
|
|
6350
|
+
"type": "base_list",
|
|
6351
|
+
"named": true
|
|
6352
|
+
},
|
|
6235
6353
|
{
|
|
6236
6354
|
"type": "declaration",
|
|
6237
6355
|
"named": true
|
|
@@ -6322,6 +6440,16 @@
|
|
|
6322
6440
|
}
|
|
6323
6441
|
]
|
|
6324
6442
|
},
|
|
6443
|
+
"base": {
|
|
6444
|
+
"multiple": true,
|
|
6445
|
+
"required": false,
|
|
6446
|
+
"types": [
|
|
6447
|
+
{
|
|
6448
|
+
"type": "type",
|
|
6449
|
+
"named": true
|
|
6450
|
+
}
|
|
6451
|
+
]
|
|
6452
|
+
},
|
|
6325
6453
|
"condition": {
|
|
6326
6454
|
"multiple": false,
|
|
6327
6455
|
"required": true,
|
|
@@ -6355,12 +6483,30 @@
|
|
|
6355
6483
|
"named": true
|
|
6356
6484
|
}
|
|
6357
6485
|
]
|
|
6486
|
+
},
|
|
6487
|
+
"underlying_type": {
|
|
6488
|
+
"multiple": false,
|
|
6489
|
+
"required": false,
|
|
6490
|
+
"types": [
|
|
6491
|
+
{
|
|
6492
|
+
"type": "type",
|
|
6493
|
+
"named": true
|
|
6494
|
+
}
|
|
6495
|
+
]
|
|
6358
6496
|
}
|
|
6359
6497
|
},
|
|
6360
6498
|
"children": {
|
|
6361
6499
|
"multiple": true,
|
|
6362
6500
|
"required": false,
|
|
6363
6501
|
"types": [
|
|
6502
|
+
{
|
|
6503
|
+
"type": "argument_list",
|
|
6504
|
+
"named": true
|
|
6505
|
+
},
|
|
6506
|
+
{
|
|
6507
|
+
"type": "base_list",
|
|
6508
|
+
"named": true
|
|
6509
|
+
},
|
|
6364
6510
|
{
|
|
6365
6511
|
"type": "declaration",
|
|
6366
6512
|
"named": true
|
|
@@ -6567,44 +6713,6 @@
|
|
|
6567
6713
|
]
|
|
6568
6714
|
}
|
|
6569
6715
|
},
|
|
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
6716
|
{
|
|
6609
6717
|
"type": "property_declaration",
|
|
6610
6718
|
"named": true,
|
|
@@ -6863,6 +6971,16 @@
|
|
|
6863
6971
|
"type": "record_declaration",
|
|
6864
6972
|
"named": true,
|
|
6865
6973
|
"fields": {
|
|
6974
|
+
"base": {
|
|
6975
|
+
"multiple": true,
|
|
6976
|
+
"required": false,
|
|
6977
|
+
"types": [
|
|
6978
|
+
{
|
|
6979
|
+
"type": "type",
|
|
6980
|
+
"named": true
|
|
6981
|
+
}
|
|
6982
|
+
]
|
|
6983
|
+
},
|
|
6866
6984
|
"body": {
|
|
6867
6985
|
"multiple": false,
|
|
6868
6986
|
"required": false,
|
|
@@ -6888,6 +7006,10 @@
|
|
|
6888
7006
|
"multiple": true,
|
|
6889
7007
|
"required": false,
|
|
6890
7008
|
"types": [
|
|
7009
|
+
{
|
|
7010
|
+
"type": "argument_list",
|
|
7011
|
+
"named": true
|
|
7012
|
+
},
|
|
6891
7013
|
{
|
|
6892
7014
|
"type": "attribute_list",
|
|
6893
7015
|
"named": true
|
|
@@ -6904,6 +7026,10 @@
|
|
|
6904
7026
|
"type": "parameter_list",
|
|
6905
7027
|
"named": true
|
|
6906
7028
|
},
|
|
7029
|
+
{
|
|
7030
|
+
"type": "preproc_if",
|
|
7031
|
+
"named": true
|
|
7032
|
+
},
|
|
6907
7033
|
{
|
|
6908
7034
|
"type": "preproc_if_in_attribute_list",
|
|
6909
7035
|
"named": true
|
|
@@ -7255,6 +7381,16 @@
|
|
|
7255
7381
|
"type": "struct_declaration",
|
|
7256
7382
|
"named": true,
|
|
7257
7383
|
"fields": {
|
|
7384
|
+
"base": {
|
|
7385
|
+
"multiple": true,
|
|
7386
|
+
"required": false,
|
|
7387
|
+
"types": [
|
|
7388
|
+
{
|
|
7389
|
+
"type": "type",
|
|
7390
|
+
"named": true
|
|
7391
|
+
}
|
|
7392
|
+
]
|
|
7393
|
+
},
|
|
7258
7394
|
"body": {
|
|
7259
7395
|
"multiple": false,
|
|
7260
7396
|
"required": false,
|
|
@@ -7280,6 +7416,10 @@
|
|
|
7280
7416
|
"multiple": true,
|
|
7281
7417
|
"required": false,
|
|
7282
7418
|
"types": [
|
|
7419
|
+
{
|
|
7420
|
+
"type": "argument_list",
|
|
7421
|
+
"named": true
|
|
7422
|
+
},
|
|
7283
7423
|
{
|
|
7284
7424
|
"type": "attribute_list",
|
|
7285
7425
|
"named": true
|
|
@@ -7296,6 +7436,10 @@
|
|
|
7296
7436
|
"type": "parameter_list",
|
|
7297
7437
|
"named": true
|
|
7298
7438
|
},
|
|
7439
|
+
{
|
|
7440
|
+
"type": "preproc_if",
|
|
7441
|
+
"named": true
|
|
7442
|
+
},
|
|
7299
7443
|
{
|
|
7300
7444
|
"type": "preproc_if_in_attribute_list",
|
|
7301
7445
|
"named": true
|
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|