summary refs log tree commit diff
path: root/src/evaluator.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/evaluator.zig')
-rw-r--r--src/evaluator.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/evaluator.zig b/src/evaluator.zig
index 9e89fc4..9f8b61f 100644
--- a/src/evaluator.zig
+++ b/src/evaluator.zig
@@ -165,6 +165,13 @@ pub const Evaluator = struct {
                 if (x.addition) return try self.create_variable(.{ .NUMBER = lhs.NUMBER + rhs.NUMBER });
                 return try self.create_variable(.{ .NUMBER = lhs.NUMBER - rhs.NUMBER });
             },
+            .MULTIPLICATIVE_EXPRESSION => |x| {
+                const lhs = try self.get_expression_value(x.lhs) orelse return EvaluatorError.EvaluationError;
+                const rhs = try self.get_expression_value(x.rhs) orelse return EvaluatorError.EvaluationError;
+                std.debug.assert(lhs.* == .NUMBER and rhs.* == .NUMBER);
+                if (x.multiplication) return try self.create_variable(.{ .NUMBER = lhs.NUMBER * rhs.NUMBER });
+                return try self.create_variable(.{ .NUMBER = @divFloor(lhs.NUMBER, rhs.NUMBER) });
+            },
             .UNARY_EXPRESSION => |x| {
                 const val = try self.get_expression_value(x.expression) orelse return EvaluatorError.EvaluationError;
                 std.debug.assert(val.* == .BOOLEAN);