@willbooster/tree-sitter-c 5.0.3 → 5.0.4

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 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($._old_style_function_declarator, $.function_declarator)),
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('(', commaSep(choice($.identifier, alias(VA_ARG_KEYWORDS, $.identifier), $.variadic_parameter)), ')'),
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: ($) =>
@@ -1360,7 +1374,6 @@ module.exports = Object.assign(
1360
1374
  "'"
1361
1375
  ),
1362
1376
 
1363
- // Must concatenate at least 2 nodes, one of which must be a string_literal.
1364
1377
  // Identifier is added to parse macros that are strings, like PRIu64.
1365
1378
  concatenated_string: ($) =>
1366
1379
  prec.right(
@@ -1426,7 +1439,6 @@ module.exports = Object.assign(
1426
1439
  )
1427
1440
  ),
1428
1441
 
1429
- // http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
1430
1442
  comment: () => token(choice(LINE_COMMENT, seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
1431
1443
  },
1432
1444
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "C grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -16,7 +16,7 @@
16
16
  }
17
17
  ],
18
18
  "metadata": {
19
- "version": "5.0.3",
19
+ "version": "5.0.4",
20
20
  "license": "MIT",
21
21
  "description": "C grammar for tree-sitter",
22
22
  "authors": [