diff --git a/src/direct/mod.rs b/src/direct/mod.rs index 52c1e3d..e963031 100644 --- a/src/direct/mod.rs +++ b/src/direct/mod.rs @@ -1,4 +1,4 @@ -use std::{collections::VecDeque}; +use std::{collections::VecDeque, path::Path}; use crate::{token::{Token, MessageType}, builtin::modules::Module}; @@ -22,12 +22,12 @@ impl LangSpecs { } } -pub fn resolve_directives(tokens: &mut VecDeque) -> LangSpecs { +pub fn resolve_directives(tokens: &mut VecDeque, origin: &String) -> LangSpecs { let mut specs = LangSpecs::default(); for (idx, token) in tokens.iter().enumerate() { match token { - Token::CompilerDirective(text, _) => parse_directive(text, idx, &mut specs), + Token::CompilerDirective(text, _) => parse_directive(text, idx, &mut specs, origin), _ => () } } @@ -56,7 +56,9 @@ pub fn from_list(text: &str) -> Vec { vec } -fn parse_directive(text: &str, token_idx: usize, specs: &mut LangSpecs) { +fn parse_directive(text: &str, token_idx: usize, specs: &mut LangSpecs, origin: &String) { + + std::env::set_current_dir(Path::new(origin).parent().unwrap()).expect("unable to change cwd"); for cap in DIRECTIVE_REGEX.captures_iter(text) { let mut enumerator = cap.iter().enumerate(); diff --git a/src/main.rs b/src/main.rs index a5590ee..be992cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ fn compile(settings: &Settings) -> Option<(Vec, Vec, Vec