/* Automatically @generated by tree-sitter v0.25.6 */ #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 15 #define LARGE_STATE_COUNT 5 #define SYMBOL_COUNT 15 #define ALIAS_COUNT 0 #define TOKEN_COUNT 9 #define EXTERNAL_TOKEN_COUNT 0 #define FIELD_COUNT 0 #define MAX_ALIAS_SEQUENCE_LENGTH 5 #define MAX_RESERVED_WORD_SET_SIZE 0 #define PRODUCTION_ID_COUNT 1 #define SUPERTYPE_COUNT 0 enum ts_symbol_identifiers { sym_identifier = 1, sym_number = 2, sym_string = 3, anon_sym_let = 4, anon_sym_EQ = 5, anon_sym_SEMI = 6, anon_sym_SLASH_SLASH = 7, aux_sym_line_comment_token1 = 8, sym_source_file = 9, sym_expression = 10, sym_statement = 11, sym_variable_declaration = 12, sym_line_comment = 13, aux_sym_source_file_repeat1 = 14, }; static const char * const ts_symbol_names[] = { [ts_builtin_sym_end] = "end", [sym_identifier] = "identifier", [sym_number] = "number", [sym_string] = "string", [anon_sym_let] = "let", [anon_sym_EQ] = "=", [anon_sym_SEMI] = ";", [anon_sym_SLASH_SLASH] = "//", [aux_sym_line_comment_token1] = "line_comment_token1", [sym_source_file] = "source_file", [sym_expression] = "expression", [sym_statement] = "statement", [sym_variable_declaration] = "variable_declaration", [sym_line_comment] = "line_comment", [aux_sym_source_file_repeat1] = "source_file_repeat1", }; static const TSSymbol ts_symbol_map[] = { [ts_builtin_sym_end] = ts_builtin_sym_end, [sym_identifier] = sym_identifier, [sym_number] = sym_number, [sym_string] = sym_string, [anon_sym_let] = anon_sym_let, [anon_sym_EQ] = anon_sym_EQ, [anon_sym_SEMI] = anon_sym_SEMI, [anon_sym_SLASH_SLASH] = anon_sym_SLASH_SLASH, [aux_sym_line_comment_token1] = aux_sym_line_comment_token1, [sym_source_file] = sym_source_file, [sym_expression] = sym_expression, [sym_statement] = sym_statement, [sym_variable_declaration] = sym_variable_declaration, [sym_line_comment] = sym_line_comment, [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1, }; static const TSSymbolMetadata ts_symbol_metadata[] = { [ts_builtin_sym_end] = { .visible = false, .named = true, }, [sym_identifier] = { .visible = true, .named = true, }, [sym_number] = { .visible = true, .named = true, }, [sym_string] = { .visible = true, .named = true, }, [anon_sym_let] = { .visible = true, .named = false, }, [anon_sym_EQ] = { .visible = true, .named = false, }, [anon_sym_SEMI] = { .visible = true, .named = false, }, [anon_sym_SLASH_SLASH] = { .visible = true, .named = false, }, [aux_sym_line_comment_token1] = { .visible = false, .named = false, }, [sym_source_file] = { .visible = true, .named = true, }, [sym_expression] = { .visible = true, .named = true, }, [sym_statement] = { .visible = true, .named = true, }, [sym_variable_declaration] = { .visible = true, .named = true, }, [sym_line_comment] = { .visible = true, .named = true, }, [aux_sym_source_file_repeat1] = { .visible = false, .named = false, }, }; 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, }; static bool ts_lex(TSLexer *lexer, TSStateId state) { START_LEXER(); eof = lexer->eof(lexer); switch (state) { case 0: if (eof) ADVANCE(3); if (lookahead == '"') ADVANCE(1); if (lookahead == '/') ADVANCE(2); if (lookahead == ';') ADVANCE(8); if (lookahead == '=') ADVANCE(7); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(0); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(5); if (('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || ('a' <= lookahead && lookahead <= 'z')) ADVANCE(4); END_STATE(); case 1: if (lookahead == '"') ADVANCE(6); if (lookahead != 0) ADVANCE(1); END_STATE(); case 2: if (lookahead == '/') ADVANCE(9); END_STATE(); case 3: ACCEPT_TOKEN(ts_builtin_sym_end); END_STATE(); case 4: ACCEPT_TOKEN(sym_identifier); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || lookahead == '_' || ('a' <= lookahead && lookahead <= 'z')) ADVANCE(4); END_STATE(); case 5: ACCEPT_TOKEN(sym_number); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(5); END_STATE(); case 6: ACCEPT_TOKEN(sym_string); END_STATE(); case 7: ACCEPT_TOKEN(anon_sym_EQ); END_STATE(); case 8: ACCEPT_TOKEN(anon_sym_SEMI); END_STATE(); case 9: ACCEPT_TOKEN(anon_sym_SLASH_SLASH); END_STATE(); case 10: ACCEPT_TOKEN(anon_sym_SLASH_SLASH); if (lookahead != 0 && lookahead != '\n') ADVANCE(13); END_STATE(); case 11: ACCEPT_TOKEN(aux_sym_line_comment_token1); if (lookahead == '/') ADVANCE(12); if (lookahead == '\t' || (0x0b <= lookahead && lookahead <= '\r') || lookahead == ' ') ADVANCE(11); if (lookahead != 0 && (lookahead < '\t' || '\r' < lookahead)) ADVANCE(13); END_STATE(); case 12: ACCEPT_TOKEN(aux_sym_line_comment_token1); if (lookahead == '/') ADVANCE(10); if (lookahead != 0 && lookahead != '\n') ADVANCE(13); END_STATE(); case 13: ACCEPT_TOKEN(aux_sym_line_comment_token1); if (lookahead != 0 && lookahead != '\n') ADVANCE(13); END_STATE(); default: return false; } } static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { START_LEXER(); eof = lexer->eof(lexer); switch (state) { case 0: if (lookahead == 'l') ADVANCE(1); if (('\t' <= lookahead && lookahead <= '\r') || lookahead == ' ') SKIP(0); END_STATE(); case 1: if (lookahead == 'e') ADVANCE(2); END_STATE(); case 2: if (lookahead == 't') ADVANCE(3); END_STATE(); case 3: ACCEPT_TOKEN(anon_sym_let); 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 = 11}, [10] = {.lex_state = 0}, [11] = {.lex_state = 0}, [12] = {.lex_state = 0}, [13] = {.lex_state = 0}, [14] = {(TSStateId)(-1),}, }; static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [STATE(0)] = { [sym_line_comment] = STATE(0), [ts_builtin_sym_end] = ACTIONS(1), [sym_identifier] = ACTIONS(1), [sym_number] = ACTIONS(1), [sym_string] = ACTIONS(1), [anon_sym_let] = ACTIONS(1), [anon_sym_EQ] = ACTIONS(1), [anon_sym_SEMI] = ACTIONS(1), [anon_sym_SLASH_SLASH] = ACTIONS(3), }, [STATE(1)] = { [sym_source_file] = STATE(11), [sym_expression] = STATE(5), [sym_statement] = STATE(5), [sym_variable_declaration] = STATE(6), [sym_line_comment] = STATE(1), [aux_sym_source_file_repeat1] = STATE(2), [ts_builtin_sym_end] = ACTIONS(5), [sym_identifier] = ACTIONS(7), [sym_number] = ACTIONS(9), [sym_string] = ACTIONS(9), [anon_sym_let] = ACTIONS(11), [anon_sym_SLASH_SLASH] = ACTIONS(3), }, [STATE(2)] = { [sym_expression] = STATE(5), [sym_statement] = STATE(5), [sym_variable_declaration] = STATE(6), [sym_line_comment] = STATE(2), [aux_sym_source_file_repeat1] = STATE(3), [ts_builtin_sym_end] = ACTIONS(13), [sym_identifier] = ACTIONS(7), [sym_number] = ACTIONS(9), [sym_string] = ACTIONS(9), [anon_sym_let] = ACTIONS(11), [anon_sym_SLASH_SLASH] = ACTIONS(3), }, [STATE(3)] = { [sym_expression] = STATE(5), [sym_statement] = STATE(5), [sym_variable_declaration] = STATE(6), [sym_line_comment] = STATE(3), [aux_sym_source_file_repeat1] = STATE(3), [ts_builtin_sym_end] = ACTIONS(15), [sym_identifier] = ACTIONS(17), [sym_number] = ACTIONS(20), [sym_string] = ACTIONS(20), [anon_sym_let] = ACTIONS(23), [anon_sym_SLASH_SLASH] = ACTIONS(3), }, [STATE(4)] = { [sym_line_comment] = STATE(4), [ts_builtin_sym_end] = ACTIONS(26), [sym_identifier] = ACTIONS(28), [sym_number] = ACTIONS(26), [sym_string] = ACTIONS(26), [anon_sym_let] = ACTIONS(28), [anon_sym_SEMI] = ACTIONS(26), [anon_sym_SLASH_SLASH] = ACTIONS(3), }, }; static const uint16_t ts_small_parse_table[] = { [0] = 4, ACTIONS(3), 1, anon_sym_SLASH_SLASH, STATE(5), 1, sym_line_comment, ACTIONS(32), 2, sym_identifier, anon_sym_let, ACTIONS(30), 3, ts_builtin_sym_end, sym_number, sym_string, [16] = 4, ACTIONS(3), 1, anon_sym_SLASH_SLASH, STATE(6), 1, sym_line_comment, ACTIONS(36), 2, sym_identifier, anon_sym_let, ACTIONS(34), 3, ts_builtin_sym_end, sym_number, sym_string, [32] = 4, ACTIONS(3), 1, anon_sym_SLASH_SLASH, STATE(7), 1, sym_line_comment, ACTIONS(40), 2, sym_identifier, anon_sym_let, ACTIONS(38), 3, ts_builtin_sym_end, sym_number, sym_string, [48] = 4, ACTIONS(3), 1, anon_sym_SLASH_SLASH, STATE(8), 1, sym_line_comment, STATE(13), 1, sym_expression, ACTIONS(9), 3, sym_identifier, sym_number, sym_string, [63] = 3, ACTIONS(42), 1, anon_sym_SLASH_SLASH, ACTIONS(44), 1, aux_sym_line_comment_token1, STATE(9), 1, sym_line_comment, [73] = 3, ACTIONS(3), 1, anon_sym_SLASH_SLASH, ACTIONS(46), 1, sym_identifier, STATE(10), 1, sym_line_comment, [83] = 3, ACTIONS(3), 1, anon_sym_SLASH_SLASH, ACTIONS(48), 1, ts_builtin_sym_end, STATE(11), 1, sym_line_comment, [93] = 3, ACTIONS(3), 1, anon_sym_SLASH_SLASH, ACTIONS(50), 1, anon_sym_EQ, STATE(12), 1, sym_line_comment, [103] = 3, ACTIONS(3), 1, anon_sym_SLASH_SLASH, ACTIONS(52), 1, anon_sym_SEMI, STATE(13), 1, sym_line_comment, [113] = 1, ACTIONS(54), 1, ts_builtin_sym_end, }; static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(5)] = 0, [SMALL_STATE(6)] = 16, [SMALL_STATE(7)] = 32, [SMALL_STATE(8)] = 48, [SMALL_STATE(9)] = 63, [SMALL_STATE(10)] = 73, [SMALL_STATE(11)] = 83, [SMALL_STATE(12)] = 93, [SMALL_STATE(13)] = 103, [SMALL_STATE(14)] = 113, }; 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(9), [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0, 0, 0), [7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(4), [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(10), [13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0), [15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), [17] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(4), [20] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(4), [23] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(10), [26] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 1, 0, 0), [28] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expression, 1, 0, 0), [30] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 1, 0, 0), [32] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 1, 0, 0), [34] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_statement, 1, 0, 0), [36] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_statement, 1, 0, 0), [38] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_variable_declaration, 5, 0, 0), [40] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_variable_declaration, 5, 0, 0), [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(9), [44] = {.entry = {.count = 1, .reusable = false}}, SHIFT(14), [46] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), [48] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), [50] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), [52] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), [54] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_line_comment, 2, 0, 0), }; #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_test_lang(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, .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_identifier, .primary_state_ids = ts_primary_state_ids, }; return &language; } #ifdef __cplusplus } #endif