@willbooster/tree-sitter-c-sharp 3.0.6 → 5.0.0

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
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.28.6-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-c-sharp.svg)](https://crates.io/crates/willbooster-tree-sitter-c-sharp)
10
10
 
11
11
  C# grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -33,8 +33,9 @@ Known gaps:
33
33
 
34
34
  The npm package ships `tree-sitter-c_sharp.wasm` for
35
35
  [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
36
- browsers, and Cloudflare Workers. Use runtime version 1.3.0 or later for the compact ABI 16 parser. Install the runtime alongside the grammar when using the Wasm parser; it
37
- remains an optional peer for consumers that only use the grammar source or queries.
36
+ browsers, and Cloudflare Workers. The parser carries the ABI number of WillBooster/tree-sitter, so it loads only with
37
+ that runtime, version 2.0.0 or later; upstream's runtime rejects it. Install the runtime alongside the grammar when using
38
+ the Wasm parser; it remains an optional peer for consumers that only use the grammar source or queries.
38
39
 
39
40
  In Node.js and Bun, load it from the package:
40
41
 
@@ -76,15 +77,17 @@ parser.setLanguage(await Language.load(cSharp));
76
77
  ```
77
78
 
78
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.
79
82
 
80
83
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-c-sharp) and on
81
84
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
82
- fuzzed with. The compact ABI 16 parser requires runtime 1.3.0 or later:
85
+ fuzzed with. The parser requires runtime 2.0.0 or later:
83
86
 
84
87
  ```toml
85
88
  [dependencies]
86
- tree-sitter = { package = "willbooster-tree-sitter", version = "1.3.0" }
87
- tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "3" }
89
+ tree-sitter = { package = "willbooster-tree-sitter", version = "2.0.0" }
90
+ tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "5" }
88
91
  ```
89
92
 
90
93
  ```rust
@@ -109,7 +112,7 @@ runtime this package ships. The first run downloads that CLI from its GitHub Rel
109
112
  `cargo` (with the `cmake` that `mise.toml` pins) when the download fails or the release has no binary that runs here. The `tree-sitter-cli` package provides
110
113
  only the types of the grammar DSL that `grammar.js` checks against; its `tree-sitter` binary is upstream's.
111
114
 
112
- `bun run generate` records a fresh ABI 16 generation profile from the applicable `test/corpus` cases and Git-tracked
115
+ `bun run generate` records a fresh generation profile from the applicable `test/corpus` cases and Git-tracked
113
116
  files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar,
114
117
  `tree-sitter.json`, a corpus case, or a tracked example,
115
118
  regenerate and commit `src/`. Stage added or removed examples with `git add -A examples` before generation so the profile uses the intended file list.
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: ($) => [
@@ -1524,7 +1534,7 @@ module.exports = grammar({
1524
1534
 
1525
1535
  interpolation_alignment_clause: ($) => seq(',', $.expression),
1526
1536
 
1527
- interpolation_format_clause: () => seq(':', /[^}"]+/),
1537
+ interpolation_format_clause: ($) => seq(':', optional($._file_directive_literal_context), /[^}"]+/),
1528
1538
 
1529
1539
  member_access_expression: ($) =>
1530
1540
  prec(
@@ -1719,7 +1729,7 @@ module.exports = grammar({
1719
1729
  string_literal: ($) =>
1720
1730
  seq(
1721
1731
  '"',
1722
- repeat(choice($.string_literal_content, $.escape_sequence)),
1732
+ repeat(choice($.string_literal_content, $.escape_sequence, $._file_directive_literal_context)),
1723
1733
  token.immediate('"'),
1724
1734
  optional($.string_literal_encoding)
1725
1735
  ),
@@ -1896,6 +1906,7 @@ module.exports = grammar({
1896
1906
  repeat(
1897
1907
  choice(
1898
1908
  $.string_literal_content,
1909
+ $._file_directive_literal_context,
1899
1910
  alias(token.immediate(prec(-1, '\\')), $.string_literal_content),
1900
1911
  alias(
1901
1912
  token.immediate(
@@ -1959,25 +1970,17 @@ module.exports = grammar({
1959
1970
  choice(
1960
1971
  fileDirectiveArguments(
1961
1972
  $,
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
- ),
1973
+ choice(alias($._file_directive_sdk, '#:sdk'), alias($._file_directive_package, '#:package')),
1966
1974
  '@',
1967
1975
  'metadata'
1968
1976
  ),
1969
- fileDirectiveArguments(
1970
- $,
1971
- alias(token(prec(-2, /#:[pP][rR][oO][pP][eE][rR][tT][yY]/)), '#:property'),
1972
- '=',
1973
- 'value'
1974
- ),
1977
+ fileDirectiveArguments($, alias($._file_directive_property, '#:property'), '=', 'value'),
1975
1978
  seq(
1976
1979
  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')
1980
+ alias($._file_directive_project, '#:project'),
1981
+ alias($._file_directive_ref, '#:ref'),
1982
+ alias($._file_directive_include, '#:include'),
1983
+ alias($._file_directive_exclude, '#:exclude')
1981
1984
  ),
1982
1985
  optional(seq($._file_directive_spacing, field('value', $.file_directive_value)))
1983
1986
  ),
@@ -1987,11 +1990,9 @@ module.exports = grammar({
1987
1990
  )
1988
1991
  ),
1989
1992
  optional($._file_directive_spacing),
1990
- choice(token.immediate(new RegExp(String.raw`\r\n|[${directiveLineBreak}]`)), $._end_of_input)
1993
+ choice($._file_directive_newline, $._end_of_input)
1991
1994
  ),
1992
1995
 
1993
- file_directive_kind: () => token(prec(-2, new RegExp(`#:[^${directiveWhitespace}]*`))),
1994
-
1995
1996
  _file_directive_spacing: () => token.immediate(prec(1, new RegExp(`[${directiveHorizontal}]+`))),
1996
1997
  file_directive_name: () =>
1997
1998
  token.immediate(
@@ -2068,7 +2069,7 @@ function directiveEnd($) {
2068
2069
 
2069
2070
  /** @param {GrammarSymbols<string>} $ */
2070
2071
  function directiveNewLine($) {
2071
- return choice($._directive_crlf, /[\r\n\u0085\u2028\u2029]/);
2072
+ return $._directive_newline;
2072
2073
  }
2073
2074
 
2074
2075
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "3.0.6",
3
+ "version": "5.0.0",
4
4
  "description": "C# grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -47,8 +47,8 @@
47
47
  "@vitest/browser-playwright": "5.0.3",
48
48
  "@willbooster/oxfmt-config": "1.2.2",
49
49
  "@willbooster/oxlint-config": "1.4.8",
50
- "@willbooster/wb": "22.23.1",
51
- "@willbooster/web-tree-sitter": "1.4.8",
50
+ "@willbooster/wb": "22.24.0",
51
+ "@willbooster/web-tree-sitter": "2.0.1",
52
52
  "conventional-changelog-conventionalcommits": "10.4.0",
53
53
  "lefthook": "2.1.16",
54
54
  "oxfmt": "0.71.0",
@@ -64,7 +64,7 @@
64
64
  "wrangler": "4.147.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "@willbooster/web-tree-sitter": "^1.3.0"
67
+ "@willbooster/web-tree-sitter": "^2.0.0"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "@willbooster/web-tree-sitter": {
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "3.0.6",
22
+ "version": "5.0.0",
23
23
  "license": "MIT",
24
24
  "description": "C# grammar for tree-sitter",
25
25
  "authors": [