@willbooster/tree-sitter-c 5.0.6 → 5.1.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
@@ -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.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.41.8-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
package/grammar.js CHANGED
@@ -96,6 +96,11 @@ module.exports = Object.assign(
96
96
  [$._single_attributed_statement],
97
97
  [$._declaration_modifiers, $.attributed_statement],
98
98
  [$.enum_specifier],
99
+ [sym('preproc_if_in_enumerator_list'), sym('preproc_if_in_enumerator_list_no_comma')],
100
+ [sym('preproc_ifdef_in_enumerator_list'), sym('preproc_ifdef_in_enumerator_list_no_comma')],
101
+ [sym('preproc_else_in_enumerator_list'), sym('preproc_else_in_enumerator_list_no_comma')],
102
+ [sym('preproc_elif_in_enumerator_list'), sym('preproc_elif_in_enumerator_list_no_comma')],
103
+ [sym('preproc_elifdef_in_enumerator_list'), sym('preproc_elifdef_in_enumerator_list_no_comma')],
99
104
  [$.type_specifier, $._old_style_parameter_list],
100
105
  [$.parameter_list, $._old_style_parameter_list],
101
106
  [$.function_declarator, $._function_declaration_declarator],
@@ -244,8 +249,19 @@ module.exports = Object.assign(
244
249
  ...preprocIf('', () => sym('_block_item')),
245
250
  ...preprocIf('_in_single_case', () => sym('_single_case_body'), 0, true),
246
251
  ...preprocIf('_in_field_declaration_list', () => sym('_field_declaration_list_item')),
247
- ...preprocIf('_in_enumerator_list', () => seq(sym('enumerator'), ',')),
248
- ...preprocIf('_in_enumerator_list_no_comma', () => sym('enumerator'), -1),
252
+ ...preprocIf('_in_enumerator_list', () => choice(seq(sym('enumerator'), ','), sym('_enumerator_directives'))),
253
+ ...preprocIf(
254
+ '_in_enumerator_list_no_comma',
255
+ () =>
256
+ choice(
257
+ seq(optional(sym('_enumerator_directives')), sym('enumerator'), optional(sym('_enumerator_directives'))),
258
+ sym('_enumerator_directives')
259
+ ),
260
+ 0,
261
+ false
262
+ ),
263
+
264
+ _enumerator_directives: ($) => prec.right(repeat1($.preproc_call)),
249
265
 
250
266
  _preproc_newline: () => token.immediate(/\r?\n/),
251
267
 
@@ -783,7 +799,8 @@ module.exports = Object.assign(
783
799
  seq($.enumerator, ','),
784
800
  alias(sym('preproc_if_in_enumerator_list'), sym('preproc_if')),
785
801
  alias(sym('preproc_ifdef_in_enumerator_list'), sym('preproc_ifdef')),
786
- seq($.preproc_call, ',')
802
+ seq($.preproc_call, ','),
803
+ prec(1, $.preproc_call)
787
804
  )
788
805
  ),
789
806
  optional(
@@ -791,11 +808,11 @@ module.exports = Object.assign(
791
808
  choice(
792
809
  $.enumerator,
793
810
  alias(sym('preproc_if_in_enumerator_list_no_comma'), sym('preproc_if')),
794
- alias(sym('preproc_ifdef_in_enumerator_list_no_comma'), sym('preproc_ifdef')),
795
- $.preproc_call
811
+ alias(sym('preproc_ifdef_in_enumerator_list_no_comma'), sym('preproc_ifdef'))
796
812
  )
797
813
  )
798
814
  ),
815
+ repeat($.preproc_call),
799
816
  '}'
800
817
  ),
801
818
 
@@ -1048,6 +1065,7 @@ module.exports = Object.assign(
1048
1065
  $.cast_expression,
1049
1066
  $.pointer_expression,
1050
1067
  $.sizeof_expression,
1068
+ $.countof_expression,
1051
1069
  $.alignof_expression,
1052
1070
  $.offsetof_expression,
1053
1071
  $.va_arg_expression,
@@ -1153,6 +1171,18 @@ module.exports = Object.assign(
1153
1171
  )
1154
1172
  ),
1155
1173
 
1174
+ countof_expression: ($) =>
1175
+ prec(
1176
+ PREC.SIZEOF,
1177
+ seq(
1178
+ '_Countof',
1179
+ choice(
1180
+ field('value', prec.dynamic(3, $.expression)),
1181
+ prec.dynamic(2, seq('(', field('type', $.type_descriptor), ')'))
1182
+ )
1183
+ )
1184
+ ),
1185
+
1156
1186
  alignof_expression: ($) =>
1157
1187
  prec.dynamic(
1158
1188
  2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c",
3
- "version": "5.0.6",
3
+ "version": "5.1.1",
4
4
  "description": "C grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -60,7 +60,6 @@
60
60
  "playwright": "1.64.0",
61
61
  "semantic-release": "25.0.9",
62
62
  "sort-package-json": "4.0.0",
63
- "typescript": "7.0.2",
64
63
  "vitest": "5.0.3",
65
64
  "wrangler": "4.149.0"
66
65
  },
@@ -5,6 +5,7 @@
5
5
 
6
6
  ((storage_class_specifier) @keyword
7
7
  (#eq? @keyword "auto"))
8
+ "_Countof" @keyword
8
9
  "_Generic" @keyword
9
10
  "_Thread_local" @keyword
10
11
  "break" @keyword
@@ -159,6 +159,10 @@
159
159
  "type": "conditional_expression",
160
160
  "named": true
161
161
  },
162
+ {
163
+ "type": "countof_expression",
164
+ "named": true
165
+ },
162
166
  {
163
167
  "type": "extension_expression",
164
168
  "named": true
@@ -1288,6 +1292,32 @@
1288
1292
  "named": true,
1289
1293
  "fields": {}
1290
1294
  },
1295
+ {
1296
+ "type": "countof_expression",
1297
+ "named": true,
1298
+ "fields": {
1299
+ "type": {
1300
+ "multiple": false,
1301
+ "required": false,
1302
+ "types": [
1303
+ {
1304
+ "type": "type_descriptor",
1305
+ "named": true
1306
+ }
1307
+ ]
1308
+ },
1309
+ "value": {
1310
+ "multiple": false,
1311
+ "required": false,
1312
+ "types": [
1313
+ {
1314
+ "type": "expression",
1315
+ "named": true
1316
+ }
1317
+ ]
1318
+ }
1319
+ }
1320
+ },
1291
1321
  {
1292
1322
  "type": "declaration",
1293
1323
  "named": true,
@@ -4577,6 +4607,10 @@
4577
4607
  "type": "_Complex",
4578
4608
  "named": false
4579
4609
  },
4610
+ {
4611
+ "type": "_Countof",
4612
+ "named": false
4613
+ },
4580
4614
  {
4581
4615
  "type": "_Generic",
4582
4616
  "named": false
Binary file
package/tree-sitter.json CHANGED
@@ -16,7 +16,7 @@
16
16
  }
17
17
  ],
18
18
  "metadata": {
19
- "version": "5.0.6",
19
+ "version": "5.1.1",
20
20
  "license": "MIT",
21
21
  "description": "C grammar for tree-sitter",
22
22
  "authors": [