fix for latest zig
This commit is contained in:
parent
ff5a532c58
commit
fa47bd7a7e
4 changed files with 11 additions and 12 deletions
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue