@willbooster/tree-sitter-c-sharp 4.0.0 → 5.0.1

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
@@ -77,6 +77,8 @@ parser.setLanguage(await Language.load(cSharp));
77
77
  ```
78
78
 
79
79
  The package also ships the queries in `queries/` and the node types in `src/node-types.json`.
80
+ When extending the source grammar, use `grammar.js` and `src/scanner.c` from the same repository release tag.
81
+ Their external directive tokens and serialized scanner state must match.
80
82
 
81
83
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-c-sharp) and on
82
84
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
@@ -85,7 +87,7 @@ fuzzed with. The parser requires runtime 2.0.0 or later:
85
87
  ```toml
86
88
  [dependencies]
87
89
  tree-sitter = { package = "willbooster-tree-sitter", version = "2.0.0" }
88
- tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "4" }
90
+ tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "5" }
89
91
  ```
90
92
 
91
93
  ```rust
package/grammar.js CHANGED
@@ -152,8 +152,18 @@ module.exports = grammar({
152
152
  // modifier) closed by ')=>'.
153
153
  $._lambda_paren_open,
154
154
  $._end_of_input,
155
- $._directive_crlf,
155
+ $._directive_newline,
156
156
  $._file_directive_preproc_arg,
157
+ $._file_directive_sdk,
158
+ $._file_directive_package,
159
+ $._file_directive_property,
160
+ $._file_directive_project,
161
+ $._file_directive_ref,
162
+ $._file_directive_include,
163
+ $._file_directive_exclude,
164
+ $.file_directive_kind,
165
+ $._file_directive_literal_context,
166
+ $._file_directive_newline,
157
167
  ],
158
168
 
159
169
  extras: ($) => [
@@ -1508,23 +1518,43 @@ module.exports = grammar({
1508
1518
  choice(alias($.interpolation_string_content, $.string_content), $.escape_sequence, $.interpolation),
1509
1519
 
1510
1520
  _interpolated_verbatim_string_content: ($) =>
1511
- choice(alias($.interpolation_string_content, $.string_content), $.interpolation),
1521
+ choice(
1522
+ alias($.interpolation_string_content, $.string_content),
1523
+ alias($._multiline_interpolation, $.interpolation)
1524
+ ),
1512
1525
 
1513
1526
  _interpolated_raw_string_content: ($) =>
1514
- choice(alias($.interpolation_string_content, $.string_content), $.interpolation),
1527
+ choice(
1528
+ alias($.interpolation_string_content, $.string_content),
1529
+ alias($._multiline_interpolation, $.interpolation)
1530
+ ),
1515
1531
 
1516
1532
  interpolation: ($) =>
1517
1533
  seq(
1518
1534
  alias($.interpolation_open_brace, $.interpolation_brace),
1519
1535
  $.expression,
1520
1536
  optional($.interpolation_alignment_clause),
1521
- optional($.interpolation_format_clause),
1522
- alias($.interpolation_close_brace, $.interpolation_brace)
1537
+ choice(
1538
+ alias($.interpolation_close_brace, $.interpolation_brace),
1539
+ seq($.interpolation_format_clause, alias(token.immediate('}'), $.interpolation_brace))
1540
+ )
1523
1541
  ),
1524
1542
 
1525
1543
  interpolation_alignment_clause: ($) => seq(',', $.expression),
1526
1544
 
1527
- interpolation_format_clause: () => seq(':', /[^}"]+/),
1545
+ interpolation_format_clause: ($) =>
1546
+ seq(':', optional($._file_directive_literal_context), token.immediate(/[^}"\n\r\u0085\u2028\u2029]+/)),
1547
+
1548
+ _multiline_interpolation: ($) =>
1549
+ seq(
1550
+ alias($.interpolation_open_brace, $.interpolation_brace),
1551
+ $.expression,
1552
+ optional($.interpolation_alignment_clause),
1553
+ optional(alias($._multiline_interpolation_format_clause, $.interpolation_format_clause)),
1554
+ alias($.interpolation_close_brace, $.interpolation_brace)
1555
+ ),
1556
+
1557
+ _multiline_interpolation_format_clause: ($) => seq(':', optional($._file_directive_literal_context), /[^}"]+/),
1528
1558
 
1529
1559
  member_access_expression: ($) =>
1530
1560
  prec(
@@ -1719,7 +1749,7 @@ module.exports = grammar({
1719
1749
  string_literal: ($) =>
1720
1750
  seq(
1721
1751
  '"',
1722
- repeat(choice($.string_literal_content, $.escape_sequence)),
1752
+ repeat(choice($.string_literal_content, $.escape_sequence, $._file_directive_literal_context)),
1723
1753
  token.immediate('"'),
1724
1754
  optional($.string_literal_encoding)
1725
1755
  ),
@@ -1896,6 +1926,7 @@ module.exports = grammar({
1896
1926
  repeat(
1897
1927
  choice(
1898
1928
  $.string_literal_content,
1929
+ $._file_directive_literal_context,
1899
1930
  alias(token.immediate(prec(-1, '\\')), $.string_literal_content),
1900
1931
  alias(
1901
1932
  token.immediate(
@@ -1959,25 +1990,17 @@ module.exports = grammar({
1959
1990
  choice(
1960
1991
  fileDirectiveArguments(
1961
1992
  $,
1962
- choice(
1963
- alias(token(prec(-2, /#:[sS][dD][kK]/)), '#:sdk'),
1964
- alias(token(prec(-2, /#:[pP][aA][cC][kK][aA][gG][eE]/)), '#:package')
1965
- ),
1993
+ choice(alias($._file_directive_sdk, '#:sdk'), alias($._file_directive_package, '#:package')),
1966
1994
  '@',
1967
1995
  'metadata'
1968
1996
  ),
1969
- fileDirectiveArguments(
1970
- $,
1971
- alias(token(prec(-2, /#:[pP][rR][oO][pP][eE][rR][tT][yY]/)), '#:property'),
1972
- '=',
1973
- 'value'
1974
- ),
1997
+ fileDirectiveArguments($, alias($._file_directive_property, '#:property'), '=', 'value'),
1975
1998
  seq(
1976
1999
  choice(
1977
- alias(token(prec(-2, /#:[pP][rR][oO][jJ][eE][cC][tT]/)), '#:project'),
1978
- alias(token(prec(-2, /#:[rR][eE][fF]/)), '#:ref'),
1979
- alias(token(prec(-2, /#:[iI][nN][cC][lL][uU][dD][eE]/)), '#:include'),
1980
- alias(token(prec(-2, /#:[eE][xX][cC][lL][uU][dD][eE]/)), '#:exclude')
2000
+ alias($._file_directive_project, '#:project'),
2001
+ alias($._file_directive_ref, '#:ref'),
2002
+ alias($._file_directive_include, '#:include'),
2003
+ alias($._file_directive_exclude, '#:exclude')
1981
2004
  ),
1982
2005
  optional(seq($._file_directive_spacing, field('value', $.file_directive_value)))
1983
2006
  ),
@@ -1987,11 +2010,9 @@ module.exports = grammar({
1987
2010
  )
1988
2011
  ),
1989
2012
  optional($._file_directive_spacing),
1990
- choice(token.immediate(new RegExp(String.raw`\r\n|[${directiveLineBreak}]`)), $._end_of_input)
2013
+ choice($._file_directive_newline, $._end_of_input)
1991
2014
  ),
1992
2015
 
1993
- file_directive_kind: () => token(prec(-2, new RegExp(`#:[^${directiveWhitespace}]*`))),
1994
-
1995
2016
  _file_directive_spacing: () => token.immediate(prec(1, new RegExp(`[${directiveHorizontal}]+`))),
1996
2017
  file_directive_name: () =>
1997
2018
  token.immediate(
@@ -2068,7 +2089,7 @@ function directiveEnd($) {
2068
2089
 
2069
2090
  /** @param {GrammarSymbols<string>} $ */
2070
2091
  function directiveNewLine($) {
2071
- return choice($._directive_crlf, /[\r\n\u0085\u2028\u2029]/);
2092
+ return $._directive_newline;
2072
2093
  }
2073
2094
 
2074
2095
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "4.0.0",
3
+ "version": "5.0.1",
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": "4.0.0",
22
+ "version": "5.0.1",
23
23
  "license": "MIT",
24
24
  "description": "C# grammar for tree-sitter",
25
25
  "authors": [