@willbooster/tree-sitter-c-sharp 1.0.5 → 1.0.7
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 +19 -11
- 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.
|
|
@@ -1027,13 +1030,15 @@ module.exports = grammar({
|
|
|
1027
1030
|
// reparse can switch it without reporting a changed range.
|
|
1028
1031
|
type_pattern: ($) => prec.dynamic(-1, field('type', $.type)),
|
|
1029
1032
|
|
|
1033
|
+
// Left-associative so that a contextual keyword after `]` (`when` in a switch arm or section, `select` in a query)
|
|
1034
|
+
// ends the pattern instead of becoming its designation.
|
|
1030
1035
|
list_pattern: ($) =>
|
|
1031
|
-
prec.
|
|
1036
|
+
prec.left(
|
|
1032
1037
|
seq(
|
|
1033
1038
|
'[',
|
|
1034
1039
|
optional(seq(commaSep1(choice($.pattern, $.slice_pattern)), optional(','))),
|
|
1035
1040
|
']',
|
|
1036
|
-
optional($.
|
|
1041
|
+
optional($._simple_designation)
|
|
1037
1042
|
)
|
|
1038
1043
|
),
|
|
1039
1044
|
|
|
@@ -1052,7 +1057,7 @@ module.exports = grammar({
|
|
|
1052
1057
|
field('type', $._name),
|
|
1053
1058
|
$.positional_pattern_clause,
|
|
1054
1059
|
optional($.property_pattern_clause),
|
|
1055
|
-
$.
|
|
1060
|
+
$._simple_designation
|
|
1056
1061
|
)
|
|
1057
1062
|
),
|
|
1058
1063
|
// name followed by positional pattern WITHOUT variable designation
|
|
@@ -1061,19 +1066,19 @@ module.exports = grammar({
|
|
|
1061
1066
|
seq(field('type', $._name), $.positional_pattern_clause, optional($.property_pattern_clause))
|
|
1062
1067
|
),
|
|
1063
1068
|
// positional pattern with variable designation (no type prefix)
|
|
1064
|
-
prec.dynamic(1, seq($.positional_pattern_clause, $.
|
|
1069
|
+
prec.dynamic(1, seq($.positional_pattern_clause, $._simple_designation)),
|
|
1065
1070
|
// positional pattern without variable designation (no type prefix)
|
|
1066
1071
|
$.positional_pattern_clause,
|
|
1067
1072
|
// other type followed by pattern clauses (type is required here to avoid ambiguity)
|
|
1068
1073
|
seq(
|
|
1069
1074
|
field('type', $.type),
|
|
1070
1075
|
choice(seq($.positional_pattern_clause, optional($.property_pattern_clause)), $.property_pattern_clause),
|
|
1071
|
-
optional($.
|
|
1076
|
+
optional($._simple_designation)
|
|
1072
1077
|
),
|
|
1073
1078
|
// no type, just pattern clauses (no variable designation to avoid conflict with above)
|
|
1074
1079
|
seq(
|
|
1075
1080
|
choice(seq($.positional_pattern_clause, $.property_pattern_clause), $.property_pattern_clause),
|
|
1076
|
-
optional($.
|
|
1081
|
+
optional($._simple_designation)
|
|
1077
1082
|
)
|
|
1078
1083
|
)
|
|
1079
1084
|
),
|
|
@@ -1095,10 +1100,13 @@ module.exports = grammar({
|
|
|
1095
1100
|
or_pattern: ($) =>
|
|
1096
1101
|
prec.left(PREC.OR, seq(field('left', $.pattern), field('operator', 'or'), field('right', $.pattern))),
|
|
1097
1102
|
|
|
1098
|
-
declaration_pattern: ($) => seq(field('type', $.type), $.
|
|
1103
|
+
declaration_pattern: ($) => seq(field('type', $.type), $._simple_designation),
|
|
1104
|
+
|
|
1105
|
+
_variable_designation: ($) => choice($._simple_designation, $.parenthesized_variable_designation),
|
|
1099
1106
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1107
|
+
// C# admits a parenthesized designation in a pattern only after `var`; elsewhere `T (x)` and `nameof(x)` are
|
|
1108
|
+
// positional patterns or invocations.
|
|
1109
|
+
_simple_designation: ($) => prec(1, choice($.discard, field('name', $.identifier))),
|
|
1102
1110
|
|
|
1103
1111
|
parenthesized_variable_designation: ($) => seq('(', commaSep($._variable_designation), ')'),
|
|
1104
1112
|
|
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
|