parser

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package parser provides interfaces and implementations for extracting import dependencies and exported symbols from source files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser interface {
	// Language returns the language name (e.g., "go", "typescript", "python").
	Language() string

	// Extensions returns file extensions this parser handles (e.g., ".go", ".ts").
	Extensions() []string

	// ParseImports returns the raw import paths found in the file.
	ParseImports(filePath string) ([]model.Import, error)

	// ParseSymbols returns exported symbols from the file.
	// May return nil if the parser doesn't support symbol extraction.
	ParseSymbols(filePath string) ([]model.Symbol, error)
}

Parser extracts import/dependency edges from a source file.

type Registry

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

Registry holds parsers keyed by extension and language.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns a registry with tree-sitter parsers for all supported languages.

func NewRegistry

func NewRegistry(parsers ...Parser) *Registry

NewRegistry creates a registry from the given parsers.

func (*Registry) ForExtension

func (r *Registry) ForExtension(ext string) Parser

ForExtension returns the parser registered for the given extension, or nil.

func (*Registry) ForLanguage

func (r *Registry) ForLanguage(lang string) Parser

ForLanguage returns the parser registered for the given language name, or nil.

func (*Registry) Languages

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

Languages returns all registered language names.

func (*Registry) RegisteredExtensions

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

RegisteredExtensions returns all file extensions the registry handles.

type TreeSitterParser

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

TreeSitterParser extracts imports and symbols using tree-sitter grammars.

func (*TreeSitterParser) Extensions

func (p *TreeSitterParser) Extensions() []string

func (*TreeSitterParser) Language

func (p *TreeSitterParser) Language() string

func (*TreeSitterParser) ParseImports

func (p *TreeSitterParser) ParseImports(filePath string) ([]model.Import, error)

func (*TreeSitterParser) ParseSymbols

func (p *TreeSitterParser) ParseSymbols(filePath string) ([]model.Symbol, error)

Jump to

Keyboard shortcuts

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