parser

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtractPattern

type ExtractPattern struct {
	Type       string                 // Type of pattern (function_call, error_handling, import, etc.)
	Template   string                 // Abstracted template with placeholders
	Variables  map[string]string      // Extracted variables and their types
	Metadata   map[string]interface{} // Additional metadata
	Confidence float64                // Confidence score for the pattern
}

ExtractPattern represents an extracted code pattern

type Language

type Language string

Language represents a supported programming language

const (
	LangGo         Language = "go"
	LangPython     Language = "python"
	LangJavaScript Language = "javascript"
	LangTypeScript Language = "typescript"
	LangUnknown    Language = "unknown"
)

type ParsedCode

type ParsedCode struct {
	Language Language
	Tree     *sitter.Tree
	Source   []byte
}

ParsedCode represents a parsed code snippet with its abstract syntax tree

type Parser

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

Parser provides Tree-sitter based code parsing capabilities

func NewParser

func NewParser() *Parser

NewParser creates a new code parser with language support

func (*Parser) DetectLanguage

func (p *Parser) DetectLanguage(code string) Language

DetectLanguage attempts to detect the programming language from code content

func (*Parser) ExtractPatterns

func (p *Parser) ExtractPatterns(parsed *ParsedCode) ([]ExtractPattern, error)

ExtractPatterns extracts generalizable patterns from parsed code

func (*Parser) Parse

func (p *Parser) Parse(ctx context.Context, code string, lang Language) (*ParsedCode, error)

Parse parses code and returns its syntax tree

Jump to

Keyboard shortcuts

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