return grouping;
}
- try self.@"error"(self.peek(), "Expect expression.");
+ try self.err(self.peek(), "Expect expression.");
}
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 {
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;
}
} else if (isAlpha(c)) {
try self.identifier();
} else {
- try lox.@"error"(self.line, "Unexpected character.");
+ try lox.scanError(self.line, "Unexpected character.");
},
}
}
}
if (self.isAtEnd()) {
- try lox.@"error"(self.line, "Unterminated string.");
+ try lox.scanError(self.line, "Unterminated string.");
return;
}
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);
}
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 {