@willbooster/tree-sitter-c 46.0.0 → 48.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/grammar.js +5 -13
- package/package.json +1 -1
- package/src/functionMacro.h +11 -2
- package/src/grammarKeywords.cjs +9 -1
- package/src/keywords.h +68 -1
- package/tree-sitter-c.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -500,7 +500,6 @@ module.exports = Object.assign(
|
|
|
500
500
|
[$.attributed_type_declarator, $._type_declarator],
|
|
501
501
|
[$._declaration_modifiers, $._field_declaration_list_item],
|
|
502
502
|
[$._declaration_specifiers],
|
|
503
|
-
[$._compound_literal_constexpr_specifier, $.type_qualifier],
|
|
504
503
|
[$._marked_macro_type_specifiers],
|
|
505
504
|
[$._braced_leading_macro_attribute_specifier, $._post_type_macro_attribute_specifier],
|
|
506
505
|
[
|
|
@@ -1386,7 +1385,7 @@ module.exports = Object.assign(
|
|
|
1386
1385
|
$._type_identifier,
|
|
1387
1386
|
alias('thread_local', sym('type_identifier')),
|
|
1388
1387
|
alias(choice('signed', 'unsigned', 'long', 'short'), $.primitive_type),
|
|
1389
|
-
$.primitive_type
|
|
1388
|
+
alias($.primitive_type, sym('type_identifier'))
|
|
1390
1389
|
),
|
|
1391
1390
|
|
|
1392
1391
|
_abstract_declarator: ($) =>
|
|
@@ -1605,6 +1604,7 @@ module.exports = Object.assign(
|
|
|
1605
1604
|
'static',
|
|
1606
1605
|
'auto',
|
|
1607
1606
|
'register',
|
|
1607
|
+
'constexpr',
|
|
1608
1608
|
'inline',
|
|
1609
1609
|
'__inline',
|
|
1610
1610
|
'__inline__',
|
|
@@ -1617,7 +1617,6 @@ module.exports = Object.assign(
|
|
|
1617
1617
|
type_qualifier: ($) =>
|
|
1618
1618
|
choice(
|
|
1619
1619
|
'const',
|
|
1620
|
-
'constexpr',
|
|
1621
1620
|
'volatile',
|
|
1622
1621
|
'restrict',
|
|
1623
1622
|
'__restrict__',
|
|
@@ -2256,7 +2255,7 @@ module.exports = Object.assign(
|
|
|
2256
2255
|
|
|
2257
2256
|
platform_version: ($) => seq(field('platform', $.identifier), field('version', $.version_number)),
|
|
2258
2257
|
|
|
2259
|
-
version_number: () => /\d+(\.\d+){0,2}
|
|
2258
|
+
version_number: () => token(prec(-1, /\d+(\.\d+){0,2}/)),
|
|
2260
2259
|
|
|
2261
2260
|
gnu_asm_expression: ($) =>
|
|
2262
2261
|
prec(
|
|
@@ -2340,22 +2339,15 @@ module.exports = Object.assign(
|
|
|
2340
2339
|
seq(
|
|
2341
2340
|
'(',
|
|
2342
2341
|
repeat(
|
|
2343
|
-
|
|
2344
|
-
optional(
|
|
2345
|
-
field('storage_class', alias($._compound_literal_constexpr_specifier, $.storage_class_specifier))
|
|
2346
|
-
),
|
|
2347
|
-
field('storage_class', alias($._compound_literal_storage_class_specifier, $.storage_class_specifier))
|
|
2348
|
-
)
|
|
2342
|
+
field('storage_class', alias($._compound_literal_storage_class_specifier, $.storage_class_specifier))
|
|
2349
2343
|
),
|
|
2350
2344
|
field('type', $.type_descriptor),
|
|
2351
2345
|
')',
|
|
2352
2346
|
field('value', $.initializer_list)
|
|
2353
2347
|
),
|
|
2354
2348
|
|
|
2355
|
-
_compound_literal_constexpr_specifier: () => 'constexpr',
|
|
2356
|
-
|
|
2357
2349
|
_compound_literal_storage_class_specifier: () =>
|
|
2358
|
-
choice('static', 'register', 'thread_local', '_Thread_local', '__thread'),
|
|
2350
|
+
choice('static', 'constexpr', 'register', 'thread_local', '_Thread_local', '__thread'),
|
|
2359
2351
|
|
|
2360
2352
|
parenthesized_expression: ($) => seq('(', choice($.expression, $.comma_expression, $.compound_statement), ')'),
|
|
2361
2353
|
|
package/package.json
CHANGED
package/src/functionMacro.h
CHANGED
|
@@ -54,6 +54,7 @@ static bool function_macro_type_prefix_keyword(const MacroName *name, const char
|
|
|
54
54
|
static bool function_macro_group(int32_t c, int32_t open, int32_t close, unsigned *depth, unsigned *nested, unsigned *braces);
|
|
55
55
|
static void function_macro_note_literal(bool *literal, unsigned depth, unsigned nested, const MacroArgumentWord *word, int32_t c);
|
|
56
56
|
static bool function_macro_tail_word(TSLexer *lexer, bool escaped, MacroPrototypeTail *tail);
|
|
57
|
+
static bool function_macro_tail_modifier(const char *word, bool before_declarator);
|
|
57
58
|
static MacroGroup function_macro_tail_group(TSLexer *lexer, int32_t c, MacroPrototypeTail *tail, const PragmaTrivia *trivia);
|
|
58
59
|
static bool function_macro_tail_punctuator(TSLexer *lexer, int32_t c, MacroPrototypeTail *tail);
|
|
59
60
|
static bool function_macro_declaration_continues(TSLexer *lexer, bool post_type, bool allow_braced, const PragmaTrivia *trivia);
|
|
@@ -661,8 +662,16 @@ static bool function_macro_tail_word(TSLexer *lexer, bool escaped, MacroPrototyp
|
|
|
661
662
|
tail->modifier = pragma || (name.ascii && function_macro_word_in(word, function_macro_group_modifiers,
|
|
662
663
|
sizeof(function_macro_group_modifiers) / sizeof(function_macro_group_modifiers[0])));
|
|
663
664
|
return !tail->post_type || !keyword ||
|
|
664
|
-
|
|
665
|
-
|
|
665
|
+
function_macro_tail_modifier(word, !tail->declarator_name && !tail->declarator_group);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
static bool function_macro_tail_modifier(const char *word, bool before_declarator) {
|
|
669
|
+
if (before_declarator) {
|
|
670
|
+
return function_macro_word_in(word, function_macro_type_prefix_modifiers,
|
|
671
|
+
sizeof(function_macro_type_prefix_modifiers) / sizeof(function_macro_type_prefix_modifiers[0]));
|
|
672
|
+
}
|
|
673
|
+
return function_macro_word_in(word, function_macro_declaration_modifiers,
|
|
674
|
+
sizeof(function_macro_declaration_modifiers) / sizeof(function_macro_declaration_modifiers[0]));
|
|
666
675
|
}
|
|
667
676
|
|
|
668
677
|
static bool function_macro_argument_escape(TSLexer *lexer, MacroArgumentWord *word) {
|
package/src/grammarKeywords.cjs
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
// oxlint-disable-next-line unicorn/prefer-module -- Tree-sitter loads grammar dependencies as CommonJS.
|
|
4
|
-
module.exports = {
|
|
4
|
+
module.exports = {
|
|
5
|
+
primitiveTypeKeywords: [
|
|
6
|
+
'_Bool', 'bool', 'char', 'int', 'float', 'double', 'void',
|
|
7
|
+
'_Float16', '_Float32', '_Float64', '_Float128',
|
|
8
|
+
'_Float32x', '_Float64x', '_Float128x',
|
|
9
|
+
'_Decimal32', '_Decimal64', '_Decimal96', '_Decimal128', '_Decimal64x', '_Decimal128x',
|
|
10
|
+
'__fp16', '__float80', '__float128', '__ibm128',
|
|
11
|
+
],
|
|
12
|
+
};
|
package/src/keywords.h
CHANGED
|
@@ -12,7 +12,20 @@ static const char *const function_macro_keywords[] = {
|
|
|
12
12
|
"_Bool",
|
|
13
13
|
"_Complex",
|
|
14
14
|
"_Countof",
|
|
15
|
+
"_Decimal128",
|
|
16
|
+
"_Decimal128x",
|
|
17
|
+
"_Decimal32",
|
|
18
|
+
"_Decimal64",
|
|
19
|
+
"_Decimal64x",
|
|
20
|
+
"_Decimal96",
|
|
15
21
|
"_Defer",
|
|
22
|
+
"_Float128",
|
|
23
|
+
"_Float128x",
|
|
24
|
+
"_Float16",
|
|
25
|
+
"_Float32",
|
|
26
|
+
"_Float32x",
|
|
27
|
+
"_Float64",
|
|
28
|
+
"_Float64x",
|
|
16
29
|
"_Generic",
|
|
17
30
|
"_Imaginary",
|
|
18
31
|
"_Nonnull",
|
|
@@ -35,7 +48,11 @@ static const char *const function_macro_keywords[] = {
|
|
|
35
48
|
"__extension__",
|
|
36
49
|
"__fastcall",
|
|
37
50
|
"__finally",
|
|
51
|
+
"__float128",
|
|
52
|
+
"__float80",
|
|
38
53
|
"__forceinline",
|
|
54
|
+
"__fp16",
|
|
55
|
+
"__ibm128",
|
|
39
56
|
"__inline",
|
|
40
57
|
"__inline__",
|
|
41
58
|
"__leave",
|
|
@@ -151,8 +168,25 @@ static const char *const function_macro_type_keywords[] = {
|
|
|
151
168
|
"_BitInt",
|
|
152
169
|
"_Bool",
|
|
153
170
|
"_Complex",
|
|
171
|
+
"_Decimal128",
|
|
172
|
+
"_Decimal128x",
|
|
173
|
+
"_Decimal32",
|
|
174
|
+
"_Decimal64",
|
|
175
|
+
"_Decimal64x",
|
|
176
|
+
"_Decimal96",
|
|
177
|
+
"_Float128",
|
|
178
|
+
"_Float128x",
|
|
179
|
+
"_Float16",
|
|
180
|
+
"_Float32",
|
|
181
|
+
"_Float32x",
|
|
182
|
+
"_Float64",
|
|
183
|
+
"_Float64x",
|
|
154
184
|
"_Imaginary",
|
|
155
185
|
"__complex__",
|
|
186
|
+
"__float128",
|
|
187
|
+
"__float80",
|
|
188
|
+
"__fp16",
|
|
189
|
+
"__ibm128",
|
|
156
190
|
"__typeof",
|
|
157
191
|
"__typeof__",
|
|
158
192
|
"__typeof_unqual",
|
|
@@ -195,6 +229,23 @@ static const char *const function_macro_type_keywords[] = {
|
|
|
195
229
|
};
|
|
196
230
|
static const char *const function_macro_scalar_type_keywords[] = {
|
|
197
231
|
"_Bool",
|
|
232
|
+
"_Decimal128",
|
|
233
|
+
"_Decimal128x",
|
|
234
|
+
"_Decimal32",
|
|
235
|
+
"_Decimal64",
|
|
236
|
+
"_Decimal64x",
|
|
237
|
+
"_Decimal96",
|
|
238
|
+
"_Float128",
|
|
239
|
+
"_Float128x",
|
|
240
|
+
"_Float16",
|
|
241
|
+
"_Float32",
|
|
242
|
+
"_Float32x",
|
|
243
|
+
"_Float64",
|
|
244
|
+
"_Float64x",
|
|
245
|
+
"__float128",
|
|
246
|
+
"__float80",
|
|
247
|
+
"__fp16",
|
|
248
|
+
"__ibm128",
|
|
198
249
|
"bool",
|
|
199
250
|
"char",
|
|
200
251
|
"char16_t",
|
|
@@ -227,6 +278,19 @@ static const char *const function_macro_object_prefix_keywords[] = {
|
|
|
227
278
|
"_Atomic",
|
|
228
279
|
"_Bool",
|
|
229
280
|
"_Complex",
|
|
281
|
+
"_Decimal128",
|
|
282
|
+
"_Decimal128x",
|
|
283
|
+
"_Decimal32",
|
|
284
|
+
"_Decimal64",
|
|
285
|
+
"_Decimal64x",
|
|
286
|
+
"_Decimal96",
|
|
287
|
+
"_Float128",
|
|
288
|
+
"_Float128x",
|
|
289
|
+
"_Float16",
|
|
290
|
+
"_Float32",
|
|
291
|
+
"_Float32x",
|
|
292
|
+
"_Float64",
|
|
293
|
+
"_Float64x",
|
|
230
294
|
"_Imaginary",
|
|
231
295
|
"_Nonnull",
|
|
232
296
|
"_Noreturn",
|
|
@@ -241,7 +305,11 @@ static const char *const function_macro_object_prefix_keywords[] = {
|
|
|
241
305
|
"__declspec",
|
|
242
306
|
"__extension__",
|
|
243
307
|
"__fastcall",
|
|
308
|
+
"__float128",
|
|
309
|
+
"__float80",
|
|
244
310
|
"__forceinline",
|
|
311
|
+
"__fp16",
|
|
312
|
+
"__ibm128",
|
|
245
313
|
"__inline",
|
|
246
314
|
"__inline__",
|
|
247
315
|
"__restrict__",
|
|
@@ -332,7 +400,6 @@ static const char *const function_macro_declaration_modifiers[] = {
|
|
|
332
400
|
"alignas",
|
|
333
401
|
"asm",
|
|
334
402
|
"const",
|
|
335
|
-
"constexpr",
|
|
336
403
|
"noreturn",
|
|
337
404
|
"restrict",
|
|
338
405
|
"volatile",
|
package/tree-sitter-c.wasm
CHANGED
|
Binary file
|