Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak committed Sep 19, 2024
1 parent 592228b commit 1bb5c78
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,45 @@ impl Compiler {
optional,
path,
} => {
let import_base = current
let import = current
.path
.parent()
.unwrap()
.join(Self::expand_tilde(&relative.cooked)?)
.lexiclean();

println!("IMPORT: {}", import.display());

let glob_options = glob::MatchOptions {
case_sensitive: true,
require_literal_separator: false,
require_literal_leading_dot: false,
};

let import_paths = glob::glob_with(&import_base.display().to_string(), glob_options);
for import in import_paths {
if import.is_file() {

let import_base_str = import.to_string_lossy();
let has_glob = import_base_str.find('*').is_some();

if has_glob {
let glob_options = glob::MatchOptions {
case_sensitive: true,
require_literal_separator: false,
require_literal_leading_dot: false,
};
let import_paths = glob::glob_with(&import_base_str, glob_options).unwrap();
for import in import_paths {
let import = import.unwrap();

if import.is_file() {
if current.file_path.contains(&import) {
return Err(Error::CircularImport {
current: current.path,
import,
});
}
absolute_paths.push(import.clone());
stack.push(current.import(import, path.offset));
}
}

}




if import.is_file() {
} else if import.is_file() {
if current.file_path.contains(&import) {
return Err(Error::CircularImport {
current: current.path,
import,
});
}
//*absolute = Some(import.clone());
*absolute_paths = vec![import.clone()];
absolute_paths.push(import.clone());
stack.push(current.import(import, path.offset));
} else if !*optional {
return Err(Error::MissingImportFile { path: *path });
Expand Down

0 comments on commit 1bb5c78

Please sign in to comment.