From b967fa1911eafd4d5ba591b0dbba4f3ada278fb0 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 7 Nov 2019 02:42:17 -0800 Subject: [PATCH] to_repl() doesn't need symbol table handle --- schala-lang/language/src/eval.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index f97add4..7f1949b 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -69,12 +69,12 @@ fn paren_wrapped_vec(terms: impl Iterator) -> String { impl Node { - fn to_repl(&self, symbol_table: &SymbolTable) -> String { + fn to_repl(&self) -> String { match self { - Node::Expr(e) => e.to_repl(symbol_table), + Node::Expr(e) => e.to_repl(), Node::PrimObject { name, items, .. } if items.len() == 0 => format!("{}", name), - Node::PrimObject { name, items, .. } => format!("{}{}", name, paren_wrapped_vec(items.iter().map(|x| x.to_repl(symbol_table)))), - Node::PrimTuple { items } => format!("{}", paren_wrapped_vec(items.iter().map(|x| x.to_repl(symbol_table)))), + Node::PrimObject { name, items, .. } => format!("{}{}", name, paren_wrapped_vec(items.iter().map(|x| x.to_repl()))), + Node::PrimTuple { items } => format!("{}", paren_wrapped_vec(items.iter().map(|x| x.to_repl()))), } } fn is_true(&self) -> bool { @@ -99,12 +99,10 @@ impl Expr { fn to_node(self) -> Node { Node::Expr(self) } - fn to_repl(&self, symbol_table: &SymbolTable) -> String { + fn to_repl(&self) -> String { use self::Lit::*; use self::Func::*; - let _ = symbol_table; - match self { Expr::Lit(ref l) => match l { Nat(n) => format!("{}", n), @@ -121,7 +119,7 @@ impl Expr { Expr::Constructor { type_name, arity, .. } => { format!("", type_name, arity) }, - Expr::Tuple(exprs) => paren_wrapped_vec(exprs.iter().map(|x| x.to_repl(symbol_table))), + Expr::Tuple(exprs) => paren_wrapped_vec(exprs.iter().map(|x| x.to_repl())), _ => format!("{:?}", self), } } @@ -156,8 +154,7 @@ impl<'a> State<'a> { for statement in ast.0 { match self.statement(statement) { Ok(Some(ref output)) if repl => { - let ref symbol_table = self.symbol_table_handle.borrow(); - acc.push(Ok(output.to_repl(symbol_table))) + acc.push(Ok(output.to_repl())) }, Ok(_) => (), Err(error) => { @@ -342,13 +339,11 @@ impl<'a> State<'a> { /* builtin functions */ (IOPrint, &[ref anything]) => { - let ref symbol_table = self.symbol_table_handle.borrow(); - print!("{}", anything.to_repl(symbol_table)); + print!("{}", anything.to_repl()); Expr::Unit.to_node() }, (IOPrintLn, &[ref anything]) => { - let ref symbol_table = self.symbol_table_handle.borrow(); - println!("{}", anything.to_repl(symbol_table)); + println!("{}", anything.to_repl()); Expr::Unit.to_node() }, (IOGetLine, &[]) => {