use std::path::{Path, PathBuf}; use common::{build::Builder, logging::log}; use compiler::Compiler; fn main() { // read from input file: syntax "c_compiler [output.dsa]" let args: Vec = std::env::args().collect(); if args.len() < 2 { eprintln!("Usage: c_compiler [output.dsa]"); return; } let input_file = &args[1]; let output_file = if args.len() > 2 { &args[2] } else { "output.dsa" }; { let mut builder = Compiler::new(PathBuf::from(input_file)); builder.start(); let result = builder.output().unwrap(); std::fs::write(output_file, &result).expect("Failed to write output"); log(&format!( "Compilation Successful ✅ \n\tSource: {}\n\tOutput: {}\n", input_file, output_file, )); } }