From 975951e582aa2210a26b0bac3d889eb7417341d6 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 12 Jul 2019 02:14:39 -0700 Subject: [PATCH] Reducer changes --- schala-lang/language/src/reduced_ast.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 7117394..21fdf25 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -97,15 +97,16 @@ pub enum Func { struct Reducer<'a> { symbol_table: &'a SymbolTable, + reduced_ast: ReducedAST, } impl<'a> Reducer<'a> { fn new(symbol_table: &'a SymbolTable) -> Reducer { - Reducer { symbol_table } + Reducer { symbol_table, reduced_ast: ReducedAST(vec![]) } } - fn output(&mut self) -> Result { - Err("yolo".to_string()) + fn done(self) -> Result { + Ok(self.reduced_ast) } } @@ -116,7 +117,7 @@ impl<'a> ASTVisitor for Reducer<'a> { pub fn perform_reduction(mut input: AST, symbol_table: &SymbolTable) -> Result { let mut reducer = Reducer::new(symbol_table); let _ = input.visit(&mut reducer).map_err(|e| e.to_string())?; - reducer.output() + reducer.done() } impl AST {