qL#t-*@_;upT6@Nc1)THoi@?TbXf#gf@7hh9^HB|5kcH;#tb%x>_8L^C1l|L}l
zH0DwK8_B;>;nl<|6~2vleT@ITpdE?A+){68@I$51F7lgPp*gQi>WD8;_yOXb2^{Ai
z`KQ3xQ=@Gfdz4VXSTp%^+#$meKh6-(S9m9JUEvoc_u&Qk72zrsG$_0$&Lic4AeXPi
z)9ZeQ{Y(h2UueZlXqwPUjG!0Ao&qsZCzCEsUZG1922y=7(^?F=S4b-c>GTO{^oe*E
zjk@Vb{X)k&%^wyz7RpC2su*#y4CvL01u{I*FIV(RNk*v!gjb3fNYzNy,
) -> Result<(GlobalDefinitionTable, HashMap), WErr> {
let mut global_table = GlobalDefinitionTable::new();
+
register_builtin(&mut global_table);
let unprocessed_functions = resolve_names(ast, &mut global_table)?;
diff --git a/src/root/parser/parse.rs b/src/root/parser/parse.rs
index 9a95fb1..eb61ed4 100644
--- a/src/root/parser/parse.rs
+++ b/src/root/parser/parse.rs
@@ -35,7 +35,8 @@ pub fn parse(path_storage: &mut PathStorage) -> Result, WErr
let base = Span::new_extra(&text, file_id);
- let (after_use, new_files) = handle_error(parse_imports(base, path_storage, file_id), path_storage)?;
+ let (after_use, new_files) =
+ handle_error(parse_imports(base, path_storage, file_id), path_storage)?;
path_queue.extend(new_files);
let res = parse_toplevel::parse_toplevel(after_use);
diff --git a/src/root/parser/parse_imports.rs b/src/root/parser/parse_imports.rs
index 26a3078..897a5b6 100644
--- a/src/root/parser/parse_imports.rs
+++ b/src/root/parser/parse_imports.rs
@@ -44,7 +44,7 @@ pub fn parse_imports<'a>(
}
let (_, ids) = path_storage.get_id_and_add_to_file(current_file, is_use, path)?;
-
+
for id in ids {
found_paths.push((id, Location::from_span(&path)));
}
diff --git a/src/root/parser/path_storage.rs b/src/root/parser/path_storage.rs
index 0c69666..ddd5604 100644
--- a/src/root/parser/path_storage.rs
+++ b/src/root/parser/path_storage.rs
@@ -1,11 +1,11 @@
-use std::collections::HashMap;
-use std::fs;
use crate::root::errors::parser_errors::create_custom_error;
use crate::root::errors::WErr;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::utils::identify_first_last::IdentifyLast;
use nom::character::complete::anychar;
use nom::InputTake;
+use std::collections::HashMap;
+use std::fs;
#[derive(Hash, Copy, Clone, Debug, Eq, PartialEq)]
pub struct FileID(usize);
@@ -52,7 +52,9 @@ pub struct PathStorage {
impl PathStorage {
pub fn new(main: &str) -> Result {
// TODO: Only allow certain characters in base
- if !main.ends_with(".why") { todo!() }
+ if !main.ends_with(".why") {
+ todo!()
+ }
let main = &main[..main.len() - ".why".len()];
let mut folders = vec![CodeFolder::root()];
@@ -195,24 +197,38 @@ impl PathStorage {
if is_folder {
let folder = self.add_folder(section, current);
if !is_use {
- self.get_file_mut(current_file).imported_folders.push(folder);
+ self.get_file_mut(current_file)
+ .imported_folders
+ .push(folder);
}
let folder_path = self.reconstruct_folder(folder);
let mut new_files = Vec::new();
- let Ok(subpaths) = fs::read_dir(folder_path) else { todo!() };
+ let Ok(subpaths) = fs::read_dir(folder_path) else {
+ todo!()
+ };
for path in subpaths {
let Ok(path) = path else { todo!() };
let Ok(t) = path.file_type() else { todo!() };
- if !t.is_file() { continue; }
+ if !t.is_file() {
+ continue;
+ }
let path = path.path();
- if !path.extension().and_then(|e| e.to_str()).is_some_and(|e| e == "why") {
+ if !path
+ .extension()
+ .and_then(|e| e.to_str())
+ .is_some_and(|e| e == "why")
+ {
continue;
}
- let Some(name) = path.file_stem().and_then(|f| f.to_str()) else { todo!() };
+ let Some(name) = path.file_stem().and_then(|f| f.to_str()) else {
+ todo!()
+ };
let (file, is_new) = self.add_file(name, folder);
- if is_new { new_files.push(file); }
+ if is_new {
+ new_files.push(file);
+ }
if is_use {
self.get_file_mut(current_file).imported_files.push(file);
}
@@ -235,7 +251,7 @@ impl PathStorage {
Ok(((), vec![file]))
} else {
Ok(((), vec![]))
- }
+ };
}
} else {
current = self.add_folder(section, current);