tree-sitter implementation for the confindent configuration language
1/* Automatically generated by tree-sitter v0.25.3 */
2
3#include "tree_sitter/parser.h"
4
5#if defined(__GNUC__) || defined(__clang__)
6#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
7#endif
8
9#define LANGUAGE_VERSION 15
10#define STATE_COUNT 9
11#define LARGE_STATE_COUNT 4
12#define SYMBOL_COUNT 7
13#define ALIAS_COUNT 0
14#define TOKEN_COUNT 4
15#define EXTERNAL_TOKEN_COUNT 0
16#define FIELD_COUNT 0
17#define MAX_ALIAS_SEQUENCE_LENGTH 3
18#define MAX_RESERVED_WORD_SET_SIZE 0
19#define PRODUCTION_ID_COUNT 1
20#define SUPERTYPE_COUNT 0
21
22enum ts_symbol_identifiers {
23 aux_sym_definition_token1 = 1,
24 sym_key = 2,
25 sym_value = 3,
26 sym_source_file = 4,
27 sym_definition = 5,
28 aux_sym_source_file_repeat1 = 6,
29};
30
31static const char * const ts_symbol_names[] = {
32 [ts_builtin_sym_end] = "end",
33 [aux_sym_definition_token1] = "definition_token1",
34 [sym_key] = "key",
35 [sym_value] = "value",
36 [sym_source_file] = "source_file",
37 [sym_definition] = "definition",
38 [aux_sym_source_file_repeat1] = "source_file_repeat1",
39};
40
41static const TSSymbol ts_symbol_map[] = {
42 [ts_builtin_sym_end] = ts_builtin_sym_end,
43 [aux_sym_definition_token1] = aux_sym_definition_token1,
44 [sym_key] = sym_key,
45 [sym_value] = sym_value,
46 [sym_source_file] = sym_source_file,
47 [sym_definition] = sym_definition,
48 [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1,
49};
50
51static const TSSymbolMetadata ts_symbol_metadata[] = {
52 [ts_builtin_sym_end] = {
53 .visible = false,
54 .named = true,
55 },
56 [aux_sym_definition_token1] = {
57 .visible = false,
58 .named = false,
59 },
60 [sym_key] = {
61 .visible = true,
62 .named = true,
63 },
64 [sym_value] = {
65 .visible = true,
66 .named = true,
67 },
68 [sym_source_file] = {
69 .visible = true,
70 .named = true,
71 },
72 [sym_definition] = {
73 .visible = true,
74 .named = true,
75 },
76 [aux_sym_source_file_repeat1] = {
77 .visible = false,
78 .named = false,
79 },
80};
81
82static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
83 [0] = {0},
84};
85
86static const uint16_t ts_non_terminal_alias_map[] = {
87 0,
88};
89
90static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
91 [0] = 0,
92 [1] = 1,
93 [2] = 2,
94 [3] = 3,
95 [4] = 4,
96 [5] = 5,
97 [6] = 6,
98 [7] = 7,
99 [8] = 8,
100};
101
102static bool ts_lex(TSLexer *lexer, TSStateId state) {
103 START_LEXER();
104 eof = lexer->eof(lexer);
105 switch (state) {
106 case 0:
107 if (eof) ADVANCE(4);
108 if (lookahead == '\n') ADVANCE(5);
109 if (lookahead == '\t' ||
110 lookahead == ' ') ADVANCE(12);
111 if ((0x0b <= lookahead && lookahead <= '\r')) ADVANCE(8);
112 if (lookahead != 0) ADVANCE(9);
113 END_STATE();
114 case 1:
115 if (lookahead == '\n') ADVANCE(6);
116 if (('\t' <= lookahead && lookahead <= '\r') ||
117 lookahead == ' ') ADVANCE(13);
118 if (lookahead != 0) ADVANCE(14);
119 END_STATE();
120 case 2:
121 if (lookahead == '\n') ADVANCE(7);
122 if (('\t' <= lookahead && lookahead <= '\r') ||
123 lookahead == ' ') SKIP(2);
124 END_STATE();
125 case 3:
126 if (eof) ADVANCE(4);
127 if (lookahead == '\t' ||
128 lookahead == ' ') SKIP(3);
129 if (('\n' <= lookahead && lookahead <= '\r')) ADVANCE(10);
130 if (lookahead != 0) ADVANCE(11);
131 END_STATE();
132 case 4:
133 ACCEPT_TOKEN(ts_builtin_sym_end);
134 END_STATE();
135 case 5:
136 ACCEPT_TOKEN(aux_sym_definition_token1);
137 if (lookahead == '\n') ADVANCE(5);
138 if (lookahead == '\t' ||
139 lookahead == ' ') ADVANCE(12);
140 if ((0x0b <= lookahead && lookahead <= '\r')) ADVANCE(8);
141 END_STATE();
142 case 6:
143 ACCEPT_TOKEN(aux_sym_definition_token1);
144 if (lookahead == '\n') ADVANCE(6);
145 if (('\t' <= lookahead && lookahead <= '\r') ||
146 lookahead == ' ') ADVANCE(13);
147 END_STATE();
148 case 7:
149 ACCEPT_TOKEN(aux_sym_definition_token1);
150 if (lookahead == '\n') ADVANCE(7);
151 END_STATE();
152 case 8:
153 ACCEPT_TOKEN(sym_key);
154 if (lookahead == '\n') ADVANCE(5);
155 if (lookahead == '\t' ||
156 lookahead == ' ') ADVANCE(12);
157 if ((0x0b <= lookahead && lookahead <= '\r')) ADVANCE(8);
158 if (lookahead != 0) ADVANCE(9);
159 END_STATE();
160 case 9:
161 ACCEPT_TOKEN(sym_key);
162 if (lookahead == '\n') ADVANCE(11);
163 if (lookahead == '\t' ||
164 lookahead == ' ') ADVANCE(14);
165 if (lookahead != 0) ADVANCE(9);
166 END_STATE();
167 case 10:
168 ACCEPT_TOKEN(sym_key);
169 if (('\n' <= lookahead && lookahead <= '\r')) ADVANCE(10);
170 if (lookahead != 0 &&
171 (lookahead < '\t' || '\r' < lookahead) &&
172 lookahead != ' ') ADVANCE(11);
173 END_STATE();
174 case 11:
175 ACCEPT_TOKEN(sym_key);
176 if (lookahead != 0 &&
177 lookahead != '\t' &&
178 lookahead != ' ') ADVANCE(11);
179 END_STATE();
180 case 12:
181 ACCEPT_TOKEN(sym_value);
182 if (lookahead == '\n') ADVANCE(5);
183 if (lookahead == '\t' ||
184 lookahead == ' ') ADVANCE(12);
185 if ((0x0b <= lookahead && lookahead <= '\r')) ADVANCE(8);
186 if (lookahead != 0) ADVANCE(9);
187 END_STATE();
188 case 13:
189 ACCEPT_TOKEN(sym_value);
190 if (lookahead == '\n') ADVANCE(6);
191 if (('\t' <= lookahead && lookahead <= '\r') ||
192 lookahead == ' ') ADVANCE(13);
193 if (lookahead != 0) ADVANCE(14);
194 END_STATE();
195 case 14:
196 ACCEPT_TOKEN(sym_value);
197 if (lookahead != 0 &&
198 lookahead != '\n') ADVANCE(14);
199 END_STATE();
200 default:
201 return false;
202 }
203}
204
205static const TSLexerMode ts_lex_modes[STATE_COUNT] = {
206 [0] = {.lex_state = 0},
207 [1] = {.lex_state = 3},
208 [2] = {.lex_state = 3},
209 [3] = {.lex_state = 3},
210 [4] = {.lex_state = 1},
211 [5] = {.lex_state = 3},
212 [6] = {.lex_state = 3},
213 [7] = {.lex_state = 0},
214 [8] = {.lex_state = 2},
215};
216
217static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
218 [STATE(0)] = {
219 [ts_builtin_sym_end] = ACTIONS(1),
220 [aux_sym_definition_token1] = ACTIONS(1),
221 [sym_key] = ACTIONS(1),
222 [sym_value] = ACTIONS(1),
223 },
224 [STATE(1)] = {
225 [sym_source_file] = STATE(7),
226 [sym_definition] = STATE(2),
227 [aux_sym_source_file_repeat1] = STATE(2),
228 [ts_builtin_sym_end] = ACTIONS(3),
229 [sym_key] = ACTIONS(5),
230 },
231 [STATE(2)] = {
232 [sym_definition] = STATE(3),
233 [aux_sym_source_file_repeat1] = STATE(3),
234 [ts_builtin_sym_end] = ACTIONS(7),
235 [sym_key] = ACTIONS(5),
236 },
237 [STATE(3)] = {
238 [sym_definition] = STATE(3),
239 [aux_sym_source_file_repeat1] = STATE(3),
240 [ts_builtin_sym_end] = ACTIONS(9),
241 [sym_key] = ACTIONS(11),
242 },
243};
244
245static const uint16_t ts_small_parse_table[] = {
246 [0] = 2,
247 ACTIONS(14), 1,
248 aux_sym_definition_token1,
249 ACTIONS(16), 1,
250 sym_value,
251 [7] = 1,
252 ACTIONS(18), 2,
253 ts_builtin_sym_end,
254 sym_key,
255 [12] = 1,
256 ACTIONS(20), 2,
257 ts_builtin_sym_end,
258 sym_key,
259 [17] = 1,
260 ACTIONS(22), 1,
261 ts_builtin_sym_end,
262 [21] = 1,
263 ACTIONS(24), 1,
264 aux_sym_definition_token1,
265};
266
267static const uint32_t ts_small_parse_table_map[] = {
268 [SMALL_STATE(4)] = 0,
269 [SMALL_STATE(5)] = 7,
270 [SMALL_STATE(6)] = 12,
271 [SMALL_STATE(7)] = 17,
272 [SMALL_STATE(8)] = 21,
273};
274
275static const TSParseActionEntry ts_parse_actions[] = {
276 [0] = {.entry = {.count = 0, .reusable = false}},
277 [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
278 [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0, 0, 0),
279 [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
280 [7] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0),
281 [9] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0),
282 [11] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(4),
283 [14] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5),
284 [16] = {.entry = {.count = 1, .reusable = false}}, SHIFT(8),
285 [18] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition, 2, 0, 0),
286 [20] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition, 3, 0, 0),
287 [22] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
288 [24] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6),
289};
290
291#ifdef __cplusplus
292extern "C" {
293#endif
294#ifdef TREE_SITTER_HIDE_SYMBOLS
295#define TS_PUBLIC
296#elif defined(_WIN32)
297#define TS_PUBLIC __declspec(dllexport)
298#else
299#define TS_PUBLIC __attribute__((visibility("default")))
300#endif
301
302TS_PUBLIC const TSLanguage *tree_sitter_confindent(void) {
303 static const TSLanguage language = {
304 .abi_version = LANGUAGE_VERSION,
305 .symbol_count = SYMBOL_COUNT,
306 .alias_count = ALIAS_COUNT,
307 .token_count = TOKEN_COUNT,
308 .external_token_count = EXTERNAL_TOKEN_COUNT,
309 .state_count = STATE_COUNT,
310 .large_state_count = LARGE_STATE_COUNT,
311 .production_id_count = PRODUCTION_ID_COUNT,
312 .supertype_count = SUPERTYPE_COUNT,
313 .field_count = FIELD_COUNT,
314 .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
315 .parse_table = &ts_parse_table[0][0],
316 .small_parse_table = ts_small_parse_table,
317 .small_parse_table_map = ts_small_parse_table_map,
318 .parse_actions = ts_parse_actions,
319 .symbol_names = ts_symbol_names,
320 .symbol_metadata = ts_symbol_metadata,
321 .public_symbol_map = ts_symbol_map,
322 .alias_map = ts_non_terminal_alias_map,
323 .alias_sequences = &ts_alias_sequences[0][0],
324 .lex_modes = (const void*)ts_lex_modes,
325 .lex_fn = ts_lex,
326 .primary_state_ids = ts_primary_state_ids,
327 .name = "confindent",
328 .max_reserved_word_set_size = 0,
329 .metadata = {
330 .major_version = 0,
331 .minor_version = 1,
332 .patch_version = 0,
333 },
334 };
335 return &language;
336}
337#ifdef __cplusplus
338}
339#endif