SymbolTable in reducer

This commit is contained in:
greg 2019-07-12 02:11:24 -07:00
parent b0dd1a6527
commit 59f5032a61

View File

@ -95,13 +95,13 @@ pub enum Func {
} }
} }
struct Reducer { struct Reducer<'a> {
symbol_table: &'a SymbolTable,
} }
impl Reducer { impl<'a> Reducer<'a> {
fn new() -> Reducer { fn new(symbol_table: &'a SymbolTable) -> Reducer {
Reducer { } Reducer { symbol_table }
} }
fn output(&mut self) -> Result<ReducedAST, String> { fn output(&mut self) -> Result<ReducedAST, String> {
@ -109,12 +109,12 @@ impl Reducer {
} }
} }
impl ASTVisitor for Reducer { 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(); 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.output()
} }