Start using ASTVisitor for reduction process
This commit is contained in:
parent
a187d43fc1
commit
74a574b093
@ -3,6 +3,7 @@ use std::rc::Rc;
|
||||
use crate::ast::*;
|
||||
use crate::symbol_table::{Symbol, SymbolSpec, SymbolTable};
|
||||
use crate::builtin::{BinOp, PrefixOp};
|
||||
use crate::visitor::{ASTVisitor, Visitable};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ReducedAST(pub Vec<Stmt>);
|
||||
@ -94,6 +95,30 @@ pub enum Func {
|
||||
}
|
||||
}
|
||||
|
||||
struct Reducer {
|
||||
|
||||
}
|
||||
|
||||
impl Reducer {
|
||||
fn new() -> Reducer {
|
||||
Reducer { }
|
||||
}
|
||||
|
||||
fn output(&mut self) -> Result<ReducedAST, String> {
|
||||
Err("yolo".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl ASTVisitor for Reducer {
|
||||
|
||||
}
|
||||
|
||||
pub fn perform_reduction(mut input: AST, _symbol_table: &SymbolTable) -> Result<ReducedAST, String> {
|
||||
let mut reducer = Reducer::new();
|
||||
input.visit(&mut reducer);
|
||||
reducer.output()
|
||||
}
|
||||
|
||||
impl AST {
|
||||
pub fn reduce(&self, symbol_table: &SymbolTable) -> ReducedAST {
|
||||
let mut output = vec![];
|
||||
|
Loading…
Reference in New Issue
Block a user