treesittergo

package module
v0.0.0-...-0d1d618 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 11 Imported by: 1

README

(WIP) tree sitter in go without cgo utilizing wazero

some code taken from https://github.com/smacker/go-tree-sitter

Documentation

Index

Constants

View Source
const (
	QueryErrorNone uint32 = iota
	QueryErrorSyntax
	QueryErrorNodeType
	QueryErrorField
	QueryErrorCapture
	QueryErrorStructure
	QueryErrorLanguage
)

Variables

This section is empty.

Functions

func QueryErrorTypeToString

func QueryErrorTypeToString(errorType uint32) string

Types

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(ctx context.Context, fn func(Node) error) error

func (*Iterator) Next

func (iter *Iterator) Next(ctx context.Context) (Node, error)

type Language

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

func NewLanguage

func NewLanguage(l uint64, t Treesitter) Language

func (Language) Name

func (l Language) Name(ctx context.Context) (string, error)

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(ctx context.Context, index uint64) (Node, error)

func (Node) ChildCount

func (n Node) ChildCount(ctx context.Context) (uint64, error)

func (Node) EndByte

func (n Node) EndByte(ctx context.Context) (uint64, error)

func (Node) IsError

func (n Node) IsError(ctx context.Context) (bool, error)

func (Node) Kind

func (n Node) Kind(ctx context.Context) (string, error)

func (Node) NamedChild

func (n Node) NamedChild(ctx context.Context, index uint64) (Node, error)

func (Node) NamedChildCount

func (n Node) NamedChildCount(ctx context.Context) (uint64, error)

func (Node) StartByte

func (n Node) StartByte(ctx context.Context) (uint64, error)

func (Node) String

func (n Node) String(ctx context.Context) (string, error)

type Parser

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

func (Parser) Close

func (p Parser) Close(ctx context.Context) error

func (Parser) GetLanguageVersion

func (p Parser) GetLanguageVersion(ctx context.Context, l Language) (uint64, error)

func (Parser) ParseString

func (p Parser) ParseString(ctx context.Context, str string) (Tree, error)

func (Parser) SetLanguage

func (p Parser) SetLanguage(ctx context.Context, l Language) error

type Query

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

func (Query) CaptureNameForID

func (q Query) CaptureNameForID(ctx context.Context, 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(ctx context.Context, q Query, n Node) error

func (QueryCursor) NextMatch

func (qc QueryCursor) NextMatch(ctx context.Context) (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(ctx context.Context) (Node, error)

type Treesitter

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

func New

func New(ctx context.Context) (Treesitter, error)

func (Treesitter) LanguageSQL

func (t Treesitter) LanguageSQL(ctx context.Context) (Language, error)

func (Treesitter) NewIterator

func (t Treesitter) NewIterator(n Node, mode IterMode) Iterator

func (Treesitter) NewParser

func (t Treesitter) NewParser(ctx context.Context) (Parser, error)

func (Treesitter) NewQuery

func (t Treesitter) NewQuery(ctx context.Context, pattern string, l Language) (Query, error)

func (Treesitter) NewQueryCursor

func (t Treesitter) NewQueryCursor(ctx context.Context) (QueryCursor, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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