class TreeSitter::Query
- TreeSitter::Query
- Reference
- Object
Overview
A query consists of one or more patterns, where each pattern is an S-expression that matches a certain set of nodes in a syntax tree. The expression to match a given node consists of a pair of parentheses containing two things: the node’s type, and optionally, a series of other S-expressions that match the node’s children.
Defined in:
tree_sitter/query.crConstructors
-
.new(language : Language, source : String)
Create a new query from a string containing one or more S-expression patterns.
Instance Method Summary
Constructor Detail
Create a new query from a string containing one or more S-expression patterns. The query is associated with a particular language, and can only be run on syntax nodes parsed with that language.
If all of the given patterns are valid, this returns a Query
.
If a pattern is invalid, this raises an Error
exception that provides two pieces
of information about the problem:
- The byte offset of the error.
- The type of error.