parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package parser wraps Go's go/parser to produce ASTs from source files with error tolerance. Partial ASTs are returned even when files contain syntax errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParsedFile

type ParsedFile struct {
	File    *ast.File
	Fset    *token.FileSet
	Source  model.SourceFile
	Content []byte
}

ParsedFile holds the AST and metadata for a single parsed Go source file.

func ParseFile

func ParseFile(sf model.SourceFile, log *slog.Logger) (*ParsedFile, error)

ParseFile parses a single Go source file. It tolerates syntax errors and returns partial ASTs when possible. If the file fails to parse entirely, it returns nil with an error.

func ParseFiles

func ParseFiles(files []model.SourceFile, log *slog.Logger) []*ParsedFile

ParseFiles parses all source files and returns successfully parsed files. Files that fail to parse are logged and skipped.

Jump to

Keyboard shortcuts

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