From 34d3b12c56a6d49a9cd30e344769af2c6e5f0d7a Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 8 Sep 2019 17:27:59 -0300 Subject: [PATCH] add basic main loop --- src/main.zig | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main.zig b/src/main.zig index 4211446..fe3ce9a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -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 {