treesitter

package
v3.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine parses a source file once and allows repeated query execution against it.

func New

func New(ctx context.Context, lang Lang, src []byte) (*Engine, error)

New parses src using the given language and returns an Engine ready for queries. The parse is done once here; subsequent Query calls reuse the tree.

func (*Engine) Query

func (e *Engine) Query(pattern string) ([]Match, error)

Query compiles pattern and executes it against the parsed tree, returning all matches with named captures resolved to their text content. Predicate filters (#match?, #eq?, etc.) declared in the pattern are applied.

type Lang

type Lang int

Lang identifies a source language for parsing.

const (
	LangGo Lang = iota
	LangRuby
	LangPython
	LangJavaScript
)

func ParseLang

func ParseLang(s string) (Lang, bool)

ParseLang converts a string like "go" or "ruby" to a Lang constant.

type Match

type Match struct {
	// Captures maps capture name (without the @) to the matched node's text content.
	Captures map[string]string
}

Match is one tree-sitter query match with its named text captures.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL