From cefaeb1180ec2e815a61ff16cbf41e83364cf5ff Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 3 Sep 2019 02:59:19 -0700 Subject: [PATCH] Make ScopeResolver struct --- schala-lang/language/src/schala.rs | 3 +- schala-lang/language/src/scope_resolution.rs | 38 ++++++++++++-------- schala-repl/src/lib.rs | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/schala-lang/language/src/schala.rs b/schala-lang/language/src/schala.rs index 6dc3747..a3f41cd 100644 --- a/schala-lang/language/src/schala.rs +++ b/schala-lang/language/src/schala.rs @@ -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 { - let () = crate::scope_resolution::resolve_scopes(&mut input)?; + let mut resolver = crate::scope_resolution::ScopeResolver::new(); + let () = resolver.resolve(&mut input)?; Ok(input) } diff --git a/schala-lang/language/src/scope_resolution.rs b/schala-lang/language/src/scope_resolution.rs index 8eee33a..c396b86 100644 --- a/schala-lang/language/src/scope_resolution.rs +++ b/schala-lang/language/src/scope_resolution.rs @@ -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) -> Result<(), String> { + Ok(()) + } -fn resolve_expr(expr: &mut Meta) -> Result<(), String> { - Ok(()) } diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index 579d811..69f6c1d 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -45,7 +45,7 @@ pub fn start_repl(langs: Vec>) { let mut repl = repl::Repl::new(langs); repl.run_repl(); } - [_, ref filename, _..] => { + [_, ref filename, ..] => { run_noninteractive(filename, langs); } };