diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-18 23:34:35 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-18 23:34:35 +0100 |
commit | 90679500271f9d9e19b252ee627a4fc86e147ef6 (patch) | |
tree | 8f8995827dce38bb5a9a57b753178f36935e4c85 /src/evaluator.zig | |
parent | Feature: Add basic support for if statements (diff) | |
download | interpreter-90679500271f9d9e19b252ee627a4fc86e147ef6.tar.gz interpreter-90679500271f9d9e19b252ee627a4fc86e147ef6.tar.bz2 interpreter-90679500271f9d9e19b252ee627a4fc86e147ef6.zip |
Feature: Add support for substraction
Diffstat (limited to 'src/evaluator.zig')
-rw-r--r-- | src/evaluator.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/evaluator.zig b/src/evaluator.zig index ec5df8c..2fc5441 100644 --- a/src/evaluator.zig +++ b/src/evaluator.zig @@ -136,7 +136,8 @@ pub const Evaluator = struct { .ADDITIVE_EXPRESSION => |x| { const lhs = try self.get_expression_value(x.lhs); const rhs = try self.get_expression_value(x.rhs); - return lhs + rhs; + if (x.addition) return lhs + rhs; + return lhs - rhs; }, .PRIMARY_EXPRESSION => |x| { switch (x) { |