Skip to content

Commit

Permalink
Symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
GoogleFeud committed Nov 25, 2021
1 parent 8234d62 commit 314ab57
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 15 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ edition = "2018"
[dependencies]
parser = { path = "./src/parser" }
errors = { path = "./src/errors" }
file_host = { path = "./src/file_host" }
semantic_analyzer = { path = "./src/semantic_analyzer" }
8 changes: 0 additions & 8 deletions src/file_host/Cargo.toml

This file was deleted.

6 changes: 0 additions & 6 deletions src/file_host/src/lib.rs

This file was deleted.

11 changes: 11 additions & 0 deletions src/semantic_analyzer/src/file_host.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

pub struct Module {

}

pub trait FileHost {
fn get(&mut self, path: String) -> String;
fn exists(&mut self, path: String) -> bool;
fn create(&mut self, path: String, content: String);
fn get_mod(&self, path: String) -> Module;
}
4 changes: 4 additions & 0 deletions src/semantic_analyzer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

pub use parser;
pub mod symbol;
pub mod file_host;
44 changes: 44 additions & 0 deletions src/semantic_analyzer/src/symbol.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

pub use parser::ast::model::*;

pub enum SymbolDeclaration {
Expression(ASTExpression),
Statement(ASTStatement),
Typing(ASTTypings)
}

pub enum SymbolKind {
Struct{
properties: Vec<(String, Symbol)>,
impls: Vec<Symbol>
},
Enum{
members: Vec<(String, Symbol)>,
impls: Vec<Symbol>
},
Fn{
parameters: Vec<(String, Symbol)>,
return_type: Symbol
},
Module{
elements: Vec<Symbol>
}
}

pub struct Symbol {
pub name: String,
pub id: u32,
pub kind: Box<SymbolKind>,
pub type_params: Vec<Symbol>,
pub declaration: Option<SymbolDeclaration>
}

pub struct SymbolInstance {
pub id: u32,
pub type_params: Vec<Symbol>
}

pub struct SymbolAlias {
pub name: String,
pub id: u32
}

0 comments on commit 314ab57

Please sign in to comment.