From 74a574b093613b2d1101302f026ad30f69665b08 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 11 Jul 2019 19:11:54 -0700 Subject: [PATCH] Start using ASTVisitor for reduction process --- schala-lang/language/src/reduced_ast.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 695d771..5737587 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -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); @@ -94,6 +95,30 @@ pub enum Func { } } +struct Reducer { + +} + +impl Reducer { + fn new() -> Reducer { + Reducer { } + } + + fn output(&mut self) -> Result { + Err("yolo".to_string()) + } +} + +impl ASTVisitor for Reducer { + +} + +pub fn perform_reduction(mut input: AST, _symbol_table: &SymbolTable) -> Result { + 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![];