parser

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package parser implements source code parsing. It uses parser (and lexer) generated by ANTLR4 from neva.g4 grammar file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomErrorListener added in v0.4.0

type CustomErrorListener struct {
	*antlr.DefaultErrorListener
	Errors []*compiler.Error
}

func (*CustomErrorListener) SyntaxError added in v0.4.0

func (c *CustomErrorListener) SyntaxError(
	_ antlr.Recognizer,
	offendingSymbol any,
	line, column int,
	msg string,
	e antlr.RecognitionException,
)

type ParsedSource added in v0.41.0

type ParsedSource struct {
	Tree   generated.IProgContext
	Source []byte
	Tokens []antlr.Token
}

ParsedSource is the syntax-preserving result of parsing one Neva source file.

Unlike the compiler AST, it retains the original source and every parser-visible token, including comments and newlines. Source tooling such as the formatter must use this representation rather than the semantic AST, whose maps do not retain source order or complete trivia.

func ParseSource added in v0.41.0

func ParseSource(source []byte) (ParsedSource, *compiler.Error)

ParseSource parses source without building the compiler's semantic AST. It returns the complete parser-visible token stream so source tooling can preserve comments and newlines while rendering the parsed syntax.

type Parser

type Parser struct{}

func New

func New() Parser

func (Parser) ParseFiles

func (p Parser) ParseFiles(
	modRef core.ModuleRef,
	pkgName string,
	files map[string][]byte,
) (map[string]src.File, *compiler.Error)

func (Parser) ParseManifest

func (p Parser) ParseManifest(raw []byte) (src.ModuleManifest, error)

func (Parser) ParseModules

func (p Parser) ParseModules(
	rawMods map[core.ModuleRef]compiler.RawModule,
) (map[core.ModuleRef]src.Module, *compiler.Error)

func (Parser) ParsePackages

func (p Parser) ParsePackages(
	modRef core.ModuleRef,
	rawPkgs map[string]compiler.RawPackage,
) (
	map[string]src.Package,
	*compiler.Error,
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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