diff --git a/src/commands/eval.rs b/src/commands/eval.rs index f854394..952db38 100644 --- a/src/commands/eval.rs +++ b/src/commands/eval.rs @@ -9,6 +9,7 @@ use lento_core::{ value::Value, }, parser::parser::{from_string, Parser}, + stdlib::init::stdlib, type_checker::{checker::TypeChecker, types::GetType}, }; @@ -24,9 +25,13 @@ pub fn handle_command_eval(args: &ArgMatches, _arg_parser: &mut Command) { } let expr = args.get_one::("expr").unwrap().to_owned(); + let std = stdlib(); let mut parser = from_string(expr); + std.init_parser(&mut parser); let mut checker = TypeChecker::default(); + std.init_type_checker(&mut checker); let mut env = global_env(); + std.init_environment(&mut env); eval_all(&mut parser, &mut checker, &mut env, false, false); } diff --git a/src/commands/files.rs b/src/commands/files.rs index 4b8e30d..941b54c 100644 --- a/src/commands/files.rs +++ b/src/commands/files.rs @@ -11,6 +11,7 @@ use lento_core::{ value::Value, }, parser::{ast::Module, parser::parse_path_all}, + stdlib::init::stdlib, type_checker::checker::TypeChecker, util::failable::Failable, }; @@ -57,9 +58,10 @@ fn validate_files(files: &Vec<&Path>, arg_parser: &mut Command) { fn parse_files<'a>(files: &Vec<&'a Path>) -> Vec<(&'a Path, Module)> { // Parallelize this parse-map operation to optimize detecting errors in multiple files (pre-execution) + let std = stdlib(); let results: Vec<(&'a Path, Module)> = files .par_iter() - .filter_map(|f| match parse_path_all(f) { + .filter_map(|f| match parse_path_all(f, Some(&std)) { Ok(module) => Some((*f, module)), Err(err) => { print_error(format!( @@ -84,7 +86,11 @@ fn parse_files<'a>(files: &Vec<&'a Path>) -> Vec<(&'a Path, Module)> { fn interpret_parse_results(parse_results: Vec<(&Path, Module)>) -> Failable> { // Interpret all files in order. Unwrap is safe because we already checked for errors in the parse_results function let mut errors: Vec = vec![]; + let std = stdlib(); let mut checker = TypeChecker::default(); + std.init_type_checker(&mut checker); + let mut env = global_env(); + std.init_environment(&mut env); for (file_path, module) in parse_results { println!( "{} '{}'...", @@ -98,7 +104,7 @@ fn interpret_parse_results(parse_results: Vec<(&Path, Module)>) -> Failable { println!("{} executed program!", "Successfully".light_green()); if val != Value::Unit { diff --git a/src/commands/repl.rs b/src/commands/repl.rs index be4240a..832e43c 100644 --- a/src/commands/repl.rs +++ b/src/commands/repl.rs @@ -47,6 +47,7 @@ pub fn handle_command_repl(args: &ArgMatches, _arg_parser: &mut Command) { let mut checker = TypeChecker::default(); std.init_type_checker(&mut checker); let mut env = global_env(); + std.init_environment(&mut env); loop { print!("> "); std::io::stdout().flush().unwrap();