@willbooster/tree-sitter-c 1.4.2 → 1.5.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 +44 -15
- package/package.json +1 -1
- package/queries/highlights.scm +2 -0
- package/src/node-types.json +38 -0
- package/tree-sitter-c.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -37,6 +37,7 @@ const PREC = {
|
|
|
37
37
|
|
|
38
38
|
const LINE_COMMENT = seq('//', /(\\+(.|\r?\n)|[^\\\n])*/);
|
|
39
39
|
const PRAGMA_SPACING = repeat(choice(/\s/, /\\\r?\n/));
|
|
40
|
+
const VA_ARG_KEYWORDS = choice('va_arg', '__builtin_va_arg');
|
|
40
41
|
|
|
41
42
|
// oxlint-disable-next-line unicorn/prefer-module -- This package is CommonJS, so tree-sitter loads grammar.js as CommonJS.
|
|
42
43
|
module.exports = Object.assign(
|
|
@@ -44,6 +45,8 @@ module.exports = Object.assign(
|
|
|
44
45
|
name: 'c',
|
|
45
46
|
|
|
46
47
|
conflicts: ($) => [
|
|
48
|
+
[$.type_specifier, $.expression, $.va_arg_expression, $.macro_type_specifier],
|
|
49
|
+
[$.va_arg_expression, $.expression],
|
|
47
50
|
[$.type_definition, $._declaration_modifiers],
|
|
48
51
|
[$.type_definition, $.type_specifier],
|
|
49
52
|
[$.type_definition, $.type_qualifier, $.extension_expression],
|
|
@@ -414,7 +417,8 @@ module.exports = Object.assign(
|
|
|
414
417
|
$.function_declarator,
|
|
415
418
|
$.array_declarator,
|
|
416
419
|
$.parenthesized_declarator,
|
|
417
|
-
$.identifier
|
|
420
|
+
$.identifier,
|
|
421
|
+
alias(VA_ARG_KEYWORDS, $.identifier)
|
|
418
422
|
),
|
|
419
423
|
|
|
420
424
|
_declaration_declarator: ($) =>
|
|
@@ -424,7 +428,8 @@ module.exports = Object.assign(
|
|
|
424
428
|
alias($._function_declaration_declarator, $.function_declarator),
|
|
425
429
|
$.array_declarator,
|
|
426
430
|
$.parenthesized_declarator,
|
|
427
|
-
$.identifier
|
|
431
|
+
$.identifier,
|
|
432
|
+
alias(VA_ARG_KEYWORDS, $.identifier)
|
|
428
433
|
),
|
|
429
434
|
|
|
430
435
|
_field_declarator: ($) =>
|
|
@@ -812,7 +817,8 @@ module.exports = Object.assign(
|
|
|
812
817
|
|
|
813
818
|
parameter_list: ($) =>
|
|
814
819
|
seq('(', choice(commaSep(choice($.parameter_declaration, $.variadic_parameter)), $.compound_statement), ')'),
|
|
815
|
-
_old_style_parameter_list: ($) =>
|
|
820
|
+
_old_style_parameter_list: ($) =>
|
|
821
|
+
seq('(', commaSep(choice($.identifier, alias(VA_ARG_KEYWORDS, $.identifier), $.variadic_parameter)), ')'),
|
|
816
822
|
|
|
817
823
|
parameter_declaration: ($) =>
|
|
818
824
|
seq(
|
|
@@ -956,6 +962,7 @@ module.exports = Object.assign(
|
|
|
956
962
|
$.sizeof_expression,
|
|
957
963
|
$.alignof_expression,
|
|
958
964
|
$.offsetof_expression,
|
|
965
|
+
$.va_arg_expression,
|
|
959
966
|
$.generic_expression,
|
|
960
967
|
$.subscript_expression,
|
|
961
968
|
$.call_expression,
|
|
@@ -963,6 +970,7 @@ module.exports = Object.assign(
|
|
|
963
970
|
$.compound_literal_expression,
|
|
964
971
|
$.identifier,
|
|
965
972
|
alias('thread_local', $.identifier),
|
|
973
|
+
alias(VA_ARG_KEYWORDS, $.identifier),
|
|
966
974
|
$.number_literal,
|
|
967
975
|
$._string,
|
|
968
976
|
$.true,
|
|
@@ -994,6 +1002,7 @@ module.exports = Object.assign(
|
|
|
994
1002
|
|
|
995
1003
|
_assignment_left_expression: ($) =>
|
|
996
1004
|
choice(
|
|
1005
|
+
alias(VA_ARG_KEYWORDS, $.identifier),
|
|
997
1006
|
$.identifier,
|
|
998
1007
|
$.call_expression,
|
|
999
1008
|
$.field_expression,
|
|
@@ -1069,17 +1078,23 @@ module.exports = Object.assign(
|
|
|
1069
1078
|
),
|
|
1070
1079
|
|
|
1071
1080
|
sizeof_expression: ($) =>
|
|
1072
|
-
prec(
|
|
1073
|
-
|
|
1074
|
-
|
|
1081
|
+
prec.dynamic(
|
|
1082
|
+
2,
|
|
1083
|
+
prec(
|
|
1084
|
+
PREC.SIZEOF,
|
|
1085
|
+
seq('sizeof', choice(field('value', $.expression), seq('(', field('type', $.type_descriptor), ')')))
|
|
1086
|
+
)
|
|
1075
1087
|
),
|
|
1076
1088
|
|
|
1077
1089
|
alignof_expression: ($) =>
|
|
1078
|
-
prec(
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
seq(
|
|
1090
|
+
prec.dynamic(
|
|
1091
|
+
2,
|
|
1092
|
+
prec(
|
|
1093
|
+
PREC.SIZEOF,
|
|
1094
|
+
seq(
|
|
1095
|
+
choice('__alignof__', '__alignof', '_alignof', 'alignof', '_Alignof'),
|
|
1096
|
+
seq('(', field('type', $.type_descriptor), ')')
|
|
1097
|
+
)
|
|
1083
1098
|
)
|
|
1084
1099
|
),
|
|
1085
1100
|
|
|
@@ -1089,6 +1104,12 @@ module.exports = Object.assign(
|
|
|
1089
1104
|
seq('offsetof', seq('(', field('type', $.type_descriptor), ',', field('member', $._field_identifier), ')'))
|
|
1090
1105
|
),
|
|
1091
1106
|
|
|
1107
|
+
va_arg_expression: ($) =>
|
|
1108
|
+
prec.dynamic(
|
|
1109
|
+
1,
|
|
1110
|
+
seq(VA_ARG_KEYWORDS, '(', field('value', $.expression), ',', field('type', $.type_descriptor), ')')
|
|
1111
|
+
),
|
|
1112
|
+
|
|
1092
1113
|
generic_expression: ($) =>
|
|
1093
1114
|
prec(
|
|
1094
1115
|
PREC.CALL,
|
|
@@ -1339,14 +1360,22 @@ module.exports = Object.assign(
|
|
|
1339
1360
|
identifier: () =>
|
|
1340
1361
|
/(\p{XID_Start}|\$|_|\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})(\p{XID_Continue}|\$|\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})*/u,
|
|
1341
1362
|
|
|
1342
|
-
_type_identifier: ($) => alias($.identifier, sym('type_identifier')),
|
|
1343
|
-
_field_identifier: ($) => alias($.identifier, sym('field_identifier')),
|
|
1344
|
-
_statement_identifier: ($) => alias($.identifier, sym('statement_identifier')),
|
|
1363
|
+
_type_identifier: ($) => alias(choice($.identifier, VA_ARG_KEYWORDS), sym('type_identifier')),
|
|
1364
|
+
_field_identifier: ($) => alias(choice($.identifier, VA_ARG_KEYWORDS), sym('field_identifier')),
|
|
1365
|
+
_statement_identifier: ($) => alias(choice($.identifier, VA_ARG_KEYWORDS), sym('statement_identifier')),
|
|
1345
1366
|
|
|
1346
1367
|
_empty_declaration: ($) => seq(repeat($.ms_declspec_modifier), $.type_specifier, ';'),
|
|
1347
1368
|
|
|
1348
1369
|
macro_type_specifier: ($) =>
|
|
1349
|
-
prec.dynamic(
|
|
1370
|
+
prec.dynamic(
|
|
1371
|
+
-1,
|
|
1372
|
+
seq(
|
|
1373
|
+
field('name', choice($.identifier, alias(VA_ARG_KEYWORDS, $.identifier))),
|
|
1374
|
+
'(',
|
|
1375
|
+
field('type', $.type_descriptor),
|
|
1376
|
+
')'
|
|
1377
|
+
)
|
|
1378
|
+
),
|
|
1350
1379
|
|
|
1351
1380
|
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
|
1352
1381
|
comment: () => token(choice(LINE_COMMENT, seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
package/src/node-types.json
CHANGED
|
@@ -226,6 +226,10 @@
|
|
|
226
226
|
{
|
|
227
227
|
"type": "update_expression",
|
|
228
228
|
"named": true
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"type": "va_arg_expression",
|
|
232
|
+
"named": true
|
|
229
233
|
}
|
|
230
234
|
]
|
|
231
235
|
},
|
|
@@ -4280,6 +4284,32 @@
|
|
|
4280
4284
|
}
|
|
4281
4285
|
}
|
|
4282
4286
|
},
|
|
4287
|
+
{
|
|
4288
|
+
"type": "va_arg_expression",
|
|
4289
|
+
"named": true,
|
|
4290
|
+
"fields": {
|
|
4291
|
+
"type": {
|
|
4292
|
+
"multiple": false,
|
|
4293
|
+
"required": true,
|
|
4294
|
+
"types": [
|
|
4295
|
+
{
|
|
4296
|
+
"type": "type_descriptor",
|
|
4297
|
+
"named": true
|
|
4298
|
+
}
|
|
4299
|
+
]
|
|
4300
|
+
},
|
|
4301
|
+
"value": {
|
|
4302
|
+
"multiple": false,
|
|
4303
|
+
"required": true,
|
|
4304
|
+
"types": [
|
|
4305
|
+
{
|
|
4306
|
+
"type": "expression",
|
|
4307
|
+
"named": true
|
|
4308
|
+
}
|
|
4309
|
+
]
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
},
|
|
4283
4313
|
{
|
|
4284
4314
|
"type": "variadic_parameter",
|
|
4285
4315
|
"named": true,
|
|
@@ -4627,6 +4657,10 @@
|
|
|
4627
4657
|
"type": "__builtin_available",
|
|
4628
4658
|
"named": false
|
|
4629
4659
|
},
|
|
4660
|
+
{
|
|
4661
|
+
"type": "__builtin_va_arg",
|
|
4662
|
+
"named": false
|
|
4663
|
+
},
|
|
4630
4664
|
{
|
|
4631
4665
|
"type": "__cdecl",
|
|
4632
4666
|
"named": false
|
|
@@ -4985,6 +5019,10 @@
|
|
|
4985
5019
|
"type": "unsigned",
|
|
4986
5020
|
"named": false
|
|
4987
5021
|
},
|
|
5022
|
+
{
|
|
5023
|
+
"type": "va_arg",
|
|
5024
|
+
"named": false
|
|
5025
|
+
},
|
|
4988
5026
|
{
|
|
4989
5027
|
"type": "version_number",
|
|
4990
5028
|
"named": true
|
package/tree-sitter-c.wasm
CHANGED
|
Binary file
|