Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v2
- name: Setup Zig
run: |
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-x86_64-linux-0.15.2.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-x86_64-linux-0.16.0.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: check linting
run:
zig fmt --check .
Expand Down
13 changes: 8 additions & 5 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ const build_context = eval_pkg.build_context;
const sema = eval_pkg.sema;
const expect = std.testing.expectEqual;

pub fn main() !void {
pub fn main(init: std.process.Init) !void {
const alloc = std.heap.page_allocator;
const args = try std.process.argsAlloc(alloc);
const io = init.io;

const args = try init.minimal.args.toSlice(alloc);
assert(args.len == 2);

const file_path = args[1];
const file = try std.fs.cwd().openFile(file_path, .{});
defer file.close();
const file = try std.Io.Dir.cwd().openFile(io, file_path, .{});
defer file.close(io);

const MAX_SIZE = 1024 * 1024;

const source_code = try file.readToEndAlloc(alloc, MAX_SIZE);
var file_reader = file.reader(io, &.{});
const source_code = try file_reader.interface.allocRemaining(alloc, .limited(MAX_SIZE));
defer alloc.free(source_code);

var lexer = Lexer.init(source_code, file_path);
Expand Down
Loading