regenerate_zero_copy_bytecode/
regenerate_zero_copy_bytecode.rs1use std::fs;
19use std::path::PathBuf;
20
21use keleusma::compiler::compile;
22use keleusma::lexer::tokenize;
23use keleusma::parser::parse;
24
25fn main() {
26 let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
27 let source_path = manifest_dir.join("examples").join("zero_copy_demo.kel");
28 let binary_path = manifest_dir.join("examples").join("zero_copy_demo.kel.bin");
29
30 let source = fs::read_to_string(&source_path).expect("read source");
31 let tokens = tokenize(&source).expect("lex");
32 let program = parse(&tokens).expect("parse");
33 let module = compile(&program).expect("compile");
34 let bytes = module.to_bytes().expect("encode");
35
36 fs::write(&binary_path, &bytes).expect("write binary");
37 println!("wrote {} ({} bytes)", binary_path.display(), bytes.len());
38}