diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 16 |
1 files changed, 11 insertions, 5 deletions
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<PathBuf> { 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<Error>> { 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)] |
