@gram-data/tree-sitter-gram 0.1.9 → 0.1.10
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 +6 -6
- package/package.json +8 -8
- package/prebuilds/darwin-arm64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/darwin-x64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/linux-arm64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/linux-x64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/win32-arm64/@gram-data+tree-sitter-gram.node +0 -0
- package/prebuilds/win32-x64/@gram-data+tree-sitter-gram.node +0 -0
- package/src/grammar.json +80 -63
- package/src/node-types.json +173 -92
- package/src/parser.c +809 -788
- package/src/tree_sitter/parser.h +27 -7
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;
|
|
@@ -79,6 +85,12 @@ typedef struct {
|
|
|
79
85
|
uint16_t external_lex_state;
|
|
80
86
|
} TSLexMode;
|
|
81
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
|
+
|
|
82
94
|
typedef union {
|
|
83
95
|
TSParseAction action;
|
|
84
96
|
struct {
|
|
@@ -93,7 +105,7 @@ typedef struct {
|
|
|
93
105
|
} TSCharacterRange;
|
|
94
106
|
|
|
95
107
|
struct TSLanguage {
|
|
96
|
-
uint32_t
|
|
108
|
+
uint32_t abi_version;
|
|
97
109
|
uint32_t symbol_count;
|
|
98
110
|
uint32_t alias_count;
|
|
99
111
|
uint32_t token_count;
|
|
@@ -109,13 +121,13 @@ struct TSLanguage {
|
|
|
109
121
|
const TSParseActionEntry *parse_actions;
|
|
110
122
|
const char * const *symbol_names;
|
|
111
123
|
const char * const *field_names;
|
|
112
|
-
const
|
|
124
|
+
const TSMapSlice *field_map_slices;
|
|
113
125
|
const TSFieldMapEntry *field_map_entries;
|
|
114
126
|
const TSSymbolMetadata *symbol_metadata;
|
|
115
127
|
const TSSymbol *public_symbol_map;
|
|
116
128
|
const uint16_t *alias_map;
|
|
117
129
|
const TSSymbol *alias_sequences;
|
|
118
|
-
const
|
|
130
|
+
const TSLexerMode *lex_modes;
|
|
119
131
|
bool (*lex_fn)(TSLexer *, TSStateId);
|
|
120
132
|
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
|
121
133
|
TSSymbol keyword_capture_token;
|
|
@@ -129,15 +141,23 @@ struct TSLanguage {
|
|
|
129
141
|
void (*deserialize)(void *, const char *, unsigned);
|
|
130
142
|
} external_scanner;
|
|
131
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;
|
|
132
152
|
};
|
|
133
153
|
|
|
134
|
-
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) {
|
|
135
155
|
uint32_t index = 0;
|
|
136
156
|
uint32_t size = len - index;
|
|
137
157
|
while (size > 1) {
|
|
138
158
|
uint32_t half_size = size / 2;
|
|
139
159
|
uint32_t mid_index = index + half_size;
|
|
140
|
-
TSCharacterRange *range = &ranges[mid_index];
|
|
160
|
+
const TSCharacterRange *range = &ranges[mid_index];
|
|
141
161
|
if (lookahead >= range->start && lookahead <= range->end) {
|
|
142
162
|
return true;
|
|
143
163
|
} else if (lookahead > range->end) {
|
|
@@ -145,7 +165,7 @@ static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t
|
|
|
145
165
|
}
|
|
146
166
|
size -= half_size;
|
|
147
167
|
}
|
|
148
|
-
TSCharacterRange *range = &ranges[index];
|
|
168
|
+
const TSCharacterRange *range = &ranges[index];
|
|
149
169
|
return (lookahead >= range->start && lookahead <= range->end);
|
|
150
170
|
}
|
|
151
171
|
|