@ast-grep/lang-javascript 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
@@ -20,6 +20,10 @@ type javascriptTypes = {
20
20
  "type": "lexical_declaration",
21
21
  "named": true
22
22
  },
23
+ {
24
+ "type": "using_declaration",
25
+ "named": true
26
+ },
23
27
  {
24
28
  "type": "variable_declaration",
25
29
  "named": true
@@ -1117,7 +1121,7 @@ type javascriptTypes = {
1117
1121
  ]
1118
1122
  },
1119
1123
  "kind": {
1120
- "multiple": false,
1124
+ "multiple": true,
1121
1125
  "required": false,
1122
1126
  "types": []
1123
1127
  },
@@ -1966,7 +1970,7 @@ type javascriptTypes = {
1966
1970
  "fields": {},
1967
1971
  "children": {
1968
1972
  "multiple": false,
1969
- "required": true,
1973
+ "required": false,
1970
1974
  "types": [
1971
1975
  {
1972
1976
  "type": "identifier",
@@ -2693,6 +2697,27 @@ type javascriptTypes = {
2693
2697
  }
2694
2698
  }
2695
2699
  },
2700
+ "using_declaration": {
2701
+ "type": "using_declaration",
2702
+ "named": true,
2703
+ "fields": {
2704
+ "kind": {
2705
+ "multiple": true,
2706
+ "required": true,
2707
+ "types": []
2708
+ }
2709
+ },
2710
+ "children": {
2711
+ "multiple": true,
2712
+ "required": true,
2713
+ "types": [
2714
+ {
2715
+ "type": "variable_declarator",
2716
+ "named": true
2717
+ }
2718
+ ]
2719
+ }
2720
+ },
2696
2721
  "variable_declaration": {
2697
2722
  "type": "variable_declaration",
2698
2723
  "named": true,
@@ -2811,7 +2836,8 @@ type javascriptTypes = {
2811
2836
  },
2812
2837
  "comment": {
2813
2838
  "type": "comment",
2814
- "named": true
2839
+ "named": true,
2840
+ "extra": true
2815
2841
  },
2816
2842
  "escape_sequence": {
2817
2843
  "type": "escape_sequence",
@@ -2831,7 +2857,8 @@ type javascriptTypes = {
2831
2857
  },
2832
2858
  "html_comment": {
2833
2859
  "type": "html_comment",
2834
- "named": true
2860
+ "named": true,
2861
+ "extra": true
2835
2862
  },
2836
2863
  "identifier": {
2837
2864
  "type": "identifier",