Remove bx! macro from crate root

This commit is contained in:
Greg Shuflin 2021-10-14 17:42:04 -07:00
parent ed6360247d
commit f8924cf65f
3 changed files with 11 additions and 11 deletions

View File

@ -11,12 +11,6 @@ extern crate schala_repl;
extern crate schala_lang_codegen; extern crate schala_lang_codegen;
extern crate derivative; extern crate derivative;
macro_rules! bx {
($e:expr) => {
Box::new($e)
};
}
#[macro_use] #[macro_use]
mod util; mod util;
#[macro_use] #[macro_use]

View File

@ -643,7 +643,7 @@ impl Parser {
None => unreachable!() None => unreachable!()
}; };
let rhs = self.precedence_expr(new_precedence)?; 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; self.parse_level -= 1;
Ok(lhs) Ok(lhs)
@ -661,7 +661,7 @@ impl Parser {
let prefix_op = PrefixOp::from_str(sigil.as_str()).unwrap(); let prefix_op = PrefixOp::from_str(sigil.as_str()).unwrap();
Ok(Expression::new( Ok(Expression::new(
self.id_store.fresh(), self.id_store.fresh(),
ExpressionKind::PrefixExp(prefix_op, bx!(expr)) ExpressionKind::PrefixExp(prefix_op, Box::new(expr))
)) ))
}, },
_ => self.call_expr() _ => self.call_expr()
@ -673,7 +673,7 @@ impl Parser {
let mut expr = self.index_expr()?; let mut expr = self.index_expr()?;
while let LParen = self.token_handler.peek_kind() { while let LParen = self.token_handler.peek_kind() {
let arguments = delimited!(self, LParen, invocation_argument, Comma, RParen); 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) Ok(expr)
@ -710,7 +710,7 @@ impl Parser {
Ok(if let LSquareBracket = self.token_handler.peek_kind() { Ok(if let LSquareBracket = self.token_handler.peek_kind() {
let indexers = delimited!(self, LSquareBracket, expression, Comma, RSquareBracket); let indexers = delimited!(self, LSquareBracket, expression, Comma, RSquareBracket);
Expression::new(self.id_store.fresh(), ExpressionKind::Index { 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, indexers,
}) })
} else { } else {
@ -1055,7 +1055,7 @@ impl Parser {
self.restrictions.no_struct_literal = true; self.restrictions.no_struct_literal = true;
let x = self.while_cond(); let x = self.while_cond();
self.restrictions.no_struct_literal = false; self.restrictions.no_struct_literal = false;
x?.map(|expr| bx!(expr)) x?.map(|expr| Box::new(expr))
}; };
let body = self.block()?; let body = self.block()?;
Ok(Expression::new(self.id_store.fresh(), WhileExpression {condition, body})) Ok(Expression::new(self.id_store.fresh(), WhileExpression {condition, body}))

View File

@ -34,6 +34,12 @@ fn make_statement(kind: StatementKind) -> Statement {
} }
} }
macro_rules! bx {
($e:expr) => {
Box::new($e)
};
}
macro_rules! parse_test { macro_rules! parse_test {
($string:expr, $correct:expr) => { ($string:expr, $correct:expr) => {
assert_eq!(parse($string).unwrap(), $correct) assert_eq!(parse($string).unwrap(), $correct)