tree-sitter-muttrc 0.0.5 → 0.0.6

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.
@@ -86,6 +86,11 @@ typedef union {
86
86
  } entry;
87
87
  } TSParseActionEntry;
88
88
 
89
+ typedef struct {
90
+ int32_t start;
91
+ int32_t end;
92
+ } TSCharacterRange;
93
+
89
94
  struct TSLanguage {
90
95
  uint32_t version;
91
96
  uint32_t symbol_count;
@@ -125,6 +130,24 @@ struct TSLanguage {
125
130
  const TSStateId *primary_state_ids;
126
131
  };
127
132
 
133
+ static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
134
+ uint32_t index = 0;
135
+ uint32_t size = len - index;
136
+ while (size > 1) {
137
+ uint32_t half_size = size / 2;
138
+ uint32_t mid_index = index + half_size;
139
+ TSCharacterRange *range = &ranges[mid_index];
140
+ if (lookahead >= range->start && lookahead <= range->end) {
141
+ return true;
142
+ } else if (lookahead > range->end) {
143
+ index = mid_index;
144
+ }
145
+ size -= half_size;
146
+ }
147
+ TSCharacterRange *range = &ranges[index];
148
+ return (lookahead >= range->start && lookahead <= range->end);
149
+ }
150
+
128
151
  /*
129
152
  * Lexer Macros
130
153
  */
@@ -154,6 +177,17 @@ struct TSLanguage {
154
177
  goto next_state; \
155
178
  }
156
179
 
180
+ #define ADVANCE_MAP(...) \
181
+ { \
182
+ static const uint16_t map[] = { __VA_ARGS__ }; \
183
+ for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \
184
+ if (map[i] == lookahead) { \
185
+ state = map[i + 1]; \
186
+ goto next_state; \
187
+ } \
188
+ } \
189
+ }
190
+
157
191
  #define SKIP(state_value) \
158
192
  { \
159
193
  skip = true; \
@@ -203,14 +237,15 @@ struct TSLanguage {
203
237
  } \
204
238
  }}
205
239
 
206
- #define REDUCE(symbol_val, child_count_val, ...) \
207
- {{ \
208
- .reduce = { \
209
- .type = TSParseActionTypeReduce, \
210
- .symbol = symbol_val, \
211
- .child_count = child_count_val, \
212
- __VA_ARGS__ \
213
- }, \
240
+ #define REDUCE(symbol_name, children, precedence, prod_id) \
241
+ {{ \
242
+ .reduce = { \
243
+ .type = TSParseActionTypeReduce, \
244
+ .symbol = symbol_name, \
245
+ .child_count = children, \
246
+ .dynamic_precedence = precedence, \
247
+ .production_id = prod_id \
248
+ }, \
214
249
  }}
215
250
 
216
251
  #define RECOVER() \