include derives prant folder from main file
This commit is contained in:
parent
a7899c15b1
commit
a567fc75b9
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::VecDeque};
|
use std::{collections::VecDeque, path::Path};
|
||||||
|
|
||||||
use crate::{token::{Token, MessageType}, builtin::modules::Module};
|
use crate::{token::{Token, MessageType}, builtin::modules::Module};
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ impl LangSpecs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_directives(tokens: &mut VecDeque<Token>) -> LangSpecs {
|
pub fn resolve_directives(tokens: &mut VecDeque<Token>, origin: &String) -> LangSpecs {
|
||||||
let mut specs = LangSpecs::default();
|
let mut specs = LangSpecs::default();
|
||||||
|
|
||||||
for (idx, token) in tokens.iter().enumerate() {
|
for (idx, token) in tokens.iter().enumerate() {
|
||||||
match token {
|
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<String> {
|
||||||
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) {
|
for cap in DIRECTIVE_REGEX.captures_iter(text) {
|
||||||
let mut enumerator = cap.iter().enumerate();
|
let mut enumerator = cap.iter().enumerate();
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn compile(settings: &Settings) -> Option<(Vec<Func>, Vec<Declr>, Vec<BuiltinFun
|
||||||
diagnostics.add_source_origin(code, src.path());
|
diagnostics.add_source_origin(code, src.path());
|
||||||
|
|
||||||
if let Ok(mut tokens) = tokenize(code, &mut diagnostics) {
|
if let Ok(mut tokens) = tokenize(code, &mut diagnostics) {
|
||||||
let specs = crate::direct::resolve_directives(&mut tokens);
|
let specs = crate::direct::resolve_directives(&mut tokens, src.path());
|
||||||
|
|
||||||
// read source of every embedded file and tokenize
|
// read source of every embedded file and tokenize
|
||||||
for (idx, src, path) in specs.embedded_files() {
|
for (idx, src, path) in specs.embedded_files() {
|
||||||
|
|
Loading…
Reference in New Issue