about summary refs log tree commit diff
path: root/src/evaluator.zig
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-03-23 23:57:05 +0100
committerBaitinq <[email protected]>2025-03-24 00:17:07 +0100
commit31fa32743a5ed25724868cfa476e3af028adb118 (patch)
tree97afd19643223af3784baef5c2b57e48467dcce9 /src/evaluator.zig
parentParser: Fix ambiguity with symbol declaration (diff)
downloadinterpreter-31fa32743a5ed25724868cfa476e3af028adb118.tar.gz
interpreter-31fa32743a5ed25724868cfa476e3af028adb118.tar.bz2
interpreter-31fa32743a5ed25724868cfa476e3af028adb118.zip
Feature: Add support for strings
Diffstat (limited to 'src/evaluator.zig')
-rw-r--r--src/evaluator.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/evaluator.zig b/src/evaluator.zig
index fef08a2..f3c0a6c 100644
--- a/src/evaluator.zig
+++ b/src/evaluator.zig
@@ -6,11 +6,12 @@ const EvaluatorError = error{
     OutOfMemory,
 };
 
-const VariableType = enum { NUMBER, BOOLEAN, FUNCTION_DEFINITION };
+const VariableType = enum { NUMBER, BOOLEAN, STRING, FUNCTION_DEFINITION };
 
 const Variable = union(VariableType) {
     NUMBER: i64,
     BOOLEAN: bool,
+    STRING: []const u8,
     FUNCTION_DEFINITION: *parser.Node,
 };
 
@@ -206,6 +207,7 @@ pub const Evaluator = struct {
                 switch (x) {
                     .NUMBER => |number| return self.create_variable(.{ .NUMBER = number.value }),
                     .BOOLEAN => |b| return self.create_variable(.{ .BOOLEAN = b.value }),
+                    .STRING => |s| return self.create_variable(.{ .STRING = s.value }),
                     .IDENTIFIER => |identifier| {
                         const val = self.environment.get_variable(identifier.name) orelse {
                             std.debug.print("Identifier {any} not found\n", .{identifier.name});