diff --git a/src/main.rs b/src/main.rs index febceaf..3cb9cc9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,13 +19,29 @@ mod eval; fn main() { let args: Vec = std::env::args().collect(); - println!("Schala v 0.02"); if let Some(filename) = args.get(1) { let mut source_file = File::open(&Path::new(filename)).unwrap(); let mut buffer = String::new(); source_file.read_to_string(&mut buffer).unwrap(); - panic!("Not implemented yet"); + + let tokens = match tokenize(&buffer) { + Some(t) => t, + None => { println!("Tokenization error"); return; } + }; + + let ast = match parse(&tokens, &[]) { + Ok(ast) => ast, + Err(err) => { println!("Parse error: {:?}", err); return; } + }; + + let mut evaluator = Evaluator::new(); + let results = evaluator.run(ast); + for result in results.iter() { + println!("{}", result); + } + } else { + println!("Schala v 0.02"); let initial_state = InterpreterState { show_tokens: false, show_parse: false,