@willbooster/tree-sitter-c-sharp 1.0.14 → 1.0.16
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 +10 -4
- package/grammar.js +31 -12
- package/package.json +6 -5
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +1 -1
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
|
|
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
|
@@ -45,6 +45,7 @@ module.exports = grammar({
|
|
|
45
45
|
name: 'c_sharp',
|
|
46
46
|
|
|
47
47
|
conflicts: ($) => [
|
|
48
|
+
[$.modifier, $._constructor_declaration_initializer, $._reserved_identifier],
|
|
48
49
|
[$._simple_name, $.generic_name],
|
|
49
50
|
[$._simple_name, $.type_parameter],
|
|
50
51
|
[$._simple_name, $.subpattern],
|
|
@@ -137,6 +138,7 @@ module.exports = grammar({
|
|
|
137
138
|
// simple-lambda parameter list (at least one element has a parameter
|
|
138
139
|
// modifier) closed by ')=>'.
|
|
139
140
|
$._lambda_paren_open,
|
|
141
|
+
$._end_of_input,
|
|
140
142
|
],
|
|
141
143
|
|
|
142
144
|
extras: ($) => [
|
|
@@ -266,7 +268,7 @@ module.exports = grammar({
|
|
|
266
268
|
seq(
|
|
267
269
|
repeat($._attribute_list),
|
|
268
270
|
repeat($.modifier),
|
|
269
|
-
optional('ref'),
|
|
271
|
+
optional(seq('ref', optional(alias('partial', $.modifier)))),
|
|
270
272
|
'struct',
|
|
271
273
|
field('name', $.identifier),
|
|
272
274
|
repeat(choice($.type_parameter_list, $.parameter_list, $.base_list)),
|
|
@@ -535,7 +537,10 @@ module.exports = grammar({
|
|
|
535
537
|
_constructor_declaration_initializer: ($) =>
|
|
536
538
|
seq(
|
|
537
539
|
repeat($._attribute_list),
|
|
538
|
-
|
|
540
|
+
choice(
|
|
541
|
+
repeat($.modifier),
|
|
542
|
+
prec.dynamic(1, seq(repeat($.modifier), alias('partial', $.modifier), repeat($.modifier)))
|
|
543
|
+
),
|
|
539
544
|
field('name', $.identifier),
|
|
540
545
|
field('parameters', $.parameter_list),
|
|
541
546
|
optional($.constructor_initializer)
|
|
@@ -1704,6 +1709,7 @@ module.exports = grammar({
|
|
|
1704
1709
|
'on',
|
|
1705
1710
|
'orderby',
|
|
1706
1711
|
'param',
|
|
1712
|
+
'partial',
|
|
1707
1713
|
'property',
|
|
1708
1714
|
'scoped',
|
|
1709
1715
|
'select',
|
|
@@ -1766,9 +1772,10 @@ module.exports = grammar({
|
|
|
1766
1772
|
);
|
|
1767
1773
|
},
|
|
1768
1774
|
|
|
1769
|
-
preproc_region: ($) => seq(preprocessor('region'), optional(field('content', $.preproc_arg)),
|
|
1775
|
+
preproc_region: ($) => seq(preprocessor('region'), optional(field('content', $.preproc_arg)), directiveEnd($)),
|
|
1770
1776
|
|
|
1771
|
-
preproc_endregion: ($) =>
|
|
1777
|
+
preproc_endregion: ($) =>
|
|
1778
|
+
seq(preprocessor('endregion'), optional(field('content', $.preproc_arg)), directiveEnd($)),
|
|
1772
1779
|
|
|
1773
1780
|
preproc_line: ($) =>
|
|
1774
1781
|
seq(
|
|
@@ -1793,7 +1800,7 @@ module.exports = grammar({
|
|
|
1793
1800
|
$.string_literal
|
|
1794
1801
|
)
|
|
1795
1802
|
),
|
|
1796
|
-
|
|
1803
|
+
directiveEnd($)
|
|
1797
1804
|
),
|
|
1798
1805
|
|
|
1799
1806
|
preproc_pragma: ($) =>
|
|
@@ -1803,24 +1810,24 @@ module.exports = grammar({
|
|
|
1803
1810
|
seq('warning', choice('disable', 'restore'), commaSep(choice($.identifier, $.integer_literal))),
|
|
1804
1811
|
seq('checksum', $.string_literal, $.string_literal, $.string_literal)
|
|
1805
1812
|
),
|
|
1806
|
-
|
|
1813
|
+
directiveEnd($)
|
|
1807
1814
|
),
|
|
1808
1815
|
|
|
1809
|
-
preproc_nullable: () =>
|
|
1816
|
+
preproc_nullable: ($) =>
|
|
1810
1817
|
seq(
|
|
1811
1818
|
preprocessor('nullable'),
|
|
1812
1819
|
choice('enable', 'disable', 'restore'),
|
|
1813
1820
|
optional(choice('annotations', 'warnings')),
|
|
1814
|
-
|
|
1821
|
+
directiveEnd($)
|
|
1815
1822
|
),
|
|
1816
1823
|
|
|
1817
|
-
preproc_error: ($) => seq(preprocessor('error'), $.preproc_arg,
|
|
1824
|
+
preproc_error: ($) => seq(preprocessor('error'), $.preproc_arg, directiveEnd($)),
|
|
1818
1825
|
|
|
1819
|
-
preproc_warning: ($) => seq(preprocessor('warning'), $.preproc_arg,
|
|
1826
|
+
preproc_warning: ($) => seq(preprocessor('warning'), $.preproc_arg, directiveEnd($)),
|
|
1820
1827
|
|
|
1821
|
-
preproc_define: ($) => seq(preprocessor('define'), $.preproc_arg,
|
|
1828
|
+
preproc_define: ($) => seq(preprocessor('define'), $.preproc_arg, directiveEnd($)),
|
|
1822
1829
|
|
|
1823
|
-
preproc_undef: ($) => seq(preprocessor('undef'), $.preproc_arg,
|
|
1830
|
+
preproc_undef: ($) => seq(preprocessor('undef'), $.preproc_arg, directiveEnd($)),
|
|
1824
1831
|
|
|
1825
1832
|
shebang_directive: () => token(seq('#!', /.*/)),
|
|
1826
1833
|
|
|
@@ -1828,6 +1835,18 @@ module.exports = grammar({
|
|
|
1828
1835
|
},
|
|
1829
1836
|
});
|
|
1830
1837
|
|
|
1838
|
+
/**
|
|
1839
|
+
* Ends a directive that opens no conditional section: at a line break, or at the end of the input, which a file may
|
|
1840
|
+
* reach without a final line break.
|
|
1841
|
+
*
|
|
1842
|
+
* @param {GrammarSymbols<string>} $
|
|
1843
|
+
*
|
|
1844
|
+
* @returns {ChoiceRule}
|
|
1845
|
+
*/
|
|
1846
|
+
function directiveEnd($) {
|
|
1847
|
+
return choice(/\n/, $._end_of_input);
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1831
1850
|
/**
|
|
1832
1851
|
* Creates a preprocessor regex rule
|
|
1833
1852
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-c-sharp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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.
|
|
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",
|
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|