@ast-grep/lang-go 0.0.3 → 0.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.
@@ -14,6 +14,7 @@ extern "C" {
14
14
  #include <string.h>
15
15
 
16
16
  #ifdef _MSC_VER
17
+ #pragma warning(push)
17
18
  #pragma warning(disable : 4101)
18
19
  #elif defined(__GNUC__) || defined(__clang__)
19
20
  #pragma GCC diagnostic push
@@ -278,7 +279,7 @@ static inline void _array__splice(Array *self, size_t element_size,
278
279
  #define _compare_int(a, b) ((int)*(a) - (int)(b))
279
280
 
280
281
  #ifdef _MSC_VER
281
- #pragma warning(default : 4101)
282
+ #pragma warning(pop)
282
283
  #elif defined(__GNUC__) || defined(__clang__)
283
284
  #pragma GCC diagnostic pop
284
285
  #endif
@@ -18,6 +18,11 @@ typedef uint16_t TSStateId;
18
18
  typedef uint16_t TSSymbol;
19
19
  typedef uint16_t TSFieldId;
20
20
  typedef struct TSLanguage TSLanguage;
21
+ typedef struct TSLanguageMetadata {
22
+ uint8_t major_version;
23
+ uint8_t minor_version;
24
+ uint8_t patch_version;
25
+ } TSLanguageMetadata;
21
26
  #endif
22
27
 
23
28
  typedef struct {
@@ -26,10 +31,11 @@ typedef struct {
26
31
  bool inherited;
27
32
  } TSFieldMapEntry;
28
33
 
34
+ // Used to index the field and supertype maps.
29
35
  typedef struct {
30
36
  uint16_t index;
31
37
  uint16_t length;
32
- } TSFieldMapSlice;
38
+ } TSMapSlice;
33
39
 
34
40
  typedef struct {
35
41
  bool visible;
@@ -79,6 +85,12 @@ typedef struct {
79
85
  uint16_t external_lex_state;
80
86
  } TSLexMode;
81
87
 
88
+ typedef struct {
89
+ uint16_t lex_state;
90
+ uint16_t external_lex_state;
91
+ uint16_t reserved_word_set_id;
92
+ } TSLexerMode;
93
+
82
94
  typedef union {
83
95
  TSParseAction action;
84
96
  struct {
@@ -93,7 +105,7 @@ typedef struct {
93
105
  } TSCharacterRange;
94
106
 
95
107
  struct TSLanguage {
96
- uint32_t version;
108
+ uint32_t abi_version;
97
109
  uint32_t symbol_count;
98
110
  uint32_t alias_count;
99
111
  uint32_t token_count;
@@ -109,13 +121,13 @@ struct TSLanguage {
109
121
  const TSParseActionEntry *parse_actions;
110
122
  const char * const *symbol_names;
111
123
  const char * const *field_names;
112
- const TSFieldMapSlice *field_map_slices;
124
+ const TSMapSlice *field_map_slices;
113
125
  const TSFieldMapEntry *field_map_entries;
114
126
  const TSSymbolMetadata *symbol_metadata;
115
127
  const TSSymbol *public_symbol_map;
116
128
  const uint16_t *alias_map;
117
129
  const TSSymbol *alias_sequences;
118
- const TSLexMode *lex_modes;
130
+ const TSLexerMode *lex_modes;
119
131
  bool (*lex_fn)(TSLexer *, TSStateId);
120
132
  bool (*keyword_lex_fn)(TSLexer *, TSStateId);
121
133
  TSSymbol keyword_capture_token;
@@ -129,15 +141,23 @@ struct TSLanguage {
129
141
  void (*deserialize)(void *, const char *, unsigned);
130
142
  } external_scanner;
131
143
  const TSStateId *primary_state_ids;
144
+ const char *name;
145
+ const TSSymbol *reserved_words;
146
+ uint16_t max_reserved_word_set_size;
147
+ uint32_t supertype_count;
148
+ const TSSymbol *supertype_symbols;
149
+ const TSMapSlice *supertype_map_slices;
150
+ const TSSymbol *supertype_map_entries;
151
+ TSLanguageMetadata metadata;
132
152
  };
133
153
 
134
- static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
154
+ static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
135
155
  uint32_t index = 0;
136
156
  uint32_t size = len - index;
137
157
  while (size > 1) {
138
158
  uint32_t half_size = size / 2;
139
159
  uint32_t mid_index = index + half_size;
140
- TSCharacterRange *range = &ranges[mid_index];
160
+ const TSCharacterRange *range = &ranges[mid_index];
141
161
  if (lookahead >= range->start && lookahead <= range->end) {
142
162
  return true;
143
163
  } else if (lookahead > range->end) {
@@ -145,7 +165,7 @@ static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t
145
165
  }
146
166
  size -= half_size;
147
167
  }
148
- TSCharacterRange *range = &ranges[index];
168
+ const TSCharacterRange *range = &ranges[index];
149
169
  return (lookahead >= range->start && lookahead <= range->end);
150
170
  }
151
171
 
package/type.d.ts CHANGED
@@ -394,11 +394,11 @@ type goTypes = {
394
394
  "named": true,
395
395
  "fields": {},
396
396
  "children": {
397
- "multiple": true,
397
+ "multiple": false,
398
398
  "required": false,
399
399
  "types": [
400
400
  {
401
- "type": "_statement",
401
+ "type": "statement_list",
402
402
  "named": true
403
403
  }
404
404
  ]
@@ -491,11 +491,11 @@ type goTypes = {
491
491
  }
492
492
  },
493
493
  "children": {
494
- "multiple": true,
494
+ "multiple": false,
495
495
  "required": false,
496
496
  "types": [
497
497
  {
498
- "type": "_statement",
498
+ "type": "statement_list",
499
499
  "named": true
500
500
  }
501
501
  ]
@@ -641,11 +641,11 @@ type goTypes = {
641
641
  "named": true,
642
642
  "fields": {},
643
643
  "children": {
644
- "multiple": true,
644
+ "multiple": false,
645
645
  "required": false,
646
646
  "types": [
647
647
  {
648
- "type": "_statement",
648
+ "type": "statement_list",
649
649
  "named": true
650
650
  }
651
651
  ]
@@ -692,11 +692,11 @@ type goTypes = {
692
692
  }
693
693
  },
694
694
  "children": {
695
- "multiple": true,
695
+ "multiple": false,
696
696
  "required": false,
697
697
  "types": [
698
698
  {
699
- "type": "_statement",
699
+ "type": "statement_list",
700
700
  "named": true
701
701
  }
702
702
  ]
@@ -1960,6 +1960,21 @@ type goTypes = {
1960
1960
  ]
1961
1961
  }
1962
1962
  },
1963
+ "statement_list": {
1964
+ "type": "statement_list",
1965
+ "named": true,
1966
+ "fields": {},
1967
+ "children": {
1968
+ "multiple": true,
1969
+ "required": true,
1970
+ "types": [
1971
+ {
1972
+ "type": "_statement",
1973
+ "named": true
1974
+ }
1975
+ ]
1976
+ }
1977
+ },
1963
1978
  "struct_type": {
1964
1979
  "type": "struct_type",
1965
1980
  "named": true,
@@ -1998,6 +2013,16 @@ type goTypes = {
1998
2013
  "named": true
1999
2014
  }
2000
2015
  ]
2016
+ },
2017
+ "type_parameters": {
2018
+ "multiple": false,
2019
+ "required": false,
2020
+ "types": [
2021
+ {
2022
+ "type": "type_parameter_list",
2023
+ "named": true
2024
+ }
2025
+ ]
2001
2026
  }
2002
2027
  }
2003
2028
  },
@@ -2058,11 +2083,11 @@ type goTypes = {
2058
2083
  }
2059
2084
  },
2060
2085
  "children": {
2061
- "multiple": true,
2086
+ "multiple": false,
2062
2087
  "required": false,
2063
2088
  "types": [
2064
2089
  {
2065
- "type": "_statement",
2090
+ "type": "statement_list",
2066
2091
  "named": true
2067
2092
  }
2068
2093
  ]
@@ -2434,7 +2459,8 @@ type goTypes = {
2434
2459
  },
2435
2460
  "comment": {
2436
2461
  "type": "comment",
2437
- "named": true
2462
+ "named": true,
2463
+ "extra": true
2438
2464
  },
2439
2465
  "escape_sequence": {
2440
2466
  "type": "escape_sequence",