about summary refs log tree commit diff
path: root/src/tokenizer.zig
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-01-12 19:47:16 +0100
committerBaitinq <[email protected]>2025-01-12 19:47:32 +0100
commitb08960fa4f3e3c5c45a1b92ec80a82ad02d82c8c (patch)
tree0f9355bd993c6863361bb643397c49140d4428a5 /src/tokenizer.zig
parentEvaluator: Store variables with value instead of reference (diff)
downloadinterpreter-b08960fa4f3e3c5c45a1b92ec80a82ad02d82c8c.tar.gz
interpreter-b08960fa4f3e3c5c45a1b92ec80a82ad02d82c8c.tar.bz2
interpreter-b08960fa4f3e3c5c45a1b92ec80a82ad02d82c8c.zip
Implement "return"
Diffstat (limited to '')
-rw-r--r--src/tokenizer.zig3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/tokenizer.zig b/src/tokenizer.zig
index 20f80cc..aab8aa2 100644
--- a/src/tokenizer.zig
+++ b/src/tokenizer.zig
@@ -8,6 +8,7 @@ pub const TokenType = enum {
     // Keywords
     LET,
     PRINT,
+    RETURN,
 
     // Identifiers
     IDENTIFIER,
@@ -28,6 +29,7 @@ pub const TokenType = enum {
 pub const Token = union(TokenType) {
     LET: void,
     PRINT: void,
+    RETURN: void,
     IDENTIFIER: []u8,
     NUMBER: i64,
     EQUALS: void,
@@ -64,6 +66,7 @@ pub const Tokenizer = struct {
 
         if (std.mem.eql(u8, string, "let")) return Token{ .LET = void{} };
         if (std.mem.eql(u8, string, "print")) return Token{ .PRINT = void{} };
+        if (std.mem.eql(u8, string, "return")) return Token{ .RETURN = void{} };
 
         if (std.fmt.parseInt(i32, string, 10) catch null) |i| return Token{ .NUMBER = i };