From f37732448a2a374281c9610d05a10315e97dcbbf Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 07:51:24 -0300 Subject: examples/live: the language's grammar, its colours and a new line's indent grammar/grammar.js is the language as src/Lang.zig parses it, for tree-sitter (24 lines): lines of `name = expression` parted by newlines, `+ -` below `* /` below unary `-`, calls, parentheses, numbers (Lang's digits, point and `e`), names, `#` comments as extras. `tree-sitter generate` (tree-sitter 0.26.9; ABI 14, the CLI's without a tree-sitter.json) wrote grammar/src/parser.c (918 lines) and its tree_sitter/ headers, committed: the build compiles them into the sketch as a static library and never runs the generator. The `Language` is handed to the editor at run time (`tree_sitter_live`, queries/highlights.scm and queries/indents.scm embedded). The parse is a module's `Syntax`, kept between calls so Alt-i goes back the way Alt-o came, handed to every key, forgotten at a jump (in `draw`, `in.jumped`) and started again by a reload (the tree a reload leaves is leaked: marked ponytail). `code` colours each run of bytes by `Syntax.colors` in pardes's own theme (orchard, the first): a defined name as a keyword, a called builtin as a string, numbers and comments as theirs, the rest in the theme's ink. indents.scm gives a new line no indent outside an open call or parenthesis: pardes's plain indent is a level more after `)`, so every line of this language that ends in a call pushed the next one in. The library now reads a handed-in language's indent query (pardes, its own change). Test: test/grammar.zig parses with the grammar and compiles with Lang.zig 22 texts: the survey's program and two others both take; eleven broken lines both refuse (an unclosed or extra parenthesis, a missing operand or `=`, two numbers, `1.2.3`, a stray `$`); eight both parse but only Lang.zig refuses, as only it knows names, builtins, arities and where a colour may stand (a name used before it is defined or defined twice, a builtin redefined or called with too few arguments, an unknown call, a colour outside the color line, a name called). Lang.zig's survey is public for it. zig build test: 85 of 85 steps. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- examples/live/grammar/src/parser.c | 918 +++++++++++++++++++++++++++++++++++++ 1 file changed, 918 insertions(+) create mode 100644 examples/live/grammar/src/parser.c (limited to 'examples/live/grammar/src/parser.c') diff --git a/examples/live/grammar/src/parser.c b/examples/live/grammar/src/parser.c new file mode 100644 index 0000000..e694827 --- /dev/null +++ b/examples/live/grammar/src/parser.c @@ -0,0 +1,918 @@ +/* Automatically @generated by tree-sitter */ + +#include "tree_sitter/parser.h" + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#define LANGUAGE_VERSION 14 +#define STATE_COUNT 31 +#define LARGE_STATE_COUNT 2 +#define SYMBOL_COUNT 22 +#define ALIAS_COUNT 0 +#define TOKEN_COUNT 13 +#define EXTERNAL_TOKEN_COUNT 0 +#define FIELD_COUNT 7 +#define MAX_ALIAS_SEQUENCE_LENGTH 5 +#define MAX_RESERVED_WORD_SET_SIZE 0 +#define PRODUCTION_ID_COUNT 5 +#define SUPERTYPE_COUNT 0 + +enum ts_symbol_identifiers { + sym_name = 1, + anon_sym_LF = 2, + anon_sym_EQ = 3, + anon_sym_PLUS = 4, + anon_sym_DASH = 5, + anon_sym_STAR = 6, + anon_sym_SLASH = 7, + anon_sym_LPAREN = 8, + anon_sym_COMMA = 9, + anon_sym_RPAREN = 10, + sym_number = 11, + sym_comment = 12, + sym_source_file = 13, + sym_definition = 14, + sym__expression = 15, + sym_binary = 16, + sym_unary = 17, + sym_call = 18, + sym_parenthesized = 19, + aux_sym_source_file_repeat1 = 20, + aux_sym_call_repeat1 = 21, +}; + +static const char * const ts_symbol_names[] = { + [ts_builtin_sym_end] = "end", + [sym_name] = "name", + [anon_sym_LF] = "\n", + [anon_sym_EQ] = "=", + [anon_sym_PLUS] = "+", + [anon_sym_DASH] = "-", + [anon_sym_STAR] = "*", + [anon_sym_SLASH] = "/", + [anon_sym_LPAREN] = "(", + [anon_sym_COMMA] = ",", + [anon_sym_RPAREN] = ")", + [sym_number] = "number", + [sym_comment] = "comment", + [sym_source_file] = "source_file", + [sym_definition] = "definition", + [sym__expression] = "_expression", + [sym_binary] = "binary", + [sym_unary] = "unary", + [sym_call] = "call", + [sym_parenthesized] = "parenthesized", + [aux_sym_source_file_repeat1] = "source_file_repeat1", + [aux_sym_call_repeat1] = "call_repeat1", +}; + +static const TSSymbol ts_symbol_map[] = { + [ts_builtin_sym_end] = ts_builtin_sym_end, + [sym_name] = sym_name, + [anon_sym_LF] = anon_sym_LF, + [anon_sym_EQ] = anon_sym_EQ, + [anon_sym_PLUS] = anon_sym_PLUS, + [anon_sym_DASH] = anon_sym_DASH, + [anon_sym_STAR] = anon_sym_STAR, + [anon_sym_SLASH] = anon_sym_SLASH, + [anon_sym_LPAREN] = anon_sym_LPAREN, + [anon_sym_COMMA] = anon_sym_COMMA, + [anon_sym_RPAREN] = anon_sym_RPAREN, + [sym_number] = sym_number, + [sym_comment] = sym_comment, + [sym_source_file] = sym_source_file, + [sym_definition] = sym_definition, + [sym__expression] = sym__expression, + [sym_binary] = sym_binary, + [sym_unary] = sym_unary, + [sym_call] = sym_call, + [sym_parenthesized] = sym_parenthesized, + [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1, + [aux_sym_call_repeat1] = aux_sym_call_repeat1, +}; + +static const TSSymbolMetadata ts_symbol_metadata[] = { + [ts_builtin_sym_end] = { + .visible = false, + .named = true, + }, + [sym_name] = { + .visible = true, + .named = true, + }, + [anon_sym_LF] = { + .visible = true, + .named = false, + }, + [anon_sym_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_PLUS] = { + .visible = true, + .named = false, + }, + [anon_sym_DASH] = { + .visible = true, + .named = false, + }, + [anon_sym_STAR] = { + .visible = true, + .named = false, + }, + [anon_sym_SLASH] = { + .visible = true, + .named = false, + }, + [anon_sym_LPAREN] = { + .visible = true, + .named = false, + }, + [anon_sym_COMMA] = { + .visible = true, + .named = false, + }, + [anon_sym_RPAREN] = { + .visible = true, + .named = false, + }, + [sym_number] = { + .visible = true, + .named = true, + }, + [sym_comment] = { + .visible = true, + .named = true, + }, + [sym_source_file] = { + .visible = true, + .named = true, + }, + [sym_definition] = { + .visible = true, + .named = true, + }, + [sym__expression] = { + .visible = false, + .named = true, + }, + [sym_binary] = { + .visible = true, + .named = true, + }, + [sym_unary] = { + .visible = true, + .named = true, + }, + [sym_call] = { + .visible = true, + .named = true, + }, + [sym_parenthesized] = { + .visible = true, + .named = true, + }, + [aux_sym_source_file_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_call_repeat1] = { + .visible = false, + .named = false, + }, +}; + +enum ts_field_identifiers { + field_function = 1, + field_left = 2, + field_name = 3, + field_operand = 4, + field_operator = 5, + field_right = 6, + field_value = 7, +}; + +static const char * const ts_field_names[] = { + [0] = NULL, + [field_function] = "function", + [field_left] = "left", + [field_name] = "name", + [field_operand] = "operand", + [field_operator] = "operator", + [field_right] = "right", + [field_value] = "value", +}; + +static const TSMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { + [1] = {.index = 0, .length = 2}, + [2] = {.index = 2, .length = 1}, + [3] = {.index = 3, .length = 1}, + [4] = {.index = 4, .length = 3}, +}; + +static const TSFieldMapEntry ts_field_map_entries[] = { + [0] = + {field_name, 0}, + {field_value, 2}, + [2] = + {field_operand, 1}, + [3] = + {field_function, 0}, + [4] = + {field_left, 0}, + {field_operator, 1}, + {field_right, 2}, +}; + +static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { + [0] = {0}, +}; + +static const uint16_t ts_non_terminal_alias_map[] = { + 0, +}; + +static const TSStateId ts_primary_state_ids[STATE_COUNT] = { + [0] = 0, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, + [5] = 5, + [6] = 6, + [7] = 7, + [8] = 8, + [9] = 9, + [10] = 10, + [11] = 11, + [12] = 12, + [13] = 13, + [14] = 14, + [15] = 15, + [16] = 16, + [17] = 17, + [18] = 18, + [19] = 19, + [20] = 20, + [21] = 21, + [22] = 22, + [23] = 23, + [24] = 24, + [25] = 25, + [26] = 26, + [27] = 27, + [28] = 28, + [29] = 29, + [30] = 30, +}; + +static bool ts_lex(TSLexer *lexer, TSStateId state) { + START_LEXER(); + eof = lexer->eof(lexer); + switch (state) { + case 0: + if (eof) ADVANCE(4); + ADVANCE_MAP( + '\n', 5, + '#', 18, + '(', 11, + ')', 13, + '*', 9, + '+', 7, + ',', 12, + '-', 8, + '.', 2, + '/', 10, + '=', 6, + ); + if (lookahead == '\t' || + lookahead == '\r' || + lookahead == ' ') SKIP(0); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(14); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(17); + END_STATE(); + case 1: + if (lookahead == '+' || + lookahead == '-') ADVANCE(3); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(16); + END_STATE(); + case 2: + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(15); + END_STATE(); + case 3: + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(16); + END_STATE(); + case 4: + ACCEPT_TOKEN(ts_builtin_sym_end); + END_STATE(); + case 5: + ACCEPT_TOKEN(anon_sym_LF); + END_STATE(); + case 6: + ACCEPT_TOKEN(anon_sym_EQ); + END_STATE(); + case 7: + ACCEPT_TOKEN(anon_sym_PLUS); + END_STATE(); + case 8: + ACCEPT_TOKEN(anon_sym_DASH); + END_STATE(); + case 9: + ACCEPT_TOKEN(anon_sym_STAR); + END_STATE(); + case 10: + ACCEPT_TOKEN(anon_sym_SLASH); + END_STATE(); + case 11: + ACCEPT_TOKEN(anon_sym_LPAREN); + END_STATE(); + case 12: + ACCEPT_TOKEN(anon_sym_COMMA); + END_STATE(); + case 13: + ACCEPT_TOKEN(anon_sym_RPAREN); + END_STATE(); + case 14: + ACCEPT_TOKEN(sym_number); + if (lookahead == '.') ADVANCE(15); + if (lookahead == 'e') ADVANCE(1); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(14); + END_STATE(); + case 15: + ACCEPT_TOKEN(sym_number); + if (lookahead == 'e') ADVANCE(1); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(15); + END_STATE(); + case 16: + ACCEPT_TOKEN(sym_number); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(16); + END_STATE(); + case 17: + ACCEPT_TOKEN(sym_name); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(17); + END_STATE(); + case 18: + ACCEPT_TOKEN(sym_comment); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(18); + END_STATE(); + default: + return false; + } +} + +static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { + START_LEXER(); + eof = lexer->eof(lexer); + switch (state) { + case 0: + ACCEPT_TOKEN(ts_builtin_sym_end); + END_STATE(); + default: + return false; + } +} + +static const TSLexMode ts_lex_modes[STATE_COUNT] = { + [0] = {.lex_state = 0}, + [1] = {.lex_state = 0}, + [2] = {.lex_state = 0}, + [3] = {.lex_state = 0}, + [4] = {.lex_state = 0}, + [5] = {.lex_state = 0}, + [6] = {.lex_state = 0}, + [7] = {.lex_state = 0}, + [8] = {.lex_state = 0}, + [9] = {.lex_state = 0}, + [10] = {.lex_state = 0}, + [11] = {.lex_state = 0}, + [12] = {.lex_state = 0}, + [13] = {.lex_state = 0}, + [14] = {.lex_state = 0}, + [15] = {.lex_state = 0}, + [16] = {.lex_state = 0}, + [17] = {.lex_state = 0}, + [18] = {.lex_state = 0}, + [19] = {.lex_state = 0}, + [20] = {.lex_state = 0}, + [21] = {.lex_state = 0}, + [22] = {.lex_state = 0}, + [23] = {.lex_state = 0}, + [24] = {.lex_state = 0}, + [25] = {.lex_state = 0}, + [26] = {.lex_state = 0}, + [27] = {.lex_state = 0}, + [28] = {.lex_state = 0}, + [29] = {.lex_state = 0}, + [30] = {.lex_state = 0}, +}; + +static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { + [STATE(0)] = { + [ts_builtin_sym_end] = ACTIONS(1), + [sym_name] = ACTIONS(1), + [anon_sym_LF] = ACTIONS(1), + [anon_sym_EQ] = ACTIONS(1), + [anon_sym_PLUS] = ACTIONS(1), + [anon_sym_DASH] = ACTIONS(1), + [anon_sym_STAR] = ACTIONS(1), + [anon_sym_SLASH] = ACTIONS(1), + [anon_sym_LPAREN] = ACTIONS(1), + [anon_sym_COMMA] = ACTIONS(1), + [anon_sym_RPAREN] = ACTIONS(1), + [sym_number] = ACTIONS(1), + [sym_comment] = ACTIONS(3), + }, + [STATE(1)] = { + [sym_source_file] = STATE(30), + [sym_definition] = STATE(22), + [aux_sym_source_file_repeat1] = STATE(23), + [ts_builtin_sym_end] = ACTIONS(5), + [sym_name] = ACTIONS(7), + [anon_sym_LF] = ACTIONS(9), + [sym_comment] = ACTIONS(3), + }, +}; + +static const uint16_t ts_small_parse_table[] = { + [0] = 7, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + sym_name, + ACTIONS(13), 1, + anon_sym_DASH, + ACTIONS(15), 1, + anon_sym_LPAREN, + ACTIONS(17), 1, + anon_sym_RPAREN, + ACTIONS(19), 1, + sym_number, + STATE(17), 5, + sym__expression, + sym_binary, + sym_unary, + sym_call, + sym_parenthesized, + [26] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + sym_name, + ACTIONS(13), 1, + anon_sym_DASH, + ACTIONS(15), 1, + anon_sym_LPAREN, + ACTIONS(21), 1, + sym_number, + STATE(10), 5, + sym__expression, + sym_binary, + sym_unary, + sym_call, + sym_parenthesized, + [49] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + sym_name, + ACTIONS(13), 1, + anon_sym_DASH, + ACTIONS(15), 1, + anon_sym_LPAREN, + ACTIONS(23), 1, + sym_number, + STATE(18), 5, + sym__expression, + sym_binary, + sym_unary, + sym_call, + sym_parenthesized, + [72] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + sym_name, + ACTIONS(13), 1, + anon_sym_DASH, + ACTIONS(15), 1, + anon_sym_LPAREN, + ACTIONS(25), 1, + sym_number, + STATE(20), 5, + sym__expression, + sym_binary, + sym_unary, + sym_call, + sym_parenthesized, + [95] = 3, + ACTIONS(3), 1, + sym_comment, + ACTIONS(29), 1, + anon_sym_LPAREN, + ACTIONS(27), 8, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [112] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + sym_name, + ACTIONS(13), 1, + anon_sym_DASH, + ACTIONS(15), 1, + anon_sym_LPAREN, + ACTIONS(31), 1, + sym_number, + STATE(13), 5, + sym__expression, + sym_binary, + sym_unary, + sym_call, + sym_parenthesized, + [135] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + sym_name, + ACTIONS(13), 1, + anon_sym_DASH, + ACTIONS(15), 1, + anon_sym_LPAREN, + ACTIONS(33), 1, + sym_number, + STATE(19), 5, + sym__expression, + sym_binary, + sym_unary, + sym_call, + sym_parenthesized, + [158] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(11), 1, + sym_name, + ACTIONS(13), 1, + anon_sym_DASH, + ACTIONS(15), 1, + anon_sym_LPAREN, + ACTIONS(35), 1, + sym_number, + STATE(14), 5, + sym__expression, + sym_binary, + sym_unary, + sym_call, + sym_parenthesized, + [181] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(37), 8, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [195] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(39), 8, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [209] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(41), 8, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [223] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(43), 8, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [237] = 3, + ACTIONS(3), 1, + sym_comment, + ACTIONS(45), 2, + anon_sym_STAR, + anon_sym_SLASH, + ACTIONS(43), 6, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [253] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(47), 8, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [267] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(49), 8, + ts_builtin_sym_end, + anon_sym_LF, + anon_sym_PLUS, + anon_sym_DASH, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_COMMA, + anon_sym_RPAREN, + [281] = 6, + ACTIONS(3), 1, + sym_comment, + ACTIONS(53), 1, + anon_sym_COMMA, + ACTIONS(55), 1, + anon_sym_RPAREN, + STATE(26), 1, + aux_sym_call_repeat1, + ACTIONS(45), 2, + anon_sym_STAR, + anon_sym_SLASH, + ACTIONS(51), 2, + anon_sym_PLUS, + anon_sym_DASH, + [302] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(45), 2, + anon_sym_STAR, + anon_sym_SLASH, + ACTIONS(51), 2, + anon_sym_PLUS, + anon_sym_DASH, + ACTIONS(57), 2, + ts_builtin_sym_end, + anon_sym_LF, + [318] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(45), 2, + anon_sym_STAR, + anon_sym_SLASH, + ACTIONS(51), 2, + anon_sym_PLUS, + anon_sym_DASH, + ACTIONS(59), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [334] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(61), 1, + anon_sym_RPAREN, + ACTIONS(45), 2, + anon_sym_STAR, + anon_sym_SLASH, + ACTIONS(51), 2, + anon_sym_PLUS, + anon_sym_DASH, + [349] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(7), 1, + sym_name, + STATE(28), 1, + sym_definition, + ACTIONS(63), 2, + ts_builtin_sym_end, + anon_sym_LF, + [363] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(9), 1, + anon_sym_LF, + ACTIONS(65), 1, + ts_builtin_sym_end, + STATE(24), 1, + aux_sym_source_file_repeat1, + [376] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(9), 1, + anon_sym_LF, + ACTIONS(65), 1, + ts_builtin_sym_end, + STATE(25), 1, + aux_sym_source_file_repeat1, + [389] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(9), 1, + anon_sym_LF, + ACTIONS(67), 1, + ts_builtin_sym_end, + STATE(25), 1, + aux_sym_source_file_repeat1, + [402] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(69), 1, + ts_builtin_sym_end, + ACTIONS(71), 1, + anon_sym_LF, + STATE(25), 1, + aux_sym_source_file_repeat1, + [415] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(53), 1, + anon_sym_COMMA, + ACTIONS(74), 1, + anon_sym_RPAREN, + STATE(27), 1, + aux_sym_call_repeat1, + [428] = 4, + ACTIONS(3), 1, + sym_comment, + ACTIONS(59), 1, + anon_sym_RPAREN, + ACTIONS(76), 1, + anon_sym_COMMA, + STATE(27), 1, + aux_sym_call_repeat1, + [441] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(69), 2, + ts_builtin_sym_end, + anon_sym_LF, + [449] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(79), 1, + anon_sym_EQ, + [456] = 2, + ACTIONS(3), 1, + sym_comment, + ACTIONS(81), 1, + ts_builtin_sym_end, +}; + +static const uint32_t ts_small_parse_table_map[] = { + [SMALL_STATE(2)] = 0, + [SMALL_STATE(3)] = 26, + [SMALL_STATE(4)] = 49, + [SMALL_STATE(5)] = 72, + [SMALL_STATE(6)] = 95, + [SMALL_STATE(7)] = 112, + [SMALL_STATE(8)] = 135, + [SMALL_STATE(9)] = 158, + [SMALL_STATE(10)] = 181, + [SMALL_STATE(11)] = 195, + [SMALL_STATE(12)] = 209, + [SMALL_STATE(13)] = 223, + [SMALL_STATE(14)] = 237, + [SMALL_STATE(15)] = 253, + [SMALL_STATE(16)] = 267, + [SMALL_STATE(17)] = 281, + [SMALL_STATE(18)] = 302, + [SMALL_STATE(19)] = 318, + [SMALL_STATE(20)] = 334, + [SMALL_STATE(21)] = 349, + [SMALL_STATE(22)] = 363, + [SMALL_STATE(23)] = 376, + [SMALL_STATE(24)] = 389, + [SMALL_STATE(25)] = 402, + [SMALL_STATE(26)] = 415, + [SMALL_STATE(27)] = 428, + [SMALL_STATE(28)] = 441, + [SMALL_STATE(29)] = 449, + [SMALL_STATE(30)] = 456, +}; + +static const TSParseActionEntry ts_parse_actions[] = { + [0] = {.entry = {.count = 0, .reusable = false}}, + [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), + [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), + [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0, 0, 0), + [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), + [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), + [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), + [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), + [21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), + [25] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), + [27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__expression, 1, 0, 0), + [29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), + [31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [33] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), + [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), + [37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unary, 2, 0, 2), + [39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parenthesized, 3, 0, 0), + [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_call, 3, 0, 3), + [43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_binary, 3, 0, 4), + [45] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [47] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_call, 4, 0, 3), + [49] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_call, 5, 0, 3), + [51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), + [55] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [57] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_definition, 3, 0, 1), + [59] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_call_repeat1, 2, 0, 0), + [61] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), + [63] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 1, 0, 0), + [65] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0), + [67] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 2, 0, 0), + [69] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), + [71] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(21), + [74] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), + [76] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_call_repeat1, 2, 0, 0), SHIFT_REPEAT(8), + [79] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), + [81] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), +}; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef TREE_SITTER_HIDE_SYMBOLS +#define TS_PUBLIC +#elif defined(_WIN32) +#define TS_PUBLIC __declspec(dllexport) +#else +#define TS_PUBLIC __attribute__((visibility("default"))) +#endif + +TS_PUBLIC const TSLanguage *tree_sitter_live(void) { + static const TSLanguage language = { + .abi_version = LANGUAGE_VERSION, + .symbol_count = SYMBOL_COUNT, + .alias_count = ALIAS_COUNT, + .token_count = TOKEN_COUNT, + .external_token_count = EXTERNAL_TOKEN_COUNT, + .state_count = STATE_COUNT, + .large_state_count = LARGE_STATE_COUNT, + .production_id_count = PRODUCTION_ID_COUNT, + .field_count = FIELD_COUNT, + .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, + .parse_table = &ts_parse_table[0][0], + .small_parse_table = ts_small_parse_table, + .small_parse_table_map = ts_small_parse_table_map, + .parse_actions = ts_parse_actions, + .symbol_names = ts_symbol_names, + .field_names = ts_field_names, + .field_map_slices = ts_field_map_slices, + .field_map_entries = ts_field_map_entries, + .symbol_metadata = ts_symbol_metadata, + .public_symbol_map = ts_symbol_map, + .alias_map = ts_non_terminal_alias_map, + .alias_sequences = &ts_alias_sequences[0][0], + .lex_modes = (const void*)ts_lex_modes, + .lex_fn = ts_lex, + .keyword_lex_fn = ts_lex_keywords, + .keyword_capture_token = sym_name, + .primary_state_ids = ts_primary_state_ids, + }; + return &language; +} +#ifdef __cplusplus +} +#endif -- cgit v1.3