class TreeSitter::Query

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(language : Language, source : String) #

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:

  1. The byte offset of the error.
  2. The type of error.

[View source]

Instance Method Detail

def capture_count : UInt32 #

[View source]
def pattern_count : UInt32 #

[View source]
def string_count : UInt32 #

[View source]