From 2590def3be48d6a2d165def0d3975c1fb439e3f4 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 5 Jan 2019 15:54:03 -0800 Subject: [PATCH] More Node-wrapping --- schala-lang/language/src/ast.rs | 2 +- schala-lang/language/src/parsing.rs | 4 ++-- schala-lang/language/src/reduced_ast.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index 9c65033..9517bd3 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -110,7 +110,7 @@ pub enum ExpressionType { FloatLiteral(f64), StringLiteral(Rc), BoolLiteral(bool), - BinExp(BinOp, Box, Box), + BinExp(BinOp, Box>, Box>), PrefixExp(PrefixOp, Box), TupleLiteral(Vec), Value(Rc), diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index c8fbfc1..8e8b044 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -565,7 +565,7 @@ impl Parser { None => unreachable!() }; let rhs = self.precedence_expr(new_precedence)?; - lhs = Expression(ExpressionType::BinExp(operation, bx!(lhs), bx!(rhs)), None); + lhs = Expression(ExpressionType::BinExp(operation, bx!(lhs.into()), bx!(rhs.into())), None); } self.parse_level -= 1; Ok(lhs) @@ -1158,7 +1158,7 @@ mod parse_tests { } macro_rules! binexp { - ($op:expr, $lhs:expr, $rhs:expr) => { BinExp(BinOp::from_sigil($op), bx!(Expression($lhs, None)), bx!(Expression($rhs, None))) } + ($op:expr, $lhs:expr, $rhs:expr) => { BinExp(BinOp::from_sigil($op), bx!(Expression($lhs, None).into()), bx!(Expression($rhs, None).into())) } } macro_rules! prefexp { ($op:expr, $lhs:expr) => { PrefixExp(PrefixOp::from_sigil($op), bx!(Expression($lhs, None))) } diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 9e032f8..f70821d 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -377,15 +377,15 @@ impl Declaration { } impl BinOp { - fn reduce(&self, symbol_table: &SymbolTable, lhs: &Box, rhs: &Box) -> Expr { + fn reduce(&self, symbol_table: &SymbolTable, lhs: &Box>, rhs: &Box>) -> Expr { if **self.sigil() == "=" { Expr::Assign { - val: Box::new(lhs.reduce(symbol_table)), - expr: Box::new(rhs.reduce(symbol_table)), + val: Box::new(lhs.node().reduce(symbol_table)), + expr: Box::new(rhs.node().reduce(symbol_table)), } } else { let f = Box::new(Expr::Func(Func::BuiltIn(self.sigil().clone()))); - Expr::Call { f, args: vec![lhs.reduce(symbol_table), rhs.reduce(symbol_table)]} + Expr::Call { f, args: vec![lhs.node().reduce(symbol_table), rhs.node().reduce(symbol_table)]} } } }