taproot

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package taproot is the common front-end harness shared by M31 DSLs that use the gotreesitter runtime. It provides grammar generation + caching, a CST Walker, and one-stop Parse helpers.

The grammar-free core (Walker, blob-only language load, parse-from-blob) lives in the taproot/walk subpackage, which depends only on the gotreesitter runtime — no grammargen, no grammars registry. A DSL that embeds a pre-generated grammar blob should import taproot/walk so it doesn't link the ~200-grammar registry. The functions here add the grammargen DSL fallback (build-from-source when no blob is present) and re-export walk's Walker for backward compatibility.

The Walker error-leaf finder is lifted from elio/parse/tree.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Language

func Language(name string, build func() *grammargen.Grammar) (*gts.Language, error)

Language generates and caches (once per name) the tree-sitter Language for a grammar. build is called only on a cache miss.

func LanguageFromBlob

func LanguageFromBlob(name string, blob []byte, build func() *grammargen.Grammar) (*gts.Language, error)

LanguageFromBlob loads and caches (once per name) the tree-sitter Language from blob when possible, falling back to build when blob is empty or corrupt. The blob path is grammar-free (delegated to taproot/walk); only the fallback pulls grammargen.

func NewWalker

func NewWalker(lang *gts.Language, src []byte) *walk.Walker

NewWalker constructs a Walker for the given language and source.

func Parse

func Parse(name string, build func() *grammargen.Grammar, src []byte) (*gts.Node, *walk.Walker, error)

Parse runs the full common DSL parse flow: obtain (or generate+cache) the Language for name, parse src, and return (root, walker, syntaxErr).

func ParseFromBlob

func ParseFromBlob(name string, blob []byte, build func() *grammargen.Grammar, src []byte) (*gts.Node, *walk.Walker, error)

ParseFromBlob is the blob-aware variant of Parse. It obtains the language via LanguageFromBlob, then follows the same parse/error flow as Parse.

Types

type Walker

type Walker = walk.Walker

Walker is the CST cursor helper. It is re-exported from taproot/walk so existing taproot.Walker / *taproot.Walker references keep working; new code that only needs the grammar-free path should import taproot/walk directly.

Directories

Path Synopsis
Package diag provides a generic structured diagnostic type and a source-quoting renderer.
Package diag provides a generic structured diagnostic type and a source-quoting renderer.
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.
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.

Jump to

Keyboard shortcuts

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