From f8924cf65ffb178d3a3e1afea1c6bc63ff8c2e08 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 14 Oct 2021 17:42:04 -0700 Subject: [PATCH] Remove bx! macro from crate root --- schala-lang/language/src/lib.rs | 6 ------ schala-lang/language/src/parsing/mod.rs | 10 +++++----- schala-lang/language/src/parsing/test.rs | 6 ++++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index b17a174..789d813 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -11,12 +11,6 @@ extern crate schala_repl; extern crate schala_lang_codegen; extern crate derivative; -macro_rules! bx { - ($e:expr) => { - Box::new($e) - }; -} - #[macro_use] mod util; #[macro_use] diff --git a/schala-lang/language/src/parsing/mod.rs b/schala-lang/language/src/parsing/mod.rs index 8c675ad..93e7115 100644 --- a/schala-lang/language/src/parsing/mod.rs +++ b/schala-lang/language/src/parsing/mod.rs @@ -643,7 +643,7 @@ impl Parser { None => unreachable!() }; let rhs = self.precedence_expr(new_precedence)?; - lhs = Expression::new(self.id_store.fresh(), ExpressionKind::BinExp(operation, bx!(lhs), bx!(rhs))); + lhs = Expression::new(self.id_store.fresh(), ExpressionKind::BinExp(operation, Box::new(lhs), Box::new(rhs))); } self.parse_level -= 1; Ok(lhs) @@ -661,7 +661,7 @@ impl Parser { let prefix_op = PrefixOp::from_str(sigil.as_str()).unwrap(); Ok(Expression::new( self.id_store.fresh(), - ExpressionKind::PrefixExp(prefix_op, bx!(expr)) + ExpressionKind::PrefixExp(prefix_op, Box::new(expr)) )) }, _ => self.call_expr() @@ -673,7 +673,7 @@ impl Parser { let mut expr = self.index_expr()?; while let LParen = self.token_handler.peek_kind() { let arguments = delimited!(self, LParen, invocation_argument, Comma, RParen); - expr = Expression::new(self.id_store.fresh(), ExpressionKind::Call { f: bx!(expr), arguments }); //TODO no type anno is incorrect + expr = Expression::new(self.id_store.fresh(), ExpressionKind::Call { f: Box::new(expr), arguments }); //TODO no type anno is incorrect } Ok(expr) @@ -710,7 +710,7 @@ impl Parser { Ok(if let LSquareBracket = self.token_handler.peek_kind() { let indexers = delimited!(self, LSquareBracket, expression, Comma, RSquareBracket); Expression::new(self.id_store.fresh(), ExpressionKind::Index { - indexee: bx!(Expression::new(self.id_store.fresh(), primary.kind)), + indexee: Box::new(Expression::new(self.id_store.fresh(), primary.kind)), indexers, }) } else { @@ -1055,7 +1055,7 @@ impl Parser { self.restrictions.no_struct_literal = true; let x = self.while_cond(); self.restrictions.no_struct_literal = false; - x?.map(|expr| bx!(expr)) + x?.map(|expr| Box::new(expr)) }; let body = self.block()?; Ok(Expression::new(self.id_store.fresh(), WhileExpression {condition, body})) diff --git a/schala-lang/language/src/parsing/test.rs b/schala-lang/language/src/parsing/test.rs index 3d9df00..4575953 100644 --- a/schala-lang/language/src/parsing/test.rs +++ b/schala-lang/language/src/parsing/test.rs @@ -34,6 +34,12 @@ fn make_statement(kind: StatementKind) -> Statement { } } +macro_rules! bx { + ($e:expr) => { + Box::new($e) + }; +} + macro_rules! parse_test { ($string:expr, $correct:expr) => { assert_eq!(parse($string).unwrap(), $correct)