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 ¶
New creates a new parser from a source string.
Lexer errors (invalid characters, bad indentation, etc.) are collected into the parser's error list and returned by Parse() as individual positioned errors ("file:line:col: message"). The error return value is always nil; it exists only for backward compatibility and will be removed in a future version. Callers should check the errors returned by Parse() instead of the error returned here.
func NewFromTokens ¶
NewFromTokens creates a new parser from a slice of tokens