Make ScopeResolver struct

This commit is contained in:
greg 2019-09-03 02:59:19 -07:00
parent 724237545f
commit cefaeb1180
3 changed files with 27 additions and 16 deletions

View File

@ -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> {
let () = crate::scope_resolution::resolve_scopes(&mut input)?;
let mut resolver = crate::scope_resolution::ScopeResolver::new();
let () = resolver.resolve(&mut input)?;
Ok(input)
}

View File

@ -1,20 +1,30 @@
use crate::ast::*;
pub fn resolve_scopes(ast: &mut AST) -> Result<(), String> {
println!("Resolving scopes - nothing so far!");
for statement in ast.0.iter_mut() {
match statement.mut_node() {
Statement::Declaration(ref mut decl) => resolve_decl(decl),
Statement::ExpressionStatement(ref mut expr) => resolve_expr(expr),
}?;
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!");
for statement in ast.0.iter_mut() {
match statement.mut_node() {
Statement::Declaration(ref mut decl) => self.decl(decl),
Statement::ExpressionStatement(ref mut expr) => self.expr(expr),
}?;
}
Ok(())
}
Ok(())
}
fn resolve_decl(decl: &mut Declaration) -> Result<(), String> {
Ok(())
}
fn decl(&mut self, decl: &mut Declaration) -> Result<(), String> {
Ok(())
}
fn expr(&mut self, expr: &mut Meta<Expression>) -> Result<(), String> {
Ok(())
}
fn resolve_expr(expr: &mut Meta<Expression>) -> Result<(), String> {
Ok(())
}

View File

@ -45,7 +45,7 @@ pub fn start_repl(langs: Vec<Box<dyn ProgrammingLanguageInterface>>) {
let mut repl = repl::Repl::new(langs);
repl.run_repl();
}
[_, ref filename, _..] => {
[_, ref filename, ..] => {
run_noninteractive(filename, langs);
}
};