[fine] Beginning a binary

This commit is contained in:
John Doty 2024-01-03 05:44:59 -08:00
parent 8a867de7e7
commit d73f77cf00

View file

@ -1 +1,37 @@
pub fn main() {}
use fine::parser::Parser;
use std::env;
use std::fs;
pub fn process_file(file: &str) {
println!("{file}");
let source = match fs::read_to_string(file) {
Ok(c) => c,
Err(e) => {
eprintln!("Unable to read file {file}: {e}");
return;
}
};
let (mut tree, expr, lines) = Parser::new(&source).parse();
if tree.errors.len() > 0 {
for error in tree.errors {
eprintln!("{error}");
}
return;
}
let _expr_type = tree.expr_type(&expr, &lines, true);
if tree.errors.len() > 0 {
for error in tree.errors {
eprintln!("{error}");
}
return;
}
}
pub fn main() {
let args: Vec<String> = env::args().collect();
for arg in &args[1..] {
process_file(arg);
}
}