mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-24 23:41:30 +02:00
lang: remove this attempt
This commit is contained in:
parent
1c6180aabc
commit
eb7806572b
19 changed files with 1 additions and 1885 deletions
|
@ -1,72 +0,0 @@
|
|||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use rowan::ast::{AstNode, AstPtr};
|
||||
|
||||
use self::{
|
||||
error::{Error, WorldCreationError},
|
||||
mod_tree::ModuleTree,
|
||||
namespace::Registry,
|
||||
source_file::SourceFile,
|
||||
};
|
||||
|
||||
mod error;
|
||||
mod mod_tree;
|
||||
mod namespace;
|
||||
mod nodes;
|
||||
mod path;
|
||||
mod source_file;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Loc<T: AstNode> {
|
||||
file: PathBuf,
|
||||
syntax_el: AstPtr<T>,
|
||||
}
|
||||
|
||||
impl<T: AstNode> Loc<T> {
|
||||
pub fn new(file: PathBuf, syntax_el: &T) -> Self {
|
||||
Self {
|
||||
file,
|
||||
syntax_el: AstPtr::new(syntax_el),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file(&self) -> &PathBuf {
|
||||
&self.file
|
||||
}
|
||||
}
|
||||
|
||||
pub struct World {
|
||||
entry_point: PathBuf,
|
||||
files: HashMap<PathBuf, SourceFile>,
|
||||
errors: Vec<Error>,
|
||||
module_tree: ModuleTree,
|
||||
registry: Registry,
|
||||
}
|
||||
|
||||
impl World {
|
||||
pub fn new(entry_point: PathBuf) -> Result<Self, WorldCreationError> {
|
||||
let entry_point = entry_point.canonicalize().unwrap();
|
||||
let source = match std::fs::read_to_string(&entry_point) {
|
||||
Ok(f) => f,
|
||||
Err(e) => return Err(WorldCreationError::FailedToOpenEntryPoint(entry_point, e)),
|
||||
};
|
||||
|
||||
let (src, mut errors) = SourceFile::parse_from(&entry_point, source);
|
||||
|
||||
let (module_tree, mut files, new_errors, registry) =
|
||||
ModuleTree::parse_from_main(&entry_point, &src);
|
||||
errors.extend(new_errors);
|
||||
module_tree.print_tree(&src.tree());
|
||||
dbg!(&errors);
|
||||
|
||||
let _ = files.insert(entry_point.clone(), src);
|
||||
|
||||
Ok(Self {
|
||||
files,
|
||||
entry_point,
|
||||
errors,
|
||||
module_tree,
|
||||
registry,
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue