Documentation
¶
Index ¶
- type ASTComparator
- type CompareResult
- type ErrorCollector
- type NativeTreeSitterProcessor
- type ParseError
- type ParseErrorKind
- type Processor
- func (p *Processor) EnableTreeSitter()
- func (p *Processor) InitializeWASM(ctx context.Context, wasmBytes []byte) error
- func (p *Processor) Process(ctx context.Context, reader io.Reader, filename string) (*ir.DistilledFile, error)
- func (p *Processor) ProcessFile(filename string, opts processor.ProcessOptions) (*ir.DistilledFile, error)
- func (p *Processor) ProcessWithOptions(ctx context.Context, reader io.Reader, filename string, ...) (*ir.DistilledFile, error)
- type PythonAST
- type PythonClass
- type PythonFunction
- type PythonImport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASTComparator ¶
type ASTComparator struct {
// contains filtered or unexported fields
}
ASTComparator compares our parsed output with Python's ast module
func NewASTComparator ¶
func NewASTComparator() *ASTComparator
NewASTComparator creates a new AST comparator
func (*ASTComparator) CompareFile ¶
func (c *ASTComparator) CompareFile(filename string, ourAST *ir.DistilledFile) (*CompareResult, error)
CompareFile compares a file parsed by our parser with Python's ast
type CompareResult ¶
type CompareResult struct {
Match bool
MissingInOurs []string
MissingInPython []string
Differences []string
OurNodeCount int
PythonNodeCount int
}
CompareResult holds the comparison results
type ErrorCollector ¶
type ErrorCollector struct {
// contains filtered or unexported fields
}
ErrorCollector collects errors during parsing
func NewErrorCollector ¶
func NewErrorCollector() *ErrorCollector
NewErrorCollector creates a new error collector
func (*ErrorCollector) AddError ¶
func (ec *ErrorCollector) AddError(line, column int, message string, kind ParseErrorKind)
AddError adds an error to the collector
func (*ErrorCollector) AddWarning ¶
func (ec *ErrorCollector) AddWarning(line, column int, message string, kind ParseErrorKind)
AddWarning adds a warning to the collector
func (*ErrorCollector) ToDistilledErrors ¶
func (ec *ErrorCollector) ToDistilledErrors() []ir.DistilledError
ToDistilledErrors converts collected errors to IR errors
type NativeTreeSitterProcessor ¶
type NativeTreeSitterProcessor struct {
// contains filtered or unexported fields
}
NativeTreeSitterProcessor uses native Go tree-sitter bindings
func NewNativeTreeSitterProcessor ¶
func NewNativeTreeSitterProcessor() (*NativeTreeSitterProcessor, error)
NewNativeTreeSitterProcessor creates a new native tree-sitter processor
func (*NativeTreeSitterProcessor) ProcessSource ¶
func (p *NativeTreeSitterProcessor) ProcessSource(ctx context.Context, source []byte, filename string) (*ir.DistilledFile, error)
ProcessSource processes Python source code using tree-sitter
type ParseError ¶
type ParseError struct {
Line int
Column int
Message string
Kind ParseErrorKind
Severity string // "error", "warning", "info"
}
ParseError represents a parsing error with recovery information
type ParseErrorKind ¶
type ParseErrorKind string
ParseErrorKind represents types of parsing errors
const ( ErrorKindSyntax ParseErrorKind = "syntax" ErrorKindIndentation ParseErrorKind = "indentation" ErrorKindUnclosedExpr ParseErrorKind = "unclosed_expression" ErrorKindInvalidName ParseErrorKind = "invalid_name" ErrorKindIncomplete ParseErrorKind = "incomplete_definition" )
type Processor ¶
type Processor struct {
processor.BaseProcessor
// contains filtered or unexported fields
}
Processor implements the LanguageProcessor interface for Python
func NewProcessor ¶
func NewProcessor() *Processor
NewProcessor creates a new Python language processor
func (*Processor) EnableTreeSitter ¶
func (p *Processor) EnableTreeSitter()
EnableTreeSitter enables tree-sitter based parsing
func (*Processor) InitializeWASM ¶
InitializeWASM sets up the WASM runtime and loads the Python parser
func (*Processor) Process ¶
func (p *Processor) Process(ctx context.Context, reader io.Reader, filename string) (*ir.DistilledFile, error)
Process parses Python source code and returns the IR representation
func (*Processor) ProcessFile ¶
func (p *Processor) ProcessFile(filename string, opts processor.ProcessOptions) (*ir.DistilledFile, error)
ProcessFile processes a file by path
func (*Processor) ProcessWithOptions ¶
func (p *Processor) ProcessWithOptions(ctx context.Context, reader io.Reader, filename string, opts processor.ProcessOptions) (*ir.DistilledFile, error)
ProcessWithOptions parses with specific options
type PythonAST ¶
type PythonAST struct {
Type string `json:"type"`
Name string `json:"name,omitempty"`
Functions []PythonFunction `json:"functions"`
Classes []PythonClass `json:"classes"`
Imports []PythonImport `json:"imports"`
Errors []string `json:"errors"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
}
PythonAST represents the structure returned by Python's ast module
type PythonClass ¶
type PythonClass struct {
Name string `json:"name"`
Bases []string `json:"bases"`
Methods []PythonFunction `json:"methods"`
LineNumber int `json:"lineno"`
}