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)
- The program reaches a browser surface (the DOM, the signal store, WebRTC), which the AOT-Rust tier does not have
§Example
let source = "## Main\nLet x be 5.\nShow x.";
let rust_code = compile_to_rust(source)?;
assert!(rust_code.contains("fn main()"));
assert!(!rust_code.contains("compile_error!"));