add push and list commands
This commit is contained in:
parent
c90590e3b5
commit
058bf8deb9
1 changed files with 10 additions and 8 deletions
18
src/main.zig
18
src/main.zig
|
@ -43,6 +43,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
defer lang.deinit();
|
defer lang.deinit();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
lang.reset();
|
||||||
try stdout.print("> ");
|
try stdout.print("> ");
|
||||||
|
|
||||||
var buffer = try std.Buffer.init(allocator, ""[0..]);
|
var buffer = try std.Buffer.init(allocator, ""[0..]);
|
||||||
|
@ -51,19 +52,20 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
return err;
|
return err;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, line, "push")) {
|
||||||
|
try file.seekTo(0);
|
||||||
|
try printer.printList(cmds, stream);
|
||||||
|
continue;
|
||||||
|
} else if (std.mem.eql(u8, line, "list")) {
|
||||||
|
try printer.printList(cmds, stream);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var cmds_parsed = lang.parse(line) catch |err| {
|
var cmds_parsed = lang.parse(line) catch |err| {
|
||||||
std.debug.warn("repl: error while parsing: {}\n", err);
|
std.debug.warn("repl: error while parsing: {}\n", err);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
try cmds.append(cmds_parsed.at(0));
|
try cmds.append(cmds_parsed.at(0));
|
||||||
|
|
||||||
lang.reset();
|
|
||||||
|
|
||||||
// TODO save the line to scri_file? or should we have a special `push`
|
|
||||||
// to do so?
|
|
||||||
|
|
||||||
try file.seekTo(0);
|
|
||||||
try printer.printList(cmds, stream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue