aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/mitjafelicijan/go-tree-sitter/test_grammar.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mitjafelicijan/go-tree-sitter/test_grammar.go')
-rw-r--r--vendor/github.com/mitjafelicijan/go-tree-sitter/test_grammar.go553
1 files changed, 553 insertions, 0 deletions
diff --git a/vendor/github.com/mitjafelicijan/go-tree-sitter/test_grammar.go b/vendor/github.com/mitjafelicijan/go-tree-sitter/test_grammar.go
new file mode 100644
index 0000000..c727c24
--- /dev/null
+++ b/vendor/github.com/mitjafelicijan/go-tree-sitter/test_grammar.go
@@ -0,0 +1,553 @@
1//Code generated by test_grammar_generate.sh; DO NOT EDIT.
2package sitter
3//#ifndef TREE_SITTER_PARSER_H_
4//#define TREE_SITTER_PARSER_H_
5//
6//#ifdef __cplusplus
7//extern "C" {
8//#endif
9//
10//#include <stdbool.h>
11//#include <stdint.h>
12//#include <stdlib.h>
13//
14//#define ts_builtin_sym_error ((TSSymbol)-1)
15//#define ts_builtin_sym_end 0
16//#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
17//
18//typedef uint16_t TSStateId;
19//
20//#ifndef TREE_SITTER_API_H_
21//typedef uint16_t TSSymbol;
22//typedef uint16_t TSFieldId;
23//typedef struct TSLanguage TSLanguage;
24//#endif
25//
26//typedef struct {
27// TSFieldId field_id;
28// uint8_t child_index;
29// bool inherited;
30//} TSFieldMapEntry;
31//
32//typedef struct {
33// uint16_t index;
34// uint16_t length;
35//} TSFieldMapSlice;
36//
37//typedef struct {
38// bool visible;
39// bool named;
40// bool supertype;
41//} TSSymbolMetadata;
42//
43//typedef struct TSLexer TSLexer;
44//
45//struct TSLexer {
46// int32_t lookahead;
47// TSSymbol result_symbol;
48// void (*advance)(TSLexer *, bool);
49// void (*mark_end)(TSLexer *);
50// uint32_t (*get_column)(TSLexer *);
51// bool (*is_at_included_range_start)(const TSLexer *);
52// bool (*eof)(const TSLexer *);
53//};
54//
55//typedef enum {
56// TSParseActionTypeShift,
57// TSParseActionTypeReduce,
58// TSParseActionTypeAccept,
59// TSParseActionTypeRecover,
60//} TSParseActionType;
61//
62//typedef union {
63// struct {
64// uint8_t type;
65// TSStateId state;
66// bool extra;
67// bool repetition;
68// } shift;
69// struct {
70// uint8_t type;
71// uint8_t child_count;
72// TSSymbol symbol;
73// int16_t dynamic_precedence;
74// uint16_t production_id;
75// } reduce;
76// uint8_t type;
77//} TSParseAction;
78//
79//typedef struct {
80// uint16_t lex_state;
81// uint16_t external_lex_state;
82//} TSLexMode;
83//
84//typedef union {
85// TSParseAction action;
86// struct {
87// uint8_t count;
88// bool reusable;
89// } entry;
90//} TSParseActionEntry;
91//
92//struct TSLanguage {
93// uint32_t version;
94// uint32_t symbol_count;
95// uint32_t alias_count;
96// uint32_t token_count;
97// uint32_t external_token_count;
98// uint32_t state_count;
99// uint32_t large_state_count;
100// uint32_t production_id_count;
101// uint32_t field_count;
102// uint16_t max_alias_sequence_length;
103// const uint16_t *parse_table;
104// const uint16_t *small_parse_table;
105// const uint32_t *small_parse_table_map;
106// const TSParseActionEntry *parse_actions;
107// const char * const *symbol_names;
108// const char * const *field_names;
109// const TSFieldMapSlice *field_map_slices;
110// const TSFieldMapEntry *field_map_entries;
111// const TSSymbolMetadata *symbol_metadata;
112// const TSSymbol *public_symbol_map;
113// const uint16_t *alias_map;
114// const TSSymbol *alias_sequences;
115// const TSLexMode *lex_modes;
116// bool (*lex_fn)(TSLexer *, TSStateId);
117// bool (*keyword_lex_fn)(TSLexer *, TSStateId);
118// TSSymbol keyword_capture_token;
119// struct {
120// const bool *states;
121// const TSSymbol *symbol_map;
122// void *(*create)(void);
123// void (*destroy)(void *);
124// bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
125// unsigned (*serialize)(void *, char *);
126// void (*deserialize)(void *, const char *, unsigned);
127// } external_scanner;
128//};
129//
130///*
131// * Lexer Macros
132// */
133//
134//#define START_LEXER() \
135// bool result = false; \
136// bool skip = false; \
137// bool eof = false; \
138// int32_t lookahead; \
139// goto start; \
140// next_state: \
141// lexer->advance(lexer, skip); \
142// start: \
143// skip = false; \
144// lookahead = lexer->lookahead;
145//
146//#define ADVANCE(state_value) \
147// { \
148// state = state_value; \
149// goto next_state; \
150// }
151//
152//#define SKIP(state_value) \
153// { \
154// skip = true; \
155// state = state_value; \
156// goto next_state; \
157// }
158//
159//#define ACCEPT_TOKEN(symbol_value) \
160// result = true; \
161// lexer->result_symbol = symbol_value; \
162// lexer->mark_end(lexer);
163//
164//#define END_STATE() return result;
165//
166///*
167// * Parse Table Macros
168// */
169//
170//#define SMALL_STATE(id) id - LARGE_STATE_COUNT
171//
172//#define STATE(id) id
173//
174//#define ACTIONS(id) id
175//
176//#define SHIFT(state_value) \
177// {{ \
178// .shift = { \
179// .type = TSParseActionTypeShift, \
180// .state = state_value \
181// } \
182// }}
183//
184//#define SHIFT_REPEAT(state_value) \
185// {{ \
186// .shift = { \
187// .type = TSParseActionTypeShift, \
188// .state = state_value, \
189// .repetition = true \
190// } \
191// }}
192//
193//#define SHIFT_EXTRA() \
194// {{ \
195// .shift = { \
196// .type = TSParseActionTypeShift, \
197// .extra = true \
198// } \
199// }}
200//
201//#define REDUCE(symbol_val, child_count_val, ...) \
202// {{ \
203// .reduce = { \
204// .type = TSParseActionTypeReduce, \
205// .symbol = symbol_val, \
206// .child_count = child_count_val, \
207// __VA_ARGS__ \
208// }, \
209// }}
210//
211//#define RECOVER() \
212// {{ \
213// .type = TSParseActionTypeRecover \
214// }}
215//
216//#define ACCEPT_INPUT() \
217// {{ \
218// .type = TSParseActionTypeAccept \
219// }}
220//
221//#ifdef __cplusplus
222//}
223//#endif
224//
225//#endif // TREE_SITTER_PARSER_H_
226//
227//#if defined(__GNUC__) || defined(__clang__)
228//#pragma GCC diagnostic push
229//#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
230//#endif
231//
232//#define LANGUAGE_VERSION 13
233//#define STATE_COUNT 9
234//#define LARGE_STATE_COUNT 4
235//#define SYMBOL_COUNT 9
236//#define ALIAS_COUNT 0
237//#define TOKEN_COUNT 7
238//#define EXTERNAL_TOKEN_COUNT 0
239//#define FIELD_COUNT 2
240//#define MAX_ALIAS_SEQUENCE_LENGTH 3
241//#define PRODUCTION_ID_COUNT 2
242//
243//enum {
244// anon_sym_LPAREN = 1,
245// anon_sym_RPAREN = 2,
246// anon_sym_PLUS = 3,
247// sym_number = 4,
248// sym_comment = 5,
249// sym_variable = 6,
250// sym_expression = 7,
251// sym_sum = 8,
252//};
253//
254//static const char * const ts_symbol_names[] = {
255// [ts_builtin_sym_end] = "end",
256// [anon_sym_LPAREN] = "(",
257// [anon_sym_RPAREN] = ")",
258// [anon_sym_PLUS] = "+",
259// [sym_number] = "number",
260// [sym_comment] = "comment",
261// [sym_variable] = "variable",
262// [sym_expression] = "expression",
263// [sym_sum] = "sum",
264//};
265//
266//static const TSSymbol ts_symbol_map[] = {
267// [ts_builtin_sym_end] = ts_builtin_sym_end,
268// [anon_sym_LPAREN] = anon_sym_LPAREN,
269// [anon_sym_RPAREN] = anon_sym_RPAREN,
270// [anon_sym_PLUS] = anon_sym_PLUS,
271// [sym_number] = sym_number,
272// [sym_comment] = sym_comment,
273// [sym_variable] = sym_variable,
274// [sym_expression] = sym_expression,
275// [sym_sum] = sym_sum,
276//};
277//
278//static const TSSymbolMetadata ts_symbol_metadata[] = {
279// [ts_builtin_sym_end] = {
280// .visible = false,
281// .named = true,
282// },
283// [anon_sym_LPAREN] = {
284// .visible = true,
285// .named = false,
286// },
287// [anon_sym_RPAREN] = {
288// .visible = true,
289// .named = false,
290// },
291// [anon_sym_PLUS] = {
292// .visible = true,
293// .named = false,
294// },
295// [sym_number] = {
296// .visible = true,
297// .named = true,
298// },
299// [sym_comment] = {
300// .visible = true,
301// .named = true,
302// },
303// [sym_variable] = {
304// .visible = true,
305// .named = true,
306// },
307// [sym_expression] = {
308// .visible = true,
309// .named = true,
310// },
311// [sym_sum] = {
312// .visible = true,
313// .named = true,
314// },
315//};
316//
317//enum {
318// field_left = 1,
319// field_right = 2,
320//};
321//
322//static const char * const ts_field_names[] = {
323// [0] = NULL,
324// [field_left] = "left",
325// [field_right] = "right",
326//};
327//
328//static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = {
329// [1] = {.index = 0, .length = 2},
330//};
331//
332//static const TSFieldMapEntry ts_field_map_entries[] = {
333// [0] =
334// {field_left, 0},
335// {field_right, 2},
336//};
337//
338//static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
339// [0] = {0},
340//};
341//
342//static const uint16_t ts_non_terminal_alias_map[] = {
343// 0,
344//};
345//
346//static bool ts_lex(TSLexer *lexer, TSStateId state) {
347// START_LEXER();
348// eof = lexer->eof(lexer);
349// switch (state) {
350// case 0:
351// if (eof) ADVANCE(3);
352// if (lookahead == '(') ADVANCE(4);
353// if (lookahead == ')') ADVANCE(5);
354// if (lookahead == '+') ADVANCE(6);
355// if (lookahead == '/') ADVANCE(1);
356// if (lookahead == '\t' ||
357// lookahead == '\n' ||
358// lookahead == '\r' ||
359// lookahead == ' ') SKIP(0)
360// if (('0' <= lookahead && lookahead <= '9')) ADVANCE(7);
361// if (('A' <= lookahead && lookahead <= 'Z') ||
362// ('a' <= lookahead && lookahead <= 'z')) ADVANCE(2);
363// END_STATE();
364// case 1:
365// if (lookahead == '/') ADVANCE(8);
366// END_STATE();
367// case 2:
368// if (lookahead == '\\') ADVANCE(9);
369// END_STATE();
370// case 3:
371// ACCEPT_TOKEN(ts_builtin_sym_end);
372// END_STATE();
373// case 4:
374// ACCEPT_TOKEN(anon_sym_LPAREN);
375// END_STATE();
376// case 5:
377// ACCEPT_TOKEN(anon_sym_RPAREN);
378// END_STATE();
379// case 6:
380// ACCEPT_TOKEN(anon_sym_PLUS);
381// END_STATE();
382// case 7:
383// ACCEPT_TOKEN(sym_number);
384// if (('0' <= lookahead && lookahead <= '9')) ADVANCE(7);
385// END_STATE();
386// case 8:
387// ACCEPT_TOKEN(sym_comment);
388// if (lookahead != 0 &&
389// lookahead != '\n') ADVANCE(8);
390// END_STATE();
391// case 9:
392// ACCEPT_TOKEN(sym_variable);
393// if (lookahead == 'w') ADVANCE(9);
394// END_STATE();
395// default:
396// return false;
397// }
398//}
399//
400//static const TSLexMode ts_lex_modes[STATE_COUNT] = {
401// [0] = {.lex_state = 0},
402// [1] = {.lex_state = 0},
403// [2] = {.lex_state = 0},
404// [3] = {.lex_state = 0},
405// [4] = {.lex_state = 0},
406// [5] = {.lex_state = 0},
407// [6] = {.lex_state = 0},
408// [7] = {.lex_state = 0},
409// [8] = {.lex_state = 0},
410//};
411//
412//static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
413// [0] = {
414// [ts_builtin_sym_end] = ACTIONS(1),
415// [anon_sym_LPAREN] = ACTIONS(1),
416// [anon_sym_RPAREN] = ACTIONS(1),
417// [anon_sym_PLUS] = ACTIONS(1),
418// [sym_number] = ACTIONS(1),
419// [sym_comment] = ACTIONS(3),
420// [sym_variable] = ACTIONS(1),
421// },
422// [1] = {
423// [sym_expression] = STATE(7),
424// [sym_sum] = STATE(4),
425// [anon_sym_LPAREN] = ACTIONS(5),
426// [sym_number] = ACTIONS(7),
427// [sym_comment] = ACTIONS(3),
428// [sym_variable] = ACTIONS(7),
429// },
430// [2] = {
431// [sym_expression] = STATE(8),
432// [sym_sum] = STATE(4),
433// [anon_sym_LPAREN] = ACTIONS(5),
434// [sym_number] = ACTIONS(7),
435// [sym_comment] = ACTIONS(3),
436// [sym_variable] = ACTIONS(7),
437// },
438// [3] = {
439// [sym_expression] = STATE(6),
440// [sym_sum] = STATE(4),
441// [anon_sym_LPAREN] = ACTIONS(5),
442// [sym_number] = ACTIONS(7),
443// [sym_comment] = ACTIONS(3),
444// [sym_variable] = ACTIONS(7),
445// },
446//};
447//
448//static const uint16_t ts_small_parse_table[] = {
449// [0] = 2,
450// ACTIONS(3), 1,
451// sym_comment,
452// ACTIONS(9), 3,
453// ts_builtin_sym_end,
454// anon_sym_RPAREN,
455// anon_sym_PLUS,
456// [9] = 2,
457// ACTIONS(3), 1,
458// sym_comment,
459// ACTIONS(11), 3,
460// ts_builtin_sym_end,
461// anon_sym_RPAREN,
462// anon_sym_PLUS,
463// [18] = 2,
464// ACTIONS(3), 1,
465// sym_comment,
466// ACTIONS(13), 3,
467// ts_builtin_sym_end,
468// anon_sym_RPAREN,
469// anon_sym_PLUS,
470// [27] = 3,
471// ACTIONS(3), 1,
472// sym_comment,
473// ACTIONS(15), 1,
474// ts_builtin_sym_end,
475// ACTIONS(17), 1,
476// anon_sym_PLUS,
477// [37] = 3,
478// ACTIONS(3), 1,
479// sym_comment,
480// ACTIONS(17), 1,
481// anon_sym_PLUS,
482// ACTIONS(19), 1,
483// anon_sym_RPAREN,
484//};
485//
486//static const uint32_t ts_small_parse_table_map[] = {
487// [SMALL_STATE(4)] = 0,
488// [SMALL_STATE(5)] = 9,
489// [SMALL_STATE(6)] = 18,
490// [SMALL_STATE(7)] = 27,
491// [SMALL_STATE(8)] = 37,
492//};
493//
494//static const TSParseActionEntry ts_parse_actions[] = {
495// [0] = {.entry = {.count = 0, .reusable = false}},
496// [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
497// [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),
498// [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),
499// [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
500// [9] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 1),
501// [11] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 3),
502// [13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_sum, 3, .production_id = 1),
503// [15] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
504// [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),
505// [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5),
506//};
507//
508//#ifdef __cplusplus
509//extern "C" {
510//#endif
511//#ifdef _WIN32
512//#define extern __declspec(dllexport)
513//#endif
514//
515//extern const TSLanguage *tree_sitter_test_grammar(void) {
516// static const TSLanguage language = {
517// .version = LANGUAGE_VERSION,
518// .symbol_count = SYMBOL_COUNT,
519// .alias_count = ALIAS_COUNT,
520// .token_count = TOKEN_COUNT,
521// .external_token_count = EXTERNAL_TOKEN_COUNT,
522// .state_count = STATE_COUNT,
523// .large_state_count = LARGE_STATE_COUNT,
524// .production_id_count = PRODUCTION_ID_COUNT,
525// .field_count = FIELD_COUNT,
526// .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
527// .parse_table = &ts_parse_table[0][0],
528// .small_parse_table = ts_small_parse_table,
529// .small_parse_table_map = ts_small_parse_table_map,
530// .parse_actions = ts_parse_actions,
531// .symbol_names = ts_symbol_names,
532// .field_names = ts_field_names,
533// .field_map_slices = ts_field_map_slices,
534// .field_map_entries = ts_field_map_entries,
535// .symbol_metadata = ts_symbol_metadata,
536// .public_symbol_map = ts_symbol_map,
537// .alias_map = ts_non_terminal_alias_map,
538// .alias_sequences = &ts_alias_sequences[0][0],
539// .lex_modes = ts_lex_modes,
540// .lex_fn = ts_lex,
541// };
542// return &language;
543//}
544//#ifdef __cplusplus
545//}
546//#endif
547import "C"
548import "unsafe"
549
550func getTestGrammar() *Language {
551 ptr := unsafe.Pointer(C.tree_sitter_test_grammar())
552 return NewLanguage(ptr)
553}