parse

package
v0.0.0-...-721e887 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeID

func MakeID(qname, lang string, startByte int) string

MakeID returns a stable 16-char hash for (qname, language, startByte). All language parsers must use this so node IDs collide deterministically across pass boundaries and re-runs.

Types

type ParseResult

type ParseResult struct {
	Path    string
	Nodes   []types.Node
	Edges   []types.Edge
	Pending []PendingRef
}

ParseResult is the per-file output of Pass 1.

type Parser

type Parser interface {
	// ParseFile runs Pass 1 on a single file. Pure function — must be safe
	// to call concurrently from a worker pool.
	ParseFile(path string, src []byte) (*ParseResult, error)

	// Resolve runs Pass 2 over the union of ParseResults from the same language.
	Resolve(results []*ParseResult) (*ResolvedGraph, error)

	// Extensions reports the file extensions this parser handles (lowercase, with leading ".").
	Extensions() []string
}

Parser is the contract every language parser implements.

type PendingRef

type PendingRef struct {
	SrcID       string
	EdgeType    types.EdgeType
	TargetQName string
	HintFile    string
	Line        int
	// ByteOffset (W-C W6 V2.15, 2026-05-15): byte position of the
	// referent in the source file. Used by the Solidity resolver to
	// disambiguate same-line shadow scopes — when V2.0's line-only
	// `declLine <= useSiteLine <= scopeEndLine` filter admits multiple
	// decls, the byte offset breaks the tie via containment. Zero =
	// unset (other parsers leave it default; Sol resolver falls back
	// to V2.0 line-only behavior when bytes are missing).
	ByteOffset int
	// Order (W-C W7.3, 2026-05-18): source-order index. Carried to the
	// resolved Edge.Order field. Currently populated by Sol's
	// runHasModifier walker; ignored elsewhere.
	Order        int
	DispatchKind string
}

PendingRef is an unresolved cross-file reference produced in Pass 1 and resolved (or marked AMBIGUOUS) in Pass 2.

DispatchKind (Track C P1b, schema 1.7): optional metadata for `invokes` edges. Empty for static `calls`. Carried through Pass 2 Resolve so the final edge row preserves the dispatch classification decided at AST time (when types.Info is still in scope).

type Registry

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

Registry maps file extensions to parser instances.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry. Use Register to add parsers.

func (*Registry) For

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

For returns the parser registered for path's extension, or nil if none.

func (*Registry) Register

func (r *Registry) Register(p Parser) error

Register associates each of p.Extensions() with p. Returns an error if any extension is already registered.

type ResolvedGraph

type ResolvedGraph struct {
	Nodes []types.Node
	Edges []types.Edge
}

ResolvedGraph is the per-language Pass 2 output: in addition to the union of per-file results, edges that resolved or were marked AMBIGUOUS.

Directories

Path Synopsis
Package golang is the Go-language parser for CKG.
Package golang is the Go-language parser for CKG.
Package proto implements the CKG parser for `.proto` files (schema 1.9 W3a).
Package proto implements the CKG parser for `.proto` files (schema 1.9 W3a).
Package solidity implements the CKG parser for .sol files (spec §4.6.3).
Package solidity implements the CKG parser for .sol files (spec §4.6.3).
binding
Package binding wraps the tree-sitter-solidity grammar (vendored from github.com/JoranHonig/tree-sitter-solidity v1.2.11, MIT-licensed) into a *sitter.Language usable by github.com/tree-sitter/go-tree-sitter.
Package binding wraps the tree-sitter-solidity grammar (vendored from github.com/JoranHonig/tree-sitter-solidity v1.2.11, MIT-licensed) into a *sitter.Language usable by github.com/tree-sitter/go-tree-sitter.
Package typescript — body_walk.go implements P3 of the TS parser: statement-level call extraction inside function/method bodies.
Package typescript — body_walk.go implements P3 of the TS parser: statement-level call extraction inside function/method bodies.

Jump to

Keyboard shortcuts

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