diff --git a/src/protocol/parser/mod.rs b/src/protocol/parser/mod.rs index 1d2eee5bc1b2683818d37d490b6d745636b034f2..8f1500639951df5c37527325b710f7e2f3e88097 100644 --- a/src/protocol/parser/mod.rs +++ b/src/protocol/parser/mod.rs @@ -136,11 +136,12 @@ pub struct Parser { // Compiler options pub write_tokens_to: Option, pub write_ast_to: Option, + pub std_lib_dir: Option, pub(crate) arch: TargetArch, } impl Parser { - pub fn new() -> Result { + pub fn new(std_lib_dir: Option) -> Result { let mut parser = Parser{ heap: Heap::new(), string_pool: StringPool::new(), @@ -158,6 +159,7 @@ impl Parser { pass_stack_size: PassStackSize::new(), write_tokens_to: None, write_ast_to: None, + std_lib_dir, arch: TargetArch::new(), }; @@ -309,9 +311,16 @@ impl Parser { // Path variable is set (path, true) } else { - let mut path = String::with_capacity(REOWOLF_PATH_DIR.len() + 2); - path.push_str("./"); - path.push_str(REOWOLF_PATH_DIR); + let path = match self.std_lib_dir.take() { + Some(path) => path, + None => { + let mut path = String::with_capacity(REOWOLF_PATH_DIR.len() + 2); + path.push_str("./"); + path.push_str(REOWOLF_PATH_DIR); + path + } + }; + (path, false) };