diff --git a/subprojects/packagefiles/tree-sitter-0.20.7/meson.build b/subprojects/packagefiles/tree-sitter-0.21.0/meson.build similarity index 100% rename from subprojects/packagefiles/tree-sitter-0.20.7/meson.build rename to subprojects/packagefiles/tree-sitter-0.21.0/meson.build diff --git a/subprojects/rizin-shell-parser/Cargo.toml b/subprojects/rizin-shell-parser/Cargo.toml index 3a39e5fa602..e2b98807dde 100644 --- a/subprojects/rizin-shell-parser/Cargo.toml +++ b/subprojects/rizin-shell-parser/Cargo.toml @@ -20,7 +20,7 @@ include = [ path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = "0.20" +tree-sitter = "0.21" [build-dependencies] cc = "1.0" diff --git a/subprojects/rizin-shell-parser/package-lock.json b/subprojects/rizin-shell-parser/package-lock.json index 126ad6f79f6..fc410cce505 100644 --- a/subprojects/rizin-shell-parser/package-lock.json +++ b/subprojects/rizin-shell-parser/package-lock.json @@ -12,7 +12,7 @@ "nan": "^2.17.0" }, "devDependencies": { - "tree-sitter-cli": "^0.20.7" + "tree-sitter-cli": "^0.21.0" } }, "node_modules/nan": { @@ -21,9 +21,9 @@ "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==" }, "node_modules/tree-sitter-cli": { - "version": "0.20.7", - "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.7.tgz", - "integrity": "sha512-MHABT8oCPr4D0fatsPo6ATQ9H4h9vHpPRjlxkxJs80tpfAEKGn6A1zU3eqfCKBcgmfZDe9CiL3rKOGMzYHwA3w==", + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.21.0.tgz", + "integrity": "sha512-wA7wT5724fNQW82XDH6zT6ZcYonjrAKLCHHuhLsPcAKULrhp3rNuMvlgBdB5FUBvmjHNhtTZF/qpHenMoRJPBw==", "dev": true, "hasInstallScript": true, "bin": { @@ -38,9 +38,9 @@ "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==" }, "tree-sitter-cli": { - "version": "0.20.7", - "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.7.tgz", - "integrity": "sha512-MHABT8oCPr4D0fatsPo6ATQ9H4h9vHpPRjlxkxJs80tpfAEKGn6A1zU3eqfCKBcgmfZDe9CiL3rKOGMzYHwA3w==", + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.21.0.tgz", + "integrity": "sha512-wA7wT5724fNQW82XDH6zT6ZcYonjrAKLCHHuhLsPcAKULrhp3rNuMvlgBdB5FUBvmjHNhtTZF/qpHenMoRJPBw==", "dev": true } } diff --git a/subprojects/rizin-shell-parser/package.json b/subprojects/rizin-shell-parser/package.json index d1c81e77684..09da439e4dd 100644 --- a/subprojects/rizin-shell-parser/package.json +++ b/subprojects/rizin-shell-parser/package.json @@ -12,6 +12,6 @@ "nan": "^2.17.0" }, "devDependencies": { - "tree-sitter-cli": "^0.20.7" + "tree-sitter-cli": "^0.21.0" } } diff --git a/subprojects/rizin-shell-parser/src/grammar.json b/subprojects/rizin-shell-parser/src/grammar.json index 8621e31c125..e246731c506 100644 --- a/subprojects/rizin-shell-parser/src/grammar.json +++ b/subprojects/rizin-shell-parser/src/grammar.json @@ -3127,4 +3127,3 @@ ], "supertypes": [] } - diff --git a/subprojects/rizin-shell-parser/src/parser.c b/subprojects/rizin-shell-parser/src/parser.c index 06e2ba05386..cc59b62838b 100644 --- a/subprojects/rizin-shell-parser/src/parser.c +++ b/subprojects/rizin-shell-parser/src/parser.c @@ -1,4 +1,4 @@ -#include +#include "tree_sitter/parser.h" #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push @@ -16,7 +16,7 @@ #define MAX_ALIAS_SEQUENCE_LENGTH 5 #define PRODUCTION_ID_COUNT 22 -enum { +enum ts_symbol_identifiers { anon_sym_DQUOTE = 1, aux_sym_legacy_quoted_stmt_token1 = 2, anon_sym_TILDE = 3, @@ -1525,7 +1525,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { }, }; -enum { +enum ts_field_identifiers { field_arg = 1, field_args = 2, field_argv = 3, @@ -2091,50 +2091,48 @@ static inline bool sym_grep_specifier_identifier_character_set_3(int32_t c) { } static inline bool aux_sym_tmp_eval_arg_token1_character_set_1(int32_t c) { - return (c < ';' - ? (c < '"' + return (c < '>' + ? (c < '\'' ? (c < '\n' ? c == 0 - : (c <= '\n' || c == '\r')) - : (c <= '$' || (c < ',' - ? (c >= '\'' && c <= ')') - : c <= ','))) - : (c <= ';' || (c < '`' - ? (c < '@' - ? c == '>' - : (c <= '@' || c == '\\')) + : (c <= '\r' || (c >= '"' && c <= '$'))) + : (c <= ')' || (c < ';' + ? c == ',' + : c <= ';'))) + : (c <= '>' || (c < '`' + ? (c < '\\' + ? c == '@' + : c <= '\\') : (c <= '`' || (c < '~' ? c == '|' : c <= '~'))))); } static inline bool sym__eq_sep_key_identifier_character_set_1(int32_t c) { - return (c < ';' - ? (c < '\r' + return (c < '=' + ? (c < '(' ? (c < '\n' ? c == 0 - : c <= '\n') - : (c <= '\r' || (c < ',' - ? (c >= '(' && c <= ')') - : c <= ','))) - : (c <= ';' || (c < '\\' - ? (c < '@' - ? (c >= '=' && c <= '>') - : c <= '@') - : (c <= '\\' || (c < '~' - ? c == '|' - : c <= '~'))))); + : c <= '\r') + : (c <= ')' || (c < ';' + ? c == ',' + : c <= ';'))) + : (c <= '>' || (c < '|' + ? (c < '\\' + ? c == '@' + : c <= '\\') + : (c <= '|' || c == '~')))); } static inline bool sym__eq_sep_key_identifier_character_set_2(int32_t c) { return (c < ';' - ? (c < ' ' + ? (c < '"' ? (c < '\t' ? c == 0 - : (c <= '\n' || c == '\r')) - : (c <= ' ' || (c < '\'' - ? (c >= '"' && c <= '#') - : (c <= ')' || c == ',')))) + : (c <= '\r' || c == ' ')) + : (c <= '#' || (c < ',' + ? (c >= '\'' && c <= ')') + : c <= ','))) : (c <= ';' || (c < '`' ? (c < '@' ? (c >= '=' && c <= '>') @@ -2146,13 +2144,13 @@ static inline bool sym__eq_sep_key_identifier_character_set_2(int32_t c) { static inline bool sym__eq_sep_key_identifier_character_set_3(int32_t c) { return (c < ';' - ? (c < ' ' + ? (c < '"' ? (c < '\t' ? c == 0 - : (c <= '\n' || c == '\r')) - : (c <= ' ' || (c < '\'' - ? (c >= '"' && c <= '#') - : (c <= ')' || c == ',')))) + : (c <= '\r' || c == ' ')) + : (c <= '#' || (c < ',' + ? (c >= '\'' && c <= ')') + : c <= ','))) : (c <= ';' || (c < '`' ? (c < '@' ? c == '=' @@ -2163,18 +2161,18 @@ static inline bool sym__eq_sep_key_identifier_character_set_3(int32_t c) { } static inline bool aux_sym_arg_identifier_token1_character_set_1(int32_t c) { - return (c < ';' - ? (c < ' ' + return (c < '>' + ? (c < '"' ? (c < '\t' ? c == 0 - : (c <= '\n' || c == '\r')) - : (c <= ' ' || (c < '\'' - ? (c >= '"' && c <= '#') - : c <= ')'))) - : (c <= ';' || (c < '`' - ? (c < '@' - ? c == '>' - : (c <= '@' || c == '\\')) + : (c <= '\r' || c == ' ')) + : (c <= '#' || (c < ';' + ? (c >= '\'' && c <= ')') + : c <= ';'))) + : (c <= '>' || (c < '`' + ? (c < '\\' + ? c == '@' + : c <= '\\') : (c <= '`' || (c < '~' ? c == '|' : c <= '~'))))); @@ -2185,7 +2183,7 @@ static inline bool aux_sym_arg_identifier_token1_character_set_2(int32_t c) { ? (c < ' ' ? (c < '\t' ? c == 0 - : (c <= '\n' || c == '\r')) + : c <= '\r') : (c <= ' ' || (c < '\'' ? (c >= '"' && c <= '#') : c <= ')'))) @@ -2199,18 +2197,18 @@ static inline bool aux_sym_arg_identifier_token1_character_set_2(int32_t c) { } static inline bool aux_sym_arg_identifier_token1_character_set_3(int32_t c) { - return (c < ',' - ? (c < ' ' + return (c < ';' + ? (c < '"' ? (c < '\t' ? c == 0 - : (c <= '\n' || c == '\r')) - : (c <= ' ' || (c < '\'' - ? (c >= '"' && c <= '#') - : c <= ')'))) - : (c <= ',' || (c < '`' - ? (c < '>' - ? c == ';' - : (c <= '>' || c == '@')) + : (c <= '\r' || c == ' ')) + : (c <= '#' || (c < ',' + ? (c >= '\'' && c <= ')') + : c <= ','))) + : (c <= ';' || (c < '`' + ? (c < '@' + ? c == '>' + : c <= '@') : (c <= '`' || (c < '~' ? c == '|' : c <= '~'))))); @@ -2218,11 +2216,13 @@ static inline bool aux_sym_arg_identifier_token1_character_set_3(int32_t c) { static inline bool aux_sym_arg_identifier_token1_character_set_4(int32_t c) { return (c < ';' - ? (c < '\'' - ? (c < '"' + ? (c < '"' + ? (c < 11 ? c == '\t' - : c <= '#') - : (c <= ')' || c == ',')) + : c <= '\f') + : (c <= '#' || (c < ',' + ? (c >= '\'' && c <= ')') + : c <= ','))) : (c <= ';' || (c < '`' ? (c < '@' ? c == '>' @@ -2235,7 +2235,7 @@ static inline bool aux_sym_arg_identifier_token1_character_set_5(int32_t c) { ? (c < ' ' ? (c < '\t' ? c == 0 - : (c <= '\n' || c == '\r')) + : c <= '\r') : (c <= ' ' || (c < '\'' ? (c >= '"' && c <= '#') : c <= ')'))) @@ -2253,7 +2253,7 @@ static inline bool aux_sym_spec_arg_identifier_token1_character_set_1(int32_t c) ? (c < '"' ? (c < '\n' ? c == 0 - : (c <= '\n' || c == '\r')) + : c <= '\r') : (c <= '"' || (c < ',' ? (c >= '\'' && c <= ')') : c <= ','))) @@ -2267,18 +2267,18 @@ static inline bool aux_sym_spec_arg_identifier_token1_character_set_1(int32_t c) } static inline bool aux_sym_spec_arg_identifier_token1_character_set_2(int32_t c) { - return (c < ',' - ? (c < ' ' + return (c < ':' + ? (c < '"' ? (c < '\t' ? c == 0 - : (c <= '\n' || c == '\r')) - : (c <= ' ' || (c < '\'' - ? (c >= '"' && c <= '#') - : c <= ')'))) - : (c <= ',' || (c < '`' - ? (c < '>' - ? (c >= ':' && c <= ';') - : (c <= '>' || c == '@')) + : (c <= '\r' || c == ' ')) + : (c <= '#' || (c < ',' + ? (c >= '\'' && c <= ')') + : c <= ','))) + : (c <= ';' || (c < '`' + ? (c < '@' + ? c == '>' + : c <= '@') : (c <= '`' || (c < '~' ? c == '|' : c <= '~'))))); @@ -2286,11 +2286,13 @@ static inline bool aux_sym_spec_arg_identifier_token1_character_set_2(int32_t c) static inline bool aux_sym_spec_arg_identifier_token1_character_set_3(int32_t c) { return (c < ':' - ? (c < '\'' - ? (c < '"' + ? (c < '"' + ? (c < 11 ? c == '\t' - : c <= '#') - : (c <= ')' || c == ',')) + : c <= '\f') + : (c <= '#' || (c < ',' + ? (c >= '\'' && c <= ')') + : c <= ','))) : (c <= ';' || (c < '`' ? (c < '@' ? c == '>' @@ -2330,7 +2332,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '~') ADVANCE(61); if (lookahead == '\t' || lookahead == ' ') SKIP(0) - if (lookahead != 0) ADVANCE(151); + if (lookahead != 0 && + lookahead != 11 && + lookahead != '\f') ADVANCE(151); END_STATE(); case 1: if (lookahead == ' ') ADVANCE(100); @@ -2670,7 +2674,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '~') ADVANCE(61); if (lookahead == '\t' || lookahead == ' ') SKIP(52) - if (lookahead != 0) ADVANCE(159); + if (lookahead != 0 && + lookahead != 11 && + lookahead != '\f') ADVANCE(159); END_STATE(); case 53: if (eof) ADVANCE(57); @@ -2689,6 +2695,8 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '\t' || lookahead == ' ') SKIP(53) if (lookahead != 0 && + lookahead != 11 && + lookahead != '\f' && lookahead != '>' && lookahead != '@' && lookahead != '|' && @@ -2714,6 +2722,8 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '\t' || lookahead == ' ') SKIP(54) if (lookahead != 0 && + lookahead != 11 && + lookahead != '\f' && lookahead != '(' && lookahead != ',' && lookahead != '=' && @@ -2756,6 +2766,8 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '\t' || lookahead == ' ') SKIP(56) if (lookahead != 0 && + lookahead != 11 && + lookahead != '\f' && (lookahead < '"' || '$' < lookahead) && lookahead != '\'' && lookahead != '(' && @@ -3243,8 +3255,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '}') ADVANCE(159); if (aux_sym_arg_identifier_token1_character_set_4(lookahead)) ADVANCE(37); if (lookahead != 0 && - lookahead != '\n' && - lookahead != '\r' && + (lookahead < '\n' || '\r' < lookahead) && lookahead != ' ') ADVANCE(160); END_STATE(); case 161: @@ -3289,8 +3300,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '}') ADVANCE(165); if (aux_sym_spec_arg_identifier_token1_character_set_3(lookahead)) ADVANCE(39); if (lookahead != 0 && - lookahead != '\n' && - lookahead != '\r' && + (lookahead < '\n' || '\r' < lookahead) && lookahead != ' ') ADVANCE(166); END_STATE(); case 167: @@ -3820,74 +3830,6 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { [391] = {.lex_state = 0}, }; -enum { - ts_external_token__cmd_identifier = 0, - ts_external_token__help_stmt = 1, - ts_external_token_file_descriptor = 2, - ts_external_token__eq_sep_concat = 3, - ts_external_token__concat = 4, - ts_external_token__spec_sep = 5, -}; - -static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = { - [ts_external_token__cmd_identifier] = sym__cmd_identifier, - [ts_external_token__help_stmt] = sym__help_stmt, - [ts_external_token_file_descriptor] = sym_file_descriptor, - [ts_external_token__eq_sep_concat] = sym__eq_sep_concat, - [ts_external_token__concat] = sym__concat, - [ts_external_token__spec_sep] = sym__spec_sep, -}; - -static const bool ts_external_scanner_states[12][EXTERNAL_TOKEN_COUNT] = { - [1] = { - [ts_external_token__cmd_identifier] = true, - [ts_external_token__help_stmt] = true, - [ts_external_token_file_descriptor] = true, - [ts_external_token__eq_sep_concat] = true, - [ts_external_token__concat] = true, - [ts_external_token__spec_sep] = true, - }, - [2] = { - [ts_external_token__cmd_identifier] = true, - [ts_external_token__help_stmt] = true, - }, - [3] = { - [ts_external_token__cmd_identifier] = true, - [ts_external_token__help_stmt] = true, - [ts_external_token_file_descriptor] = true, - }, - [4] = { - [ts_external_token_file_descriptor] = true, - }, - [5] = { - [ts_external_token_file_descriptor] = true, - [ts_external_token__spec_sep] = true, - }, - [6] = { - [ts_external_token_file_descriptor] = true, - [ts_external_token__concat] = true, - }, - [7] = { - [ts_external_token_file_descriptor] = true, - [ts_external_token__eq_sep_concat] = true, - [ts_external_token__concat] = true, - }, - [8] = { - [ts_external_token_file_descriptor] = true, - [ts_external_token__eq_sep_concat] = true, - }, - [9] = { - [ts_external_token__concat] = true, - }, - [10] = { - [ts_external_token__eq_sep_concat] = true, - [ts_external_token__concat] = true, - }, - [11] = { - [ts_external_token__eq_sep_concat] = true, - }, -}; - static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [0] = { [ts_builtin_sym_end] = ACTIONS(1), @@ -23133,6 +23075,74 @@ static const TSParseActionEntry ts_parse_actions[] = { [1187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(150), }; +enum ts_external_scanner_symbol_identifiers { + ts_external_token__cmd_identifier = 0, + ts_external_token__help_stmt = 1, + ts_external_token_file_descriptor = 2, + ts_external_token__eq_sep_concat = 3, + ts_external_token__concat = 4, + ts_external_token__spec_sep = 5, +}; + +static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = { + [ts_external_token__cmd_identifier] = sym__cmd_identifier, + [ts_external_token__help_stmt] = sym__help_stmt, + [ts_external_token_file_descriptor] = sym_file_descriptor, + [ts_external_token__eq_sep_concat] = sym__eq_sep_concat, + [ts_external_token__concat] = sym__concat, + [ts_external_token__spec_sep] = sym__spec_sep, +}; + +static const bool ts_external_scanner_states[12][EXTERNAL_TOKEN_COUNT] = { + [1] = { + [ts_external_token__cmd_identifier] = true, + [ts_external_token__help_stmt] = true, + [ts_external_token_file_descriptor] = true, + [ts_external_token__eq_sep_concat] = true, + [ts_external_token__concat] = true, + [ts_external_token__spec_sep] = true, + }, + [2] = { + [ts_external_token__cmd_identifier] = true, + [ts_external_token__help_stmt] = true, + }, + [3] = { + [ts_external_token__cmd_identifier] = true, + [ts_external_token__help_stmt] = true, + [ts_external_token_file_descriptor] = true, + }, + [4] = { + [ts_external_token_file_descriptor] = true, + }, + [5] = { + [ts_external_token_file_descriptor] = true, + [ts_external_token__spec_sep] = true, + }, + [6] = { + [ts_external_token_file_descriptor] = true, + [ts_external_token__concat] = true, + }, + [7] = { + [ts_external_token_file_descriptor] = true, + [ts_external_token__eq_sep_concat] = true, + [ts_external_token__concat] = true, + }, + [8] = { + [ts_external_token_file_descriptor] = true, + [ts_external_token__eq_sep_concat] = true, + }, + [9] = { + [ts_external_token__concat] = true, + }, + [10] = { + [ts_external_token__eq_sep_concat] = true, + [ts_external_token__concat] = true, + }, + [11] = { + [ts_external_token__eq_sep_concat] = true, + }, +}; + #ifdef __cplusplus extern "C" { #endif diff --git a/subprojects/rizin-shell-parser/src/tree_sitter/parser.h b/subprojects/rizin-shell-parser/src/tree_sitter/parser.h index 2b14ac1046b..17b4fde9821 100644 --- a/subprojects/rizin-shell-parser/src/tree_sitter/parser.h +++ b/subprojects/rizin-shell-parser/src/tree_sitter/parser.h @@ -13,9 +13,8 @@ extern "C" { #define ts_builtin_sym_end 0 #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 -typedef uint16_t TSStateId; - #ifndef TREE_SITTER_API_H_ +typedef uint16_t TSStateId; typedef uint16_t TSSymbol; typedef uint16_t TSFieldId; typedef struct TSLanguage TSLanguage; @@ -130,9 +129,16 @@ struct TSLanguage { * Lexer Macros */ +#ifdef _MSC_VER +#define UNUSED __pragma(warning(suppress : 4101)) +#else +#define UNUSED __attribute__((unused)) +#endif + #define START_LEXER() \ bool result = false; \ bool skip = false; \ + UNUSED \ bool eof = false; \ int32_t lookahead; \ goto start; \ @@ -166,7 +172,7 @@ struct TSLanguage { * Parse Table Macros */ -#define SMALL_STATE(id) id - LARGE_STATE_COUNT +#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT) #define STATE(id) id @@ -176,7 +182,7 @@ struct TSLanguage { {{ \ .shift = { \ .type = TSParseActionTypeShift, \ - .state = state_value \ + .state = (state_value) \ } \ }} @@ -184,7 +190,7 @@ struct TSLanguage { {{ \ .shift = { \ .type = TSParseActionTypeShift, \ - .state = state_value, \ + .state = (state_value), \ .repetition = true \ } \ }} diff --git a/subprojects/tree-sitter.wrap b/subprojects/tree-sitter.wrap index 5ef72f7c058..d5f56613dfd 100644 --- a/subprojects/tree-sitter.wrap +++ b/subprojects/tree-sitter.wrap @@ -1,6 +1,6 @@ [wrap-file] -source_url = https://github.com/tree-sitter/tree-sitter/archive/v0.20.7.tar.gz -source_filename = v0.20.7.tar.gz -source_hash = b355e968ec2d0241bbd96748e00a9038f83968f85d822ecb9940cbe4c42e182e -patch_directory = tree-sitter-0.20.7 -directory = tree-sitter-0.20.7 +source_url = https://github.com/tree-sitter/tree-sitter/archive/v0.21.0.tar.gz +source_filename = v0.21.0.tar.gz +source_hash = 6bb60e5b63c1dc18aba57a9e7b3ea775b4f9ceec44cc35dac4634d26db4eb69c +patch_directory = tree-sitter-0.21.0 +directory = tree-sitter-0.21.0