From 71ed4cea3994fa146f54649a41af94483f1a3b8c Mon Sep 17 00:00:00 2001 From: Goren Barak Date: Sat, 16 Dec 2023 10:02:31 -0500 Subject: [PATCH] Made the frontend for math, actually, completely work. --- src/lex/tok.rs | 2 +- src/main.rs | 36 +----------------------------------- src/parse/parse.rs | 4 ++-- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/lex/tok.rs b/src/lex/tok.rs index 6758e93..95f934f 100644 --- a/src/lex/tok.rs +++ b/src/lex/tok.rs @@ -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"), diff --git a/src/main.rs b/src/main.rs index b4d6115..f0d216b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); diff --git a/src/parse/parse.rs b/src/parse/parse.rs index 302f33d..808bb21 100644 --- a/src/parse/parse.rs +++ b/src/parse/parse.rs @@ -43,10 +43,10 @@ pub fn match_operator(token: &Option>) -> Option 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 }