@willbooster/tree-sitter-c-sharp 14.1.1 → 14.1.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 +30 -7
- package/package.json +1 -1
- package/src/node-types.json +10 -0
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +2 -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' | '_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 */
|
|
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' | '_dangling_else_if_statement' | 'attribute_list' | 'declaration' | 'enum_member_declaration' | 'expression' | 'if_statement' | 'method_signature' | 'statement'} PreprocContentRule */
|
|
15
15
|
|
|
16
16
|
const PREC = {
|
|
17
17
|
GENERIC: 19,
|
|
@@ -348,6 +348,7 @@ module.exports = grammar({
|
|
|
348
348
|
sym('_pragma_text'),
|
|
349
349
|
sym('_expression_generic_end'),
|
|
350
350
|
sym('_definite_expression_generic_end'),
|
|
351
|
+
sym('_if_alternative_directive'),
|
|
351
352
|
],
|
|
352
353
|
|
|
353
354
|
extras: ($) => [
|
|
@@ -1456,15 +1457,23 @@ module.exports = grammar({
|
|
|
1456
1457
|
if_statement: ($) =>
|
|
1457
1458
|
prec.right(
|
|
1458
1459
|
seq(
|
|
1459
|
-
|
|
1460
|
-
'(',
|
|
1461
|
-
field('condition', $.expression),
|
|
1462
|
-
')',
|
|
1463
|
-
field('consequence', $.statement),
|
|
1460
|
+
$._if_statement_head,
|
|
1461
|
+
repeat(seq(sym('_if_alternative_directive'), alias(sym('preproc_if_in_if_alternative'), sym('preproc_if')))),
|
|
1464
1462
|
optional(seq('else', field('alternative', $.statement)))
|
|
1465
1463
|
)
|
|
1466
1464
|
),
|
|
1467
1465
|
|
|
1466
|
+
_if_statement_head: ($) => seq('if', '(', field('condition', $.expression), ')', field('consequence', $.statement)),
|
|
1467
|
+
|
|
1468
|
+
// An `else` directly before a conditional directive takes the statement after the directive as its body, which a
|
|
1469
|
+
// tree cannot attach across the directive boundary.
|
|
1470
|
+
_dangling_else_if_statement: ($) =>
|
|
1471
|
+
seq(
|
|
1472
|
+
$._if_statement_head,
|
|
1473
|
+
'else',
|
|
1474
|
+
optional(field('alternative', alias($._dangling_else_if_statement, $.if_statement)))
|
|
1475
|
+
),
|
|
1476
|
+
|
|
1468
1477
|
while_statement: ($) => seq('while', '(', field('condition', $.expression), ')', field('body', $.statement)),
|
|
1469
1478
|
|
|
1470
1479
|
local_declaration_statement: ($) =>
|
|
@@ -2699,7 +2708,9 @@ module.exports = grammar({
|
|
|
2699
2708
|
...preprocIf('_in_base_list_separator', ($) => $._base_list_separator_path, 0, false, true),
|
|
2700
2709
|
...preprocIf('_in_base_list_suffix', ($) => $._base_list_suffix, 0, false),
|
|
2701
2710
|
...preprocIf('', ($) => $.declaration),
|
|
2702
|
-
...preprocIf('_in_top_level', ($) =>
|
|
2711
|
+
...preprocIf('_in_top_level', ($) => conditionalStatements($), 0, false, true),
|
|
2712
|
+
...preprocIf('_in_if_alternative', ($) => seq(optional('else'), conditionalStatements($)), 0, false),
|
|
2713
|
+
|
|
2703
2714
|
...preprocIf('_in_expression', ($) => $.expression, -2, false),
|
|
2704
2715
|
...preprocIf('_in_enum_member_declaration', ($) => $.enum_member_declaration, 0, false),
|
|
2705
2716
|
...preprocIf('_in_attribute_list', ($) => $.attribute_list, -1, false),
|
|
@@ -3110,6 +3121,18 @@ function preprocIf(suffix, content, precedence = 0, rep = true, required = false
|
|
|
3110
3121
|
};
|
|
3111
3122
|
}
|
|
3112
3123
|
|
|
3124
|
+
/**
|
|
3125
|
+
* Statements of a conditional branch, where the last may be an if statement whose `else` body follows the directive.
|
|
3126
|
+
*
|
|
3127
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
|
3128
|
+
*/
|
|
3129
|
+
function conditionalStatements($) {
|
|
3130
|
+
return seq(
|
|
3131
|
+
repeat(choice($._top_level_item_no_statement, $.statement)),
|
|
3132
|
+
optional(alias($._dangling_else_if_statement, $.if_statement))
|
|
3133
|
+
);
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3113
3136
|
/**
|
|
3114
3137
|
* @param {'if' | 'elif'} command
|
|
3115
3138
|
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|
package/tree-sitter.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"external-files": [
|
|
20
20
|
"src/genericExpressions.h",
|
|
21
21
|
"src/identifierCharacters.h",
|
|
22
|
+
"src/ifAlternativeDirective.h",
|
|
22
23
|
"src/nullableRank.h",
|
|
23
24
|
"src/nullableTypes.h",
|
|
24
25
|
"src/questionContext.h",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
}
|
|
31
32
|
],
|
|
32
33
|
"metadata": {
|
|
33
|
-
"version": "14.1.
|
|
34
|
+
"version": "14.1.2",
|
|
34
35
|
"license": "MIT",
|
|
35
36
|
"description": "C# grammar for tree-sitter",
|
|
36
37
|
"authors": [
|