sitter

package module
v0.0.0-...-934d75d Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 19 Imported by: 0

README

tree-sitter Go Reference Release Go Report Card License

Go module github.com/malivvan/tree-sitter is a cgo-free tree-sitter wrapper.
It wraps a Wasm build of tree-sitter, and uses wazero as the runtime.

This is pre release software so expect bugs and potentially API breaking changes but each release will be tagged to avoid breaking people's code.

Installation

# go 1.23.4+
go get github.com/malivvan/tree-sitter@latest

Credits

License

This project is licensed under the MIT License.

Documentation

Index

Constants

View Source
const (
	QueryErrorNone uint32 = iota
	QueryErrorSyntax
	QueryErrorNodeType
	QueryErrorField
	QueryErrorCapture
	QueryErrorStructure
	QueryErrorLanguage
)
View Source
const Version = "v0.24.7"

Variables

This section is empty.

Functions

func QueryErrorTypeToString

func QueryErrorTypeToString(errorType uint32) string

Types

type Context

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

type IterMode

type IterMode int
const (
	DFSMode IterMode = iota
	BFSMode
)

type Iterator

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

func NewNamedIterator

func NewNamedIterator(n *Node, mode IterMode) *Iterator

func (*Iterator) ForEach

func (iter *Iterator) ForEach(fn func(*Node) error) error

func (*Iterator) Next

func (iter *Iterator) Next() (*Node, error)

type Language

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

func NewLanguage

func NewLanguage(l uint64, t *TreeSitter) *Language

type LanguageError

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

func (LanguageError) Error

func (l LanguageError) Error() string

type Node

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

func (*Node) Child

func (n *Node) Child(index uint64) (*Node, error)

func (*Node) ChildCount

func (n *Node) ChildCount() (uint64, error)

func (*Node) EndByte

func (n *Node) EndByte() (uint64, error)

func (*Node) IsError

func (n *Node) IsError() (bool, error)

func (*Node) IsNull

func (n *Node) IsNull() (bool, error)

func (*Node) Kind

func (n *Node) Kind() (string, error)

func (*Node) NamedChild

func (n *Node) NamedChild(index uint64) (*Node, error)

func (*Node) NamedChildCount

func (n *Node) NamedChildCount() (uint64, error)

func (*Node) StartByte

func (n *Node) StartByte() (uint64, error)

func (*Node) String

func (n *Node) String() (string, error)

type Parser

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

func (*Parser) Close

func (p *Parser) Close() error

func (*Parser) GetLanguageVersion

func (p *Parser) GetLanguageVersion(l *Language) (uint64, error)

func (*Parser) ParseString

func (p *Parser) ParseString(str string) (*Tree, error)

func (*Parser) SetLanguage

func (p *Parser) SetLanguage(l *Language) error

type Query

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

func (*Query) CaptureNameForID

func (q *Query) CaptureNameForID(id uint32) (string, error)

type QueryCapture

type QueryCapture struct {
	ID   uint32
	Node *Node
}

type QueryCursor

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

func (*QueryCursor) Exec

func (qc *QueryCursor) Exec(q *Query, n *Node) error

func (QueryCursor) NextMatch

func (qc QueryCursor) NextMatch() (*QueryMatch, bool, error)

type QueryMatch

type QueryMatch struct {
	ID           uint32
	PatternIndex uint16
	Captures     []QueryCapture
}

type Tree

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

func (*Tree) RootNode

func (t *Tree) RootNode() (*Node, error)

type TreeSitter

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

func New

func New(vfs fs.FS, out io.Writer) (*TreeSitter, error)

func (*TreeSitter) Language

func (ts *TreeSitter) Language(name string) (*Language, error)

func (*TreeSitter) NewIterator

func (ts *TreeSitter) NewIterator(n *Node, mode IterMode) *Iterator

func (*TreeSitter) NewParser

func (ts *TreeSitter) NewParser() (*Parser, error)

func (*TreeSitter) NewQuery

func (ts *TreeSitter) NewQuery(pattern string, l *Language) (*Query, error)

func (*TreeSitter) NewQueryCursor

func (ts *TreeSitter) NewQueryCursor() (*QueryCursor, error)

Directories

Path Synopsis
lib
_gen command
src
_gen command

Jump to

Keyboard shortcuts

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