add basic main loop

This commit is contained in:
Luna 2019-09-08 17:27:59 -03:00
parent fc8dcf4583
commit 34d3b12c56
1 changed files with 19 additions and 4 deletions

View File

@ -14,20 +14,35 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
// now have a 'repl' argument right before it. to counteract that, the
// initial repl buffer contains 'load :1' instead.
var buf = langs.CommandList.init(allocator);
defer buf.deinit();
var cmds = langs.CommandList.init(allocator);
defer cmds.deinit();
var loadargs = langs.ArgList.init(allocator);
defer loadargs.deinit();
try loadargs.append(":1");
try buf.append(langs.Command{
try cmds.append(langs.Command{
.command = .Load,
.args = loadargs,
});
// TODO the rest
// TODO start a runner and keep it hot
while (true) {
try stdout.print("> ");
var buffer = try std.Buffer.init(allocator, ""[0..]);
var line = std.io.readLine(&buffer) catch |err| {
if (err == error.EndOfStream) return;
return err;
};
// TODO parse the line through langs.parse, then add the command to cmds
// TODO save the line to scri_file? or should we have a special `push`
// to do so?
}
}
pub fn main() !void {