Add a whole-file/program parser to twill-parser #45

Closed
opened 2026-08-20 20:00:03 +00:00 by jacksonopp · 0 comments
Owner

twill-parser has no entry point that parses a whole source file. stmt_parser() parses exactly one statement, and every call site (including all existing tests) only ever calls it once -- there's no repeated()-style production that consumes a sequence of top-level statements until EOF.

Discovered while working through #44 (db trait + SourceFile skeleton): twill-check's parse tracked fn needs to hand a whole file's text to twill-parser and get back a full module/program, not a single statement, so this blocks #43 (lowering the parsed AST) from doing anything real.

Scope: a program_parser (name TBD) that repeats stmt_parser() to end-of-input, returning something like Vec<Spanned<Stmt<'src>>> or a dedicated Program/Module AST node -- same one-fn-per-production, .boxed() convention as the rest of parser.rs. Snapshot-test it the same way other productions are tested.

twill-parser has no entry point that parses a whole source file. stmt_parser() parses exactly one statement, and every call site (including all existing tests) only ever calls it once -- there's no repeated()-style production that consumes a sequence of top-level statements until EOF. Discovered while working through #44 (db trait + SourceFile skeleton): twill-check's parse tracked fn needs to hand a whole file's text to twill-parser and get back a full module/program, not a single statement, so this blocks #43 (lowering the parsed AST) from doing anything real. Scope: a program_parser (name TBD) that repeats stmt_parser() to end-of-input, returning something like Vec<Spanned<Stmt<'src>>> or a dedicated Program/Module AST node -- same one-fn-per-production, .boxed() convention as the rest of parser.rs. Snapshot-test it the same way other productions are tested.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jacksonopp/twill#45
No description provided.