update to latest zig

This commit is contained in:
Luna 2020-07-23 16:38:26 -03:00
parent 38f0b04351
commit c80f887597
4 changed files with 14 additions and 14 deletions

View file

@ -13,15 +13,15 @@ fn printIdent(ident: usize) void {
}
}
fn print(ident: usize, comptime fmt: []const u8, args: var) void {
fn print(ident: usize, comptime fmt: []const u8, args: anytype) void {
printIdent(ident);
std.debug.warn(fmt, args);
}
fn printBlock(ident: usize, block: var, endNewline: bool) void {
fn printBlock(ident: usize, block: anytype, endNewline: bool) void {
std.debug.warn("(\n", .{});
for (block.toSlice()) |stmt| {
for (block.items) |stmt| {
printIdent(ident);
printStmt(ident, stmt);
std.debug.warn("\n", .{});
@ -56,7 +56,7 @@ pub fn printNode(node: *Node, ident: usize) void {
warn("(fn {} {} (", .{ name, ret_type });
}
for (decl.params.toSlice()) |param| {
for (decl.params.items) |param| {
warn("({} {}) ", .{ param.name.lexeme, param.typ.lexeme });
}
@ -67,7 +67,7 @@ pub fn printNode(node: *Node, ident: usize) void {
.ConstDecl => |consts| {
print(ident, "(const (\n", .{});
for (consts.toSlice()) |const_decl| {
for (consts.items) |const_decl| {
print(ident + 1, "({} ", .{
const_decl.name.lexeme,
});
@ -82,7 +82,7 @@ pub fn printNode(node: *Node, ident: usize) void {
.Enum => |decl| {
print(ident, "(enum {} (\n", .{decl.name.lexeme});
for (decl.fields.toSlice()) |field| {
for (decl.fields.items) |field| {
print(ident + 1, "{}\n", .{
field.lexeme,
});
@ -92,7 +92,7 @@ pub fn printNode(node: *Node, ident: usize) void {
},
.Root => {
for (node.Root.toSlice()) |child| {
for (node.Root.items) |child| {
printNode(child, ident + 1);
}
},
@ -105,7 +105,7 @@ pub fn printNode(node: *Node, ident: usize) void {
.Struct => |struc| {
print(ident, "(struct {} (\n", .{struc.name.lexeme});
for (struc.fields.toSlice()) |field| {
for (struc.fields.items) |field| {
printIdent(ident + 1);
if (field.mutable) {
std.debug.warn("(mut ", .{});
@ -157,7 +157,7 @@ pub fn printExpr(expr: *const Expr) void {
.Float => |val| std.debug.warn("{}", .{val}),
.String => |val| std.debug.warn("'{}'", .{val}),
.Array => |exprs| {
parenthetize("array", exprs.toSlice());
parenthetize("array", exprs.items);
},
else => |typ| std.debug.warn("UnknownLiteral-{}", .{typ}),
}
@ -188,7 +188,7 @@ pub fn printExpr(expr: *const Expr) void {
std.debug.warn("(", .{});
printExpr(call.callee);
for (call.arguments.toSlice()) |arg| {
for (call.arguments.items) |arg| {
std.debug.warn(" ", .{});
printExpr(arg);
}
@ -199,7 +199,7 @@ pub fn printExpr(expr: *const Expr) void {
.Struct => |val| {
std.debug.warn("({} (", .{val.name.lexeme});
for (val.inits.toSlice()) |init| {
for (val.inits.items) |init| {
std.debug.warn(" ({} ", .{init.field.lexeme});
printExpr(init.expr);
std.debug.warn(")", .{});

View file

@ -7,7 +7,7 @@ pub fn reportN(line: usize, message: []const u8) void {
report(line, "", message);
}
pub fn reportFmt(line: usize, comptime fmt: []const u8, args: var) void {
pub fn reportFmt(line: usize, comptime fmt: []const u8, args: anytype) void {
std.debug.warn("[line {}] Error", .{line});
std.debug.warn(fmt, args);
std.debug.warn("\n", .{});

View file

@ -43,7 +43,7 @@ pub const Parser = struct {
self.tokens.deinit();
}
fn doError(self: *Parser, comptime fmt: []const u8, args: var) void {
fn doError(self: *Parser, comptime fmt: []const u8, args: anytype) void {
self.hadError = true;
std.debug.warn("parser error at line {}\n\t", .{self.scanner.line});

View file

@ -15,7 +15,7 @@ pub const Runner = struct {
allocator: *Allocator,
stdout: std.fs.File.OutStream,
pub fn init(allocator: *Allocator, stdout: var) Runner {
pub fn init(allocator: *Allocator, stdout: anytype) Runner {
return .{ .allocator = allocator, .stdout = stdout };
}