diff --git a/package-lock.json b/package-lock.json index 55265dc..8ffaf5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,35 @@ { "name": "tree-sitter-clojure", "version": "0.0.9", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "tree-sitter-clojure", + "version": "0.0.9", + "dependencies": { + "nan": "2.14.2" + }, + "devDependencies": { + "tree-sitter-cli": "^0.20.6" + } + }, + "node_modules/nan": { + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", + "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" + }, + "node_modules/tree-sitter-cli": { + "version": "0.20.6", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.6.tgz", + "integrity": "sha512-tjbAeuGSMhco/EnsThjWkQbDIYMDmdkWsTPsa/NJAW7bjaki9P7oM9TkLxfdlnm4LXd1wR5wVSM2/RTLtZbm6A==", + "dev": true, + "hasInstallScript": true, + "bin": { + "tree-sitter": "cli.js" + } + } + }, "dependencies": { "nan": { "version": "2.14.2", @@ -10,9 +37,9 @@ "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" }, "tree-sitter-cli": { - "version": "0.19.3", - "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.19.3.tgz", - "integrity": "sha512-UlntGxLrlkQCKVrhm7guzfi+ovM4wDLVCCu3z5jmfDgFNoUoKa/23ddaQON5afD5jB9a02xv4N5MXJfCx+/mpw==", + "version": "0.20.6", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.6.tgz", + "integrity": "sha512-tjbAeuGSMhco/EnsThjWkQbDIYMDmdkWsTPsa/NJAW7bjaki9P7oM9TkLxfdlnm4LXd1wR5wVSM2/RTLtZbm6A==", "dev": true } } diff --git a/package.json b/package.json index 330f68f..bb6303e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "nan": "2.14.2" }, "devDependencies": { - "tree-sitter-cli": "0.19.3" + "tree-sitter-cli": "^0.20.6" }, "tree-sitter": [ { diff --git a/src/parser.c b/src/parser.c index 67833a6..8793917 100644 --- a/src/parser.c +++ b/src/parser.c @@ -85,7 +85,7 @@ enum { aux_sym_read_cond_lit_repeat1 = 66, }; -static const char *ts_symbol_names[] = { +static const char * const ts_symbol_names[] = { [ts_builtin_sym_end] = "end", [sym__ws] = "_ws", [sym_comment] = "comment", @@ -155,7 +155,7 @@ static const char *ts_symbol_names[] = { [aux_sym_read_cond_lit_repeat1] = "read_cond_lit_repeat1", }; -static TSSymbol ts_symbol_map[] = { +static const TSSymbol ts_symbol_map[] = { [ts_builtin_sym_end] = ts_builtin_sym_end, [sym__ws] = sym__ws, [sym_comment] = sym_comment, @@ -507,7 +507,7 @@ enum { field_value = 8, }; -static const char *ts_field_names[] = { +static const char * const ts_field_names[] = { [0] = NULL, [field_close] = "close", [field_marker] = "marker", @@ -725,11 +725,11 @@ static const TSFieldMapEntry ts_field_map_entries[] = { {field_value, 5}, }; -static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { +static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { [0] = {0}, }; -static uint16_t ts_non_terminal_alias_map[] = { +static const uint16_t ts_non_terminal_alias_map[] = { 0, }; @@ -771,6 +771,76 @@ static inline bool sym_kwd_lit_character_set_1(int32_t c) { : (c <= 8287 || c == 12288)))))); } +static inline bool sym_kwd_lit_character_set_2(int32_t c) { + return (c < '[' + ? (c < '(' + ? (c < 28 + ? (c < '\t' + ? c == 0 + : c <= '\r') + : (c <= ' ' || c == '"')) + : (c <= ')' || (c < ':' + ? (c < '/' + ? c == ',' + : c <= '/') + : (c <= ';' || c == '@')))) + : (c <= '^' || (c < 8192 + ? (c < '}' + ? (c < '{' + ? c == '`' + : c <= '{') + : (c <= '~' || c == 5760)) + : (c <= 8198 || (c < 8287 + ? (c < 8232 + ? (c >= 8200 && c <= 8202) + : c <= 8233) + : (c <= 8287 || c == 12288)))))); +} + +static inline bool aux_sym_sym_lit_token1_character_set_1(int32_t c) { + return (c < '\\' + ? (c < '"' + ? (c < '\t' + ? c == 0 + : (c <= '\r' || (c >= 28 && c <= ' '))) + : (c <= '"' || (c < ',' + ? c == ')' + : (c <= ',' || (c >= '0' && c <= ';'))))) + : (c <= ']' || (c < 8200 + ? (c < 5760 + ? c == '}' + : (c <= 5760 || (c >= 8192 && c <= 8198))) + : (c <= 8202 || (c < 8287 + ? (c >= 8232 && c <= 8233) + : (c <= 8287 || c == 12288)))))); +} + +static inline bool aux_sym_sym_lit_token1_character_set_2(int32_t c) { + return (c < '[' + ? (c < '(' + ? (c < 28 + ? (c < '\t' + ? c == 0 + : c <= '\r') + : (c <= ' ' || c == '"')) + : (c <= ')' || (c < ';' + ? (c < '1' + ? c == ',' + : c <= '9') + : (c <= ';' || c == '@')))) + : (c <= '^' || (c < 8192 + ? (c < '}' + ? (c < '{' + ? c == '`' + : c <= '{') + : (c <= '~' || c == 5760)) + : (c <= 8198 || (c < 8287 + ? (c < 8232 + ? (c >= 8200 && c <= 8202) + : c <= 8233) + : (c <= 8287 || c == 12288)))))); +} + static inline bool aux_sym_sym_lit_token1_character_set_3(int32_t c) { return (c < '[' ? (c < '(' @@ -797,6 +867,54 @@ static inline bool aux_sym_sym_lit_token1_character_set_3(int32_t c) { : (c <= 8287 || c == 12288)))))); } +static inline bool aux_sym_sym_lit_token1_character_set_4(int32_t c) { + return (c < '@' + ? (c < '(' + ? (c < 28 + ? (c < '\t' + ? c == 0 + : c <= '\r') + : (c <= ' ' || c == '"')) + : (c <= ')' || (c < '0' + ? c == ',' + : (c <= '9' || c == ';')))) + : (c <= '^' || (c < 8200 + ? (c < 5760 + ? (c < '}' + ? (c >= '`' && c <= '{') + : c <= '~') + : (c <= 5760 || (c >= 8192 && c <= 8198))) + : (c <= 8202 || (c < 8287 + ? (c >= 8232 && c <= 8233) + : (c <= 8287 || c == 12288)))))); +} + +static inline bool aux_sym_sym_lit_token1_character_set_5(int32_t c) { + return (c < '[' + ? (c < '(' + ? (c < 28 + ? (c < '\t' + ? c == 0 + : c <= '\r') + : (c <= ' ' || c == '"')) + : (c <= ')' || (c < ';' + ? (c < '0' + ? c == ',' + : c <= '9') + : (c <= ';' || (c >= '@' && c <= 'F'))))) + : (c <= '^' || (c < 8192 + ? (c < '}' + ? (c < '{' + ? (c >= '`' && c <= 'f') + : c <= '{') + : (c <= '~' || c == 5760)) + : (c <= 8198 || (c < 8287 + ? (c < 8232 + ? (c >= 8200 && c <= 8202) + : c <= 8233) + : (c <= 8287 || c == 12288)))))); +} + static bool ts_lex(TSLexer *lexer, TSStateId state) { START_LEXER(); eof = lexer->eof(lexer); @@ -865,23 +983,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '`') ADVANCE(105); if (lookahead == '{') ADVANCE(90); if (lookahead == '~') ADVANCE(107); - if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead) && - (lookahead < 28 || ' ' < lookahead) && - lookahead != '"' && - lookahead != ')' && - lookahead != ',' && - (lookahead < '0' || ';' < lookahead) && - lookahead != '\\' && - lookahead != ']' && - lookahead != '}' && - lookahead != 5760 && - (lookahead < 8192 || 8198 < lookahead) && - (lookahead < 8200 || 8202 < lookahead) && - lookahead != 8232 && - lookahead != 8233 && - lookahead != 8287 && - lookahead != 12288) ADVANCE(85); + if (!aux_sym_sym_lit_token1_character_set_1(lookahead)) ADVANCE(85); END_STATE(); case 4: if (lookahead == '/') ADVANCE(55); @@ -1217,28 +1319,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { case 71: ACCEPT_TOKEN(aux_sym_sym_lit_token1); if (lookahead == '0') ADVANCE(46); - if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead) && - (lookahead < 28 || ' ' < lookahead) && - lookahead != '"' && - lookahead != '(' && - lookahead != ')' && - lookahead != ',' && - (lookahead < '1' || '9' < lookahead) && - lookahead != ';' && - lookahead != '@' && - (lookahead < '[' || '^' < lookahead) && - lookahead != '`' && - lookahead != '{' && - lookahead != '}' && - lookahead != '~' && - lookahead != 5760 && - (lookahead < 8192 || 8198 < lookahead) && - (lookahead < 8200 || 8202 < lookahead) && - lookahead != 8232 && - lookahead != 8233 && - lookahead != 8287 && - lookahead != 12288) ADVANCE(85); + if (!aux_sym_sym_lit_token1_character_set_2(lookahead)) ADVANCE(85); if (('1' <= lookahead && lookahead <= '9')) ADVANCE(48); END_STATE(); case 72: @@ -1290,54 +1371,14 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { END_STATE(); case 81: ACCEPT_TOKEN(aux_sym_sym_lit_token1); - if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead) && - (lookahead < 28 || ' ' < lookahead) && - lookahead != '"' && - lookahead != '(' && - lookahead != ')' && - lookahead != ',' && - (lookahead < '0' || '9' < lookahead) && - lookahead != ';' && - (lookahead < '@' || '^' < lookahead) && - (lookahead < '`' || '{' < lookahead) && - lookahead != '}' && - lookahead != '~' && - lookahead != 5760 && - (lookahead < 8192 || 8198 < lookahead) && - (lookahead < 8200 || 8202 < lookahead) && - lookahead != 8232 && - lookahead != 8233 && - lookahead != 8287 && - lookahead != 12288) ADVANCE(85); + if (!aux_sym_sym_lit_token1_character_set_4(lookahead)) ADVANCE(85); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'Z') || ('a' <= lookahead && lookahead <= 'z')) ADVANCE(54); END_STATE(); case 82: ACCEPT_TOKEN(aux_sym_sym_lit_token1); - if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead) && - (lookahead < 28 || ' ' < lookahead) && - lookahead != '"' && - lookahead != '(' && - lookahead != ')' && - lookahead != ',' && - (lookahead < '0' || '9' < lookahead) && - lookahead != ';' && - (lookahead < '@' || 'F' < lookahead) && - (lookahead < '[' || '^' < lookahead) && - (lookahead < '`' || 'f' < lookahead) && - lookahead != '{' && - lookahead != '}' && - lookahead != '~' && - lookahead != 5760 && - (lookahead < 8192 || 8198 < lookahead) && - (lookahead < 8200 || 8202 < lookahead) && - lookahead != 8232 && - lookahead != 8233 && - lookahead != 8287 && - lookahead != 12288) ADVANCE(85); + if (!aux_sym_sym_lit_token1_character_set_5(lookahead)) ADVANCE(85); if (('0' <= lookahead && lookahead <= '9') || ('A' <= lookahead && lookahead <= 'F') || ('a' <= lookahead && lookahead <= 'f')) ADVANCE(52); @@ -1415,29 +1456,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { END_STATE(); case 99: ACCEPT_TOKEN(sym_auto_res_mark); - if (lookahead != 0 && - (lookahead < '\t' || '\r' < lookahead) && - (lookahead < 28 || ' ' < lookahead) && - lookahead != '"' && - lookahead != '(' && - lookahead != ')' && - lookahead != ',' && - lookahead != '/' && - lookahead != ':' && - lookahead != ';' && - lookahead != '@' && - (lookahead < '[' || '^' < lookahead) && - lookahead != '`' && - lookahead != '{' && - lookahead != '}' && - lookahead != '~' && - lookahead != 5760 && - (lookahead < 8192 || 8198 < lookahead) && - (lookahead < 8200 || 8202 < lookahead) && - lookahead != 8232 && - lookahead != 8233 && - lookahead != 8287 && - lookahead != 12288) ADVANCE(56); + if (!sym_kwd_lit_character_set_2(lookahead)) ADVANCE(56); END_STATE(); case 100: ACCEPT_TOKEN(anon_sym_POUND_SQUOTE); @@ -1469,7 +1488,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { } } -static TSLexMode ts_lex_modes[STATE_COUNT] = { +static const TSLexMode ts_lex_modes[STATE_COUNT] = { [0] = {.lex_state = 0}, [1] = {.lex_state = 0}, [2] = {.lex_state = 0}, @@ -1795,7 +1814,7 @@ static TSLexMode ts_lex_modes[STATE_COUNT] = { [322] = {.lex_state = 0}, }; -static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { +static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [0] = { [ts_builtin_sym_end] = ACTIONS(1), [sym__ws] = ACTIONS(1), @@ -7134,7 +7153,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { }, }; -static uint16_t ts_small_parse_table[] = { +static const uint16_t ts_small_parse_table[] = { [0] = 2, ACTIONS(616), 6, sym_nil_lit, @@ -13347,7 +13366,7 @@ static uint16_t ts_small_parse_table[] = { ts_builtin_sym_end, }; -static uint32_t ts_small_parse_table_map[] = { +static const uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(89)] = 0, [SMALL_STATE(90)] = 35, [SMALL_STATE(91)] = 70, @@ -13584,7 +13603,7 @@ static uint32_t ts_small_parse_table_map[] = { [SMALL_STATE(322)] = 7134, }; -static TSParseActionEntry ts_parse_actions[] = { +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}}, REDUCE(sym_source, 0), @@ -14137,7 +14156,7 @@ extern "C" { #endif extern const TSLanguage *tree_sitter_clojure(void) { - static TSLanguage language = { + static const TSLanguage language = { .version = LANGUAGE_VERSION, .symbol_count = SYMBOL_COUNT, .alias_count = ALIAS_COUNT, @@ -14148,18 +14167,18 @@ extern const TSLanguage *tree_sitter_clojure(void) { .production_id_count = PRODUCTION_ID_COUNT, .field_count = FIELD_COUNT, .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, - .parse_table = (const uint16_t *)ts_parse_table, - .small_parse_table = (const uint16_t *)ts_small_parse_table, - .small_parse_table_map = (const uint32_t *)ts_small_parse_table_map, + .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 = (const TSFieldMapSlice *)ts_field_map_slices, - .field_map_entries = (const TSFieldMapEntry *)ts_field_map_entries, + .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 = (const TSSymbol *)ts_alias_sequences, + .alias_sequences = &ts_alias_sequences[0][0], .lex_modes = ts_lex_modes, .lex_fn = ts_lex, }; diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h index a3a87bd..2b14ac1 100644 --- a/src/tree_sitter/parser.h +++ b/src/tree_sitter/parser.h @@ -102,8 +102,8 @@ struct TSLanguage { const uint16_t *small_parse_table; const uint32_t *small_parse_table_map; const TSParseActionEntry *parse_actions; - const char **symbol_names; - const char **field_names; + const char * const *symbol_names; + const char * const *field_names; const TSFieldMapSlice *field_map_slices; const TSFieldMapEntry *field_map_entries; const TSSymbolMetadata *symbol_metadata; @@ -123,6 +123,7 @@ struct TSLanguage { unsigned (*serialize)(void *, char *); void (*deserialize)(void *, const char *, unsigned); } external_scanner; + const TSStateId *primary_state_ids; }; /*