Skip to content

Commit 3d87bcb

Browse files
committed
Accept non TTY input
1 parent 6b4c535 commit 3d87bcb

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/bytecode/compiler.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub const Compiler = struct {
4040
errdefer compiler.deinit();
4141

4242
try compiler.compileStatements(statements);
43+
try compiler.emitOp(.@"return", 0);
4344
return program;
4445
}
4546

src/main.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ pub fn main() !void {
112112

113113
if (file_path) |path| {
114114
try runFile(path, ctx, use_interp, allocator);
115+
} else if (!std.posix.isatty(std.posix.STDIN_FILENO)) {
116+
const source = try std.fs.File.stdin().readToEndAlloc(allocator, max_input_size);
117+
defer allocator.free(source);
118+
run(source, ctx, use_interp, allocator);
115119
} else {
116120
try repl(ctx, use_interp, allocator);
117121
}

0 commit comments

Comments
 (0)