@algosail/tree-sitter 0.1.0 → 0.1.2
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/grammar.js +107 -60
- package/package.json +9 -22
- package/src/grammar.json +610 -78
- package/src/node-types.json +497 -68
- package/src/parser.c +3726 -1704
- package/src/tree_sitter/alloc.h +4 -4
- package/src/tree_sitter/array.h +112 -72
- package/src/tree_sitter/parser.h +28 -7
- package/tree-sitter-sail.wasm +0 -0
- package/binding.gyp +0 -30
- package/bindings/node/binding.cc +0 -20
- package/bindings/node/index.d.ts +0 -28
- package/bindings/node/index.js +0 -7
package/src/tree_sitter/alloc.h
CHANGED
|
@@ -12,10 +12,10 @@ extern "C" {
|
|
|
12
12
|
// Allow clients to override allocation functions
|
|
13
13
|
#ifdef TREE_SITTER_REUSE_ALLOCATOR
|
|
14
14
|
|
|
15
|
-
extern void *(*ts_current_malloc)(size_t);
|
|
16
|
-
extern void *(*ts_current_calloc)(size_t, size_t);
|
|
17
|
-
extern void *(*ts_current_realloc)(void
|
|
18
|
-
extern void (*ts_current_free)(void *);
|
|
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
19
|
|
|
20
20
|
#ifndef ts_malloc
|
|
21
21
|
#define ts_malloc ts_current_malloc
|
package/src/tree_sitter/array.h
CHANGED
|
@@ -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
|
|
@@ -51,67 +52,96 @@ extern "C" {
|
|
|
51
52
|
|
|
52
53
|
/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
|
|
53
54
|
/// less than the array's current capacity, this function has no effect.
|
|
54
|
-
#define array_reserve(self, new_capacity)
|
|
55
|
-
|
|
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
|
+
)
|
|
56
60
|
|
|
57
61
|
/// Free any memory allocated for this array. Note that this does not free any
|
|
58
62
|
/// memory allocated for the array's contents.
|
|
59
|
-
#define array_delete(self)
|
|
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
70
|
|
|
61
71
|
/// Push a new `element` onto the end of the array.
|
|
62
|
-
#define array_push(self, element)
|
|
63
|
-
|
|
64
|
-
|
|
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)
|
|
65
80
|
|
|
66
81
|
/// Increase the array's size by `count` elements.
|
|
67
82
|
/// New elements are zero-initialized.
|
|
68
|
-
#define array_grow_by(self, count)
|
|
69
|
-
do {
|
|
70
|
-
if ((count) == 0) break;
|
|
71
|
-
|
|
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
|
+
); \
|
|
72
90
|
memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
|
|
73
|
-
(self)->size += (count);
|
|
91
|
+
(self)->size += (count); \
|
|
74
92
|
} while (0)
|
|
75
93
|
|
|
76
94
|
/// Append all elements from one array to the end of another.
|
|
77
|
-
#define array_push_all(self, other)
|
|
95
|
+
#define array_push_all(self, other) \
|
|
78
96
|
array_extend((self), (other)->size, (other)->contents)
|
|
79
97
|
|
|
80
98
|
/// Append `count` elements to the end of the array, reading their values from the
|
|
81
99
|
/// `contents` pointer.
|
|
82
|
-
#define array_extend(self, count,
|
|
83
|
-
_array__splice(
|
|
84
|
-
(
|
|
85
|
-
0, count,
|
|
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 \
|
|
86
104
|
)
|
|
87
105
|
|
|
88
106
|
/// Remove `old_count` elements from the array starting at the given `index`. At
|
|
89
107
|
/// the same index, insert `new_count` new elements, reading their values from the
|
|
90
108
|
/// `new_contents` pointer.
|
|
91
|
-
#define array_splice(self, _index, old_count, new_count, new_contents)
|
|
92
|
-
_array__splice(
|
|
93
|
-
(
|
|
94
|
-
old_count, new_count, new_contents
|
|
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 \
|
|
95
113
|
)
|
|
96
114
|
|
|
97
115
|
/// Insert one `element` into the array at the given `index`.
|
|
98
|
-
#define array_insert(self, _index, element)
|
|
99
|
-
|
|
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
|
+
)
|
|
100
121
|
|
|
101
122
|
/// Remove one element from the array at the given `index`.
|
|
102
123
|
#define array_erase(self, _index) \
|
|
103
|
-
_array__erase((
|
|
124
|
+
_array__erase((void *)(self)->contents, &(self)->size, array_elem_size(self), _index)
|
|
104
125
|
|
|
105
126
|
/// Pop the last element off the array, returning the element by value.
|
|
106
127
|
#define array_pop(self) ((self)->contents[--(self)->size])
|
|
107
128
|
|
|
108
129
|
/// Assign the contents of one array to another, reallocating if necessary.
|
|
109
|
-
#define array_assign(self, other)
|
|
110
|
-
|
|
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
|
+
)
|
|
111
135
|
|
|
112
136
|
/// Swap one array with another
|
|
113
|
-
#define array_swap(self, other)
|
|
114
|
-
|
|
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)
|
|
115
145
|
|
|
116
146
|
/// Get the size of the array contents
|
|
117
147
|
#define array_elem_size(self) (sizeof *(self)->contents)
|
|
@@ -156,82 +186,90 @@ extern "C" {
|
|
|
156
186
|
|
|
157
187
|
// Private
|
|
158
188
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
self->contents = NULL;
|
|
166
|
-
self->size = 0;
|
|
167
|
-
self->capacity = 0;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
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).
|
|
170
195
|
|
|
171
196
|
/// This is not what you're looking for, see `array_erase`.
|
|
172
|
-
static inline void _array__erase(
|
|
173
|
-
uint32_t index) {
|
|
174
|
-
assert(index <
|
|
175
|
-
char *contents = (char *)
|
|
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;
|
|
176
201
|
memmove(contents + index * element_size, contents + (index + 1) * element_size,
|
|
177
|
-
(
|
|
178
|
-
|
|
202
|
+
(*size - index - 1) * element_size);
|
|
203
|
+
(*size)--;
|
|
179
204
|
}
|
|
180
205
|
|
|
181
206
|
/// This is not what you're looking for, see `array_reserve`.
|
|
182
|
-
static inline void _array__reserve(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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);
|
|
186
213
|
} else {
|
|
187
|
-
|
|
214
|
+
new_contents = ts_malloc(new_capacity * element_size);
|
|
188
215
|
}
|
|
189
|
-
|
|
216
|
+
*capacity = new_capacity;
|
|
190
217
|
}
|
|
218
|
+
return new_contents;
|
|
191
219
|
}
|
|
192
220
|
|
|
193
221
|
/// This is not what you're looking for, see `array_assign`.
|
|
194
|
-
static inline void _array__assign(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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;
|
|
198
228
|
}
|
|
199
229
|
|
|
200
230
|
/// This is not what you're looking for, see `array_swap`.
|
|
201
|
-
static inline void _array__swap(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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;
|
|
205
239
|
}
|
|
206
240
|
|
|
207
241
|
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
|
|
208
|
-
static inline void _array__grow(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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;
|
|
212
248
|
if (new_capacity < 8) new_capacity = 8;
|
|
213
249
|
if (new_capacity < new_size) new_capacity = new_size;
|
|
214
|
-
_array__reserve(
|
|
250
|
+
new_contents = _array__reserve(contents, capacity, element_size, new_capacity);
|
|
215
251
|
}
|
|
252
|
+
return new_contents;
|
|
216
253
|
}
|
|
217
254
|
|
|
218
255
|
/// This is not what you're looking for, see `array_splice`.
|
|
219
|
-
static inline void _array__splice(
|
|
256
|
+
static inline void *_array__splice(void *self_contents, uint32_t *size, uint32_t *capacity,
|
|
257
|
+
size_t element_size,
|
|
220
258
|
uint32_t index, uint32_t old_count,
|
|
221
259
|
uint32_t new_count, const void *elements) {
|
|
222
|
-
uint32_t new_size =
|
|
260
|
+
uint32_t new_size = *size + new_count - old_count;
|
|
223
261
|
uint32_t old_end = index + old_count;
|
|
224
262
|
uint32_t new_end = index + new_count;
|
|
225
|
-
assert(old_end <=
|
|
263
|
+
assert(old_end <= *size);
|
|
226
264
|
|
|
227
|
-
_array__reserve(
|
|
265
|
+
void *new_contents = _array__reserve(self_contents, capacity, element_size, new_size);
|
|
228
266
|
|
|
229
|
-
char *contents = (char *)
|
|
230
|
-
if (
|
|
267
|
+
char *contents = (char *)new_contents;
|
|
268
|
+
if (*size > old_end) {
|
|
231
269
|
memmove(
|
|
232
270
|
contents + new_end * element_size,
|
|
233
271
|
contents + old_end * element_size,
|
|
234
|
-
(
|
|
272
|
+
(*size - old_end) * element_size
|
|
235
273
|
);
|
|
236
274
|
}
|
|
237
275
|
if (new_count > 0) {
|
|
@@ -249,7 +287,9 @@ static inline void _array__splice(Array *self, size_t element_size,
|
|
|
249
287
|
);
|
|
250
288
|
}
|
|
251
289
|
}
|
|
252
|
-
|
|
290
|
+
*size += new_count - old_count;
|
|
291
|
+
|
|
292
|
+
return new_contents;
|
|
253
293
|
}
|
|
254
294
|
|
|
255
295
|
/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
|
|
@@ -278,7 +318,7 @@ static inline void _array__splice(Array *self, size_t element_size,
|
|
|
278
318
|
#define _compare_int(a, b) ((int)*(a) - (int)(b))
|
|
279
319
|
|
|
280
320
|
#ifdef _MSC_VER
|
|
281
|
-
#pragma warning(
|
|
321
|
+
#pragma warning(pop)
|
|
282
322
|
#elif defined(__GNUC__) || defined(__clang__)
|
|
283
323
|
#pragma GCC diagnostic pop
|
|
284
324
|
#endif
|
package/src/tree_sitter/parser.h
CHANGED
|
@@ -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
|
-
}
|
|
38
|
+
} TSMapSlice;
|
|
33
39
|
|
|
34
40
|
typedef struct {
|
|
35
41
|
bool visible;
|
|
@@ -47,6 +53,7 @@ struct TSLexer {
|
|
|
47
53
|
uint32_t (*get_column)(TSLexer *);
|
|
48
54
|
bool (*is_at_included_range_start)(const TSLexer *);
|
|
49
55
|
bool (*eof)(const TSLexer *);
|
|
56
|
+
void (*log)(const TSLexer *, const char *, ...);
|
|
50
57
|
};
|
|
51
58
|
|
|
52
59
|
typedef enum {
|
|
@@ -78,6 +85,12 @@ typedef struct {
|
|
|
78
85
|
uint16_t external_lex_state;
|
|
79
86
|
} TSLexMode;
|
|
80
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
|
+
|
|
81
94
|
typedef union {
|
|
82
95
|
TSParseAction action;
|
|
83
96
|
struct {
|
|
@@ -92,7 +105,7 @@ typedef struct {
|
|
|
92
105
|
} TSCharacterRange;
|
|
93
106
|
|
|
94
107
|
struct TSLanguage {
|
|
95
|
-
uint32_t
|
|
108
|
+
uint32_t abi_version;
|
|
96
109
|
uint32_t symbol_count;
|
|
97
110
|
uint32_t alias_count;
|
|
98
111
|
uint32_t token_count;
|
|
@@ -108,13 +121,13 @@ struct TSLanguage {
|
|
|
108
121
|
const TSParseActionEntry *parse_actions;
|
|
109
122
|
const char * const *symbol_names;
|
|
110
123
|
const char * const *field_names;
|
|
111
|
-
const
|
|
124
|
+
const TSMapSlice *field_map_slices;
|
|
112
125
|
const TSFieldMapEntry *field_map_entries;
|
|
113
126
|
const TSSymbolMetadata *symbol_metadata;
|
|
114
127
|
const TSSymbol *public_symbol_map;
|
|
115
128
|
const uint16_t *alias_map;
|
|
116
129
|
const TSSymbol *alias_sequences;
|
|
117
|
-
const
|
|
130
|
+
const TSLexerMode *lex_modes;
|
|
118
131
|
bool (*lex_fn)(TSLexer *, TSStateId);
|
|
119
132
|
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
|
120
133
|
TSSymbol keyword_capture_token;
|
|
@@ -128,15 +141,23 @@ struct TSLanguage {
|
|
|
128
141
|
void (*deserialize)(void *, const char *, unsigned);
|
|
129
142
|
} external_scanner;
|
|
130
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;
|
|
131
152
|
};
|
|
132
153
|
|
|
133
|
-
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) {
|
|
134
155
|
uint32_t index = 0;
|
|
135
156
|
uint32_t size = len - index;
|
|
136
157
|
while (size > 1) {
|
|
137
158
|
uint32_t half_size = size / 2;
|
|
138
159
|
uint32_t mid_index = index + half_size;
|
|
139
|
-
TSCharacterRange *range = &ranges[mid_index];
|
|
160
|
+
const TSCharacterRange *range = &ranges[mid_index];
|
|
140
161
|
if (lookahead >= range->start && lookahead <= range->end) {
|
|
141
162
|
return true;
|
|
142
163
|
} else if (lookahead > range->end) {
|
|
@@ -144,7 +165,7 @@ static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t
|
|
|
144
165
|
}
|
|
145
166
|
size -= half_size;
|
|
146
167
|
}
|
|
147
|
-
TSCharacterRange *range = &ranges[index];
|
|
168
|
+
const TSCharacterRange *range = &ranges[index];
|
|
148
169
|
return (lookahead >= range->start && lookahead <= range->end);
|
|
149
170
|
}
|
|
150
171
|
|
|
Binary file
|
package/binding.gyp
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"targets": [
|
|
3
|
-
{
|
|
4
|
-
"target_name": "tree_sitter_sail_binding",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
|
|
7
|
-
],
|
|
8
|
-
"include_dirs": [
|
|
9
|
-
"src",
|
|
10
|
-
],
|
|
11
|
-
"sources": [
|
|
12
|
-
"bindings/node/binding.cc",
|
|
13
|
-
"src/parser.c",
|
|
14
|
-
# NOTE: if your language has an external scanner, add it here.
|
|
15
|
-
],
|
|
16
|
-
"conditions": [
|
|
17
|
-
["OS!='win'", {
|
|
18
|
-
"cflags_c": [
|
|
19
|
-
"-std=c11",
|
|
20
|
-
],
|
|
21
|
-
}, { # OS == "win"
|
|
22
|
-
"cflags_c": [
|
|
23
|
-
"/std:c11",
|
|
24
|
-
"/utf-8",
|
|
25
|
-
],
|
|
26
|
-
}],
|
|
27
|
-
],
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
}
|
package/bindings/node/binding.cc
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#include <napi.h>
|
|
2
|
-
|
|
3
|
-
typedef struct TSLanguage TSLanguage;
|
|
4
|
-
|
|
5
|
-
extern "C" TSLanguage *tree_sitter_sail();
|
|
6
|
-
|
|
7
|
-
// "tree-sitter", "language" hashed with BLAKE2
|
|
8
|
-
const napi_type_tag LANGUAGE_TYPE_TAG = {
|
|
9
|
-
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
13
|
-
exports["name"] = Napi::String::New(env, "sail");
|
|
14
|
-
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_sail());
|
|
15
|
-
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
|
16
|
-
exports["language"] = language;
|
|
17
|
-
return exports;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
NODE_API_MODULE(tree_sitter_sail_binding, Init)
|
package/bindings/node/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
type BaseNode = {
|
|
2
|
-
type: string;
|
|
3
|
-
named: boolean;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
type ChildNode = {
|
|
7
|
-
multiple: boolean;
|
|
8
|
-
required: boolean;
|
|
9
|
-
types: BaseNode[];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type NodeInfo =
|
|
13
|
-
| (BaseNode & {
|
|
14
|
-
subtypes: BaseNode[];
|
|
15
|
-
})
|
|
16
|
-
| (BaseNode & {
|
|
17
|
-
fields: { [name: string]: ChildNode };
|
|
18
|
-
children: ChildNode[];
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
type Language = {
|
|
22
|
-
name: string;
|
|
23
|
-
language: unknown;
|
|
24
|
-
nodeTypeInfo: NodeInfo[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare const language: Language;
|
|
28
|
-
export = language;
|