From bc014cf19a7815fcfcde79b1f4929e5030f8d89c Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 6 Sep 2025 19:08:59 -0400 Subject: [PATCH] bindings: Vendor v0.25.9 --- bindings/vendor.sh | 2 +- bindings/vendor/src/language.c | 2 +- bindings/vendor/src/portable/endian.h | 4 ++- bindings/vendor/src/query.c | 46 ++++++++++++--------------- bindings/vendor/src/wasm_store.c | 1 + 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/bindings/vendor.sh b/bindings/vendor.sh index 1887e57..cf2e8fc 100755 --- a/bindings/vendor.sh +++ b/bindings/vendor.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash REMOTE=https://github.com/tree-sitter/tree-sitter.git -BRANCH=v0.25.8 +BRANCH=v0.25.9 rm -rf vendor rm -rf tmp diff --git a/bindings/vendor/src/language.c b/bindings/vendor/src/language.c index b341a67..2dce699 100644 --- a/bindings/vendor/src/language.c +++ b/bindings/vendor/src/language.c @@ -186,7 +186,7 @@ TSSymbol ts_language_symbol_for_name( uint32_t length, bool is_named ) { - if (!strncmp(string, "ERROR", length)) return ts_builtin_sym_error; + if (is_named && !strncmp(string, "ERROR", length)) return ts_builtin_sym_error; uint16_t count = (uint16_t)ts_language_symbol_count(self); for (TSSymbol i = 0; i < count; i++) { TSSymbolMetadata metadata = ts_language_symbol_metadata(self, i); diff --git a/bindings/vendor/src/portable/endian.h b/bindings/vendor/src/portable/endian.h index f467ec5..a656082 100644 --- a/bindings/vendor/src/portable/endian.h +++ b/bindings/vendor/src/portable/endian.h @@ -18,13 +18,15 @@ #if defined(HAVE_ENDIAN_H) || \ defined(__linux__) || \ defined(__GNU__) || \ + defined(__HAIKU__) || \ defined(__illumos__) || \ defined(__NetBSD__) || \ defined(__OpenBSD__) || \ defined(__CYGWIN__) || \ defined(__MSYS__) || \ defined(__EMSCRIPTEN__) || \ - defined(__wasi__) + defined(__wasi__) || \ + defined(__wasm__) #if defined(__NetBSD__) #define _NETBSD_SOURCE 1 diff --git a/bindings/vendor/src/query.c b/bindings/vendor/src/query.c index 4748a00..6c51488 100644 --- a/bindings/vendor/src/query.c +++ b/bindings/vendor/src/query.c @@ -928,35 +928,26 @@ static unsigned analysis_state__recursion_depth(const AnalysisState *self) { return result; } -static inline int analysis_state__compare_position( - AnalysisState *const *self, - AnalysisState *const *other -) { - for (unsigned i = 0; i < (*self)->depth; i++) { - if (i >= (*other)->depth) return -1; - if ((*self)->stack[i].child_index < (*other)->stack[i].child_index) return -1; - if ((*self)->stack[i].child_index > (*other)->stack[i].child_index) return 1; - } - if ((*self)->depth < (*other)->depth) return 1; - if ((*self)->step_index < (*other)->step_index) return -1; - if ((*self)->step_index > (*other)->step_index) return 1; - return 0; -} - static inline int analysis_state__compare( AnalysisState *const *self, AnalysisState *const *other ) { - int result = analysis_state__compare_position(self, other); - if (result != 0) return result; + if ((*self)->depth < (*other)->depth) return 1; for (unsigned i = 0; i < (*self)->depth; i++) { - if ((*self)->stack[i].parent_symbol < (*other)->stack[i].parent_symbol) return -1; - if ((*self)->stack[i].parent_symbol > (*other)->stack[i].parent_symbol) return 1; - if ((*self)->stack[i].parse_state < (*other)->stack[i].parse_state) return -1; - if ((*self)->stack[i].parse_state > (*other)->stack[i].parse_state) return 1; - if ((*self)->stack[i].field_id < (*other)->stack[i].field_id) return -1; - if ((*self)->stack[i].field_id > (*other)->stack[i].field_id) return 1; + if (i >= (*other)->depth) return -1; + AnalysisStateEntry s1 = (*self)->stack[i]; + AnalysisStateEntry s2 = (*other)->stack[i]; + if (s1.child_index < s2.child_index) return -1; + if (s1.child_index > s2.child_index) return 1; + if (s1.parent_symbol < s2.parent_symbol) return -1; + if (s1.parent_symbol > s2.parent_symbol) return 1; + if (s1.parse_state < s2.parse_state) return -1; + if (s1.parse_state > s2.parse_state) return 1; + if (s1.field_id < s2.field_id) return -1; + if (s1.field_id > s2.field_id) return 1; } + if ((*self)->step_index < (*other)->step_index) return -1; + if ((*self)->step_index > (*other)->step_index) return 1; return 0; } @@ -1247,7 +1238,7 @@ static void ts_query__perform_analysis( // the states that have made the least progress. Avoid advancing states that have already // made more progress. if (analysis->next_states.size > 0) { - int comparison = analysis_state__compare_position( + int comparison = analysis_state__compare( &state, array_back(&analysis->next_states) ); @@ -1349,7 +1340,12 @@ static void ts_query__perform_analysis( // Determine if this hypothetical child node would match the current step // of the query pattern. bool does_match = false; - if (visible_symbol) { + + // ERROR nodes can appear anywhere, so if the step is + // looking for an ERROR node, consider it potentially matchable. + if (step->symbol == ts_builtin_sym_error) { + does_match = true; + } else if (visible_symbol) { does_match = true; if (step->symbol == WILDCARD_SYMBOL) { if ( diff --git a/bindings/vendor/src/wasm_store.c b/bindings/vendor/src/wasm_store.c index d018a68..f0c0970 100644 --- a/bindings/vendor/src/wasm_store.c +++ b/bindings/vendor/src/wasm_store.c @@ -754,6 +754,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) { wasmtime_val_t stack_pointer_value = WASM_I32_VAL(0); wasmtime_global_t stack_pointer_global; error = wasmtime_global_new(context, var_i32_type, &stack_pointer_value, &stack_pointer_global); + wasm_globaltype_delete(var_i32_type); ts_assert(!error); *self = (TSWasmStore) {