Documentation
¶
Overview ¶
Package parser implements source code parsing. It uses parser (and lexer) generated by ANTLR4 from neva.g4 grammar file.
Index ¶
- type CustomErrorListener
- type ParsedSource
- type Parser
- func (p Parser) ParseFiles(modRef core.ModuleRef, pkgName string, files map[string][]byte) (map[string]src.File, *compiler.Error)
- func (p Parser) ParseManifest(raw []byte) (src.ModuleManifest, error)
- func (p Parser) ParseModules(rawMods map[core.ModuleRef]compiler.RawModule) (map[core.ModuleRef]src.Module, *compiler.Error)
- func (p Parser) ParsePackages(modRef core.ModuleRef, rawPkgs map[string]compiler.RawPackage) (map[string]src.Package, *compiler.Error)
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 (Parser) ParseFiles ¶
func (Parser) ParseManifest ¶
func (p Parser) ParseManifest(raw []byte) (src.ModuleManifest, error)