Problem: When using alternations, the `#eq?` predicate does not always use the same capture name.
Solution: Iterate the left and right captured nodes more independently.
(cherry picked from commit 79177a1cd5)
**Problem:** When encountering an invalid symbol at the beginning of the
file, the rust bindings attempt to index the character at position -1 of
the query source, which leads to an overflow and thus invalid character
index which causes a panic.
**Solution:** Bounds check the offset before performing the subtraction.
(cherry picked from commit dff828cdbe)
This allows users to bail parsing if an error was *definitely* detected
using the progress callback, as all possible stack versions have a
non-zero error cost.
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
Introduces a new function that takes in a supertype symbol and returns
all associated subtypes. Can be used by query.c to give better errors
for invalid subtypes, as well as downstream applications like the query
LSP to give better diagnostics.
The current quotation escape checker fails in the case that
there is an anonymous node that is just an escaped backslash (it thinks
the backslash escapes the quote, when really it is just an escaped
backslash itself. See the added test case for an example of this).
This commit ensures the node identification logic keeps track of the
number of backslashes seen so it can accurately determine if the
quotation is escaped or not.
WASI doesn't support `dup(2)` system call, so we cannot implement the
`print_dot_graph` and `print_dot_graphs` functions with exactly the same
semantics as in other platforms.
Currently, if a predicate is hard to match on the Rust side, a sizable
query against a very large file can take forever, and ends up hanging.
This commit adds an API function `ts_query_cursor_set_timeout_micros` to
limit how long query execution is allowed to take, thereby negating the
chance of a hang to occur.
This commit stores the result of text predicates evaluation in a separate variable to ensure that they're computed just once. As is, it is possible for e.g. #match predicates to match node against a regex twice.