@willbooster/tree-sitter-c 1.4.1 → 1.4.2

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
@@ -44,6 +44,10 @@ module.exports = Object.assign(
44
44
  name: 'c',
45
45
 
46
46
  conflicts: ($) => [
47
+ [$.type_definition, $._declaration_modifiers],
48
+ [$.type_definition, $.type_specifier],
49
+ [$.type_definition, $.type_qualifier, $.extension_expression],
50
+ [$.type_definition, $.type_qualifier],
47
51
  [$._declaration_modifiers, $._empty_declaration],
48
52
  [$.declaration, $.storage_class_specifier],
49
53
  [$.sized_type_specifier, $.enum_specifier],
@@ -57,6 +61,11 @@ module.exports = Object.assign(
57
61
  [$.sized_type_specifier],
58
62
  [$._sized_bit_int_specifier],
59
63
  [$.sized_type_specifier, $._sized_bit_int_specifier],
64
+ [$._type_declarator, $.sized_type_specifier, $._sized_bit_int_specifier],
65
+ [$.type_qualifier, $.atomic_type_specifier],
66
+ [$.type_definition, $._type_declarator],
67
+ [$.type_definition, $.sized_type_specifier],
68
+ [$.type_definition, $._sized_bit_int_specifier],
60
69
  [$.attributed_statement],
61
70
  [$._declaration_modifiers, $.attributed_statement],
62
71
  [$.enum_specifier],
@@ -77,6 +86,7 @@ module.exports = Object.assign(
77
86
  extras: ($) => [$.pragma_operator, /\s|\\\r?\n/, $.comment],
78
87
 
79
88
  inline: ($) => [
89
+ $._non_identifier_type_specifier,
80
90
  $._type_identifier,
81
91
  $._field_identifier,
82
92
  $._statement_identifier,
@@ -323,9 +333,17 @@ module.exports = Object.assign(
323
333
 
324
334
  type_definition: ($) =>
325
335
  seq(
326
- optional('__extension__'),
327
- 'typedef',
328
- $._type_definition_type,
336
+ optional(prec.dynamic(1, '__extension__')),
337
+ choice(
338
+ seq(repeat($.type_qualifier), 'typedef', $._type_definition_type),
339
+ seq(
340
+ repeat($._declaration_modifiers),
341
+ field('type', $._non_identifier_type_specifier),
342
+ repeat($.type_qualifier),
343
+ 'typedef',
344
+ repeat(choice($.type_qualifier, $._non_identifier_type_specifier))
345
+ )
346
+ ),
329
347
  $._type_definition_declarators,
330
348
  repeat($.attribute_specifier),
331
349
  ';'
@@ -626,18 +644,24 @@ module.exports = Object.assign(
626
644
  alignas_qualifier: ($) => seq(choice('alignas', '_Alignas'), '(', choice($.expression, $.type_descriptor), ')'),
627
645
 
628
646
  type_specifier: ($) =>
647
+ choice(
648
+ $._non_identifier_type_specifier,
649
+ $.macro_type_specifier,
650
+ $._type_identifier,
651
+ prec.dynamic(-1, alias('thread_local', sym('type_identifier')))
652
+ ),
653
+
654
+ _non_identifier_type_specifier: ($) =>
629
655
  choice(
630
656
  $.struct_specifier,
631
657
  $.union_specifier,
632
658
  $.enum_specifier,
633
659
  $.typeof_specifier,
634
660
  $.bit_int_specifier,
635
- $.macro_type_specifier,
661
+ $.atomic_type_specifier,
636
662
  $.sized_type_specifier,
637
663
  alias($._sized_bit_int_specifier, $.sized_type_specifier),
638
- $.primitive_type,
639
- $._type_identifier,
640
- prec.dynamic(-1, alias('thread_local', sym('type_identifier')))
664
+ $.primitive_type
641
665
  ),
642
666
 
643
667
  typeof_specifier: ($) =>
@@ -647,6 +671,8 @@ module.exports = Object.assign(
647
671
  choice($.type_descriptor, $.expression, $.comma_expression),
648
672
  ')'
649
673
  ),
674
+ atomic_type_specifier: ($) => seq('_Atomic', '(', field('type', $.type_descriptor), ')'),
675
+
650
676
  bit_int_specifier: ($) => seq('_BitInt', '(', $.expression, ')'),
651
677
 
652
678
  sized_type_specifier: ($) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "C grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -303,6 +303,10 @@
303
303
  "type": "type_specifier",
304
304
  "named": true,
305
305
  "subtypes": [
306
+ {
307
+ "type": "atomic_type_specifier",
308
+ "named": true
309
+ },
306
310
  {
307
311
  "type": "bit_int_specifier",
308
312
  "named": true
@@ -670,6 +674,22 @@
670
674
  }
671
675
  }
672
676
  },
677
+ {
678
+ "type": "atomic_type_specifier",
679
+ "named": true,
680
+ "fields": {
681
+ "type": {
682
+ "multiple": false,
683
+ "required": true,
684
+ "types": [
685
+ {
686
+ "type": "type_descriptor",
687
+ "named": true
688
+ }
689
+ ]
690
+ }
691
+ }
692
+ },
673
693
  {
674
694
  "type": "attribute",
675
695
  "named": true,
@@ -4019,13 +4039,57 @@
4019
4039
  "multiple": true,
4020
4040
  "required": false,
4021
4041
  "types": [
4042
+ {
4043
+ "type": "atomic_type_specifier",
4044
+ "named": true
4045
+ },
4046
+ {
4047
+ "type": "attribute_declaration",
4048
+ "named": true
4049
+ },
4022
4050
  {
4023
4051
  "type": "attribute_specifier",
4024
4052
  "named": true
4025
4053
  },
4054
+ {
4055
+ "type": "bit_int_specifier",
4056
+ "named": true
4057
+ },
4058
+ {
4059
+ "type": "enum_specifier",
4060
+ "named": true
4061
+ },
4062
+ {
4063
+ "type": "ms_declspec_modifier",
4064
+ "named": true
4065
+ },
4066
+ {
4067
+ "type": "primitive_type",
4068
+ "named": true
4069
+ },
4070
+ {
4071
+ "type": "sized_type_specifier",
4072
+ "named": true
4073
+ },
4074
+ {
4075
+ "type": "storage_class_specifier",
4076
+ "named": true
4077
+ },
4078
+ {
4079
+ "type": "struct_specifier",
4080
+ "named": true
4081
+ },
4026
4082
  {
4027
4083
  "type": "type_qualifier",
4028
4084
  "named": true
4085
+ },
4086
+ {
4087
+ "type": "typeof_specifier",
4088
+ "named": true
4089
+ },
4090
+ {
4091
+ "type": "union_specifier",
4092
+ "named": true
4029
4093
  }
4030
4094
  ]
4031
4095
  }
Binary file
package/tree-sitter.json CHANGED
@@ -16,7 +16,7 @@
16
16
  }
17
17
  ],
18
18
  "metadata": {
19
- "version": "1.4.1",
19
+ "version": "1.4.2",
20
20
  "license": "MIT",
21
21
  "description": "C grammar for tree-sitter",
22
22
  "authors": [