@willbooster/tree-sitter-c-sharp 1.0.6 → 1.0.8

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 CHANGED
@@ -101,6 +101,7 @@ module.exports = grammar({
101
101
  [$._reserved_identifier, $.parameter],
102
102
  [$._simple_name, $.parameter],
103
103
  [$.tuple_element, $.parameter, $.declaration_expression],
104
+ [$.parameter, $.declaration_expression],
104
105
  [$.parameter, $.tuple_element],
105
106
 
106
107
  [$.event_declaration, $.variable_declarator],
@@ -518,8 +519,9 @@ module.exports = grammar({
518
519
  )
519
520
  ),
520
521
 
522
+ // The precedence reads the `ref` of `extension(ref int)` as a modifier rather than a ref_type.
521
523
  receiver_parameter: ($) =>
522
- seq(repeat($._attribute_list), $._parameter_type_with_modifiers, optional(field('name', $.identifier))),
524
+ prec(1, seq(repeat($._attribute_list), $._parameter_type_with_modifiers, optional(field('name', $.identifier)))),
523
525
 
524
526
  extension_body: ($) => seq('{', repeat($._extension_member_declaration), '}', optional(';')),
525
527
 
@@ -615,9 +617,18 @@ module.exports = grammar({
615
617
 
616
618
  parameter_list: ($) => seq('(', sep(choice($.parameter, $._parameter_array), ','), ')'),
617
619
 
620
+ // `ref`, `out`, and `in` stay out of the repeat: reducing the repeat after them would compete with the shift of
621
+ // the next token into an argument (`(ref x)`), whose precedence wins, so `(ref int i) =>` would read `ref int` as a
622
+ // ref_type while a method's `(ref int i)` reads `ref` as a modifier.
618
623
  _parameter_type_with_modifiers: ($) =>
619
624
  seq(
620
- repeat(prec.left(alias(choice('this', 'scoped', 'ref', 'out', 'in', 'readonly'), $.modifier))),
625
+ repeat(prec.left(alias(choice('this', 'scoped', 'readonly'), $.modifier))),
626
+ optional(
627
+ seq(
628
+ alias(choice('ref', 'out', 'in'), $.modifier),
629
+ repeat(prec.left(alias(choice('this', 'readonly'), $.modifier)))
630
+ )
631
+ ),
621
632
  field('type', $.type)
622
633
  ),
623
634
 
@@ -770,7 +781,8 @@ module.exports = grammar({
770
781
  )
771
782
  ),
772
783
 
773
- ref_type: ($) => seq('ref', optional('readonly'), field('type', $.type)),
784
+ // Right-associative so that a parameter's `ref int x` keeps `ref` as a modifier instead of reducing a ref_type.
785
+ ref_type: ($) => prec.right(seq('ref', optional('readonly'), field('type', $.type))),
774
786
 
775
787
  _ref_base_type: ($) =>
776
788
  choice(
@@ -1030,8 +1042,10 @@ module.exports = grammar({
1030
1042
  // reparse can switch it without reporting a changed range.
1031
1043
  type_pattern: ($) => prec.dynamic(-1, field('type', $.type)),
1032
1044
 
1045
+ // Left-associative so that a contextual keyword after `]` (`when` in a switch arm or section, `select` in a query)
1046
+ // ends the pattern instead of becoming its designation.
1033
1047
  list_pattern: ($) =>
1034
- prec.right(
1048
+ prec.left(
1035
1049
  seq(
1036
1050
  '[',
1037
1051
  optional(seq(commaSep1(choice($.pattern, $.slice_pattern)), optional(','))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "C# grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "1.0.6",
22
+ "version": "1.0.8",
23
23
  "license": "MIT",
24
24
  "description": "C# grammar for tree-sitter",
25
25
  "authors": [