aboutsummaryrefslogtreecommitdiff
path: root/src/Lexer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Lexer.zig')
-rw-r--r--src/Lexer.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Lexer.zig b/src/Lexer.zig
index 4665379..4b664fe 100644
--- a/src/Lexer.zig
+++ b/src/Lexer.zig
@@ -13,6 +13,7 @@ pub const Token = struct {
plus,
minus,
equal,
+ colon,
invalid,
eof,
identifier,
@@ -22,7 +23,6 @@ pub const Token = struct {
right_angle_equal,
// Keywords
- let,
@"if",
@"else",
@"while",
@@ -34,6 +34,7 @@ pub const Location = struct {
end: usize,
pub fn combine(a: Location, b: Location) Location {
+ if (a.start == b.start and a.end == b.end) return a;
std.debug.assert(a.end <= b.start);
return .{ .start = @min(a.start, b.start), .end = @max(a.end, b.end) };
}
@@ -83,6 +84,7 @@ fn getNext(self: *Self) Token {
'+' => self.create(.plus),
'-' => self.create(.minus),
'=' => self.create(.equal),
+ ':' => self.create(.colon),
'<' => if (self.eatIfEqual('='))
self.create(.left_angle_equal)
else
@@ -135,7 +137,7 @@ fn identifierOrKeyword(self: *Self) Token {
}
const value = self.source[self.start..self.pos];
return self.create(switch (std.meta.stringToEnum(Token.Type, value) orelse .invalid) {
- .let, .@"if", .@"else", .@"while" => |t| t,
+ .@"if", .@"else", .@"while" => |t| t,
else => .identifier,
});
}