parser

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

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

Parser parses tokens into an AST using recursive descent.

ARCHITECTURE NOTE: The parser uses error collection (not fail-fast). When an error is encountered, it's appended to p.errors and parsing continues. This allows reporting multiple errors in a single parse, improving UX.

The parser handles Kukicha's "context-sensitive keywords" - words like `list`, `map`, and `channel` are keywords only when followed by `of` in a type context. This lets users use these as variable names in expressions.

func New

func New(source string, filename string) (*Parser, error)

New creates a new parser from a source string

func NewFromTokens

func NewFromTokens(tokens []lexer.Token) *Parser

NewFromTokens creates a new parser from a slice of tokens

func (*Parser) Errors

func (p *Parser) Errors() []error

Errors returns the parsing errors

func (*Parser) Parse

func (p *Parser) Parse() (*ast.Program, []error)

Parse parses the tokens into a Program AST

Jump to

Keyboard shortcuts

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