From 6d94077778d6043e135640f40b09e2582d3a3064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Sun, 10 Jan 2021 16:55:26 +0100 Subject: Fix this shit --- src/main.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index bcda641..53e2e08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,8 +9,11 @@ use error::Error; fn main() { let file = file_from_args().unwrap_or_else(|| Path::new("tests/simple.tdy").to_owned()); - if let Err(err) = run_file(&file) { - println!("{}", err); + if let Err(errs) = run_file(&file) { + for err in errs.iter() { + println!("{}", err); + } + println!(" {} errors occured.", errs.len()); } } @@ -18,10 +21,13 @@ fn file_from_args() -> Option { std::env::args().skip(1).map(|s| Path::new(&s).to_owned()).find(|p| p.is_file()) } -fn run_file(path: &Path) -> Result<(), Error> { +fn run_file(path: &Path) -> Result<(), Vec> { let tokens = tokenizer::file_to_tokens(path); - let block = compiler::compile("main", path, tokens); // path -> str might fail - vm::run_block(block) + match compiler::compile("main", path, tokens) { + Ok(block) => vm::run_block(block).or_else(|e| Err(vec![e])), + Err(errors) => Err(errors), + } + } #[cfg(test)] -- cgit v1.2.1