fixes for latest zig
- arraylist breaking changes - mem.separate => mem.split - heap.page_allocator
This commit is contained in:
parent
8261d202bd
commit
8bb09f1573
2 changed files with 9 additions and 10 deletions
17
src/lang.zig
17
src/lang.zig
|
@ -61,15 +61,14 @@ pub const Command = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn argAt(self: Command, idx: usize) ![]const u8 {
|
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});
|
std.debug.warn("Expected argument at index {}\n", .{idx});
|
||||||
return ParseError.ArgRequired;
|
return ParseError.ArgRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = self.args.toSliceConst();
|
return self.args.items[idx];
|
||||||
return args[idx];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn usizeArgAt(self: Command, idx: usize) !usize {
|
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 {
|
fn expectAny(self: *Lang, count: usize, args: ArgList) !void {
|
||||||
if (args.len != count) {
|
if (args.items.len != count) {
|
||||||
self.doError("expected {} arguments, found {}", .{ count, args.len });
|
self.doError("expected {} arguments, found {}", .{ count, args.items.len });
|
||||||
return error.ArgRequired;
|
return error.ArgRequired;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,8 +250,8 @@ pub const Lang = struct {
|
||||||
fn expectFloat(self: *Lang, count: usize, args: ArgList) !void {
|
fn expectFloat(self: *Lang, count: usize, args: ArgList) !void {
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
|
|
||||||
if (args.len != count) {
|
if (args.items.len != count) {
|
||||||
self.doError("expected {} arguments, found {}", .{ count, args.len });
|
self.doError("expected {} arguments, found {}", .{ count, args.items.len });
|
||||||
return error.ArgRequired;
|
return error.ArgRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +298,7 @@ pub const Lang = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(self: *Lang, data: []const u8) ParseError!CommandList {
|
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();
|
try self.fillKeywords();
|
||||||
var cmds = CommandList.init(self.allocator);
|
var cmds = CommandList.init(self.allocator);
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
const allocator = std.heap.direct_allocator;
|
const allocator = std.heap.page_allocator;
|
||||||
|
|
||||||
var lang = langs.Lang.init(allocator);
|
var lang = langs.Lang.init(allocator);
|
||||||
defer lang.deinit();
|
defer lang.deinit();
|
||||||
|
|
Loading…
Reference in a new issue