Skip to main content

with_program

Function with_program 

Source
pub fn with_program<R>(
    source: &str,
    optimize: bool,
    f: impl FnOnce(&[Stmt<'_>], &Interner) -> R,
) -> Result<R, ParseError>
Expand description

Parse source, optionally run the production optimizer, and invoke f with the resulting statements and the interner used to intern their symbols.

When optimize is true the statements are passed through optimize::optimize_program — the same 14-pass pipeline the real compiler runs — so callers can validate the optimizer’s output against the source.