@willbooster/tree-sitter-c 20.0.0 → 21.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/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-c/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-c/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-c/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.48.9-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.51.1-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.svg)](https://crates.io/crates/willbooster-tree-sitter-c)
10
10
 
11
11
  C grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -15,6 +15,13 @@ to its authors and contributors. This is not an official release of that project
15
15
  This fork fixes parsing bugs and raises conformance with the ISO C standard
16
16
  ([C23 working draft N3220](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf)).
17
17
 
18
+ ## Support Scope
19
+
20
+ This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
21
+ nodes without crashing, hanging, or taking more than linear time. Incremental parsing works as in upstream tree-sitter
22
+ but is not tested here, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and
23
+ the trees that error recovery produces may change; such changes are released as new major versions.
24
+
18
25
  ## Usage
19
26
 
20
27
  The npm package ships `tree-sitter-c.wasm` for
@@ -57,7 +64,7 @@ const parser = new Parser();
57
64
  parser.setLanguage(await Language.load(c));
58
65
  ```
59
66
 
60
- The package also ships `grammar.js`, scanner sources under `src/`, the queries in `queries/`,
67
+ The package also ships `grammar.js`, scanner sources under `src/`,
61
68
  and the node types in `src/node-types.json` for grammars extending C (such as C++).
62
69
  The scanner sources include `scanner.c`, `pragma.h`, `identifier.h`, `keywords.h`, `functionMacro.h`,
63
70
  `conditionalMacro.h`, and `gnuRawString.h`.
@@ -224,9 +231,6 @@ and the release build regenerate the parsers before compiling them.
224
231
  `bun run test` runs:
225
232
 
226
233
  - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
227
- - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
228
- edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
229
- `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
230
234
  - a check that the real-world C files in `examples/`, the checked-in ones and those of the cloned repositories, fail to
231
235
  parse exactly as listed in `script/known-failures.txt`. Many of the listed files use preprocessor conditionals or
232
236
  macros that tree-sitter parses without expanding them. The first run clones the repositories. The example
@@ -242,8 +246,7 @@ and the release build regenerate the parsers before compiling them.
242
246
  Cloudflare Workers with and without Node.js compatibility (`test/e2e/workers.test.ts`).
243
247
 
244
248
  The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
245
- by every checkout; `script/fuzz-corpus` builds a parser of its own in `.tmp/fuzz` for each run and deletes it
246
- afterwards.
249
+ by every checkout.
247
250
 
248
251
  CI also runs these tests on Linux arm64 and macOS, where the Rust binding compiles the parser natively, and fuzzes the
249
252
  parser with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c",
3
- "version": "20.0.0",
3
+ "version": "21.0.0",
4
4
  "description": "C grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "c",
@@ -17,7 +17,6 @@
17
17
  "files": [
18
18
  "grammar.js",
19
19
  "types/*",
20
- "queries/*.scm",
21
20
  "src/node-types.json",
22
21
  "tree-sitter.json",
23
22
  "*.wasm",
@@ -55,15 +54,15 @@
55
54
  },
56
55
  "devDependencies": {
57
56
  "@tsconfig/bun": "1.0.11",
58
- "@types/bun": "1.4.3",
57
+ "@types/bun": "1.4.4",
59
58
  "@vitest/browser-playwright": "5.0.5",
60
59
  "@willbooster/oxlint-config": "1.4.9",
61
- "@willbooster/wb": "22.29.3",
60
+ "@willbooster/wb": "22.32.3",
62
61
  "@willbooster/web-tree-sitter": "15.0.3",
63
62
  "conventional-changelog-conventionalcommits": "10.4.1",
64
63
  "lefthook": "2.2.2",
65
- "oxlint": "1.88.0",
66
- "oxlint-tsgolint": "7.0.2004",
64
+ "oxlint": "1.89.0",
65
+ "oxlint-tsgolint": "7.0.2005",
67
66
  "playwright": "1.64.1",
68
67
  "semantic-release": "25.0.9",
69
68
  "vitest": "5.0.5",
Binary file
package/tree-sitter.json CHANGED
@@ -10,8 +10,6 @@
10
10
  "c",
11
11
  "h"
12
12
  ],
13
- "highlights": "queries/highlights.scm",
14
- "tags": "queries/tags.scm",
15
13
  "injection-regex": "^(c|h)$",
16
14
  "external-files": [
17
15
  "src/pragma.h",
@@ -24,7 +22,7 @@
24
22
  }
25
23
  ],
