diff --git a/src/ast_printer.zig b/src/ast_printer.zig index ae1a9b7..a1fc7ea 100644 --- a/src/ast_printer.zig +++ b/src/ast_printer.zig @@ -14,9 +14,9 @@ fn parenthesize(name: []const u8, exprs: []*ast.Expr) void { pub fn printAst(ast_expr: *ast.Expr) void { switch (ast_expr.*) { - .Binary => |expr| parenthesize(expr.operator.lexeme, &[]*ast.Expr{ expr.left, expr.right }), - .Grouping => |expr| parenthesize("group", &[]*ast.Expr{expr.expression}), - .Unary => |expr| parenthesize(expr.operator.lexeme, &[]*ast.Expr{expr.right}), + .Binary => |expr| parenthesize(expr.operator.lexeme, &[_]*ast.Expr{ expr.left, expr.right }), + .Grouping => |expr| parenthesize("group", &[_]*ast.Expr{expr.expression}), + .Unary => |expr| parenthesize(expr.operator.lexeme, &[_]*ast.Expr{expr.right}), .Number => |ast_num| { switch (ast_num) { .Integer32 => |num| std.debug.warn("{}", num), diff --git a/src/main.zig b/src/main.zig index 96c4c58..bc07abc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -67,8 +67,7 @@ fn runPrompt(allocator: *Allocator) !void { } pub fn main() anyerror!void { - var da = std.heap.DirectAllocator.init(); - var arena = std.heap.ArenaAllocator.init(&da.allocator); + var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); defer arena.deinit(); var allocator = &arena.allocator; diff --git a/src/parser.zig b/src/parser.zig index 2e84369..127a34d 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -108,7 +108,7 @@ pub const Parser = struct { fn equality(self: *Parser) !Expr { var expr = try self.comparison(); - while (self.match(&[]TokenType{ TokenType.BangEqual, TokenType.EqualEqual })) { + while (self.match(&[_]TokenType{ TokenType.BangEqual, TokenType.EqualEqual })) { var operator = self.previous(); var right = try self.comparison(); @@ -121,7 +121,7 @@ pub const Parser = struct { fn comparison(self: *Parser) !Expr { var expr = try self.addition(); - while (self.match(&[]TokenType{ + while (self.match(&[_]TokenType{ TokenType.Greater, TokenType.GreaterEqual, TokenType.Less, @@ -138,7 +138,7 @@ pub const Parser = struct { fn addition(self: *Parser) !Expr { var expr = try self.multiplication(); - while (self.match(&[]TokenType{ TokenType.Minus, TokenType.Plus })) { + while (self.match(&[_]TokenType{ TokenType.Minus, TokenType.Plus })) { var operator = self.previous(); var right = try self.multiplication(); expr = ast.mkBinary(&expr, operator, &right); @@ -150,7 +150,7 @@ pub const Parser = struct { fn multiplication(self: *Parser) anyerror!Expr { var expr = try self.unary(); - while (self.match(&[]TokenType{ TokenType.Slash, TokenType.Star })) { + while (self.match(&[_]TokenType{ TokenType.Slash, TokenType.Star })) { var operator = self.previous(); var right = try self.unary(); expr = ast.mkBinary(&expr, operator, &right); @@ -160,7 +160,7 @@ pub const Parser = struct { } fn unary(self: *Parser) anyerror!Expr { - if (self.match(&[]TokenType{ TokenType.Bang, TokenType.Minus })) { + if (self.match(&[_]TokenType{ TokenType.Bang, TokenType.Minus })) { var operator = self.previous(); var right = try self.unary(); return ast.mkUnary(operator, &right); diff --git a/src/scanner.zig b/src/scanner.zig index 94faf6b..491f1f2 100644 --- a/src/scanner.zig +++ b/src/scanner.zig @@ -24,7 +24,7 @@ fn isAlphaNumeric(char: u8) bool { return isAlpha(char) or isDigit(char); } -const keywords = [][]const u8{ +const keywords = [_][]const u8{ "break", "const", "continue", @@ -51,7 +51,7 @@ const keywords = [][]const u8{ "None", }; -const keyword_ttypes = []TokenType{ +const keyword_ttypes = [_]TokenType{ .Break, .Const, .Continue,