diff options
Diffstat (limited to 'src/evaluator.zig')
-rw-r--r-- | src/evaluator.zig | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/evaluator.zig b/src/evaluator.zig index f35956a..c1997f3 100644 --- a/src/evaluator.zig +++ b/src/evaluator.zig @@ -144,6 +144,11 @@ 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 }); }, + .UNARY_EXPRESSION => |x| { + const val = try self.get_expression_value(x.expression) orelse return EvaluatorError.EvaluationError; + std.debug.assert(val.* == .BOOLEAN); + return try self.create_variable(.{ .BOOLEAN = !val.BOOLEAN }); + }, .EQUALITY_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; |