Reducer changes

This commit is contained in:
greg 2019-07-12 02:14:39 -07:00
parent 59f5032a61
commit 975951e582

View File

@ -97,15 +97,16 @@ pub enum Func {
struct Reducer<'a> { struct Reducer<'a> {
symbol_table: &'a SymbolTable, symbol_table: &'a SymbolTable,
reduced_ast: ReducedAST,
} }
impl<'a> Reducer<'a> { impl<'a> Reducer<'a> {
fn new(symbol_table: &'a SymbolTable) -> Reducer { fn new(symbol_table: &'a SymbolTable) -> Reducer {
Reducer { symbol_table } Reducer { symbol_table, reduced_ast: ReducedAST(vec![]) }
} }
fn output(&mut self) -> Result<ReducedAST, String> { fn done(self) -> Result<ReducedAST, String> {
Err("yolo".to_string()) 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<ReducedAST, String> { pub fn perform_reduction(mut input: AST, symbol_table: &SymbolTable) -> Result<ReducedAST, String> {
let mut reducer = Reducer::new(symbol_table); let mut reducer = Reducer::new(symbol_table);
let _ = input.visit(&mut reducer).map_err(|e| e.to_string())?; let _ = input.visit(&mut reducer).map_err(|e| e.to_string())?;
reducer.output() reducer.done()
} }
impl AST { impl AST {