[fine] Re-work compiler main, checking is everything

This commit is contained in:
John Doty 2024-01-11 06:32:23 -08:00
parent 5c05077312
commit d8db65af55
3 changed files with 67 additions and 30 deletions

View file

@ -1,37 +1,8 @@
use fine::parser::parse;
use fine::semantics::Semantics;
use std::env;
use std::fs;
pub fn process_file(file: &str) {
let source = match fs::read_to_string(file) {
Ok(c) => c,
Err(e) => {
eprintln!("Unable to read file {file}: {e}");
return;
}
};
// What am I doing here?
let (tree, lines) = parse(&source);
let semantics = Semantics::new(&tree, &lines);
// This is... probably wrong, I don't know, what am I doing?
for t in tree.trees() {
let _ = semantics.type_of(t);
}
// OK now there might be errors.
let mut errors = semantics.snapshot_errors();
errors.reverse();
for e in errors {
eprintln!("{file}: {}:{}: {}", e.start.0, e.start.1, e.message);
}
}
pub fn main() {
let args: Vec<String> = env::args().collect();
for arg in &args[1..] {
process_file(arg);
fine::process_file(arg);
}
}