parser

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package parser provides language-specific parsing capabilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileOutline

type FileOutline struct {
	Filename string    // Name of the parsed file
	Symbols  []*Symbol // Top-level symbols in the file
	Errors   []error   // Any errors encountered during parsing
}

FileOutline represents the parsed structure of a source file

type GoParser

type GoParser struct{}

GoParser implements Parser for Go source files

func NewGoParser

func NewGoParser() *GoParser

NewGoParser creates a new Go parser

func (*GoParser) Extensions

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

func (*GoParser) Parse

func (p *GoParser) Parse(content []byte, filename string) (*FileOutline, error)

type Parser

type Parser interface {
	// Parse analyzes the content of a file and returns a structured outline
	Parse(content []byte, filename string) (*FileOutline, error)

	// Extensions returns the file extensions this parser handles
	Extensions() []string
}

Parser defines the interface for language-specific parsers

type Registry

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

Registry manages the available parsers

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new parser registry

func (*Registry) GetParser

func (r *Registry) GetParser(filename string) Parser

GetParser returns the appropriate parser for a file extension

func (*Registry) IsSupported

func (r *Registry) IsSupported(filename string) bool

IsSupported checks if there's a parser available for the given file extension

func (*Registry) Register

func (r *Registry) Register(parser Parser)

Register adds a parser to the registry

type Symbol

type Symbol struct {
	Type       string         // e.g., "function", "class", "interface", etc.
	Name       string         // Name of the symbol
	Signature  string         // Full signature for functions/methods
	Docstring  string         // Associated documentation
	Decorators []string       // Any decorators/annotations
	Children   []*Symbol      // Nested symbols (e.g., methods in a class)
	Metadata   map[string]any // Additional language-specific metadata
}

Symbol represents a parsed symbol (function, type, class, etc.)

Jump to

Keyboard shortcuts

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