tree-sitter-ktav 0.2.1

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/src/scanner.c ADDED
@@ -0,0 +1,209 @@
1
+ // Tree-sitter external scanner for Ktav.
2
+ //
3
+ // Emits four tokens that the LR(1) grammar generated from grammar.js
4
+ // cannot express on its own:
5
+ //
6
+ // _marker_ws — a zero-width assertion that fires only when the
7
+ // byte immediately following a pair separator
8
+ // (`:`, `::`, `:i`, `:f`) is ASCII whitespace
9
+ // (space, tab, CR, LF) or EOF. The assertion is
10
+ // zero-width — it does not consume any input — so
11
+ // the existing `extras` whitespace handling and the
12
+ // `_newline` rule for empty values both still apply
13
+ // unchanged. Its sole purpose is to MAKE A PARSE FAIL
14
+ // when a writer omits the mandatory whitespace, e.g.
15
+ // `key:value` (§ 6.10 of the spec).
16
+ //
17
+ // _strict_eol — consumes `[ \t]*` followed by `\r?\n` OR by EOF.
18
+ // Used as the line terminator for compound closers
19
+ // (`}`, `]`) so that any non-whitespace content
20
+ // between the closer and the line terminator
21
+ // causes a parse failure (§ 5.6.1 closer-on-its-own-
22
+ // line and the cleanliness rule for object/array
23
+ // closers).
24
+ //
25
+ // _stripped_close — context-sensitive closer for `(...)` multi-line
26
+ // strings. Matches `)` followed by `[ \t]*\r?\n`
27
+ // (or EOF). Only valid inside the body of a
28
+ // `multiline_stripped`. A `))` line in that
29
+ // context is NOT a close — the scanner declines
30
+ // and the line falls through to the
31
+ // `multiline_content_line` regex token.
32
+ //
33
+ // _verbatim_close — context-sensitive closer for `((...))` multi-line
34
+ // strings. Matches `))` followed by `[ \t]*\r?\n`
35
+ // (or EOF). Only valid inside `multiline_verbatim`.
36
+ // A single `)` line in that context falls through
37
+ // to `multiline_content_line`.
38
+ //
39
+ // All tokens are stateless: the parser supplies the necessary context
40
+ // via `valid_symbols`. The external_scanner_state size is therefore
41
+ // zero, and serialize / deserialize are no-ops.
42
+
43
+ #include "tree_sitter/parser.h"
44
+
45
+ enum TokenType {
46
+ MARKER_WS,
47
+ STRICT_EOL,
48
+ STRIPPED_CLOSE,
49
+ VERBATIM_CLOSE,
50
+ };
51
+
52
+ void *tree_sitter_ktav_external_scanner_create(void) {
53
+ return NULL;
54
+ }
55
+
56
+ void tree_sitter_ktav_external_scanner_destroy(void *payload) {
57
+ (void)payload;
58
+ }
59
+
60
+ unsigned tree_sitter_ktav_external_scanner_serialize(void *payload, char *buffer) {
61
+ (void)payload;
62
+ (void)buffer;
63
+ return 0;
64
+ }
65
+
66
+ void tree_sitter_ktav_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {
67
+ (void)payload;
68
+ (void)buffer;
69
+ (void)length;
70
+ }
71
+
72
+ static inline bool is_h_ws(int32_t c) {
73
+ return c == ' ' || c == '\t';
74
+ }
75
+
76
+ // Consume optional `[ \t]*` then a single line terminator (LF, CRLF,
77
+ // or EOF). Returns true on success and leaves `mark_end` at the byte
78
+ // after the terminator. Returns false (without disturbing mark_end's
79
+ // previous position) if the next non-h-ws byte is not a terminator.
80
+ static bool consume_line_terminator(TSLexer *lexer) {
81
+ while (is_h_ws(lexer->lookahead)) {
82
+ lexer->advance(lexer, false);
83
+ }
84
+ int32_t c = lexer->lookahead;
85
+ if (c == '\n') {
86
+ lexer->advance(lexer, false);
87
+ lexer->mark_end(lexer);
88
+ return true;
89
+ }
90
+ if (c == '\r') {
91
+ lexer->advance(lexer, false);
92
+ if (lexer->lookahead == '\n') {
93
+ lexer->advance(lexer, false);
94
+ }
95
+ lexer->mark_end(lexer);
96
+ return true;
97
+ }
98
+ if (c == 0) {
99
+ lexer->mark_end(lexer);
100
+ return true;
101
+ }
102
+ return false;
103
+ }
104
+
105
+ bool tree_sitter_ktav_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
106
+ (void)payload;
107
+
108
+ // Mark the current lex position before any `advance` so that on
109
+ // failure we don't leave bytes consumed (which would corrupt the
110
+ // lexer state for the next attempted token).
111
+ lexer->mark_end(lexer);
112
+
113
+ // _marker_ws — zero-width. Succeed iff the next byte is horizontal
114
+ // whitespace, CR, LF, or EOF. We don't `advance`; we only `mark_end`
115
+ // at the current position so the token has zero length.
116
+ if (valid_symbols[MARKER_WS]) {
117
+ int32_t c = lexer->lookahead;
118
+ if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == 0) {
119
+ lexer->mark_end(lexer);
120
+ lexer->result_symbol = MARKER_WS;
121
+ return true;
122
+ }
123
+ // _marker_ws is the only valid token here in the strict path —
124
+ // returning false makes tree-sitter raise a parse error, which
125
+ // is exactly the § 6.10 rejection we want. The two branches are
126
+ // mutually exclusive: never fall through to STRICT_EOL.
127
+ return false;
128
+ }
129
+
130
+ // _verbatim_close — matches `[ \t]*))[ \t]*\r?\n` (or EOF). The
131
+ // closer may have leading horizontal whitespace (the `)` is "on its
132
+ // own line, possibly with leading whitespace" per § 5.6.1). Only
133
+ // valid inside the body of a `multiline_verbatim`. Tried before
134
+ // STRIPPED_CLOSE so `))` is never split into a `)` close + leftover.
135
+ // (In practice the two are mutually exclusive per parse state, so
136
+ // ordering matters only for defensive correctness.)
137
+ if (valid_symbols[VERBATIM_CLOSE]) {
138
+ while (is_h_ws(lexer->lookahead)) {
139
+ lexer->advance(lexer, false);
140
+ }
141
+ if (lexer->lookahead == ')') {
142
+ lexer->advance(lexer, false);
143
+ if (lexer->lookahead == ')') {
144
+ lexer->advance(lexer, false);
145
+ if (consume_line_terminator(lexer)) {
146
+ lexer->result_symbol = VERBATIM_CLOSE;
147
+ return true;
148
+ }
149
+ }
150
+ }
151
+ // Fall through: a non-`))` line inside verbatim becomes content.
152
+ return false;
153
+ }
154
+
155
+ // _stripped_close — matches `[ \t]*)[ \t]*\r?\n` (or EOF). Only
156
+ // valid inside `multiline_stripped`. A `))` line is NOT a stripped
157
+ // close: we require the byte after the first `)` to NOT be another
158
+ // `)`, so `))` falls through to the `multiline_content_line`
159
+ // regex token.
160
+ if (valid_symbols[STRIPPED_CLOSE]) {
161
+ while (is_h_ws(lexer->lookahead)) {
162
+ lexer->advance(lexer, false);
163
+ }
164
+ if (lexer->lookahead == ')') {
165
+ lexer->advance(lexer, false);
166
+ if (lexer->lookahead != ')') {
167
+ if (consume_line_terminator(lexer)) {
168
+ lexer->result_symbol = STRIPPED_CLOSE;
169
+ return true;
170
+ }
171
+ }
172
+ }
173
+ return false;
174
+ }
175
+
176
+ // _strict_eol — consume optional horizontal whitespace, then the
177
+ // line terminator (LF, CRLF, or EOF). If a non-whitespace byte
178
+ // appears before the line terminator, fail.
179
+ if (valid_symbols[STRICT_EOL]) {
180
+ while (is_h_ws(lexer->lookahead)) {
181
+ lexer->advance(lexer, false);
182
+ }
183
+ int32_t c = lexer->lookahead;
184
+ if (c == '\n') {
185
+ lexer->advance(lexer, false);
186
+ lexer->mark_end(lexer);
187
+ lexer->result_symbol = STRICT_EOL;
188
+ return true;
189
+ }
190
+ if (c == '\r') {
191
+ lexer->advance(lexer, false);
192
+ if (lexer->lookahead == '\n') {
193
+ lexer->advance(lexer, false);
194
+ }
195
+ lexer->mark_end(lexer);
196
+ lexer->result_symbol = STRICT_EOL;
197
+ return true;
198
+ }
199
+ if (c == 0) {
200
+ // EOF as a line terminator (§ 3.2: trailing content of the
201
+ // final line need not be followed by a line separator).
202
+ lexer->mark_end(lexer);
203
+ lexer->result_symbol = STRICT_EOL;
204
+ return true;
205
+ }
206
+ }
207
+
208
+ return false;
209
+ }
@@ -0,0 +1,54 @@
1
+ #ifndef TREE_SITTER_ALLOC_H_
2
+ #define TREE_SITTER_ALLOC_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <stdbool.h>
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+
12
+ // Allow clients to override allocation functions
13
+ #ifdef TREE_SITTER_REUSE_ALLOCATOR
14
+
15
+ extern void *(*ts_current_malloc)(size_t size);
16
+ extern void *(*ts_current_calloc)(size_t count, size_t size);
17
+ extern void *(*ts_current_realloc)(void *ptr, size_t size);
18
+ extern void (*ts_current_free)(void *ptr);
19
+
20
+ #ifndef ts_malloc
21
+ #define ts_malloc ts_current_malloc
22
+ #endif
23
+ #ifndef ts_calloc
24
+ #define ts_calloc ts_current_calloc
25
+ #endif
26
+ #ifndef ts_realloc
27
+ #define ts_realloc ts_current_realloc
28
+ #endif
29
+ #ifndef ts_free
30
+ #define ts_free ts_current_free
31
+ #endif
32
+
33
+ #else
34
+
35
+ #ifndef ts_malloc
36
+ #define ts_malloc malloc
37
+ #endif
38
+ #ifndef ts_calloc
39
+ #define ts_calloc calloc
40
+ #endif
41
+ #ifndef ts_realloc
42
+ #define ts_realloc realloc
43
+ #endif
44
+ #ifndef ts_free
45
+ #define ts_free free
46
+ #endif
47
+
48
+ #endif
49
+
50
+ #ifdef __cplusplus
51
+ }
52
+ #endif
53
+
54
+ #endif // TREE_SITTER_ALLOC_H_
@@ -0,0 +1,330 @@
1
+ #ifndef TREE_SITTER_ARRAY_H_
2
+ #define TREE_SITTER_ARRAY_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include "./alloc.h"
9
+
10
+ #include <assert.h>
11
+ #include <stdbool.h>
12
+ #include <stdint.h>
13
+ #include <stdlib.h>
14
+ #include <string.h>
15
+
16
+ #ifdef _MSC_VER
17
+ #pragma warning(push)
18
+ #pragma warning(disable : 4101)
19
+ #elif defined(__GNUC__) || defined(__clang__)
20
+ #pragma GCC diagnostic push
21
+ #pragma GCC diagnostic ignored "-Wunused-variable"
22
+ #endif
23
+
24
+ #define Array(T) \
25
+ struct { \
26
+ T *contents; \
27
+ uint32_t size; \
28
+ uint32_t capacity; \
29
+ }
30
+
31
+ /// Initialize an array.
32
+ #define array_init(self) \
33
+ ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)
34
+
35
+ /// Create an empty array.
36
+ #define array_new() \
37
+ { NULL, 0, 0 }
38
+
39
+ /// Get a pointer to the element at a given `index` in the array.
40
+ #define array_get(self, _index) \
41
+ (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
42
+
43
+ /// Get a pointer to the first element in the array.
44
+ #define array_front(self) array_get(self, 0)
45
+
46
+ /// Get a pointer to the last element in the array.
47
+ #define array_back(self) array_get(self, (self)->size - 1)
48
+
49
+ /// Clear the array, setting its size to zero. Note that this does not free any
50
+ /// memory allocated for the array's contents.
51
+ #define array_clear(self) ((self)->size = 0)
52
+
53
+ /// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
54
+ /// less than the array's current capacity, this function has no effect.
55
+ #define array_reserve(self, new_capacity) \
56
+ ((self)->contents = _array__reserve( \
57
+ (void *)(self)->contents, &(self)->capacity, \
58
+ array_elem_size(self), new_capacity) \
59
+ )
60
+
61
+ /// Free any memory allocated for this array. Note that this does not free any
62
+ /// 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)
70
+
71
+ /// Push a new `element` onto the end of the array.
72
+ #define array_push(self, element) \
73
+ do { \
74
+ (self)->contents = _array__grow( \
75
+ (void *)(self)->contents, (self)->size, &(self)->capacity, \
76
+ 1, array_elem_size(self) \
77
+ ); \
78
+ (self)->contents[(self)->size++] = (element); \
79
+ } while(0)
80
+
81
+ /// Increase the array's size by `count` elements.
82
+ /// New elements are zero-initialized.
83
+ #define array_grow_by(self, count) \
84
+ do { \
85
+ if ((count) == 0) break; \
86
+ (self)->contents = _array__grow( \
87
+ (self)->contents, (self)->size, &(self)->capacity, \
88
+ count, array_elem_size(self) \
89
+ ); \
90
+ memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
91
+ (self)->size += (count); \
92
+ } while (0)
93
+
94
+ /// Append all elements from one array to the end of another.
95
+ #define array_push_all(self, other) \
96
+ array_extend((self), (other)->size, (other)->contents)
97
+
98
+ /// Append `count` elements to the end of the array, reading their values from the
99
+ /// `contents` pointer.
100
+ #define array_extend(self, count, other_contents) \
101
+ (self)->contents = _array__splice( \
102
+ (void*)(self)->contents, &(self)->size, &(self)->capacity, \
103
+ array_elem_size(self), (self)->size, 0, count, other_contents \
104
+ )
105
+
106
+ /// Remove `old_count` elements from the array starting at the given `index`. At
107
+ /// the same index, insert `new_count` new elements, reading their values from the
108
+ /// `new_contents` pointer.
109
+ #define array_splice(self, _index, old_count, new_count, new_contents) \
110
+ (self)->contents = _array__splice( \
111
+ (void *)(self)->contents, &(self)->size, &(self)->capacity, \
112
+ array_elem_size(self), _index, old_count, new_count, new_contents \
113
+ )
114
+
115
+ /// Insert one `element` into the array at the given `index`.
116
+ #define array_insert(self, _index, element) \
117
+ (self)->contents = _array__splice( \
118
+ (void *)(self)->contents, &(self)->size, &(self)->capacity, \
119
+ array_elem_size(self), _index, 0, 1, &(element) \
120
+ )
121
+
122
+ /// Remove one element from the array at the given `index`.
123
+ #define array_erase(self, _index) \
124
+ _array__erase((void *)(self)->contents, &(self)->size, array_elem_size(self), _index)
125
+
126
+ /// Pop the last element off the array, returning the element by value.
127
+ #define array_pop(self) ((self)->contents[--(self)->size])
128
+
129
+ /// Assign the contents of one array to another, reallocating if necessary.
130
+ #define array_assign(self, other) \
131
+ (self)->contents = _array__assign( \
132
+ (void *)(self)->contents, &(self)->size, &(self)->capacity, \
133
+ (const void *)(other)->contents, (other)->size, array_elem_size(self) \
134
+ )
135
+
136
+ /// Swap one array with another
137
+ #define array_swap(self, other) \
138
+ do { \
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)
145
+
146
+ /// Get the size of the array contents
147
+ #define array_elem_size(self) (sizeof *(self)->contents)
148
+
149
+ /// Search a sorted array for a given `needle` value, using the given `compare`
150
+ /// callback to determine the order.
151
+ ///
152
+ /// If an existing element is found to be equal to `needle`, then the `index`
153
+ /// out-parameter is set to the existing value's index, and the `exists`
154
+ /// out-parameter is set to true. Otherwise, `index` is set to an index where
155
+ /// `needle` should be inserted in order to preserve the sorting, and `exists`
156
+ /// is set to false.
157
+ #define array_search_sorted_with(self, compare, needle, _index, _exists) \
158
+ _array__search_sorted(self, 0, compare, , needle, _index, _exists)
159
+
160
+ /// Search a sorted array for a given `needle` value, using integer comparisons
161
+ /// of a given struct field (specified with a leading dot) to determine the order.
162
+ ///
163
+ /// See also `array_search_sorted_with`.
164
+ #define array_search_sorted_by(self, field, needle, _index, _exists) \
165
+ _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)
166
+
167
+ /// Insert a given `value` into a sorted array, using the given `compare`
168
+ /// callback to determine the order.
169
+ #define array_insert_sorted_with(self, compare, value) \
170
+ do { \
171
+ unsigned _index, _exists; \
172
+ array_search_sorted_with(self, compare, &(value), &_index, &_exists); \
173
+ if (!_exists) array_insert(self, _index, value); \
174
+ } while (0)
175
+
176
+ /// Insert a given `value` into a sorted array, using integer comparisons of
177
+ /// a given struct field (specified with a leading dot) to determine the order.
178
+ ///
179
+ /// See also `array_search_sorted_by`.
180
+ #define array_insert_sorted_by(self, field, value) \
181
+ do { \
182
+ unsigned _index, _exists; \
183
+ array_search_sorted_by(self, field, (value) field, &_index, &_exists); \
184
+ if (!_exists) array_insert(self, _index, value); \
185
+ } while (0)
186
+
187
+ // Private
188
+
189
+ // Pointers to individual `Array` fields (rather than the entire `Array` itself)
190
+ // are passed to the various `_array__*` functions below to address strict aliasing
191
+ // violations that arises when the _entire_ `Array` struct is passed as `Array(void)*`.
192
+ //
193
+ // The `Array` type itself was not altered as a solution in order to avoid breakage
194
+ // with existing consumers (in particular, parsers with external scanners).
195
+
196
+ /// This is not what you're looking for, see `array_erase`.
197
+ static inline void _array__erase(void* self_contents, uint32_t *size,
198
+ size_t element_size, uint32_t index) {
199
+ assert(index < *size);
200
+ char *contents = (char *)self_contents;
201
+ memmove(contents + index * element_size, contents + (index + 1) * element_size,
202
+ (*size - index - 1) * element_size);
203
+ (*size)--;
204
+ }
205
+
206
+ /// This is not what you're looking for, see `array_reserve`.
207
+ static inline void *_array__reserve(void *contents, uint32_t *capacity,
208
+ size_t element_size, uint32_t new_capacity) {
209
+ void *new_contents = contents;
210
+ if (new_capacity > *capacity) {
211
+ if (contents) {
212
+ new_contents = ts_realloc(contents, new_capacity * element_size);
213
+ } else {
214
+ new_contents = ts_malloc(new_capacity * element_size);
215
+ }
216
+ *capacity = new_capacity;
217
+ }
218
+ return new_contents;
219
+ }
220
+
221
+ /// This is not what you're looking for, see `array_assign`.
222
+ static inline void *_array__assign(void* self_contents, uint32_t *self_size, uint32_t *self_capacity,
223
+ const void *other_contents, uint32_t other_size, size_t element_size) {
224
+ void *new_contents = _array__reserve(self_contents, self_capacity, element_size, other_size);
225
+ *self_size = other_size;
226
+ memcpy(new_contents, other_contents, *self_size * element_size);
227
+ return new_contents;
228
+ }
229
+
230
+ /// This is not what you're looking for, see `array_swap`.
231
+ static inline void _array__swap(uint32_t *self_size, uint32_t *self_capacity,
232
+ uint32_t *other_size, uint32_t *other_capacity) {
233
+ uint32_t tmp_size = *self_size;
234
+ uint32_t tmp_capacity = *self_capacity;
235
+ *self_size = *other_size;
236
+ *self_capacity = *other_capacity;
237
+ *other_size = tmp_size;
238
+ *other_capacity = tmp_capacity;
239
+ }
240
+
241
+ /// This is not what you're looking for, see `array_push` or `array_grow_by`.
242
+ static inline void *_array__grow(void *contents, uint32_t size, uint32_t *capacity,
243
+ uint32_t count, size_t element_size) {
244
+ void *new_contents = contents;
245
+ uint32_t new_size = size + count;
246
+ if (new_size > *capacity) {
247
+ uint32_t new_capacity = *capacity * 2;
248
+ if (new_capacity < 8) new_capacity = 8;
249
+ if (new_capacity < new_size) new_capacity = new_size;
250
+ new_contents = _array__reserve(contents, capacity, element_size, new_capacity);
251
+ }
252
+ return new_contents;
253
+ }
254
+
255
+ /// This is not what you're looking for, see `array_splice`.
256
+ static inline void *_array__splice(void *self_contents, uint32_t *size, uint32_t *capacity,
257
+ size_t element_size,
258
+ uint32_t index, uint32_t old_count,
259
+ uint32_t new_count, const void *elements) {
260
+ uint32_t new_size = *size + new_count - old_count;
261
+ uint32_t old_end = index + old_count;
262
+ uint32_t new_end = index + new_count;
263
+ assert(old_end <= *size);
264
+
265
+ void *new_contents = _array__reserve(self_contents, capacity, element_size, new_size);
266
+
267
+ char *contents = (char *)new_contents;
268
+ if (*size > old_end) {
269
+ memmove(
270
+ contents + new_end * element_size,
271
+ contents + old_end * element_size,
272
+ (*size - old_end) * element_size
273
+ );
274
+ }
275
+ if (new_count > 0) {
276
+ if (elements) {
277
+ memcpy(
278
+ (contents + index * element_size),
279
+ elements,
280
+ new_count * element_size
281
+ );
282
+ } else {
283
+ memset(
284
+ (contents + index * element_size),
285
+ 0,
286
+ new_count * element_size
287
+ );
288
+ }
289
+ }
290
+ *size += new_count - old_count;
291
+
292
+ return new_contents;
293
+ }
294
+
295
+ /// A binary search routine, based on Rust's `std::slice::binary_search_by`.
296
+ /// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.
297
+ #define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \
298
+ do { \
299
+ *(_index) = start; \
300
+ *(_exists) = false; \
301
+ uint32_t size = (self)->size - *(_index); \
302
+ if (size == 0) break; \
303
+ int comparison; \
304
+ while (size > 1) { \
305
+ uint32_t half_size = size / 2; \
306
+ uint32_t mid_index = *(_index) + half_size; \
307
+ comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \
308
+ if (comparison <= 0) *(_index) = mid_index; \
309
+ size -= half_size; \
310
+ } \
311
+ comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \
312
+ if (comparison == 0) *(_exists) = true; \
313
+ else if (comparison < 0) *(_index) += 1; \
314
+ } while (0)
315
+
316
+ /// Helper macro for the `_sorted_by` routines below. This takes the left (existing)
317
+ /// parameter by reference in order to work with the generic sorting function above.
318
+ #define _compare_int(a, b) ((int)*(a) - (int)(b))
319
+
320
+ #ifdef _MSC_VER
321
+ #pragma warning(pop)
322
+ #elif defined(__GNUC__) || defined(__clang__)
323
+ #pragma GCC diagnostic pop
324
+ #endif
325
+
326
+ #ifdef __cplusplus
327
+ }
328
+ #endif
329
+
330
+ #endif // TREE_SITTER_ARRAY_H_