#[allow(dead_code)] #[derive(Debug, Clone, PartialEq)] pub enum Expression { Literal(Literal), Variable(String), Binary(Box, Operator, Box), Unary(Operator, Box), Grouping(Box), Assignment(String, Box), FunctionCall(Box, Vec), } #[derive(Debug, Clone, PartialEq)] pub enum Literal { Number(f64), String(String), Boolean(bool), Nil, } #[derive(Debug, Clone, PartialEq)] pub enum Operator { // Unary Minus, // For unary negation e.g. -5 Almost, // For unary ~ e.g. ~5 // Binary Plus, // For addition e.g. 5 + 5 // Minus, // Note: We have Minus for unary. We'll reuse it for binary. // Alternatively, you could have BinaryMinus, UnaryMinus. // Reusing is common if context (Expression::Unary vs Expression::Binary) distinguishes them. Multiply, // For multiplication e.g. 5 * 5 Divide, // For division e.g. 5 / 5 Modulus, // For modulus e.g. 5 % 5 // Comparison operators Greater, Less, GreaterEqual, LessEqual, // Logical operators And, // For logical AND e.g. true && false Or, // For logical OR e.g. true || false // Equality (we'll add these logic for these later) EqualEqual, // For equality e.g. 5 == 5 NotEqual, // For inequality e.g. 5 != 5 // AlmostEqual, // For ~= (binary tilde-equal) 🙃 } #[derive(Debug, Clone, PartialEq)] pub enum Statement { ExpressionStatement(Expression), PrintStatement(Expression), VariableDeclaration(String, Option), Block(Vec), IfStatement(Expression, Box, Option>), WhileStatement(Expression, Box), ForStatement(Box, Expression, Box, Box), FunctionDeclaration { name: String, params: Vec, body: Vec, }, ReturnStatement(Option), }