26
24
  "metadata": {
27
- "version": "20.0.0",
25
+ "version": "21.0.0",
28
26
  "license": "MIT",
29
27
  "description": "C grammar for tree-sitter",
30
28
  "authors": [
@@ -1,122 +0,0 @@
1
- (identifier) @variable
2
-
3
- ((identifier) @constant
4
- (#match? @constant "^[A-Z][A-Z\\d_]*$"))
5
-
6
- ((storage_class_specifier) @keyword
7
- (#eq? @keyword "auto"))
8
- "_Countof" @keyword
9
- "_Defer" @keyword
10
- "_Generic" @keyword
11
- "_Thread_local" @keyword
12
- "break" @keyword
13
- "case" @keyword
14
- "const" @keyword
15
- "continue" @keyword
16
- "default" @keyword
17
- "do" @keyword
18
- "else" @keyword
19
- "enum" @keyword
20
- "extern" @keyword
21
- "for" @keyword
22
- "goto" @keyword
23
- "if" @keyword
24
- "inline" @keyword
25
- "return" @keyword
26
- "sizeof" @keyword
27
- "static" @keyword
28
- "struct" @keyword
29
- "switch" @keyword
30
- "typedef" @keyword
31
- "union" @keyword
32
- "volatile" @keyword
33
- "while" @keyword
34
-
35
- "#define" @keyword
36
- "#elif" @keyword
37
- "#elifdef" @keyword
38
- "#elifndef" @keyword
39
- "#else" @keyword
40
- "#endif" @keyword
41
- "#if" @keyword
42
- "#ifdef" @keyword
43
- "#ifndef" @keyword
44
- "#include" @keyword
45
- (preproc_directive) @keyword
46
-
47
- "--" @operator
48
- "-" @operator
49
- "-=" @operator
50
- "->" @operator
51
- "=" @operator
52
- "!=" @operator
53
- "*" @operator
54
- "&" @operator
55
- "&&" @operator
56
- "+" @operator
57
- "++" @operator
58
- "+=" @operator
59
- "<" @operator
60
- "==" @operator
61
- ">" @operator
62
- "||" @operator
63
- "*=" @operator
64
- "/=" @operator
65
- "%=" @operator
66
- "<<=" @operator
67
- ">>=" @operator
68
- "&=" @operator
69
- "|=" @operator
70
- "^=" @operator
71
- "/" @operator
72
- "%" @operator
73
- "<=" @operator
74
- ">=" @operator
75
- "<<" @operator
76
- ">>" @operator
77
- "|" @operator
78
- "^" @operator
79
- "~" @operator
80
- "!" @operator
81
-
82
- (conditional_expression
83
- ["?" ":"] @operator)
84
-
85
- (field_expression
86
- operator: "." @operator)
87
-
88
- (field_designator "." @delimiter)
89
- ";" @delimiter
90
-
91
- (string_literal) @string
92
- (raw_string_literal) @string
93
- (system_lib_string) @string
94
-
95
- (null) @constant
96
- (number_literal) @number
97
- (char_literal) @number
98
-
99
- (field_identifier) @property
100
- (statement_identifier) @label
101
- (type_identifier) @type
102
- (primitive_type) @type
103
- (sized_type_specifier) @type
104
-
105
- (call_expression
106
- function: (identifier) @function)
107
- (call_expression
108
- function: (field_expression
109
- field: (field_identifier) @function))
110
- (function_declarator
111
- declarator: (identifier) @function)
112
- (preproc_function_def
113
- name: (identifier) @function.special)
114
-
115
- (comment) @comment
116
-
117
- (typeof_specifier
118
- ["typeof" "typeof_unqual" "__typeof__" "__typeof" "__typeof_unqual" "__typeof_unqual__"] @keyword)
119
- (bit_int_specifier "_BitInt" @type)
120
- (pragma_operator) @keyword
121
-
122
- (va_arg_expression ["va_arg" "__builtin_va_arg"] @keyword)
package/queries/tags.scm DELETED
@@ -1,9 +0,0 @@
1
- (struct_specifier name: (type_identifier) @name body:(_)) @definition.class
2
-
3
- (declaration type: (union_specifier name: (type_identifier) @name)) @definition.class
4
-
5
- (function_declarator declarator: (identifier) @name) @definition.function
6
-
7
- (type_definition declarator: (type_identifier) @name) @definition.type
8
-
9
- (enum_specifier name: (type_identifier) @name) @definition.type