Documentation
¶
Overview ¶
Package walk is the grammar-free core of taproot: load a tree-sitter Language from a pre-generated blob and navigate the CST with a Walker. It depends only on the gotreesitter runtime — NOT on grammargen or the grammars registry — so a DSL that embeds a generated grammar blob can parse and highlight without linking the ~200-grammar registry (~22MB). The grammargen-backed fallback helpers (build-from-DSL) stay in the parent taproot package.
Index ¶
- func LanguageFromBlob(name string, blob []byte) (*gts.Language, error)
- type Walker
- func (w *Walker) ChildByType(n *gts.Node, typ string) *gts.Node
- func (w *Walker) Field(n *gts.Node, field string) *gts.Node
- func (w *Walker) Pos(n *gts.Node) (line, col int)
- func (w *Walker) SyntaxError(root *gts.Node) error
- func (w *Walker) Text(n *gts.Node) string
- func (w *Walker) Type(n *gts.Node) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Walker ¶
Walker bundles a parse's language and source bytes with CST cursor helpers.
func ParseFromBlob ¶
ParseFromBlob loads the language from a blob (grammar-free) then parses src.
func ParseWithLanguage ¶
ParseWithLanguage parses src with lang, returning the root node, a Walker, and a syntax error if the tree has error/missing nodes.
func (*Walker) ChildByType ¶
ChildByType returns the first direct child of n with grammar type typ, or nil.
func (*Walker) SyntaxError ¶
SyntaxError walks the subtree rooted at root to find the best error or missing leaf and returns a formatted error.