Skip to main content

Module parser

Module parser 

Source
Expand description

Hand-written recursive-descent parser for Bynk v0.

Token grammar in spec §4. The expression parser uses one function per precedence level (§4.4). Errors carry spans and short fix-oriented messages; the parser does not currently attempt synchronisation, which means at most one parse error is reported per compilation.

Functions§

parse
Parse a token slice into a Commons AST.
parse_unit
Parse a token slice into a SourceUnit — either a commons or a context.
parse_unit_with_recovery
Parse a token slice into a SourceUnit with error recovery, returning a best-effort partial AST plus the full list of parse errors and warnings.
parse_unit_with_warnings
parse_unit with the non-fatal diagnostics threaded out alongside the AST (ADR 0117) — see parse_units_with_warnings.
parse_units
Parse a token slice into all the top-level SourceUnits in one file (v0.113, testing track slice 1b). A .bynk file may hold more than one top-level declaration — an atomic file with commons/context and a suite together (DECISION S) — so the compiler parses a Vec, not a single unit. Test-ness is a property of each declaration, not of the file.
parse_units_with_warnings
parse_units with the non-fatal diagnostics threaded out alongside the AST (ADR 0117): a successful parse returns Ok((units, warnings)) instead of hard-failing on a warning-severity diagnostic (an orphan doc block used to abort file discovery and throw the good AST away). A failed parse still returns every diagnostic — errors then warnings — in the Err.
parse_with_warnings
parse with the non-fatal diagnostics threaded out alongside the AST (ADR 0117) — see parse_units_with_warnings.