Made the frontend for math, actually, completely work.

This commit is contained in:
Goren Barak 2023-12-16 10:02:31 -05:00
parent 77eb521af4
commit 71ed4cea39
3 changed files with 4 additions and 38 deletions

View file

@ -146,7 +146,7 @@ impl std::fmt::Display for Token {
BangEqual => write!(f, "!="),
LessEqual => write!(f, "<="),
GreaterEqual => write!(f, ">="),
String => write!(f, "[string]"),
StringLiteral => write!(f, "string"),
Number(n) => write!(f, "{}", n),
Identifier(i) => write!(f, "{}", i),
True => write!(f, "true"),

View file

@ -16,41 +16,7 @@ macro_rules! arrow {
}
fn main() {
// let fc = fasm_codegen!(
// vec![
// Expr::VarDefinition(VarDefinition {name: "goren", value: Value::Number(10)}),
// Expr::MathExpr(Math {
// left: &Value::Var(VarReference { name: "goren"}),
// right: &Value::Number(17),
// operator: MathOperator::OP_MULT
// }
// ),
// Expr::FunDefinition(FunDefinition {
// name: "adder", contents: vec![
// Expr::MathExpr(
// Math {
// left: &Value::Param(ParamReference {param_number: 0}),
// right: &Value::Param(ParamReference {param_number: 1}),
// operator: MathOperator::OP_ADD
// }
// )
// ]
// }),
// Expr::FunCall(
// FunCall {
// name: "adder",
// params: vec![Value::Var(VarReference {name: "goren"}), Value::Number(6)]
// }
// ),
// Expr::Breakpoint
// ]
// );
// println!("{}", fc);
let parsed = "3*10+5";
let parsed = "3*10+5/5%12";
let mut lexer = Token::lexer(parsed);

View file

@ -43,10 +43,10 @@ pub fn match_operator(token: &Option<Result<Token, ()>>) -> Option<MathOperator>
Minus => Some(MathOperator::OP_SUB),
Slash => Some(MathOperator::OP_DIV),
Star => Some(MathOperator::OP_MULT),
Percent => Some(MathOperator::OP_MOD),
Percent => Some(MathOperator::OP_MOD),
_ => None
};
}
None
}