Skip to main content

compile_to_cfg

Function compile_to_cfg 

Source
pub fn compile_to_cfg(source: &str) -> MultiErrorResult<CompileState>
Expand description

Compile source code up to CFG (control flow graph).

This is an alias for compile_frontend that provides a more intuitive name for test code. It runs the full frontend pipeline: lexing → parsing → AST to RIR → semantic analysis → CFG construction.

§Example

use gruel_compiler::compile_to_cfg;

let result = compile_to_cfg("fn main() -> i32 { if true { 1 } else { 2 } }");
assert!(result.is_ok());
let state = result.unwrap();
assert_eq!(state.functions.len(), 1);