From 0d221b4ecf4e0cfc60631fa10bc25f68f746c44c Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 18 Mar 2025 14:28:16 +0100 Subject: [PATCH] chore: regenerate parser and headers with tree-sitter 0.25 Keep ABI 14 for now. --- src/grammar.json | 5 +++-- src/node-types.json | 3 ++- src/parser.c | 14 +++++++++----- src/tree_sitter/parser.h | 35 ++++++++++++++++++++++++++++------- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/grammar.json b/src/grammar.json index ae9d01f..7d43688 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -781,5 +781,6 @@ "inline": [], "supertypes": [ "definition" - ] -} + ], + "reserved": {} +} \ No newline at end of file diff --git a/src/node-types.json b/src/node-types.json index ab84c9e..311cd0e 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -476,7 +476,8 @@ }, { "type": "comment", - "named": true + "named": true, + "extra": true }, { "type": "escape_sequence", diff --git a/src/parser.c b/src/parser.c index 93742d5..d65e80d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,3 +1,5 @@ +/* Automatically generated by tree-sitter v0.25.3 */ + #include "tree_sitter/parser.h" #if defined(__GNUC__) || defined(__clang__) @@ -13,7 +15,9 @@ #define EXTERNAL_TOKEN_COUNT 0 #define FIELD_COUNT 5 #define MAX_ALIAS_SEQUENCE_LENGTH 11 +#define MAX_RESERVED_WORD_SET_SIZE 0 #define PRODUCTION_ID_COUNT 20 +#define SUPERTYPE_COUNT 0 enum ts_symbol_identifiers { anon_sym_DOT = 1, @@ -387,7 +391,7 @@ static const char * const ts_field_names[] = { [field_type] = "type", }; -static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { +static const TSMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { [1] = {.index = 0, .length = 1}, [2] = {.index = 1, .length = 2}, [3] = {.index = 3, .length = 1}, @@ -1352,7 +1356,7 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = { }; static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { - [0] = { + [STATE(0)] = { [ts_builtin_sym_end] = ACTIONS(1), [anon_sym_DOT] = ACTIONS(1), [sym_escape_sequence] = ACTIONS(1), @@ -1375,7 +1379,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { [anon_sym_POUND] = ACTIONS(1), [sym_predicate_type] = ACTIONS(1), }, - [1] = { + [STATE(1)] = { [sym_program] = STATE(229), [sym_definition] = STATE(38), [sym_string] = STATE(59), @@ -6733,7 +6737,7 @@ extern "C" { TS_PUBLIC const TSLanguage *tree_sitter_query(void) { static const TSLanguage language = { - .version = LANGUAGE_VERSION, + .abi_version = LANGUAGE_VERSION, .symbol_count = SYMBOL_COUNT, .alias_count = ALIAS_COUNT, .token_count = TOKEN_COUNT, @@ -6755,7 +6759,7 @@ TS_PUBLIC const TSLanguage *tree_sitter_query(void) { .public_symbol_map = ts_symbol_map, .alias_map = ts_non_terminal_alias_map, .alias_sequences = &ts_alias_sequences[0][0], - .lex_modes = ts_lex_modes, + .lex_modes = (const void*)ts_lex_modes, .lex_fn = ts_lex, .primary_state_ids = ts_primary_state_ids, }; diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h index 799f599..cdbe64c 100644 --- a/src/tree_sitter/parser.h +++ b/src/tree_sitter/parser.h @@ -18,6 +18,12 @@ typedef uint16_t TSStateId; typedef uint16_t TSSymbol; typedef uint16_t TSFieldId; typedef struct TSLanguage TSLanguage; +typedef struct TSLanguageMetadata TSLanguageMetadata; +typedef struct TSLanguageMetadata { + uint8_t major_version; + uint8_t minor_version; + uint8_t patch_version; +} TSLanguageMetadata; #endif typedef struct { @@ -26,10 +32,11 @@ typedef struct { bool inherited; } TSFieldMapEntry; +// Used to index the field and supertype maps. typedef struct { uint16_t index; uint16_t length; -} TSFieldMapSlice; +} TSMapSlice; typedef struct { bool visible; @@ -79,6 +86,12 @@ typedef struct { uint16_t external_lex_state; } TSLexMode; +typedef struct { + uint16_t lex_state; + uint16_t external_lex_state; + uint16_t reserved_word_set_id; +} TSLexerMode; + typedef union { TSParseAction action; struct { @@ -93,7 +106,7 @@ typedef struct { } TSCharacterRange; struct TSLanguage { - uint32_t version; + uint32_t abi_version; uint32_t symbol_count; uint32_t alias_count; uint32_t token_count; @@ -109,13 +122,13 @@ struct TSLanguage { const TSParseActionEntry *parse_actions; const char * const *symbol_names; const char * const *field_names; - const TSFieldMapSlice *field_map_slices; + const TSMapSlice *field_map_slices; const TSFieldMapEntry *field_map_entries; const TSSymbolMetadata *symbol_metadata; const TSSymbol *public_symbol_map; const uint16_t *alias_map; const TSSymbol *alias_sequences; - const TSLexMode *lex_modes; + const TSLexerMode *lex_modes; bool (*lex_fn)(TSLexer *, TSStateId); bool (*keyword_lex_fn)(TSLexer *, TSStateId); TSSymbol keyword_capture_token; @@ -129,15 +142,23 @@ struct TSLanguage { void (*deserialize)(void *, const char *, unsigned); } external_scanner; const TSStateId *primary_state_ids; + const char *name; + const TSSymbol *reserved_words; + uint16_t max_reserved_word_set_size; + uint32_t supertype_count; + const TSSymbol *supertype_symbols; + const TSMapSlice *supertype_map_slices; + const TSSymbol *supertype_map_entries; + TSLanguageMetadata metadata; }; -static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { +static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { uint32_t index = 0; uint32_t size = len - index; while (size > 1) { uint32_t half_size = size / 2; uint32_t mid_index = index + half_size; - TSCharacterRange *range = &ranges[mid_index]; + const TSCharacterRange *range = &ranges[mid_index]; if (lookahead >= range->start && lookahead <= range->end) { return true; } else if (lookahead > range->end) { @@ -145,7 +166,7 @@ static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t } size -= half_size; } - TSCharacterRange *range = &ranges[index]; + const TSCharacterRange *range = &ranges[index]; return (lookahead >= range->start && lookahead <= range->end); }