@willbooster/tree-sitter-kotlin 1.1.0 → 1.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/README.md +17 -10
- package/package.json +8 -23
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +6 -6
- package/binding.gyp +0 -30
- package/bindings/node/binding.cc +0 -20
- package/bindings/node/binding_test.js +0 -9
- package/bindings/node/index.d.ts +0 -28
- package/bindings/node/index.js +0 -11
- package/prebuilds/darwin-arm64/tree-sitter-kotlin.node +0 -0
- package/prebuilds/darwin-x64/tree-sitter-kotlin.node +0 -0
- package/prebuilds/linux-arm64/tree-sitter-kotlin.node +0 -0
- package/prebuilds/linux-x64/tree-sitter-kotlin.node +0 -0
- package/src/grammar.json +0 -6541
- package/src/parser.c +0 -4
- package/src/scanner.c +0 -466
- package/src/tree_sitter/alloc.h +0 -54
- package/src/tree_sitter/array.h +0 -336
- package/src/tree_sitter/parser.h +0 -286
package/src/parser.c
DELETED
package/src/scanner.c
DELETED
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
#include "tree_sitter/parser.h"
|
|
2
|
-
|
|
3
|
-
#include <string.h>
|
|
4
|
-
#include <wctype.h>
|
|
5
|
-
|
|
6
|
-
enum TokenType {
|
|
7
|
-
SEMI,
|
|
8
|
-
CLASS_MEMBER_SEMI,
|
|
9
|
-
BLOCK_COMMENT,
|
|
10
|
-
NOT_IS,
|
|
11
|
-
IN,
|
|
12
|
-
Q_DOT,
|
|
13
|
-
MULTILINE_STRING_CONTENT,
|
|
14
|
-
CONSTRUCTOR,
|
|
15
|
-
GET,
|
|
16
|
-
SET,
|
|
17
|
-
DOLLAR,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
#define MAX_WORD_SIZE 16
|
|
21
|
-
#define MAX_WORDS 16
|
|
22
|
-
|
|
23
|
-
static inline void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
|
|
24
|
-
|
|
25
|
-
static inline void skip(TSLexer *lexer) { lexer->advance(lexer, true); }
|
|
26
|
-
|
|
27
|
-
static bool scan_word(TSLexer *lexer, const char *const word) {
|
|
28
|
-
for (uint8_t i = 0; word[i] != '\0'; i++) {
|
|
29
|
-
if (lexer->lookahead != word[i]) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
skip(lexer);
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static bool scan_words(TSLexer *lexer, const char words[MAX_WORDS][MAX_WORD_SIZE], char scanned_word[16],
|
|
38
|
-
uint8_t *index) {
|
|
39
|
-
if (!scanned_word[0]) {
|
|
40
|
-
for (uint8_t i = 0; i < MAX_WORD_SIZE - 1; i++) {
|
|
41
|
-
if (!iswalpha(lexer->lookahead)) {
|
|
42
|
-
if (i == 0) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
scanned_word[i] = (char)lexer->lookahead;
|
|
48
|
-
skip(lexer);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
for (uint8_t i = 0; i < MAX_WORDS; i++) {
|
|
53
|
-
if (strncmp(scanned_word, words[i], MAX_WORD_SIZE) == 0) {
|
|
54
|
-
if (index != NULL) {
|
|
55
|
-
*index = i;
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
void *tree_sitter_kotlin_external_scanner_create() { return NULL; }
|
|
65
|
-
|
|
66
|
-
void tree_sitter_kotlin_external_scanner_destroy(void *payload) {}
|
|
67
|
-
|
|
68
|
-
unsigned tree_sitter_kotlin_external_scanner_serialize(void *payload, char *buffer) { return 0; }
|
|
69
|
-
|
|
70
|
-
void tree_sitter_kotlin_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {}
|
|
71
|
-
|
|
72
|
-
bool tree_sitter_kotlin_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
|
|
73
|
-
// During error recovery every token is valid, including string content and a semicolon, which never are
|
|
74
|
-
// together otherwise. Scanning string content there would consume the rest of the input on each
|
|
75
|
-
// recovery attempt, making recovery quadratic in the input length.
|
|
76
|
-
bool error_recovery = valid_symbols[MULTILINE_STRING_CONTENT] && valid_symbols[SEMI];
|
|
77
|
-
if (valid_symbols[MULTILINE_STRING_CONTENT] && !error_recovery) {
|
|
78
|
-
bool did_advance = false;
|
|
79
|
-
lexer->result_symbol = MULTILINE_STRING_CONTENT;
|
|
80
|
-
while (!lexer->eof(lexer)) {
|
|
81
|
-
switch (lexer->lookahead) {
|
|
82
|
-
case '$':
|
|
83
|
-
lexer->mark_end(lexer);
|
|
84
|
-
advance(lexer);
|
|
85
|
-
if (iswalpha(lexer->lookahead) || lexer->lookahead == '{') {
|
|
86
|
-
return did_advance;
|
|
87
|
-
}
|
|
88
|
-
did_advance = true;
|
|
89
|
-
break;
|
|
90
|
-
case '"':
|
|
91
|
-
lexer->mark_end(lexer);
|
|
92
|
-
// 3 or 4 quotes means we're done
|
|
93
|
-
advance(lexer);
|
|
94
|
-
if (lexer->lookahead == '"') {
|
|
95
|
-
advance(lexer);
|
|
96
|
-
if (lexer->lookahead == '"') {
|
|
97
|
-
advance(lexer);
|
|
98
|
-
if (lexer->lookahead == '"') {
|
|
99
|
-
advance(lexer);
|
|
100
|
-
}
|
|
101
|
-
return did_advance;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
did_advance = true;
|
|
105
|
-
break;
|
|
106
|
-
default:
|
|
107
|
-
advance(lexer);
|
|
108
|
-
did_advance = true;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (valid_symbols[SEMI] || valid_symbols[CLASS_MEMBER_SEMI]) {
|
|
115
|
-
lexer->result_symbol = valid_symbols[SEMI] ? SEMI : CLASS_MEMBER_SEMI;
|
|
116
|
-
lexer->mark_end(lexer);
|
|
117
|
-
bool saw_newline = false;
|
|
118
|
-
for (;;) {
|
|
119
|
-
if (lexer->eof(lexer)) {
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (lexer->lookahead == ';') {
|
|
124
|
-
advance(lexer);
|
|
125
|
-
lexer->mark_end(lexer);
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (!iswspace(lexer->lookahead)) {
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (lexer->lookahead == '\n') {
|
|
134
|
-
skip(lexer);
|
|
135
|
-
saw_newline = true;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (lexer->lookahead == '\r') {
|
|
140
|
-
skip(lexer);
|
|
141
|
-
|
|
142
|
-
if (lexer->lookahead == '\n') {
|
|
143
|
-
skip(lexer);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
saw_newline = true;
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
skip(lexer);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Skip whitespace and comments
|
|
154
|
-
while (iswspace(lexer->lookahead)) {
|
|
155
|
-
skip(lexer);
|
|
156
|
-
}
|
|
157
|
-
if (lexer->lookahead == '/') {
|
|
158
|
-
goto comment;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (!saw_newline) {
|
|
162
|
-
switch (lexer->lookahead) {
|
|
163
|
-
case '!':
|
|
164
|
-
skip(lexer);
|
|
165
|
-
goto continue_not_is_from_semi;
|
|
166
|
-
case '?':
|
|
167
|
-
if (valid_symbols[Q_DOT]) {
|
|
168
|
-
goto q_dot_from_semi;
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
171
|
-
case 'i':
|
|
172
|
-
return scan_word(lexer, "import");
|
|
173
|
-
case ';':
|
|
174
|
-
advance(lexer);
|
|
175
|
-
lexer->mark_end(lexer);
|
|
176
|
-
return true;
|
|
177
|
-
// A class member may end on the line that closes its body (`class A { val x = 1 }`).
|
|
178
|
-
case '}':
|
|
179
|
-
return valid_symbols[CLASS_MEMBER_SEMI] && !valid_symbols[SEMI];
|
|
180
|
-
default:
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
char scanned_word[16] = {0};
|
|
186
|
-
_switch:
|
|
187
|
-
switch (lexer->lookahead) {
|
|
188
|
-
case ',':
|
|
189
|
-
case '.':
|
|
190
|
-
case ':':
|
|
191
|
-
case '*':
|
|
192
|
-
case '%':
|
|
193
|
-
case '>':
|
|
194
|
-
case '<':
|
|
195
|
-
case '=':
|
|
196
|
-
case '{':
|
|
197
|
-
case '[':
|
|
198
|
-
case '|':
|
|
199
|
-
case '&':
|
|
200
|
-
case '/':
|
|
201
|
-
return false;
|
|
202
|
-
// Insert a semicolon before `--` and `++`, but not before binary `+` or `-`.
|
|
203
|
-
// Insert before +/-{float}
|
|
204
|
-
case '+':
|
|
205
|
-
skip(lexer);
|
|
206
|
-
if (lexer->lookahead == '+') {
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
return iswdigit(lexer->lookahead);
|
|
210
|
-
case '-':
|
|
211
|
-
skip(lexer);
|
|
212
|
-
if (lexer->lookahead == '-') {
|
|
213
|
-
return true;
|
|
214
|
-
}
|
|
215
|
-
return iswdigit(lexer->lookahead);
|
|
216
|
-
// Don't insert a semicolon before `!=`, but do insert one before a unary `!`.
|
|
217
|
-
case '!':
|
|
218
|
-
skip(lexer);
|
|
219
|
-
if (lexer->lookahead == 'i' && valid_symbols[NOT_IS]) {
|
|
220
|
-
skip(lexer);
|
|
221
|
-
if (lexer->lookahead == 's') {
|
|
222
|
-
skip(lexer);
|
|
223
|
-
if (!iswalnum(lexer->lookahead)) {
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return lexer->lookahead != '=';
|
|
229
|
-
case '?':
|
|
230
|
-
if (valid_symbols[Q_DOT]) {
|
|
231
|
-
goto q_dot_from_semi;
|
|
232
|
-
}
|
|
233
|
-
return true;
|
|
234
|
-
case 'e':
|
|
235
|
-
case 'i':
|
|
236
|
-
case 'g':
|
|
237
|
-
case 's':
|
|
238
|
-
case 'p':
|
|
239
|
-
case 'a':
|
|
240
|
-
case 'f':
|
|
241
|
-
case 'o':
|
|
242
|
-
case 'l':
|
|
243
|
-
case 'v':
|
|
244
|
-
case 'n':
|
|
245
|
-
case 'c':
|
|
246
|
-
case 'b':
|
|
247
|
-
case 'w':
|
|
248
|
-
while (scan_words(lexer,
|
|
249
|
-
(const char[16][16]){"public", "private", "protected", "internal", "abstract",
|
|
250
|
-
"final", "open", "override", "lateinit", "vararg", "noinline",
|
|
251
|
-
"crossinline", "external", "suspend", "inline"},
|
|
252
|
-
scanned_word, NULL)) {
|
|
253
|
-
memset(scanned_word, 0, MAX_WORD_SIZE);
|
|
254
|
-
while (iswspace(lexer->lookahead)) {
|
|
255
|
-
skip(lexer);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
uint8_t index = -1;
|
|
260
|
-
bool res = scan_words(
|
|
261
|
-
lexer,
|
|
262
|
-
(const char[16][16]){"else", "in", "instanceof", "get", "set", "constructor", "by", "as", "where"},
|
|
263
|
-
scanned_word, &index);
|
|
264
|
-
|
|
265
|
-
// If `CLASS_MEMBER_SEMI` is valid, we found a secondary constructor and so we want to insert a semi, OR
|
|
266
|
-
// we found a variable named constructor whose field is being accessed
|
|
267
|
-
if (index == 5) {
|
|
268
|
-
while (iswspace(lexer->lookahead)) {
|
|
269
|
-
skip(lexer);
|
|
270
|
-
}
|
|
271
|
-
if (valid_symbols[CLASS_MEMBER_SEMI] || lexer->lookahead == '.' || lexer->lookahead == '=') {
|
|
272
|
-
return true;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
// Ordinarily, we should not insert a semicolon if there is an `else` on the next line,
|
|
276
|
-
// except for when it's a 'when entry', which has a `->` after the `else`.
|
|
277
|
-
else if (index == 0) {
|
|
278
|
-
while (iswspace(lexer->lookahead)) {
|
|
279
|
-
skip(lexer);
|
|
280
|
-
}
|
|
281
|
-
if (lexer->lookahead == '-') {
|
|
282
|
-
skip(lexer);
|
|
283
|
-
if (lexer->lookahead == '>') {
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
// If `get` was found and the keyword is not valid, return a semi since it's being used as an identifier
|
|
289
|
-
else if (index == 3 && (!valid_symbols[GET] || lexer->lookahead == '[')) {
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
// If `set` was found and the keyword is not valid, return a semi since it's being used as an identifier
|
|
293
|
-
else if (index == 4 && (!valid_symbols[SET] || lexer->lookahead == '[' || lexer->lookahead == '(' ||
|
|
294
|
-
lexer->lookahead == '.')) {
|
|
295
|
-
if (lexer->lookahead == '(' && valid_symbols[SET]) {
|
|
296
|
-
// skip until the closing parenthesis
|
|
297
|
-
while (lexer->lookahead != ')' && !lexer->eof(lexer)) {
|
|
298
|
-
skip(lexer);
|
|
299
|
-
}
|
|
300
|
-
skip(lexer);
|
|
301
|
-
|
|
302
|
-
while (iswspace(lexer->lookahead)) {
|
|
303
|
-
if (lexer->lookahead == '\n') {
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
skip(lexer);
|
|
307
|
-
}
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
// If `in` was found and this specific external keyword is valid,
|
|
313
|
-
// return a semi since it's being used in a range test
|
|
314
|
-
else if (index == 1 && valid_symbols[IN]) {
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
return !res;
|
|
318
|
-
case ';':
|
|
319
|
-
advance(lexer);
|
|
320
|
-
lexer->mark_end(lexer);
|
|
321
|
-
return true;
|
|
322
|
-
case '@':
|
|
323
|
-
if (valid_symbols[CONSTRUCTOR]) {
|
|
324
|
-
while (!lexer->eof(lexer) && !iswspace(lexer->lookahead)) {
|
|
325
|
-
skip(lexer);
|
|
326
|
-
}
|
|
327
|
-
while (iswspace(lexer->lookahead)) {
|
|
328
|
-
skip(lexer);
|
|
329
|
-
}
|
|
330
|
-
char ctor[12] = "constructor";
|
|
331
|
-
for (uint8_t i = 0; i < 11; i++) {
|
|
332
|
-
if (lexer->lookahead != ctor[i]) {
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
skip(lexer);
|
|
336
|
-
}
|
|
337
|
-
return false;
|
|
338
|
-
}
|
|
339
|
-
if (valid_symbols[GET] || valid_symbols[SET]) {
|
|
340
|
-
bool saw_paren = false;
|
|
341
|
-
while (!lexer->eof(lexer) && (saw_paren ? lexer->lookahead != '\n' : !iswspace(lexer->lookahead))) {
|
|
342
|
-
skip(lexer);
|
|
343
|
-
if (lexer->lookahead == '(') {
|
|
344
|
-
saw_paren = true;
|
|
345
|
-
}
|
|
346
|
-
if (lexer->lookahead == ')') {
|
|
347
|
-
saw_paren = false;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
while (iswspace(lexer->lookahead)) {
|
|
351
|
-
skip(lexer);
|
|
352
|
-
}
|
|
353
|
-
if (lexer->lookahead == '/') {
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
goto _switch;
|
|
357
|
-
}
|
|
358
|
-
return true;
|
|
359
|
-
|
|
360
|
-
default:
|
|
361
|
-
return true;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
while (iswspace(lexer->lookahead)) {
|
|
366
|
-
skip(lexer);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (valid_symbols[NOT_IS]) {
|
|
370
|
-
if (lexer->lookahead == '!') {
|
|
371
|
-
advance(lexer);
|
|
372
|
-
continue_not_is_from_semi:
|
|
373
|
-
if (lexer->lookahead == 'i') {
|
|
374
|
-
advance(lexer);
|
|
375
|
-
if (lexer->lookahead == 's') {
|
|
376
|
-
advance(lexer);
|
|
377
|
-
lexer->result_symbol = NOT_IS;
|
|
378
|
-
lexer->mark_end(lexer);
|
|
379
|
-
return !iswalnum(lexer->lookahead);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (valid_symbols[IN]) {
|
|
386
|
-
if (lexer->lookahead == 'i') {
|
|
387
|
-
advance(lexer);
|
|
388
|
-
if (lexer->lookahead == 'n') {
|
|
389
|
-
advance(lexer);
|
|
390
|
-
lexer->result_symbol = IN;
|
|
391
|
-
lexer->mark_end(lexer);
|
|
392
|
-
return !iswalnum(lexer->lookahead);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
q_dot_from_semi:
|
|
398
|
-
if (valid_symbols[Q_DOT]) {
|
|
399
|
-
while (iswspace(lexer->lookahead)) {
|
|
400
|
-
skip(lexer);
|
|
401
|
-
}
|
|
402
|
-
if (lexer->lookahead == '?') {
|
|
403
|
-
advance(lexer);
|
|
404
|
-
while (iswspace(lexer->lookahead)) {
|
|
405
|
-
skip(lexer);
|
|
406
|
-
}
|
|
407
|
-
if (lexer->lookahead == '.') {
|
|
408
|
-
advance(lexer);
|
|
409
|
-
lexer->result_symbol = Q_DOT;
|
|
410
|
-
lexer->mark_end(lexer);
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
comment:
|
|
417
|
-
if (valid_symbols[DOLLAR]) {
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (lexer->lookahead == '/') {
|
|
422
|
-
advance(lexer);
|
|
423
|
-
if (lexer->lookahead != '*') {
|
|
424
|
-
return false;
|
|
425
|
-
}
|
|
426
|
-
advance(lexer);
|
|
427
|
-
|
|
428
|
-
bool after_star = false;
|
|
429
|
-
unsigned nesting_depth = 1;
|
|
430
|
-
for (;;) {
|
|
431
|
-
switch (lexer->lookahead) {
|
|
432
|
-
case '\0':
|
|
433
|
-
return false;
|
|
434
|
-
case '*':
|
|
435
|
-
advance(lexer);
|
|
436
|
-
after_star = true;
|
|
437
|
-
break;
|
|
438
|
-
case '/':
|
|
439
|
-
if (after_star) {
|
|
440
|
-
advance(lexer);
|
|
441
|
-
after_star = false;
|
|
442
|
-
nesting_depth--;
|
|
443
|
-
if (nesting_depth == 0) {
|
|
444
|
-
lexer->result_symbol = BLOCK_COMMENT;
|
|
445
|
-
lexer->mark_end(lexer);
|
|
446
|
-
return true;
|
|
447
|
-
}
|
|
448
|
-
} else {
|
|
449
|
-
advance(lexer);
|
|
450
|
-
after_star = false;
|
|
451
|
-
if (lexer->lookahead == '*') {
|
|
452
|
-
nesting_depth++;
|
|
453
|
-
advance(lexer);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
break;
|
|
457
|
-
default:
|
|
458
|
-
advance(lexer);
|
|
459
|
-
after_star = false;
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return false;
|
|
466
|
-
}
|
package/src/tree_sitter/alloc.h
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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_
|