@willbooster/tree-sitter-c-sharp 1.0.14 → 1.0.15

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
@@ -105,13 +105,17 @@ script/parse-examples
105
105
  cargo test
106
106
  ```
107
107
 
108
+ `script/tree-sitter` (also `bun run tree-sitter`) runs the tree-sitter CLI of WillBooster/tree-sitter at the runtime
109
+ version locked in `Cargo.lock`, so the parser is generated, built, tested, and fuzzed with the generator and the
110
+ runtime this package ships. The first run downloads that CLI from its GitHub Release into `.tmp/`, or builds it with
111
+ `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
112
+ only the types of the grammar DSL that `grammar.js` checks against; its `tree-sitter` binary is upstream's.
113
+
108
114
  `bun run test` runs:
109
115
 
110
116
  - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
111
117
  - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
112
- edits each corpus case at random, reparses it, undoes the edits, and reparses again, on the WillBooster/tree-sitter
113
- runtime version locked in `Cargo.lock` (the first run downloads that CLI from its GitHub Release, or builds it with
114
- `cargo` when the download fails or the release has no binary that runs here). `TREE_SITTER_SEED`,
118
+ edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
115
119
  `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
116
120
  - a check that the real-world C# files cloned into `examples/` fail to parse exactly as listed in
117
121
  `script/known-failures.txt`. The first run clones them. The example repositories are pinned to commits in
@@ -127,7 +131,9 @@ cargo test
127
131
  `nodejs_compat` (`test/unit/workers.test.ts`).
128
132
 
129
133
  The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
130
- by every checkout; `script/fuzz-corpus` builds a per-run parser in `.tmp/fuzz` and deletes it afterwards.
134
+ by every checkout; `script/fuzz-corpus` builds a per-run parser in `.tmp/fuzz` and deletes it afterwards. `mise.toml`
135
+ sets `TREE_SITTER_LIBDIR` to `.tmp/tree-sitter-lib` as well, so other `tree-sitter` commands run in the checkout use
136
+ this checkout's parser too.
131
137
 
132
138
  `cargo test` also replays edits that `tree-sitter fuzz` found to break incremental parsing on runtimes without the
133
139
  fixes of willbooster-tree-sitter.
package/grammar.js CHANGED
@@ -137,6 +137,7 @@ module.exports = grammar({
137
137
  // simple-lambda parameter list (at least one element has a parameter
138
138
  // modifier) closed by ')=>'.
139
139
  $._lambda_paren_open,
140
+ $._end_of_input,
140
141
  ],
141
142
 
142
143
  extras: ($) => [
@@ -1766,9 +1767,10 @@ module.exports = grammar({
1766
1767
  );
1767
1768
  },
1768
1769
 
1769
- preproc_region: ($) => seq(preprocessor('region'), optional(field('content', $.preproc_arg)), /\n/),
1770
+ preproc_region: ($) => seq(preprocessor('region'), optional(field('content', $.preproc_arg)), directiveEnd($)),
1770
1771
 
1771
- preproc_endregion: ($) => seq(preprocessor('endregion'), optional(field('content', $.preproc_arg)), /\n/),
1772
+ preproc_endregion: ($) =>
1773
+ seq(preprocessor('endregion'), optional(field('content', $.preproc_arg)), directiveEnd($)),
1772
1774
 
1773
1775
  preproc_line: ($) =>
1774
1776
  seq(
@@ -1793,7 +1795,7 @@ module.exports = grammar({
1793
1795
  $.string_literal
1794
1796
  )
1795
1797
  ),
1796
- /\n/
1798
+ directiveEnd($)
1797
1799
  ),
1798
1800
 
1799
1801
  preproc_pragma: ($) =>
@@ -1803,24 +1805,24 @@ module.exports = grammar({
1803
1805
  seq('warning', choice('disable', 'restore'), commaSep(choice($.identifier, $.integer_literal))),
1804
1806
  seq('checksum', $.string_literal, $.string_literal, $.string_literal)
1805
1807
  ),
1806
- /\n/
1808
+ directiveEnd($)
1807
1809
  ),
1808
1810
 
1809
- preproc_nullable: () =>
1811
+ preproc_nullable: ($) =>
1810
1812
  seq(
1811
1813
  preprocessor('nullable'),
1812
1814
  choice('enable', 'disable', 'restore'),
1813
1815
  optional(choice('annotations', 'warnings')),
1814
- /\n/
1816
+ directiveEnd($)
1815
1817
  ),
1816
1818
 
1817
- preproc_error: ($) => seq(preprocessor('error'), $.preproc_arg, /\n/),
1819
+ preproc_error: ($) => seq(preprocessor('error'), $.preproc_arg, directiveEnd($)),
1818
1820
 
1819
- preproc_warning: ($) => seq(preprocessor('warning'), $.preproc_arg, /\n/),
1821
+ preproc_warning: ($) => seq(preprocessor('warning'), $.preproc_arg, directiveEnd($)),
1820
1822
 
1821
- preproc_define: ($) => seq(preprocessor('define'), $.preproc_arg, /\n/),
1823
+ preproc_define: ($) => seq(preprocessor('define'), $.preproc_arg, directiveEnd($)),
1822
1824
 
1823
- preproc_undef: ($) => seq(preprocessor('undef'), $.preproc_arg, /\n/),
1825
+ preproc_undef: ($) => seq(preprocessor('undef'), $.preproc_arg, directiveEnd($)),
1824
1826
 
1825
1827
  shebang_directive: () => token(seq('#!', /.*/)),
1826
1828
 
@@ -1828,6 +1830,18 @@ module.exports = grammar({
1828
1830
  },
1829
1831
  });
1830
1832
 
1833
+ /**
1834
+ * Ends a directive that opens no conditional section: at a line break, or at the end of the input, which a file may
1835
+ * reach without a final line break.
1836
+ *
1837
+ * @param {GrammarSymbols<string>} $
1838
+ *
1839
+ * @returns {ChoiceRule}
1840
+ */
1841
+ function directiveEnd($) {
1842
+ return choice(/\n/, $._end_of_input);
1843
+ }
1844
+
1831
1845
  /**
1832
1846
  * Creates a preprocessor regex rule
1833
1847
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "C# grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -22,8 +22,8 @@
22
22
  "*.wasm"
23
23
  ],
24
24
  "scripts": {
25
- "build-wasm": "tree-sitter build --wasm",
26
- "build/ci": "tree-sitter generate && tree-sitter build --wasm",
25
+ "build-wasm": "script/tree-sitter build --wasm",
26
+ "build/ci": "script/tree-sitter generate && script/tree-sitter build --wasm",
27
27
  "cleanup": "bun wb lint --fix --format",
28
28
  "format": "bun wb lint --format",
29
29
  "lint": "bun wb lint",
@@ -31,10 +31,11 @@
31
31
  "prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
32
32
  "release": "wb release",
33
33
  "prestart": "bun run build-wasm",
34
- "start": "tree-sitter playground",
34
+ "start": "script/tree-sitter playground",
35
35
  "test": "bun wb test",
36
36
  "test/ci": "bun wb test-on-ci",
37
37
  "test/ci-setup": "playwright install --with-deps chromium",
38
+ "tree-sitter": "script/tree-sitter",
38
39
  "typecheck": "bun wb typecheck",
39
40
  "verify": "bun wb verify",
40
41
  "verify-full": "bun wb verify --full"
@@ -46,7 +47,7 @@
46
47
  "@willbooster/oxfmt-config": "1.2.2",
47
48
  "@willbooster/oxlint-config": "1.4.8",
48
49
  "@willbooster/wb": "22.13.1",
49
- "@willbooster/web-tree-sitter": "1.0.12",
50
+ "@willbooster/web-tree-sitter": "1.0.17",
50
51
  "conventional-changelog-conventionalcommits": "10.4.0",
51
52
  "lefthook": "2.1.14",
52
53
  "oxfmt": "0.70.0",
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "1.0.14",
22
+ "version": "1.0.15",
23
23
  "license": "MIT",
24
24
  "description": "C# grammar for tree-sitter",
25
25
  "authors": [