]> Repositories - zlox.git/commitdiff
Rename error functions
authorAyo Reis <hey@ayoreis.com>
Wed, 25 Feb 2026 13:13:06 +0000 (13:13 +0000)
committerAyo Reis <hey@ayoreis.com>
Wed, 25 Feb 2026 13:13:06 +0000 (13:13 +0000)
src/Parser.zig
src/Scanner.zig
src/main.zig

index a584c3ff71f7eebcb5abba1c60a106d43fba5311..bcc6ee69ec721ae945afc0a56d667ec54dba8174 100644 (file)
@@ -138,7 +138,7 @@ fn primary(self: *Parser) !*Expr {
         return grouping;
     }
 
-    try self.@"error"(self.peek(), "Expect expression.");
+    try self.err(self.peek(), "Expect expression.");
 }
 
 fn match(self: *Parser, types: []const TokenType) bool {
@@ -155,7 +155,7 @@ fn match(self: *Parser, types: []const TokenType) bool {
 fn consume(self: *Parser, @"type": TokenType, message: []const u8) !Token {
     if (self.check(@"type")) return self.advance();
 
-    try self.@"error"(self.peek(), message);
+    try self.err(self.peek(), message);
 }
 
 fn check(self: *Parser, @"type": TokenType) bool {
@@ -180,8 +180,8 @@ fn previous(self: *Parser) Token {
     return self.tokens[self.current - 1];
 }
 
-fn @"error"(self: *Parser, token: Token, message: []const u8) !noreturn {
-    try lox.parse_error(self.allocator, token, message);
+fn err(self: *Parser, token: Token, message: []const u8) !noreturn {
+    try lox.parseError(self.allocator, token, message);
     return error.ParseError;
 }
 
index 98fc69e1a5c6626a42e3a726b8fb29e6c3bc1d89..6890df6093246d4dc6682f776a4070b23e959595 100644 (file)
@@ -87,7 +87,7 @@ fn scanToken(self: *Scanner) !void {
         } else if (isAlpha(c)) {
             try self.identifier();
         } else {
-            try lox.@"error"(self.line, "Unexpected character.");
+            try lox.scanError(self.line, "Unexpected character.");
         },
     }
 }
@@ -120,7 +120,7 @@ fn string(self: *Scanner) !void {
     }
 
     if (self.isAtEnd()) {
-        try lox.@"error"(self.line, "Unterminated string.");
+        try lox.scanError(self.line, "Unterminated string.");
         return;
     }
 
index 0e41f10eef16372fddbe6e825628bd0146a8f167..a17dbd73fe1b6e874ef360d0b4795c5b1b1220a9 100644 (file)
@@ -71,7 +71,7 @@ fn run(allocator: Allocator, source: []const u8) !void {
     std.debug.print("{s}\n", .{printed});
 }
 
-pub fn @"error"(line: u32, message: []const u8) !void {
+pub fn scanError(line: u32, message: []const u8) !void {
     try report(line, "", message);
 }
 
@@ -85,7 +85,7 @@ fn report(line: u32, where: []const u8, message: []const u8) !void {
     hadError = true;
 }
 
-pub fn parse_error(allocator: Allocator, token: Token, message: []const u8) !void {
+pub fn parseError(allocator: Allocator, token: Token, message: []const u8) !void {
     if (token.type == .eof) {
         try report(token.line, " at end", message);
     } else {