Source: src/parser/file.lx
Entry point for parsing a whole source file: reads and lexes the file, re-issues lexical errors as full diagnostics, and builds the module AST node that represents the file.
Reports a "could not read file" failure as a queued IO-error diagnostic instead of a bare stdout print.
#takes_ownership
report_read_error -> fn(
path: *byte,
message: *byte
) void
Re-issues each error buffered by the lexer as a full error.lx diagnostic, now that the token table and file path are available to render context.
post_lex_errors -> fn(
lexer: *TOK::Lexer,
tks: *TOK::Token,
tok_count: i64,
file_path: *byte
) void
Frees the tokens, statements, source buffer and parser, then returns NULL so callers can propagate parse failure.
#takes_ownership
fail -> fn(
tokens: *VEC::Vector,
stmts: *VEC::Vector,
src: *byte,
p: *PARS::Parser
) *AST::AstNode
Frees a source buffer and returns NULL, used when failure occurs before any other parse state has been allocated.
#takes_ownership
fail_early -> fn(
src: *byte
) *AST::AstNode
Reads, lexes and parses the file at path, returning the module AstNode
for the whole file (the caller owns it), or NULL on any failure.
pub #returns_ownership
parse_file -> fn(
path: *byte
) *AST::AstNode