tree-sitter-muttrc 0.0.5 → 0.1.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/LICENSE +21 -0
- package/README.md +12 -0
- package/binding.gyp +17 -3
- package/bindings/node/binding.cc +1 -2
- package/bindings/node/binding_test.js +11 -0
- package/bindings/node/index.d.ts +36 -4
- package/bindings/node/index.js +34 -4
- package/grammar.js +186 -181
- package/package.json +26 -21
- package/queries/highlights.scm +61 -0
- package/queries/injections.scm +30 -0
- package/src/grammar.json +353 -585
- package/src/node-types.json +55 -78
- package/src/parser.c +20398 -13114
- package/src/tree_sitter/alloc.h +4 -4
- package/src/tree_sitter/array.h +120 -74
- package/src/tree_sitter/parser.h +68 -12
- package/tree-sitter.json +42 -0
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
|
|
@@ -49,69 +50,104 @@ extern "C" {
|
|
|
49
50
|
/// memory allocated for the array's contents.
|
|
50
51
|
#define array_clear(self) ((self)->size = 0)
|
|
51
52
|
|
|
53
|
+
#ifdef __cplusplus
|
|
54
|
+
#define _array__cast(self, expr) (decltype((self)->contents))(expr)
|
|
55
|
+
#else
|
|
56
|
+
#define _array__cast(self, expr) (expr)
|
|
57
|
+
#endif
|
|
58
|
+
|
|
52
59
|
/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
|
|
53
60
|
/// less than the array's current capacity, this function has no effect.
|
|
54
|
-
#define array_reserve(self, new_capacity)
|
|
55
|
-
|
|
61
|
+
#define array_reserve(self, new_capacity) \
|
|
62
|
+
((self)->contents = _array__cast(self, _array__reserve( \
|
|
63
|
+
(void *)(self)->contents, &(self)->capacity, \
|
|
64
|
+
array_elem_size(self), new_capacity)) \
|
|
65
|
+
)
|
|
56
66
|
|
|
57
67
|
/// Free any memory allocated for this array. Note that this does not free any
|
|
58
68
|
/// memory allocated for the array's contents.
|
|
59
|
-
#define array_delete(self)
|
|
69
|
+
#define array_delete(self) \
|
|
70
|
+
do { \
|
|
71
|
+
if ((self)->contents) ts_free((self)->contents); \
|
|
72
|
+
(self)->contents = NULL; \
|
|
73
|
+
(self)->size = 0; \
|
|
74
|
+
(self)->capacity = 0; \
|
|
75
|
+
} while (0)
|
|
60
76
|
|
|
61
77
|
/// Push a new `element` onto the end of the array.
|
|
62
|
-
#define array_push(self, element)
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
#define array_push(self, element) \
|
|
79
|
+
do { \
|
|
80
|
+
(self)->contents = _array__cast(self, _array__grow( \
|
|
81
|
+
(void *)(self)->contents, (self)->size, &(self)->capacity, \
|
|
82
|
+
1, array_elem_size(self) \
|
|
83
|
+
)); \
|
|
84
|
+
(self)->contents[(self)->size++] = (element); \
|
|
85
|
+
} while(0)
|
|
65
86
|
|
|
66
87
|
/// Increase the array's size by `count` elements.
|
|
67
88
|
/// New elements are zero-initialized.
|
|
68
|
-
#define array_grow_by(self, count)
|
|
69
|
-
do {
|
|
70
|
-
if ((count) == 0) break;
|
|
71
|
-
|
|
89
|
+
#define array_grow_by(self, count) \
|
|
90
|
+
do { \
|
|
91
|
+
if ((count) == 0) break; \
|
|
92
|
+
(self)->contents = _array__cast(self, _array__grow( \
|
|
93
|
+
(self)->contents, (self)->size, &(self)->capacity, \
|
|
94
|
+
count, array_elem_size(self) \
|
|
95
|
+
)); \
|
|
72
96
|
memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
|
|
73
|
-
(self)->size += (count);
|
|
97
|
+
(self)->size += (count); \
|
|
74
98
|
} while (0)
|
|
75
99
|
|
|
76
100
|
/// Append all elements from one array to the end of another.
|
|
77
|
-
#define array_push_all(self, other)
|
|
101
|
+
#define array_push_all(self, other) \
|
|
78
102
|
array_extend((self), (other)->size, (other)->contents)
|
|
79
103
|
|
|
80
104
|
/// Append `count` elements to the end of the array, reading their values from the
|
|
81
105
|
/// `contents` pointer.
|
|
82
|
-
#define array_extend(self, count,
|
|
83
|
-
_array__splice(
|
|
84
|
-
(
|
|
85
|
-
0, count,
|
|
86
|
-
)
|
|
106
|
+
#define array_extend(self, count, other_contents) \
|
|
107
|
+
((self)->contents = _array__cast(self, _array__splice( \
|
|
108
|
+
(void*)(self)->contents, &(self)->size, &(self)->capacity, \
|
|
109
|
+
array_elem_size(self), (self)->size, 0, count, other_contents \
|
|
110
|
+
)))
|
|
87
111
|
|
|
88
112
|
/// Remove `old_count` elements from the array starting at the given `index`. At
|
|
89
113
|
/// the same index, insert `new_count` new elements, reading their values from the
|
|
90
114
|
/// `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
|
|
95
|
-
)
|
|
115
|
+
#define array_splice(self, _index, old_count, new_count, new_contents) \
|
|
116
|
+
((self)->contents = _array__cast(self, _array__splice( \
|
|
117
|
+
(void *)(self)->contents, &(self)->size, &(self)->capacity, \
|
|
118
|
+
array_elem_size(self), _index, old_count, new_count, new_contents \
|
|
119
|
+
)))
|
|
96
120
|
|
|
97
121
|
/// Insert one `element` into the array at the given `index`.
|
|
98
|
-
#define array_insert(self, _index, element)
|
|
99
|
-
|
|
122
|
+
#define array_insert(self, _index, element) \
|
|
123
|
+
((self)->contents = _array__cast(self, _array__splice( \
|
|
124
|
+
(void *)(self)->contents, &(self)->size, &(self)->capacity, \
|
|
125
|
+
array_elem_size(self), _index, 0, 1, &(element) \
|
|
126
|
+
)))
|
|
100
127
|
|
|
101
128
|
/// Remove one element from the array at the given `index`.
|
|
102
129
|
#define array_erase(self, _index) \
|
|
103
|
-
_array__erase((
|
|
130
|
+
_array__erase((void *)(self)->contents, &(self)->size, array_elem_size(self), _index)
|
|
104
131
|
|
|
105
132
|
/// Pop the last element off the array, returning the element by value.
|
|
106
133
|
#define array_pop(self) ((self)->contents[--(self)->size])
|
|
107
134
|
|
|
108
135
|
/// Assign the contents of one array to another, reallocating if necessary.
|
|
109
|
-
#define array_assign(self, other)
|
|
110
|
-
|
|
136
|
+
#define array_assign(self, other) \
|
|
137
|
+
((self)->contents = _array__cast(self, _array__assign( \
|
|
138
|
+
(void *)(self)->contents, &(self)->size, &(self)->capacity, \
|
|
139
|
+
(const void *)(other)->contents, (other)->size, array_elem_size(self) \
|
|
140
|
+
)))
|
|
111
141
|
|
|
112
142
|
/// Swap one array with another
|
|
113
|
-
#define array_swap(self, other)
|
|
114
|
-
|
|
143
|
+
#define array_swap(self, other) \
|
|
144
|
+
do { \
|
|
145
|
+
void *_array_swap_tmp = (void *)(self)->contents; \
|
|
146
|
+
(self)->contents = (other)->contents; \
|
|
147
|
+
(other)->contents = _array__cast(other, _array_swap_tmp); \
|
|
148
|
+
_array__swap(&(self)->size, &(self)->capacity, \
|
|
149
|
+
&(other)->size, &(other)->capacity); \
|
|
150
|
+
} while (0)
|
|
115
151
|
|
|
116
152
|
/// Get the size of the array contents
|
|
117
153
|
#define array_elem_size(self) (sizeof *(self)->contents)
|
|
@@ -156,82 +192,90 @@ extern "C" {
|
|
|
156
192
|
|
|
157
193
|
// Private
|
|
158
194
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
self->contents = NULL;
|
|
166
|
-
self->size = 0;
|
|
167
|
-
self->capacity = 0;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
195
|
+
// Pointers to individual `Array` fields (rather than the entire `Array` itself)
|
|
196
|
+
// are passed to the various `_array__*` functions below to address strict aliasing
|
|
197
|
+
// violations that arises when the _entire_ `Array` struct is passed as `Array(void)*`.
|
|
198
|
+
//
|
|
199
|
+
// The `Array` type itself was not altered as a solution in order to avoid breakage
|
|
200
|
+
// with existing consumers (in particular, parsers with external scanners).
|
|
170
201
|
|
|
171
202
|
/// 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 *)
|
|
203
|
+
static inline void _array__erase(void* self_contents, uint32_t *size,
|
|
204
|
+
size_t element_size, uint32_t index) {
|
|
205
|
+
assert(index < *size);
|
|
206
|
+
char *contents = (char *)self_contents;
|
|
176
207
|
memmove(contents + index * element_size, contents + (index + 1) * element_size,
|
|
177
|
-
(
|
|
178
|
-
|
|
208
|
+
(*size - index - 1) * element_size);
|
|
209
|
+
(*size)--;
|
|
179
210
|
}
|
|
180
211
|
|
|
181
212
|
/// This is not what you're looking for, see `array_reserve`.
|
|
182
|
-
static inline void _array__reserve(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
213
|
+
static inline void *_array__reserve(void *contents, uint32_t *capacity,
|
|
214
|
+
size_t element_size, uint32_t new_capacity) {
|
|
215
|
+
void *new_contents = contents;
|
|
216
|
+
if (new_capacity > *capacity) {
|
|
217
|
+
if (contents) {
|
|
218
|
+
new_contents = ts_realloc(contents, new_capacity * element_size);
|
|
186
219
|
} else {
|
|
187
|
-
|
|
220
|
+
new_contents = ts_malloc(new_capacity * element_size);
|
|
188
221
|
}
|
|
189
|
-
|
|
222
|
+
*capacity = new_capacity;
|
|
190
223
|
}
|
|
224
|
+
return new_contents;
|
|
191
225
|
}
|
|
192
226
|
|
|
193
227
|
/// This is not what you're looking for, see `array_assign`.
|
|
194
|
-
static inline void _array__assign(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
228
|
+
static inline void *_array__assign(void* self_contents, uint32_t *self_size, uint32_t *self_capacity,
|
|
229
|
+
const void *other_contents, uint32_t other_size, size_t element_size) {
|
|
230
|
+
void *new_contents = _array__reserve(self_contents, self_capacity, element_size, other_size);
|
|
231
|
+
*self_size = other_size;
|
|
232
|
+
memcpy(new_contents, other_contents, *self_size * element_size);
|
|
233
|
+
return new_contents;
|
|
198
234
|
}
|
|
199
235
|
|
|
200
236
|
/// This is not what you're looking for, see `array_swap`.
|
|
201
|
-
static inline void _array__swap(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
237
|
+
static inline void _array__swap(uint32_t *self_size, uint32_t *self_capacity,
|
|
238
|
+
uint32_t *other_size, uint32_t *other_capacity) {
|
|
239
|
+
uint32_t tmp_size = *self_size;
|
|
240
|
+
uint32_t tmp_capacity = *self_capacity;
|
|
241
|
+
*self_size = *other_size;
|
|
242
|
+
*self_capacity = *other_capacity;
|
|
243
|
+
*other_size = tmp_size;
|
|
244
|
+
*other_capacity = tmp_capacity;
|
|
205
245
|
}
|
|
206
246
|
|
|
207
247
|
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
|
|
208
|
-
static inline void _array__grow(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
248
|
+
static inline void *_array__grow(void *contents, uint32_t size, uint32_t *capacity,
|
|
249
|
+
uint32_t count, size_t element_size) {
|
|
250
|
+
void *new_contents = contents;
|
|
251
|
+
uint32_t new_size = size + count;
|
|
252
|
+
if (new_size > *capacity) {
|
|
253
|
+
uint32_t new_capacity = *capacity * 2;
|
|
212
254
|
if (new_capacity < 8) new_capacity = 8;
|
|
213
255
|
if (new_capacity < new_size) new_capacity = new_size;
|
|
214
|
-
_array__reserve(
|
|
256
|
+
new_contents = _array__reserve(contents, capacity, element_size, new_capacity);
|
|
215
257
|
}
|
|
258
|
+
return new_contents;
|
|
216
259
|
}
|
|
217
260
|
|
|
218
261
|
/// This is not what you're looking for, see `array_splice`.
|
|
219
|
-
static inline void _array__splice(
|
|
262
|
+
static inline void *_array__splice(void *self_contents, uint32_t *size, uint32_t *capacity,
|
|
263
|
+
size_t element_size,
|
|
220
264
|
uint32_t index, uint32_t old_count,
|
|
221
265
|
uint32_t new_count, const void *elements) {
|
|
222
|
-
uint32_t new_size =
|
|
266
|
+
uint32_t new_size = *size + new_count - old_count;
|
|
223
267
|
uint32_t old_end = index + old_count;
|
|
224
268
|
uint32_t new_end = index + new_count;
|
|
225
|
-
assert(old_end <=
|
|
269
|
+
assert(old_end <= *size);
|
|
226
270
|
|
|
227
|
-
_array__reserve(
|
|
271
|
+
void *new_contents = _array__reserve(self_contents, capacity, element_size, new_size);
|
|
228
272
|
|
|
229
|
-
char *contents = (char *)
|
|
230
|
-
if (
|
|
273
|
+
char *contents = (char *)new_contents;
|
|
274
|
+
if (*size > old_end) {
|
|
231
275
|
memmove(
|
|
232
276
|
contents + new_end * element_size,
|
|
233
277
|
contents + old_end * element_size,
|
|
234
|
-
(
|
|
278
|
+
(*size - old_end) * element_size
|
|
235
279
|
);
|
|
236
280
|
}
|
|
237
281
|
if (new_count > 0) {
|
|
@@ -249,7 +293,9 @@ static inline void _array__splice(Array *self, size_t element_size,
|
|
|
249
293
|
);
|
|
250
294
|
}
|
|
251
295
|
}
|
|
252
|
-
|
|
296
|
+
*size += new_count - old_count;
|
|
297
|
+
|
|
298
|
+
return new_contents;
|
|
253
299
|
}
|
|
254
300
|
|
|
255
301
|
/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
|
|
@@ -278,7 +324,7 @@ static inline void _array__splice(Array *self, size_t element_size,
|
|
|
278
324
|
#define _compare_int(a, b) ((int)*(a) - (int)(b))
|
|
279
325
|
|
|
280
326
|
#ifdef _MSC_VER
|
|
281
|
-
#pragma warning(
|
|
327
|
+
#pragma warning(pop)
|
|
282
328
|
#elif defined(__GNUC__) || defined(__clang__)
|
|
283
329
|
#pragma GCC diagnostic pop
|
|
284
330
|
#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 {
|
|
@@ -86,8 +99,13 @@ typedef union {
|
|
|
86
99
|
} entry;
|
|
87
100
|
} TSParseActionEntry;
|
|
88
101
|
|
|
102
|
+
typedef struct {
|
|
103
|
+
int32_t start;
|
|
104
|
+
int32_t end;
|
|
105
|
+
} TSCharacterRange;
|
|
106
|
+
|
|
89
107
|
struct TSLanguage {
|
|
90
|
-
uint32_t
|
|
108
|
+
uint32_t abi_version;
|
|
91
109
|
uint32_t symbol_count;
|
|
92
110
|
uint32_t alias_count;
|
|
93
111
|
uint32_t token_count;
|
|
@@ -103,13 +121,13 @@ struct TSLanguage {
|
|
|
103
121
|
const TSParseActionEntry *parse_actions;
|
|
104
122
|
const char * const *symbol_names;
|
|
105
123
|
const char * const *field_names;
|
|
106
|
-
const
|
|
124
|
+
const TSMapSlice *field_map_slices;
|
|
107
125
|
const TSFieldMapEntry *field_map_entries;
|
|
108
126
|
const TSSymbolMetadata *symbol_metadata;
|
|
109
127
|
const TSSymbol *public_symbol_map;
|
|
110
128
|
const uint16_t *alias_map;
|
|
111
129
|
const TSSymbol *alias_sequences;
|
|
112
|
-
const
|
|
130
|
+
const TSLexerMode *lex_modes;
|
|
113
131
|
bool (*lex_fn)(TSLexer *, TSStateId);
|
|
114
132
|
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
|
115
133
|
TSSymbol keyword_capture_token;
|
|
@@ -123,8 +141,34 @@ struct TSLanguage {
|
|
|
123
141
|
void (*deserialize)(void *, const char *, unsigned);
|
|
124
142
|
} external_scanner;
|
|
125
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;
|
|
126
152
|
};
|
|
127
153
|
|
|
154
|
+
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
|
155
|
+
uint32_t index = 0;
|
|
156
|
+
uint32_t size = len - index;
|
|
157
|
+
while (size > 1) {
|
|
158
|
+
uint32_t half_size = size / 2;
|
|
159
|
+
uint32_t mid_index = index + half_size;
|
|
160
|
+
const TSCharacterRange *range = &ranges[mid_index];
|
|
161
|
+
if (lookahead >= range->start && lookahead <= range->end) {
|
|
162
|
+
return true;
|
|
163
|
+
} else if (lookahead > range->end) {
|
|
164
|
+
index = mid_index;
|
|
165
|
+
}
|
|
166
|
+
size -= half_size;
|
|
167
|
+
}
|
|
168
|
+
const TSCharacterRange *range = &ranges[index];
|
|
169
|
+
return (lookahead >= range->start && lookahead <= range->end);
|
|
170
|
+
}
|
|
171
|
+
|
|
128
172
|
/*
|
|
129
173
|
* Lexer Macros
|
|
130
174
|
*/
|
|
@@ -154,6 +198,17 @@ struct TSLanguage {
|
|
|
154
198
|
goto next_state; \
|
|
155
199
|
}
|
|
156
200
|
|
|
201
|
+
#define ADVANCE_MAP(...) \
|
|
202
|
+
{ \
|
|
203
|
+
static const uint16_t map[] = { __VA_ARGS__ }; \
|
|
204
|
+
for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \
|
|
205
|
+
if (map[i] == lookahead) { \
|
|
206
|
+
state = map[i + 1]; \
|
|
207
|
+
goto next_state; \
|
|
208
|
+
} \
|
|
209
|
+
} \
|
|
210
|
+
}
|
|
211
|
+
|
|
157
212
|
#define SKIP(state_value) \
|
|
158
213
|
{ \
|
|
159
214
|
skip = true; \
|
|
@@ -203,14 +258,15 @@ struct TSLanguage {
|
|
|
203
258
|
} \
|
|
204
259
|
}}
|
|
205
260
|
|
|
206
|
-
#define REDUCE(
|
|
207
|
-
{{
|
|
208
|
-
.reduce = {
|
|
209
|
-
.type = TSParseActionTypeReduce,
|
|
210
|
-
.symbol =
|
|
211
|
-
.child_count =
|
|
212
|
-
|
|
213
|
-
|
|
261
|
+
#define REDUCE(symbol_name, children, precedence, prod_id) \
|
|
262
|
+
{{ \
|
|
263
|
+
.reduce = { \
|
|
264
|
+
.type = TSParseActionTypeReduce, \
|
|
265
|
+
.symbol = symbol_name, \
|
|
266
|
+
.child_count = children, \
|
|
267
|
+
.dynamic_precedence = precedence, \
|
|
268
|
+
.production_id = prod_id \
|
|
269
|
+
}, \
|
|
214
270
|
}}
|
|
215
271
|
|
|
216
272
|
#define RECOVER() \
|
package/tree-sitter.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/config.schema.json",
|
|
3
|
+
"grammars": [
|
|
4
|
+
{
|
|
5
|
+
"name": "muttrc",
|
|
6
|
+
"camelcase": "Muttrc",
|
|
7
|
+
"title": "Muttrc",
|
|
8
|
+
"scope": "source.muttrc",
|
|
9
|
+
"file-types": [
|
|
10
|
+
"muttrc"
|
|
11
|
+
],
|
|
12
|
+
"injection-regex": "^muttrc$",
|
|
13
|
+
"class-name": "TreeSitterMuttrc"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"metadata": {
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"description": "config file for mutt/neomutt",
|
|
20
|
+
"authors": [
|
|
21
|
+
{
|
|
22
|
+
"name": "Wu",
|
|
23
|
+
"email": "wuzhenyu@ustc.edu",
|
|
24
|
+
"url": "https://github.com/Freed-Wu/"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"links": {
|
|
28
|
+
"repository": "https://github.com/neomutt/tree-sitter-muttrc",
|
|
29
|
+
"funding": "https://github.com/neomutt/tree-sitter-muttrc"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"bindings": {
|
|
33
|
+
"c": true,
|
|
34
|
+
"go": true,
|
|
35
|
+
"java": true,
|
|
36
|
+
"node": true,
|
|
37
|
+
"python": true,
|
|
38
|
+
"rust": true,
|
|
39
|
+
"swift": true,
|
|
40
|
+
"zig": true
|
|
41
|
+
}
|
|
42
|
+
}
|