@willbooster/tree-sitter-c-sharp 1.0.5 → 1.0.6
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 +16 -10
- package/package.json +1 -1
- package/src/node-types.json +2 -29
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -970,7 +970,7 @@ module.exports = grammar({
|
|
|
970
970
|
),
|
|
971
971
|
|
|
972
972
|
// Uses '(' pattern ')' to create direct conflict with parenthesized_pattern
|
|
973
|
-
_parenthesized_pattern_with_designation: ($) => seq('(', $.pattern, ')', $.
|
|
973
|
+
_parenthesized_pattern_with_designation: ($) => seq('(', $.pattern, ')', $._simple_designation),
|
|
974
974
|
|
|
975
975
|
constant_pattern: ($) =>
|
|
976
976
|
choice(
|
|
@@ -1018,7 +1018,10 @@ module.exports = grammar({
|
|
|
1018
1018
|
|
|
1019
1019
|
parenthesized_pattern: ($) => seq('(', $.pattern, ')'),
|
|
1020
1020
|
|
|
1021
|
-
|
|
1021
|
+
// `var x` parses as a declaration_pattern with an implicit_type. `var (x, y)` also reads as a positional pattern
|
|
1022
|
+
// of type `var` or, after `is`, as an invocation of `o is var`; each of those carries the implicit_type's dynamic
|
|
1023
|
+
// precedence of 1, so this needs more.
|
|
1024
|
+
var_pattern: ($) => prec.dynamic(2, seq('var', $.parenthesized_variable_designation)),
|
|
1022
1025
|
|
|
1023
1026
|
// No associativity: tree-sitter 0.27 resolves a precedence tie with a right-associative reduce as a shift, which
|
|
1024
1027
|
// makes `case int when x:` and `x is A or nameof(y)` read `when` and `(y)` as a variable designation.
|
|
@@ -1033,7 +1036,7 @@ module.exports = grammar({
|
|
|
1033
1036
|
'[',
|
|
1034
1037
|
optional(seq(commaSep1(choice($.pattern, $.slice_pattern)), optional(','))),
|
|
1035
1038
|
']',
|
|
1036
|
-
optional($.
|
|
1039
|
+
optional($._simple_designation)
|
|
1037
1040
|
)
|
|
1038
1041
|
),
|
|
1039
1042
|
|
|
@@ -1052,7 +1055,7 @@ module.exports = grammar({
|
|
|
1052
1055
|
field('type', $._name),
|
|
1053
1056
|
$.positional_pattern_clause,
|
|
1054
1057
|
optional($.property_pattern_clause),
|
|
1055
|
-
$.
|
|
1058
|
+
$._simple_designation
|
|
1056
1059
|
)
|
|
1057
1060
|
),
|
|
1058
1061
|
// name followed by positional pattern WITHOUT variable designation
|
|
@@ -1061,19 +1064,19 @@ module.exports = grammar({
|
|
|
1061
1064
|
seq(field('type', $._name), $.positional_pattern_clause, optional($.property_pattern_clause))
|
|
1062
1065
|
),
|
|
1063
1066
|
// positional pattern with variable designation (no type prefix)
|
|
1064
|
-
prec.dynamic(1, seq($.positional_pattern_clause, $.
|
|
1067
|
+
prec.dynamic(1, seq($.positional_pattern_clause, $._simple_designation)),
|
|
1065
1068
|
// positional pattern without variable designation (no type prefix)
|
|
1066
1069
|
$.positional_pattern_clause,
|
|
1067
1070
|
// other type followed by pattern clauses (type is required here to avoid ambiguity)
|
|
1068
1071
|
seq(
|
|
1069
1072
|
field('type', $.type),
|
|
1070
1073
|
choice(seq($.positional_pattern_clause, optional($.property_pattern_clause)), $.property_pattern_clause),
|
|
1071
|
-
optional($.
|
|
1074
|
+
optional($._simple_designation)
|
|
1072
1075
|
),
|
|
1073
1076
|
// no type, just pattern clauses (no variable designation to avoid conflict with above)
|
|
1074
1077
|
seq(
|
|
1075
1078
|
choice(seq($.positional_pattern_clause, $.property_pattern_clause), $.property_pattern_clause),
|
|
1076
|
-
optional($.
|
|
1079
|
+
optional($._simple_designation)
|
|
1077
1080
|
)
|
|
1078
1081
|
)
|
|
1079
1082
|
),
|
|
@@ -1095,10 +1098,13 @@ module.exports = grammar({
|
|
|
1095
1098
|
or_pattern: ($) =>
|
|
1096
1099
|
prec.left(PREC.OR, seq(field('left', $.pattern), field('operator', 'or'), field('right', $.pattern))),
|
|
1097
1100
|
|
|
1098
|
-
declaration_pattern: ($) => seq(field('type', $.type), $.
|
|
1101
|
+
declaration_pattern: ($) => seq(field('type', $.type), $._simple_designation),
|
|
1099
1102
|
|
|
1100
|
-
_variable_designation: ($) =>
|
|
1101
|
-
|
|
1103
|
+
_variable_designation: ($) => choice($._simple_designation, $.parenthesized_variable_designation),
|
|
1104
|
+
|
|
1105
|
+
// C# admits a parenthesized designation in a pattern only after `var`; elsewhere `T (x)` and `nameof(x)` are
|
|
1106
|
+
// positional patterns or invocations.
|
|
1107
|
+
_simple_designation: ($) => prec(1, choice($.discard, field('name', $.identifier))),
|
|
1102
1108
|
|
|
1103
1109
|
parenthesized_variable_designation: ($) => seq('(', commaSep($._variable_designation), ')'),
|
|
1104
1110
|
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -2137,10 +2137,6 @@
|
|
|
2137
2137
|
{
|
|
2138
2138
|
"type": "discard",
|
|
2139
2139
|
"named": true
|
|
2140
|
-
},
|
|
2141
|
-
{
|
|
2142
|
-
"type": "parenthesized_variable_designation",
|
|
2143
|
-
"named": true
|
|
2144
2140
|
}
|
|
2145
2141
|
]
|
|
2146
2142
|
}
|
|
@@ -3735,10 +3731,6 @@
|
|
|
3735
3731
|
"multiple": true,
|
|
3736
3732
|
"required": false,
|
|
3737
3733
|
"types": [
|
|
3738
|
-
{
|
|
3739
|
-
"type": "parenthesized_variable_designation",
|
|
3740
|
-
"named": true
|
|
3741
|
-
},
|
|
3742
3734
|
{
|
|
3743
3735
|
"type": "pattern",
|
|
3744
3736
|
"named": true
|
|
@@ -5523,10 +5515,6 @@
|
|
|
5523
5515
|
"multiple": true,
|
|
5524
5516
|
"required": true,
|
|
5525
5517
|
"types": [
|
|
5526
|
-
{
|
|
5527
|
-
"type": "parenthesized_variable_designation",
|
|
5528
|
-
"named": true
|
|
5529
|
-
},
|
|
5530
5518
|
{
|
|
5531
5519
|
"type": "pattern",
|
|
5532
5520
|
"named": true
|
|
@@ -6390,26 +6378,11 @@
|
|
|
6390
6378
|
{
|
|
6391
6379
|
"type": "var_pattern",
|
|
6392
6380
|
"named": true,
|
|
6393
|
-
"fields": {
|
|
6394
|
-
"name": {
|
|
6395
|
-
"multiple": false,
|
|
6396
|
-
"required": false,
|
|
6397
|
-
"types": [
|
|
6398
|
-
{
|
|
6399
|
-
"type": "identifier",
|
|
6400
|
-
"named": true
|
|
6401
|
-
}
|
|
6402
|
-
]
|
|
6403
|
-
}
|
|
6404
|
-
},
|
|
6381
|
+
"fields": {},
|
|
6405
6382
|
"children": {
|
|
6406
6383
|
"multiple": false,
|
|
6407
|
-
"required":
|
|
6384
|
+
"required": true,
|
|
6408
6385
|
"types": [
|
|
6409
|
-
{
|
|
6410
|
-
"type": "discard",
|
|
6411
|
-
"named": true
|
|
6412
|
-
},
|
|
6413
6386
|
{
|
|
6414
6387
|
"type": "parenthesized_variable_designation",
|
|
6415
6388
|
"named": true
|
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|