Skip to main content

compile_to_rust

Function compile_to_rust 

Source
pub fn compile_to_rust(source: &str) -> Result<String, ParseError>
Expand description

Compile LOGOS source to Rust source code.

This is the basic compilation function that runs lexing, parsing, and escape analysis before generating Rust code.

§Arguments

  • source - LOGOS source code as a string

§Returns

Generated Rust source code on success.

§Errors

Returns ParseError if:

  • Lexical analysis fails (invalid tokens)
  • Parsing fails (syntax errors)
  • Escape analysis fails (zone-local values escaping)

§Example

let source = "## Main\nLet x be 5.\nShow x.";
let rust_code = compile_to_rust(source)?;
assert!(rust_code.contains("let x = 5;"));