Expand description
tree-sitter query parsing and compilation for lanekeep.
Parses and compiles the tree-sitter queries that gate rule execution.
Queries are the gate, not the rule language: they select which nodes reach a Turing-complete TypeScript handler. That is what keeps JavaScript execution proportional to matches rather than to nodes.
§Why the error type is the bulk of this crate
S-expression queries are the least approachable part of authoring a rule, and tree-sitter’s own diagnostics are close to unusable on their own — an unknown node kind reports a message consisting of the quoted node name and nothing else. Since a rule author’s first several attempts will fail to compile, the quality of that failure is most of what makes the query language tractable.
What CompileError renders instead:
query error: no such node kind in this grammar
the typescript grammar has no node kind `nonexistent_node`
--> query:3:11
|
3 | value: (nonexistent_node) @v) @m
| ^The line and caret matter more than they look. A real rule’s query runs to a dozen lines, and an error naming “the query” rather than a position in it leaves the author bisecting by deletion.
Structs§
- Compile
Error - A query that failed to compile.
- Compiled
Query - A query compiled against one language’s grammar.
- Query
Match - One match, with its captured nodes.
Enums§
- Compile
Error Kind - What is wrong with a query.