Skip to content

Commit

Permalink
WIP globbing
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak committed Sep 17, 2024
1 parent ab7105a commit 4a050ff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ impl<'src> Analyzer<'src> {
assignments.push(assignment);
}
Item::Comment(_) => (),
Item::Import { absolute, .. } => {
if let Some(absolute) = absolute {
stack.push(asts.get(absolute).unwrap());
Item::Import { absolute_paths, .. } => {
for p in absolute_paths {
stack.push(asts.get(p).unwrap());
}
}
Item::Module {
Expand Down
7 changes: 5 additions & 2 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Compiler {
}
Item::Import {
relative,
absolute,
absolute_paths,
optional,
path,
} => {
Expand All @@ -75,14 +75,17 @@ impl Compiler {
.join(Self::expand_tilde(&relative.cooked)?)
.lexiclean();

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

if import.is_file() {
if current.file_path.contains(&import) {
return Err(Error::CircularImport {
current: current.path,
import,
});
}
*absolute = Some(import.clone());
//*absolute = Some(import.clone());
*absolute_paths = vec![import.clone()];
stack.push(current.import(import, path.offset));
} else if !*optional {
return Err(Error::MissingImportFile { path: *path });
Expand Down
2 changes: 1 addition & 1 deletion src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub(crate) enum Item<'src> {
Assignment(Assignment<'src>),
Comment(&'src str),
Import {
absolute: Option<PathBuf>,
absolute_paths: Vec<PathBuf>,
optional: bool,
path: Token<'src>,
relative: StringLiteral<'src>,
Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl<'run, 'src> Parser<'run, 'src> {
let optional = self.accepted(QuestionMark)?;
let (path, relative) = self.parse_string_literal_token()?;
items.push(Item::Import {
absolute: None,
absolute_paths: vec![],
optional,
path,
relative,
Expand Down

0 comments on commit 4a050ff

Please sign in to comment.