Help us shape the future of Go! Take the 2026 Go Developer Survey

parser

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileNode

func FileNode(input Input, language string) graph.Node

func ModuleName

func ModuleName(path string) string

func ParseTreeSitter

func ParseTreeSitter(ctx context.Context, p *treesitter.Parser, content []byte) *treesitter.Tree

ParseTreeSitter parses UTF-8 source with an already-configured tree-sitter parser and abandons the parse once ctx is done. Tree-sitter has no context aware entry point, so cancellation rides on the progress callback it invokes periodically: returning true there stops parsing and yields a nil tree, which callers must treat as a failed parse rather than an empty file.

func Unquote

func Unquote(text string) string

func Unsupported

func Unsupported(path string) error

Types

type Builder

type Builder struct {
	Input    Input
	Language string
	Result   graph.ParseResult
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(input Input, language string) *Builder

func (*Builder) AddFact

func (b *Builder) AddFact(from string, kind graph.EdgeKind, targetID, target string, targetKind graph.NodeKind, loc graph.Location, properties map[string]string)

func (*Builder) AddNamedSourceFact

func (b *Builder) AddNamedSourceFact(source string, sourceKind graph.NodeKind, kind graph.EdgeKind, targetID, target string, targetKind graph.NodeKind, loc graph.Location, properties map[string]string)

AddNamedSourceFact records an edge whose source declaration is owned by another parse result. Storage resolves the exact source name and optional kind; the parser supplies evidence but never invents the foreign node ID.

func (*Builder) AddNode

func (b *Builder) AddNode(node graph.Node) string

func (*Builder) Declare

func (b *Builder) Declare(parent string, node graph.Node) string

func (*Builder) Diagnostic

func (b *Builder) Diagnostic(line int, level, message string)

func (*Builder) FileID

func (b *Builder) FileID() string

func (*Builder) Finish

func (b *Builder) Finish() graph.ParseResult

type Input

type Input struct {
	Root    string
	Path    string
	Content []byte
	// SourcePaths is the authoritative repository-relative source membership
	// for this indexing run. A nil slice means the caller has no membership
	// snapshot and repository-wide parsers must use their deterministic fallback.
	SourcePaths []string
	Repository  string
	RepoID      string
	GoModule    string
	SemanticKey string
}

type Parser

type Parser interface {
	Language() string
	Supports(path string) bool
	Parse(context.Context, Input) (graph.ParseResult, error)
}

type Registry

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

func NewRegistry

func NewRegistry(parsers ...Parser) *Registry

func (*Registry) For

func (r *Registry) For(path string) (Parser, bool)

func (*Registry) IsSemanticDependency

func (r *Registry) IsSemanticDependency(path string) bool

IsSemanticDependency reports whether path is an explicit repository input to any parser's semantic model, even when the parser does not parse that file as a graph source itself.

func (*Registry) Languages

func (r *Registry) Languages() []string

func (*Registry) SemanticAffectedPaths

func (r *Registry) SemanticAffectedPaths(root string, paths, changed []string) []string

func (*Registry) WorkspaceSemanticEvidenceKeys

func (r *Registry) WorkspaceSemanticEvidenceKeys(ctx context.Context, input Input) (map[string]string, bool, error)

WorkspaceSemanticEvidenceKeys returns cheap external/configuration evidence plus whether every workspace semantic key supports safe reuse.

func (*Registry) WorkspaceSemanticKeys

func (r *Registry) WorkspaceSemanticKeys(ctx context.Context, input Input) (map[string]string, error)

type SemanticChangeProvider

type SemanticChangeProvider interface {
	SemanticAffectedPaths(root string, allPaths, changedPaths []string) []string
}

SemanticChangeProvider expands incremental invalidation when a source or configuration edit can change otherwise untouched parser output. Root is the repository root the paths are relative to, so a provider that keeps a per-repository model can look up the right one rather than guess.

type SemanticDependencyProvider

type SemanticDependencyProvider interface {
	SemanticDependencies() []string
}

SemanticDependencyProvider identifies repository files whose changes can alter this parser's output for otherwise unchanged source files.

type SemanticInputProvider

type SemanticInputProvider interface {
	IsSemanticInput(string) bool
}

SemanticInputProvider recognizes repository files that contribute to a parser's semantic model without necessarily being parsed as graph sources. It covers dynamic dependency names that cannot be expressed as a fixed list.

type SemanticKeyer

type SemanticKeyer interface {
	SemanticKey(context.Context, Input) (string, error)
}

SemanticKeyer lets a parser add repository-level configuration to a file's incremental cache key. Parsers that do not depend on such configuration do not need to implement it.

A parser that also implements WorkspaceSemanticKeyer refines that shared key here with the scope-local facts that change how this one file extracts. Callers pass the already computed workspace key as Input.SemanticKey so the repository-wide part is never recomputed per file.

type WorkspaceSemanticEvidenceKeyer

type WorkspaceSemanticEvidenceKeyer interface {
	WorkspaceSemanticEvidenceKey(context.Context, Input) (string, error)
}

WorkspaceSemanticEvidenceKeyer provides cheap evidence for semantic inputs outside the repository snapshot. When every workspace keyer implements it, callers may reuse a previously computed workspace key while Git proves all in-repository inputs unchanged and these evidence keys still match.

type WorkspaceSemanticKeyer

type WorkspaceSemanticKeyer interface {
	WorkspaceSemanticKey(context.Context, Input) (string, error)
}

WorkspaceSemanticKeyer marks a semantic key that is shared by every source file in one indexing run, allowing the indexer to compute it once.

Directories

Path Synopsis
Package calleffect defines the closed, language-neutral vocabulary for repository-declared call effects.
Package calleffect defines the closed, language-neutral vocabulary for repository-declared call effects.
Package defaults owns the production parser registry shared by the CLI and deterministic evaluation corpus.
Package defaults owns the production parser registry shared by the CLI and deterministic evaluation corpus.
Package godot extracts semantic graph symbols from Godot source formats other than GDScript.
Package godot extracts semantic graph symbols from Godot source formats other than GDScript.
godotid
Package godotid is the single source of truth for Godot resource identity and for the project-level declarations that several Godot producers share.
Package godotid is the single source of truth for Godot resource identity and for the project-level declarations that several Godot producers share.
Package markdown extracts documentation structure and explicit code references.
Package markdown extracts documentation structure and explicit code references.
Package protobuf adapts protobuf source files to Grafo's shared graph model.
Package protobuf adapts protobuf source files to Grafo's shared graph model.
Package protobufbinding projects supported generated-language APIs onto canonical Protobuf declarations.
Package protobufbinding projects supported generated-language APIs onto canonical Protobuf declarations.
sql
Package sql routes SQL source files to an explicitly selected dialect.
Package sql routes SQL source files to an explicitly selected dialect.
sqlite
Package sqlite parses SQLite SQL and extracts schema declarations and relation access.
Package sqlite parses SQLite SQL and extracts schema declarations and relation access.
Package transport defines the language-neutral transport extraction contract.
Package transport defines the language-neutral transport extraction contract.

Jump to

Keyboard shortcuts

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