@willbooster/tree-sitter-c 5.0.3 → 5.0.5
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 -17
- package/package.json +1 -1
- package/src/node-types.json +12 -0
- package/tree-sitter-c.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -135,6 +135,7 @@ module.exports = Object.assign(
|
|
|
135
135
|
$._single_noncompound_statement,
|
|
136
136
|
$.type_specifier,
|
|
137
137
|
$._declarator,
|
|
138
|
+
$._old_style_declarator,
|
|
138
139
|
$._field_declarator,
|
|
139
140
|
$._type_declarator,
|
|
140
141
|
$._abstract_declarator,
|
|
@@ -145,7 +146,6 @@ module.exports = Object.assign(
|
|
|
145
146
|
rules: {
|
|
146
147
|
translation_unit: ($) => repeat($._top_level_item),
|
|
147
148
|
|
|
148
|
-
// Top level items are block items with the exception of the expression statement
|
|
149
149
|
_top_level_item: ($) =>
|
|
150
150
|
choice(
|
|
151
151
|
$.function_definition,
|
|
@@ -199,7 +199,6 @@ module.exports = Object.assign(
|
|
|
199
199
|
')'
|
|
200
200
|
)
|
|
201
201
|
),
|
|
202
|
-
// Preprocesser
|
|
203
202
|
|
|
204
203
|
preproc_include: ($) =>
|
|
205
204
|
seq(
|
|
@@ -304,8 +303,6 @@ module.exports = Object.assign(
|
|
|
304
303
|
);
|
|
305
304
|
},
|
|
306
305
|
|
|
307
|
-
// Main Grammar
|
|
308
|
-
|
|
309
306
|
function_definition: ($) =>
|
|
310
307
|
seq(
|
|
311
308
|
optional($.ms_call_modifier),
|
|
@@ -319,11 +316,32 @@ module.exports = Object.assign(
|
|
|
319
316
|
seq(
|
|
320
317
|
optional($.ms_call_modifier),
|
|
321
318
|
$._declaration_specifiers,
|
|
322
|
-
field('declarator', alias($.
|
|
319
|
+
field('declarator', alias($._old_style_declarator, $._declarator)),
|
|
323
320
|
repeat1($.declaration),
|
|
324
321
|
field('body', $.compound_statement)
|
|
325
322
|
),
|
|
326
323
|
|
|
324
|
+
_old_style_declarator: ($) =>
|
|
325
|
+
choice(
|
|
326
|
+
alias($._old_style_function_declarator, $.function_declarator),
|
|
327
|
+
alias($._old_style_pointer_declarator, $.pointer_declarator)
|
|
328
|
+
),
|
|
329
|
+
|
|
330
|
+
_old_style_pointer_declarator: ($) =>
|
|
331
|
+
prec.dynamic(
|
|
332
|
+
1,
|
|
333
|
+
prec.right(
|
|
334
|
+
seq(
|
|
335
|
+
optional($.ms_based_modifier),
|
|
336
|
+
'*',
|
|
337
|
+
repeat($.attribute_declaration),
|
|
338
|
+
repeat($.ms_pointer_modifier),
|
|
339
|
+
repeat(choice($.type_qualifier, $.attribute_specifier)),
|
|
340
|
+
field('declarator', alias($._old_style_declarator, $._declarator))
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
),
|
|
344
|
+
|
|
327
345
|
declaration: ($) =>
|
|
328
346
|
seq(
|
|
329
347
|
choice(
|
|
@@ -833,7 +851,7 @@ module.exports = Object.assign(
|
|
|
833
851
|
parameter_list: ($) =>
|
|
834
852
|
seq('(', choice(commaSep(choice($.parameter_declaration, $.variadic_parameter)), $.compound_statement), ')'),
|
|
835
853
|
_old_style_parameter_list: ($) =>
|
|
836
|
-
seq('(',
|
|
854
|
+
seq('(', commaSep1(choice($.identifier, alias(VA_ARG_KEYWORDS, $.identifier), $.variadic_parameter)), ')'),
|
|
837
855
|
|
|
838
856
|
parameter_declaration: ($) =>
|
|
839
857
|
seq(
|
|
@@ -842,8 +860,6 @@ module.exports = Object.assign(
|
|
|
842
860
|
repeat($.attribute_specifier)
|
|
843
861
|
),
|
|
844
862
|
|
|
845
|
-
// Statements
|
|
846
|
-
|
|
847
863
|
attributed_statement: ($) => seq(repeat1($.attribute_declaration), $.statement),
|
|
848
864
|
|
|
849
865
|
statement: ($) => choice($.case_statement, $._non_case_statement),
|
|
@@ -1021,8 +1037,6 @@ module.exports = Object.assign(
|
|
|
1021
1037
|
|
|
1022
1038
|
seh_leave_statement: () => seq('__leave', ';'),
|
|
1023
1039
|
|
|
1024
|
-
// Expressions
|
|
1025
|
-
|
|
1026
1040
|
expression: ($) => choice($._expression_not_binary, $.binary_expression),
|
|
1027
1041
|
|
|
1028
1042
|
_expression_not_binary: ($) =>
|
|
@@ -1356,11 +1370,12 @@ module.exports = Object.assign(
|
|
|
1356
1370
|
char_literal: ($) =>
|
|
1357
1371
|
seq(
|
|
1358
1372
|
choice("L'", "u'", "U'", "u8'", "'"),
|
|
1359
|
-
repeat1(
|
|
1373
|
+
repeat1(
|
|
1374
|
+
choice($.escape_sequence, $.invalid_escape_sequence, alias(token.immediate(/[^\\\n']/), sym('character')))
|
|
1375
|
+
),
|
|
1360
1376
|
"'"
|
|
1361
1377
|
),
|
|
1362
1378
|
|
|
1363
|
-
// Must concatenate at least 2 nodes, one of which must be a string_literal.
|
|
1364
1379
|
// Identifier is added to parse macros that are strings, like PRIu64.
|
|
1365
1380
|
concatenated_string: ($) =>
|
|
1366
1381
|
prec.right(
|
|
@@ -1377,7 +1392,13 @@ module.exports = Object.assign(
|
|
|
1377
1392
|
string_literal: ($) =>
|
|
1378
1393
|
seq(
|
|
1379
1394
|
choice('L"', 'u"', 'U"', 'u8"', '"'),
|
|
1380
|
-
repeat(
|
|
1395
|
+
repeat(
|
|
1396
|
+
choice(
|
|
1397
|
+
alias(token.immediate(prec(1, /[^\\"\n]+/)), sym('string_content')),
|
|
1398
|
+
$.escape_sequence,
|
|
1399
|
+
$.invalid_escape_sequence
|
|
1400
|
+
)
|
|
1401
|
+
),
|
|
1381
1402
|
'"'
|
|
1382
1403
|
),
|
|
1383
1404
|
|
|
@@ -1388,12 +1409,17 @@ module.exports = Object.assign(
|
|
|
1388
1409
|
seq(
|
|
1389
1410
|
'\\',
|
|
1390
1411
|
choice(
|
|
1391
|
-
/[
|
|
1412
|
+
/['"?\\abefnrtvE]/,
|
|
1413
|
+
'(',
|
|
1414
|
+
'[',
|
|
1415
|
+
'{',
|
|
1416
|
+
'%',
|
|
1417
|
+
/\r\n?|\n\r?/,
|
|
1392
1418
|
/[xu]\{[0-9a-fA-F]+\}/,
|
|
1393
1419
|
/o\{[0-7]+\}/,
|
|
1394
1420
|
/N\{[^}\n]+\}/,
|
|
1395
|
-
|
|
1396
|
-
/x[0-9a-fA-F]
|
|
1421
|
+
/[0-7]{1,3}/,
|
|
1422
|
+
/x[0-9a-fA-F]+/,
|
|
1397
1423
|
/u[0-9a-fA-F]{4}/,
|
|
1398
1424
|
/U[0-9a-fA-F]{8}/
|
|
1399
1425
|
)
|
|
@@ -1401,6 +1427,8 @@ module.exports = Object.assign(
|
|
|
1401
1427
|
)
|
|
1402
1428
|
),
|
|
1403
1429
|
|
|
1430
|
+
invalid_escape_sequence: () => token(seq('\\', choice(/[^\r\n]/, /u[0-9a-fA-F]{1,3}/, /U[0-9a-fA-F]{1,7}/))),
|
|
1431
|
+
|
|
1404
1432
|
system_lib_string: () => token(seq('<', repeat(choice(/[^>\n]/, String.raw`\>`)), '>')),
|
|
1405
1433
|
|
|
1406
1434
|
true: () => token(choice('TRUE', 'true')),
|
|
@@ -1426,7 +1454,6 @@ module.exports = Object.assign(
|
|
|
1426
1454
|
)
|
|
1427
1455
|
),
|
|
1428
1456
|
|
|
1429
|
-
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
|
1430
1457
|
comment: () => token(choice(LINE_COMMENT, seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
|
|
1431
1458
|
},
|
|
1432
1459
|
}),
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -1087,6 +1087,10 @@
|
|
|
1087
1087
|
{
|
|
1088
1088
|
"type": "escape_sequence",
|
|
1089
1089
|
"named": true
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
"type": "invalid_escape_sequence",
|
|
1093
|
+
"named": true
|
|
1090
1094
|
}
|
|
1091
1095
|
]
|
|
1092
1096
|
}
|
|
@@ -3714,6 +3718,10 @@
|
|
|
3714
3718
|
"type": "escape_sequence",
|
|
3715
3719
|
"named": true
|
|
3716
3720
|
},
|
|
3721
|
+
{
|
|
3722
|
+
"type": "invalid_escape_sequence",
|
|
3723
|
+
"named": true
|
|
3724
|
+
},
|
|
3717
3725
|
{
|
|
3718
3726
|
"type": "string_content",
|
|
3719
3727
|
"named": true
|
|
@@ -4838,6 +4846,10 @@
|
|
|
4838
4846
|
"type": "inline",
|
|
4839
4847
|
"named": false
|
|
4840
4848
|
},
|
|
4849
|
+
{
|
|
4850
|
+
"type": "invalid_escape_sequence",
|
|
4851
|
+
"named": true
|
|
4852
|
+
},
|
|
4841
4853
|
{
|
|
4842
4854
|
"type": "long",
|
|
4843
4855
|
"named": false
|
package/tree-sitter-c.wasm
CHANGED
|
Binary file
|