tree-sitter-batch 0.2.0 → 0.3.0
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/package.json +3 -3
- package/prebuilds/darwin-arm64/tree-sitter-batch.node +0 -0
- package/prebuilds/darwin-x64/tree-sitter-batch.node +0 -0
- package/prebuilds/linux-arm64/tree-sitter-batch.node +0 -0
- package/prebuilds/linux-x64/tree-sitter-batch.node +0 -0
- package/prebuilds/win32-arm64/tree-sitter-batch.node +0 -0
- package/prebuilds/win32-x64/tree-sitter-batch.node +0 -0
- package/src/grammar.json +2 -3
- package/src/parser.c +7 -19
- package/src/tree_sitter/array.h +71 -110
- package/src/tree_sitter/parser.h +7 -27
- package/tree-sitter-batch.wasm +0 -0
- package/tree-sitter.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-batch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A Windows Batch/CMD grammar for tree-sitter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"eslint": "^9.15.0",
|
|
38
38
|
"eslint-config-treesitter": "^1.0.2",
|
|
39
39
|
"prebuildify": "^6.0.1",
|
|
40
|
-
"tree-sitter-cli": "
|
|
40
|
+
"tree-sitter-cli": "0.24.7"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"tree-sitter": "
|
|
43
|
+
"tree-sitter": ">=0.25.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"tree-sitter": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
package/src/parser.c
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* Automatically @generated by tree-sitter */
|
|
2
|
-
|
|
3
1
|
#include "tree_sitter/parser.h"
|
|
4
2
|
|
|
5
3
|
#if defined(__GNUC__) || defined(__clang__)
|
|
@@ -14,7 +12,7 @@
|
|
|
14
12
|
#pragma GCC optimize ("O0")
|
|
15
13
|
#endif
|
|
16
14
|
|
|
17
|
-
#define LANGUAGE_VERSION
|
|
15
|
+
#define LANGUAGE_VERSION 14
|
|
18
16
|
#define STATE_COUNT 170
|
|
19
17
|
#define LARGE_STATE_COUNT 2
|
|
20
18
|
#define SYMBOL_COUNT 78
|
|
@@ -23,9 +21,7 @@
|
|
|
23
21
|
#define EXTERNAL_TOKEN_COUNT 0
|
|
24
22
|
#define FIELD_COUNT 0
|
|
25
23
|
#define MAX_ALIAS_SEQUENCE_LENGTH 10
|
|
26
|
-
#define MAX_RESERVED_WORD_SET_SIZE 0
|
|
27
24
|
#define PRODUCTION_ID_COUNT 1
|
|
28
|
-
#define SUPERTYPE_COUNT 0
|
|
29
25
|
|
|
30
26
|
enum ts_symbol_identifiers {
|
|
31
27
|
aux_sym_program_token1 = 1,
|
|
@@ -765,7 +761,7 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
|
|
|
765
761
|
[169] = 169,
|
|
766
762
|
};
|
|
767
763
|
|
|
768
|
-
static
|
|
764
|
+
static TSCharacterRange sym_comparison_op_character_set_1[] = {
|
|
769
765
|
{'=', '='}, {'E', 'E'}, {'G', 'G'}, {'L', 'L'}, {'N', 'N'}, {'e', 'e'}, {'g', 'g'}, {'l', 'l'},
|
|
770
766
|
{'n', 'n'},
|
|
771
767
|
};
|
|
@@ -3574,7 +3570,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
|
|
3574
3570
|
}
|
|
3575
3571
|
}
|
|
3576
3572
|
|
|
3577
|
-
static const
|
|
3573
|
+
static const TSLexMode ts_lex_modes[STATE_COUNT] = {
|
|
3578
3574
|
[0] = {.lex_state = 0},
|
|
3579
3575
|
[1] = {.lex_state = 134},
|
|
3580
3576
|
[2] = {.lex_state = 134},
|
|
@@ -3748,7 +3744,7 @@ static const TSLexerMode ts_lex_modes[STATE_COUNT] = {
|
|
|
3748
3744
|
};
|
|
3749
3745
|
|
|
3750
3746
|
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
|
3751
|
-
[
|
|
3747
|
+
[0] = {
|
|
3752
3748
|
[ts_builtin_sym_end] = ACTIONS(1),
|
|
3753
3749
|
[aux_sym_program_token1] = ACTIONS(1),
|
|
3754
3750
|
[anon_sym_AT] = ACTIONS(1),
|
|
@@ -3796,7 +3792,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
|
|
3796
3792
|
[sym_command_name] = ACTIONS(1),
|
|
3797
3793
|
[sym_command_option] = ACTIONS(1),
|
|
3798
3794
|
},
|
|
3799
|
-
[
|
|
3795
|
+
[1] = {
|
|
3800
3796
|
[sym_program] = STATE(152),
|
|
3801
3797
|
[sym__stmt] = STATE(162),
|
|
3802
3798
|
[sym_echo_off] = STATE(162),
|
|
@@ -5384,7 +5380,7 @@ extern "C" {
|
|
|
5384
5380
|
|
|
5385
5381
|
TS_PUBLIC const TSLanguage *tree_sitter_batch(void) {
|
|
5386
5382
|
static const TSLanguage language = {
|
|
5387
|
-
.
|
|
5383
|
+
.version = LANGUAGE_VERSION,
|
|
5388
5384
|
.symbol_count = SYMBOL_COUNT,
|
|
5389
5385
|
.alias_count = ALIAS_COUNT,
|
|
5390
5386
|
.token_count = TOKEN_COUNT,
|
|
@@ -5392,7 +5388,6 @@ TS_PUBLIC const TSLanguage *tree_sitter_batch(void) {
|
|
|
5392
5388
|
.state_count = STATE_COUNT,
|
|
5393
5389
|
.large_state_count = LARGE_STATE_COUNT,
|
|
5394
5390
|
.production_id_count = PRODUCTION_ID_COUNT,
|
|
5395
|
-
.supertype_count = SUPERTYPE_COUNT,
|
|
5396
5391
|
.field_count = FIELD_COUNT,
|
|
5397
5392
|
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
|
|
5398
5393
|
.parse_table = &ts_parse_table[0][0],
|
|
@@ -5404,16 +5399,9 @@ TS_PUBLIC const TSLanguage *tree_sitter_batch(void) {
|
|
|
5404
5399
|
.public_symbol_map = ts_symbol_map,
|
|
5405
5400
|
.alias_map = ts_non_terminal_alias_map,
|
|
5406
5401
|
.alias_sequences = &ts_alias_sequences[0][0],
|
|
5407
|
-
.lex_modes =
|
|
5402
|
+
.lex_modes = ts_lex_modes,
|
|
5408
5403
|
.lex_fn = ts_lex,
|
|
5409
5404
|
.primary_state_ids = ts_primary_state_ids,
|
|
5410
|
-
.name = "batch",
|
|
5411
|
-
.max_reserved_word_set_size = 0,
|
|
5412
|
-
.metadata = {
|
|
5413
|
-
.major_version = 0,
|
|
5414
|
-
.minor_version = 1,
|
|
5415
|
-
.patch_version = 0,
|
|
5416
|
-
},
|
|
5417
5405
|
};
|
|
5418
5406
|
return &language;
|
|
5419
5407
|
}
|
package/src/tree_sitter/array.h
CHANGED
|
@@ -52,96 +52,67 @@ extern "C" {
|
|
|
52
52
|
|
|
53
53
|
/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
|
|
54
54
|
/// less than the array's current capacity, this function has no effect.
|
|
55
|
-
#define array_reserve(self, new_capacity)
|
|
56
|
-
((self)
|
|
57
|
-
(void *)(self)->contents, &(self)->capacity, \
|
|
58
|
-
array_elem_size(self), new_capacity) \
|
|
59
|
-
)
|
|
55
|
+
#define array_reserve(self, new_capacity) \
|
|
56
|
+
_array__reserve((Array *)(self), array_elem_size(self), new_capacity)
|
|
60
57
|
|
|
61
58
|
/// Free any memory allocated for this array. Note that this does not free any
|
|
62
59
|
/// memory allocated for the array's contents.
|
|
63
|
-
#define array_delete(self)
|
|
64
|
-
do { \
|
|
65
|
-
if ((self)->contents) ts_free((self)->contents); \
|
|
66
|
-
(self)->contents = NULL; \
|
|
67
|
-
(self)->size = 0; \
|
|
68
|
-
(self)->capacity = 0; \
|
|
69
|
-
} while (0)
|
|
60
|
+
#define array_delete(self) _array__delete((Array *)(self))
|
|
70
61
|
|
|
71
62
|
/// Push a new `element` onto the end of the array.
|
|
72
|
-
#define array_push(self, element)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
(void *)(self)->contents, (self)->size, &(self)->capacity, \
|
|
76
|
-
1, array_elem_size(self) \
|
|
77
|
-
); \
|
|
78
|
-
(self)->contents[(self)->size++] = (element); \
|
|
79
|
-
} while(0)
|
|
63
|
+
#define array_push(self, element) \
|
|
64
|
+
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
|
|
65
|
+
(self)->contents[(self)->size++] = (element))
|
|
80
66
|
|
|
81
67
|
/// Increase the array's size by `count` elements.
|
|
82
68
|
/// New elements are zero-initialized.
|
|
83
|
-
#define array_grow_by(self, count)
|
|
84
|
-
do {
|
|
85
|
-
if ((count) == 0) break;
|
|
86
|
-
(self)
|
|
87
|
-
(self)->contents, (self)->size, &(self)->capacity, \
|
|
88
|
-
count, array_elem_size(self) \
|
|
89
|
-
); \
|
|
69
|
+
#define array_grow_by(self, count) \
|
|
70
|
+
do { \
|
|
71
|
+
if ((count) == 0) break; \
|
|
72
|
+
_array__grow((Array *)(self), count, array_elem_size(self)); \
|
|
90
73
|
memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
|
|
91
|
-
(self)->size += (count);
|
|
74
|
+
(self)->size += (count); \
|
|
92
75
|
} while (0)
|
|
93
76
|
|
|
94
77
|
/// Append all elements from one array to the end of another.
|
|
95
|
-
#define array_push_all(self, other)
|
|
78
|
+
#define array_push_all(self, other) \
|
|
96
79
|
array_extend((self), (other)->size, (other)->contents)
|
|
97
80
|
|
|
98
81
|
/// Append `count` elements to the end of the array, reading their values from the
|
|
99
82
|
/// `contents` pointer.
|
|
100
|
-
#define array_extend(self, count,
|
|
101
|
-
|
|
102
|
-
(
|
|
103
|
-
|
|
83
|
+
#define array_extend(self, count, contents) \
|
|
84
|
+
_array__splice( \
|
|
85
|
+
(Array *)(self), array_elem_size(self), (self)->size, \
|
|
86
|
+
0, count, contents \
|
|
104
87
|
)
|
|
105
88
|
|
|
106
89
|
/// Remove `old_count` elements from the array starting at the given `index`. At
|
|
107
90
|
/// the same index, insert `new_count` new elements, reading their values from the
|
|
108
91
|
/// `new_contents` pointer.
|
|
109
|
-
#define array_splice(self, _index, old_count, new_count, new_contents)
|
|
110
|
-
|
|
111
|
-
(
|
|
112
|
-
|
|
92
|
+
#define array_splice(self, _index, old_count, new_count, new_contents) \
|
|
93
|
+
_array__splice( \
|
|
94
|
+
(Array *)(self), array_elem_size(self), _index, \
|
|
95
|
+
old_count, new_count, new_contents \
|
|
113
96
|
)
|
|
114
97
|
|
|
115
98
|
/// Insert one `element` into the array at the given `index`.
|
|
116
|
-
#define array_insert(self, _index, element)
|
|
117
|
-
(self)
|
|
118
|
-
(void *)(self)->contents, &(self)->size, &(self)->capacity, \
|
|
119
|
-
array_elem_size(self), _index, 0, 1, &(element) \
|
|
120
|
-
)
|
|
99
|
+
#define array_insert(self, _index, element) \
|
|
100
|
+
_array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))
|
|
121
101
|
|
|
122
102
|
/// Remove one element from the array at the given `index`.
|
|
123
103
|
#define array_erase(self, _index) \
|
|
124
|
-
_array__erase((
|
|
104
|
+
_array__erase((Array *)(self), array_elem_size(self), _index)
|
|
125
105
|
|
|
126
106
|
/// Pop the last element off the array, returning the element by value.
|
|
127
107
|
#define array_pop(self) ((self)->contents[--(self)->size])
|
|
128
108
|
|
|
129
109
|
/// Assign the contents of one array to another, reallocating if necessary.
|
|
130
|
-
#define array_assign(self, other)
|
|
131
|
-
(self)
|
|
132
|
-
(void *)(self)->contents, &(self)->size, &(self)->capacity, \
|
|
133
|
-
(const void *)(other)->contents, (other)->size, array_elem_size(self) \
|
|
134
|
-
)
|
|
110
|
+
#define array_assign(self, other) \
|
|
111
|
+
_array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))
|
|
135
112
|
|
|
136
113
|
/// Swap one array with another
|
|
137
|
-
#define array_swap(self, other)
|
|
138
|
-
|
|
139
|
-
void *_array_swap_tmp = (void *)(self)->contents; \
|
|
140
|
-
(self)->contents = (other)->contents; \
|
|
141
|
-
(other)->contents = _array_swap_tmp; \
|
|
142
|
-
_array__swap(&(self)->size, &(self)->capacity, \
|
|
143
|
-
&(other)->size, &(other)->capacity); \
|
|
144
|
-
} while (0)
|
|
114
|
+
#define array_swap(self, other) \
|
|
115
|
+
_array__swap((Array *)(self), (Array *)(other))
|
|
145
116
|
|
|
146
117
|
/// Get the size of the array contents
|
|
147
118
|
#define array_elem_size(self) (sizeof *(self)->contents)
|
|
@@ -186,90 +157,82 @@ extern "C" {
|
|
|
186
157
|
|
|
187
158
|
// Private
|
|
188
159
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
160
|
+
typedef Array(void) Array;
|
|
161
|
+
|
|
162
|
+
/// This is not what you're looking for, see `array_delete`.
|
|
163
|
+
static inline void _array__delete(Array *self) {
|
|
164
|
+
if (self->contents) {
|
|
165
|
+
ts_free(self->contents);
|
|
166
|
+
self->contents = NULL;
|
|
167
|
+
self->size = 0;
|
|
168
|
+
self->capacity = 0;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
195
171
|
|
|
196
172
|
/// This is not what you're looking for, see `array_erase`.
|
|
197
|
-
static inline void _array__erase(
|
|
198
|
-
|
|
199
|
-
assert(index <
|
|
200
|
-
char *contents = (char *)
|
|
173
|
+
static inline void _array__erase(Array *self, size_t element_size,
|
|
174
|
+
uint32_t index) {
|
|
175
|
+
assert(index < self->size);
|
|
176
|
+
char *contents = (char *)self->contents;
|
|
201
177
|
memmove(contents + index * element_size, contents + (index + 1) * element_size,
|
|
202
|
-
(
|
|
203
|
-
|
|
178
|
+
(self->size - index - 1) * element_size);
|
|
179
|
+
self->size--;
|
|
204
180
|
}
|
|
205
181
|
|
|
206
182
|
/// This is not what you're looking for, see `array_reserve`.
|
|
207
|
-
static inline void
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (contents) {
|
|
212
|
-
new_contents = ts_realloc(contents, new_capacity * element_size);
|
|
183
|
+
static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {
|
|
184
|
+
if (new_capacity > self->capacity) {
|
|
185
|
+
if (self->contents) {
|
|
186
|
+
self->contents = ts_realloc(self->contents, new_capacity * element_size);
|
|
213
187
|
} else {
|
|
214
|
-
|
|
188
|
+
self->contents = ts_malloc(new_capacity * element_size);
|
|
215
189
|
}
|
|
216
|
-
|
|
190
|
+
self->capacity = new_capacity;
|
|
217
191
|
}
|
|
218
|
-
return new_contents;
|
|
219
192
|
}
|
|
220
193
|
|
|
221
194
|
/// This is not what you're looking for, see `array_assign`.
|
|
222
|
-
static inline void
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
*
|
|
226
|
-
memcpy(new_contents, other_contents, *self_size * element_size);
|
|
227
|
-
return new_contents;
|
|
195
|
+
static inline void _array__assign(Array *self, const Array *other, size_t element_size) {
|
|
196
|
+
_array__reserve(self, element_size, other->size);
|
|
197
|
+
self->size = other->size;
|
|
198
|
+
memcpy(self->contents, other->contents, self->size * element_size);
|
|
228
199
|
}
|
|
229
200
|
|
|
230
201
|
/// This is not what you're looking for, see `array_swap`.
|
|
231
|
-
static inline void _array__swap(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
*self_size = *other_size;
|
|
236
|
-
*self_capacity = *other_capacity;
|
|
237
|
-
*other_size = tmp_size;
|
|
238
|
-
*other_capacity = tmp_capacity;
|
|
202
|
+
static inline void _array__swap(Array *self, Array *other) {
|
|
203
|
+
Array swap = *other;
|
|
204
|
+
*other = *self;
|
|
205
|
+
*self = swap;
|
|
239
206
|
}
|
|
240
207
|
|
|
241
208
|
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
|
|
242
|
-
static inline void
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if (new_size > *capacity) {
|
|
247
|
-
uint32_t new_capacity = *capacity * 2;
|
|
209
|
+
static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {
|
|
210
|
+
uint32_t new_size = self->size + count;
|
|
211
|
+
if (new_size > self->capacity) {
|
|
212
|
+
uint32_t new_capacity = self->capacity * 2;
|
|
248
213
|
if (new_capacity < 8) new_capacity = 8;
|
|
249
214
|
if (new_capacity < new_size) new_capacity = new_size;
|
|
250
|
-
|
|
215
|
+
_array__reserve(self, element_size, new_capacity);
|
|
251
216
|
}
|
|
252
|
-
return new_contents;
|
|
253
217
|
}
|
|
254
218
|
|
|
255
219
|
/// This is not what you're looking for, see `array_splice`.
|
|
256
|
-
static inline void
|
|
257
|
-
size_t element_size,
|
|
220
|
+
static inline void _array__splice(Array *self, size_t element_size,
|
|
258
221
|
uint32_t index, uint32_t old_count,
|
|
259
222
|
uint32_t new_count, const void *elements) {
|
|
260
|
-
uint32_t new_size =
|
|
223
|
+
uint32_t new_size = self->size + new_count - old_count;
|
|
261
224
|
uint32_t old_end = index + old_count;
|
|
262
225
|
uint32_t new_end = index + new_count;
|
|
263
|
-
assert(old_end <=
|
|
226
|
+
assert(old_end <= self->size);
|
|
264
227
|
|
|
265
|
-
|
|
228
|
+
_array__reserve(self, element_size, new_size);
|
|
266
229
|
|
|
267
|
-
char *contents = (char *)
|
|
268
|
-
if (
|
|
230
|
+
char *contents = (char *)self->contents;
|
|
231
|
+
if (self->size > old_end) {
|
|
269
232
|
memmove(
|
|
270
233
|
contents + new_end * element_size,
|
|
271
234
|
contents + old_end * element_size,
|
|
272
|
-
(
|
|
235
|
+
(self->size - old_end) * element_size
|
|
273
236
|
);
|
|
274
237
|
}
|
|
275
238
|
if (new_count > 0) {
|
|
@@ -287,9 +250,7 @@ static inline void *_array__splice(void *self_contents, uint32_t *size, uint32_t
|
|
|
287
250
|
);
|
|
288
251
|
}
|
|
289
252
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
return new_contents;
|
|
253
|
+
self->size += new_count - old_count;
|
|
293
254
|
}
|
|
294
255
|
|
|
295
256
|
/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
|
package/src/tree_sitter/parser.h
CHANGED
|
@@ -18,11 +18,6 @@ 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;
|
|
26
21
|
#endif
|
|
27
22
|
|
|
28
23
|
typedef struct {
|
|
@@ -31,11 +26,10 @@ typedef struct {
|
|
|
31
26
|
bool inherited;
|
|
32
27
|
} TSFieldMapEntry;
|
|
33
28
|
|
|
34
|
-
// Used to index the field and supertype maps.
|
|
35
29
|
typedef struct {
|
|
36
30
|
uint16_t index;
|
|
37
31
|
uint16_t length;
|
|
38
|
-
}
|
|
32
|
+
} TSFieldMapSlice;
|
|
39
33
|
|
|
40
34
|
typedef struct {
|
|
41
35
|
bool visible;
|
|
@@ -85,12 +79,6 @@ typedef struct {
|
|
|
85
79
|
uint16_t external_lex_state;
|
|
86
80
|
} TSLexMode;
|
|
87
81
|
|
|
88
|
-
typedef struct {
|
|
89
|
-
uint16_t lex_state;
|
|
90
|
-
uint16_t external_lex_state;
|
|
91
|
-
uint16_t reserved_word_set_id;
|
|
92
|
-
} TSLexerMode;
|
|
93
|
-
|
|
94
82
|
typedef union {
|
|
95
83
|
TSParseAction action;
|
|
96
84
|
struct {
|
|
@@ -105,7 +93,7 @@ typedef struct {
|
|
|
105
93
|
} TSCharacterRange;
|
|
106
94
|
|
|
107
95
|
struct TSLanguage {
|
|
108
|
-
uint32_t
|
|
96
|
+
uint32_t version;
|
|
109
97
|
uint32_t symbol_count;
|
|
110
98
|
uint32_t alias_count;
|
|
111
99
|
uint32_t token_count;
|
|
@@ -121,13 +109,13 @@ struct TSLanguage {
|
|
|
121
109
|
const TSParseActionEntry *parse_actions;
|
|
122
110
|
const char * const *symbol_names;
|
|
123
111
|
const char * const *field_names;
|
|
124
|
-
const
|
|
112
|
+
const TSFieldMapSlice *field_map_slices;
|
|
125
113
|
const TSFieldMapEntry *field_map_entries;
|
|
126
114
|
const TSSymbolMetadata *symbol_metadata;
|
|
127
115
|
const TSSymbol *public_symbol_map;
|
|
128
116
|
const uint16_t *alias_map;
|
|
129
117
|
const TSSymbol *alias_sequences;
|
|
130
|
-
const
|
|
118
|
+
const TSLexMode *lex_modes;
|
|
131
119
|
bool (*lex_fn)(TSLexer *, TSStateId);
|
|
132
120
|
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
|
133
121
|
TSSymbol keyword_capture_token;
|
|
@@ -141,23 +129,15 @@ struct TSLanguage {
|
|
|
141
129
|
void (*deserialize)(void *, const char *, unsigned);
|
|
142
130
|
} external_scanner;
|
|
143
131
|
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;
|
|
152
132
|
};
|
|
153
133
|
|
|
154
|
-
static inline bool set_contains(
|
|
134
|
+
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
|
155
135
|
uint32_t index = 0;
|
|
156
136
|
uint32_t size = len - index;
|
|
157
137
|
while (size > 1) {
|
|
158
138
|
uint32_t half_size = size / 2;
|
|
159
139
|
uint32_t mid_index = index + half_size;
|
|
160
|
-
|
|
140
|
+
TSCharacterRange *range = &ranges[mid_index];
|
|
161
141
|
if (lookahead >= range->start && lookahead <= range->end) {
|
|
162
142
|
return true;
|
|
163
143
|
} else if (lookahead > range->end) {
|
|
@@ -165,7 +145,7 @@ static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, in
|
|
|
165
145
|
}
|
|
166
146
|
size -= half_size;
|
|
167
147
|
}
|
|
168
|
-
|
|
148
|
+
TSCharacterRange *range = &ranges[index];
|
|
169
149
|
return (lookahead >= range->start && lookahead <= range->end);
|
|
170
150
|
}
|
|
171
151
|
|
package/tree-sitter-batch.wasm
CHANGED
|
Binary file
|