Tree-sitter Query Syntax
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.
For example, this pattern would match any binary_expression node whose children are both number_literal nodes:
(binary_expression (number_literal) (number_literal))
field name
You do this by prefixing a child pattern with a field name followed by a colon.
! (negate)
You can also constrain a pattern so that it only matches nodes that lack a certain field.
Anonymous Nodes
The parenthesized syntax for writing nodes only applies to named nodes. To match specific anonymous nodes, you write their name between double quotes.