parser

The self-hosted parser (ADR 0043 stage 2). A port of the reference recursive-descent/Pratt parser over the Talk lexer's token stream, validated construct-by-construct against the frozen dump corpus.

Errors carry the reference diagnostic code and rendered message so the validation dump matches byte-for-byte.

The reference parser streams tokens with previous/current/next plus a previous-before-newline cursor for span ends. Here the scanner runs up front and pos indexes the token list: current is tokens[pos] (end-of-stream yields EOF tokens forever, like the reference lexer), and the previous-before-newline cursor is recovered by scanning backward past newline tokens.

API Reference

Structs

struct Fail

A structured parser diagnostic with stable code, message, and blame range.

struct DocumentedDecl

One decl with its attached leading comment group, in source order (Docs.tlk's attachment pass). ParseOutcome.docs carries these only when the parse ran through the documenting entry point.

struct ParseOutcome

The AST prefix, diagnostics, trivia, and metadata produced by one category parse.

Functions

func parse_members_source(source: String) -> ParseOutcome

Parse a whole input as nominal-body members (ADR 0026): the grammar struct and extension bodies use, so a macro expansion spliced into a declaration body yields member declarations — methods, not plain functions.