fixes for latest zig

- arraylist breaking changes
 - mem.separate => mem.split
 - heap.page_allocator
This commit is contained in:
Luna 2020-04-09 23:51:33 -03:00
parent 8261d202bd
commit 8bb09f1573
2 changed files with 9 additions and 10 deletions

View file

@ -61,15 +61,14 @@ pub const Command = struct {
}
pub fn argAt(self: Command, idx: usize) ![]const u8 {
std.debug.warn("{} {}", .{ idx, self.args.len });
std.debug.warn("{} {}", .{ idx, self.args.items.len });
if (idx > (self.args.len - 1)) {
if (idx > (self.args.items.len - 1)) {
std.debug.warn("Expected argument at index {}\n", .{idx});
return ParseError.ArgRequired;
}
const args = self.args.toSliceConst();
return args[idx];
return self.args.items[idx];
}
pub fn usizeArgAt(self: Command, idx: usize) !usize {
@ -238,8 +237,8 @@ pub const Lang = struct {
}
fn expectAny(self: *Lang, count: usize, args: ArgList) !void {
if (args.len != count) {
self.doError("expected {} arguments, found {}", .{ count, args.len });
if (args.items.len != count) {
self.doError("expected {} arguments, found {}", .{ count, args.items.len });
return error.ArgRequired;
}
}
@ -251,8 +250,8 @@ pub const Lang = struct {
fn expectFloat(self: *Lang, count: usize, args: ArgList) !void {
var i: usize = 0;
if (args.len != count) {
self.doError("expected {} arguments, found {}", .{ count, args.len });
if (args.items.len != count) {
self.doError("expected {} arguments, found {}", .{ count, args.items.len });
return error.ArgRequired;
}
@ -299,7 +298,7 @@ pub const Lang = struct {
}
pub fn parse(self: *Lang, data: []const u8) ParseError!CommandList {
var splitted_it = std.mem.separate(data, ";");
var splitted_it = std.mem.split(data, ";");
try self.fillKeywords();
var cmds = CommandList.init(self.allocator);

View file

@ -169,7 +169,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
}
pub fn main() !void {
const allocator = std.heap.direct_allocator;
const allocator = std.heap.page_allocator;
var lang = langs.Lang.init(allocator);
defer lang.deinit();