1pub mod parser;
2pub mod codegen;
3pub mod config;
4
5pub use parser::parse;
6
7use std::path::Path;
8
9pub fn generate_all(ui_dir: &Path, out_file: &Path) {
12 let mut output = String::new();
13 output.push_str("// Generated by fncc-core. Do not edit.\n\n");
14
15 let entries = std::fs::read_dir(ui_dir).expect("failed to read ui dir");
16 for entry in entries {
17 let entry = entry.expect("failed to read entry");
18 let path = entry.path();
19 if path.extension().is_some_and(|ext| ext == "fui") {
20 let source = std::fs::read_to_string(&path)
21 .expect(&format!("failed to read {:?}", path));
22 let ast = parser::parse(&source)
23 .expect(&format!("failed to parse {:?}", path));
24 let generated = codegen::generate(&ast);
25 output.push_str(&generated);
26 output.push('\n');
27 }
28 }
29
30 std::fs::write(out_file, &output)
31 .expect("failed to write generated file");
32}