@willbooster/tree-sitter-c-sharp 1.0.18 → 1.0.20

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/README.md CHANGED
@@ -27,7 +27,7 @@ The grammar is based upon the Roslyn grammar with changes in order to:
27
27
 
28
28
  Known gaps:
29
29
 
30
- - `async`, `var` and `await` cannot be used as identifiers everywhere they are valid
30
+ - `var` and `await` cannot be used as identifiers everywhere they are valid
31
31
  - A pointer dereference can be assigned to only when its operand is a variable, an address, a parenthesized or
32
32
  postfix expression, or a cast of one of these or of an invocation (`*p = 1`, `*(p + 1) = 1`, `*(int*)p = 1`,
33
33
  `*dst++ = 1`); `*++p = 1` and `*f() = 1` are not recognized
package/grammar.js CHANGED
@@ -51,6 +51,7 @@ module.exports = grammar({
51
51
  [$._simple_name, $.subpattern],
52
52
 
53
53
  [$.tuple_element, $.type_pattern],
54
+ [$.type_pattern, $.declaration_pattern],
54
55
  [$.tuple_element, $.using_variable_declarator],
55
56
 
56
57
  [$.tuple_pattern, $.parameter],
@@ -93,6 +94,13 @@ module.exports = grammar({
93
94
  [$.collection_expression, $.list_pattern],
94
95
 
95
96
  [$._reserved_identifier, $.modifier],
97
+ [$._reserved_identifier],
98
+ [$._lambda_expression_init, $.anonymous_method_expression, $._reserved_identifier],
99
+ [$._lambda_expression_init, $._reserved_identifier],
100
+ [$.modifier, $._lambda_expression_init, $.anonymous_method_expression],
101
+ [$.modifier, $._lambda_expression_init],
102
+ [$.modifier, $._lambda_expression_init, $._reserved_identifier],
103
+ [$.modifier, $._lambda_expression_init, $.anonymous_method_expression, $._reserved_identifier],
96
104
  [$._reserved_identifier, $.scoped_type],
97
105
  [$._reserved_identifier, $.implicit_type],
98
106
  [$._reserved_identifier, $.from_clause],
@@ -1511,9 +1519,11 @@ module.exports = grammar({
1511
1519
  -1,
1512
1520
  seq(
1513
1521
  repeat($._attribute_list),
1514
- repeat(prec(-1, alias(choice('static', 'async'), $.modifier))),
1515
- optional(field('type', $.type)),
1516
- field('parameters', $._lambda_parameters)
1522
+ repeat(prec.dynamic(1, alias(choice('static', 'async'), $.modifier))),
1523
+ choice(
1524
+ field('parameters', prec(-1, alias($.identifier, $.implicit_parameter))),
1525
+ seq(optional(field('type', $.type)), field('parameters', $._lambda_parameters))
1526
+ )
1517
1527
  )
1518
1528
  ),
1519
1529
 
@@ -1522,7 +1532,6 @@ module.exports = grammar({
1522
1532
  -1,
1523
1533
  choice(
1524
1534
  $.parameter_list,
1525
- alias($.identifier, $.implicit_parameter),
1526
1535
  // C# 14: `(ref x) => x`, `(out y) => ...`, `(text, out result) => ...`
1527
1536
  // The opening '(' is recognized via the external _lambda_paren_open
1528
1537
  // token, which the scanner only emits when it can confirm a closing
@@ -1555,7 +1564,7 @@ module.exports = grammar({
1555
1564
 
1556
1565
  anonymous_method_expression: ($) =>
1557
1566
  seq(
1558
- repeat(prec(-1, alias(choice('static', 'async'), $.modifier))),
1567
+ repeat(prec.dynamic(1, alias(choice('static', 'async'), $.modifier))),
1559
1568
  'delegate',
1560
1569
  optional(field('parameters', $.parameter_list)),
1561
1570
  $.block
@@ -1692,7 +1701,9 @@ module.exports = grammar({
1692
1701
 
1693
1702
  _reserved_identifier: () =>
1694
1703
  choice(
1704
+ prec(-1, '_'),
1695
1705
  'alias',
1706
+ 'async',
1696
1707
  'ascending',
1697
1708
  'by',
1698
1709
  'descending',
@@ -1791,7 +1802,7 @@ module.exports = grammar({
1791
1802
  choice(
1792
1803
  'default',
1793
1804
  'hidden',
1794
- seq($.integer_literal, optional($.string_literal)),
1805
+ seq($.integer_literal, optional(alias($._preproc_filename, $.string_literal))),
1795
1806
  seq(
1796
1807
  '(',
1797
1808
  $.integer_literal,
@@ -1805,18 +1816,36 @@ module.exports = grammar({
1805
1816
  $.integer_literal,
1806
1817
  ')',
1807
1818
  optional($.integer_literal),
1808
- $.string_literal
1819
+ alias($._preproc_filename, $.string_literal)
1809
1820
  )
1810
1821
  ),
1811
1822
  directiveEnd($)
1812
1823
  ),
1813
1824
 
1825
+ _preproc_filename: ($) =>
1826
+ seq(
1827
+ '"',
1828
+ repeat(
1829
+ choice(
1830
+ alias(token.immediate(prec(1, /[^"\\\r\n\u0085\u2028\u2029]+/)), $.string_literal_content),
1831
+ alias(token.immediate(prec(-1, '\\')), $.string_literal_content),
1832
+ alias(
1833
+ token.immediate(
1834
+ choice(/\\x[0-9a-fA-F]{1,4}/, /\\u[0-9a-fA-F]{4}/, /\\U[0-9a-fA-F]{8}/, /\\[abefnrtv'\\?0]/)
1835
+ ),
1836
+ $.escape_sequence
1837
+ )
1838
+ )
1839
+ ),
1840
+ token.immediate('"')
1841
+ ),
1842
+
1814
1843
  preproc_pragma: ($) =>
1815
1844
  seq(
1816
1845
  preprocessor('pragma'),
1817
1846
  choice(
1818
1847
  seq('warning', choice('disable', 'restore'), commaSep(choice($.identifier, $.integer_literal))),
1819
- seq('checksum', $.string_literal, $.string_literal, $.string_literal)
1848
+ seq('checksum', alias($._preproc_filename, $.string_literal), $.string_literal, $.string_literal)
1820
1849
  ),
1821
1850
  directiveEnd($)
1822
1851
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "C# grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -2291,6 +2291,11 @@
2291
2291
  ]
2292
2292
  }
2293
2293
  },
2294
+ {
2295
+ "type": "discard",
2296
+ "named": true,
2297
+ "fields": {}
2298
+ },
2294
2299
  {
2295
2300
  "type": "do_statement",
2296
2301
  "named": true,
@@ -6827,6 +6832,10 @@
6827
6832
  "type": "^=",
6828
6833
  "named": false
6829
6834
  },
6835
+ {
6836
+ "type": "_",
6837
+ "named": false
6838
+ },
6830
6839
  {
6831
6840
  "type": "__makeref",
6832
6841
  "named": false
@@ -6944,10 +6953,6 @@
6944
6953
  "type": "disable",
6945
6954
  "named": false
6946
6955
  },
6947
- {
6948
- "type": "discard",
6949
- "named": true
6950
- },
6951
6956
  {
6952
6957
  "type": "do",
6953
6958
  "named": false
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "1.0.18",
22
+ "version": "1.0.20",
23
23
  "license": "MIT",
24
24
  "description": "C# grammar for tree-sitter",
25
25
  "authors": [