Compare commits

...

2 Commits

Author SHA1 Message Date
Greg Shuflin
f8924cf65f Remove bx! macro from crate root 2021-10-14 17:42:04 -07:00
Greg Shuflin
ed6360247d rustfmt on error.rs, lib.rs 2021-10-14 16:54:05 -07:00
4 changed files with 17 additions and 16 deletions

View File

@ -1,6 +1,6 @@
use crate::parsing::ParseError;
use crate::schala::{SourceReference, Stage};
use crate::tokenizing::{Token, TokenKind, Location};
use crate::tokenizing::{Location, Token, TokenKind};
use crate::typechecking::TypeError;
pub struct SchalaError {

View File

@ -11,26 +11,21 @@ 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]
mod typechecking;
mod tokenizing;
mod ast;
mod parsing;
mod tokenizing;
#[macro_use]
mod symbol_table;
mod scope_resolution;
mod builtin;
mod reduced_ast;
mod eval;
mod error;
mod eval;
mod reduced_ast;
mod scope_resolution;
mod schala;

View File

@ -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}))

View File

@ -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)