Make ScopeResolver struct
This commit is contained in:
parent
724237545f
commit
cefaeb1180
@ -145,7 +145,8 @@ fn symbol_table(input: ast::AST, handle: &mut Schala, comp: Option<&mut PassDebu
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn scope_resolution(mut input: ast::AST, handle: &mut Schala, com: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
|
fn scope_resolution(mut input: ast::AST, handle: &mut Schala, com: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
|
||||||
let () = crate::scope_resolution::resolve_scopes(&mut input)?;
|
let mut resolver = crate::scope_resolution::ScopeResolver::new();
|
||||||
|
let () = resolver.resolve(&mut input)?;
|
||||||
Ok(input)
|
Ok(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,30 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
|
|
||||||
pub fn resolve_scopes(ast: &mut AST) -> Result<(), String> {
|
pub struct ScopeResolver {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ScopeResolver {
|
||||||
|
pub fn new() -> ScopeResolver {
|
||||||
|
ScopeResolver { }
|
||||||
|
}
|
||||||
|
pub fn resolve(&mut self, ast: &mut AST) -> Result<(), String> {
|
||||||
println!("Resolving scopes - nothing so far!");
|
println!("Resolving scopes - nothing so far!");
|
||||||
for statement in ast.0.iter_mut() {
|
for statement in ast.0.iter_mut() {
|
||||||
match statement.mut_node() {
|
match statement.mut_node() {
|
||||||
Statement::Declaration(ref mut decl) => resolve_decl(decl),
|
Statement::Declaration(ref mut decl) => self.decl(decl),
|
||||||
Statement::ExpressionStatement(ref mut expr) => resolve_expr(expr),
|
Statement::ExpressionStatement(ref mut expr) => self.expr(expr),
|
||||||
}?;
|
}?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_decl(decl: &mut Declaration) -> Result<(), String> {
|
fn decl(&mut self, decl: &mut Declaration) -> Result<(), String> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_expr(expr: &mut Meta<Expression>) -> Result<(), String> {
|
fn expr(&mut self, expr: &mut Meta<Expression>) -> Result<(), String> {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ pub fn start_repl(langs: Vec<Box<dyn ProgrammingLanguageInterface>>) {
|
|||||||
let mut repl = repl::Repl::new(langs);
|
let mut repl = repl::Repl::new(langs);
|
||||||
repl.run_repl();
|
repl.run_repl();
|
||||||
}
|
}
|
||||||
[_, ref filename, _..] => {
|
[_, ref filename, ..] => {
|
||||||
run_noninteractive(filename, langs);
|
run_noninteractive(filename, langs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user