zig/src-self-hosted/main.zig

40 lines
767 B
Zig
Raw Normal View History

2017-10-24 22:08:20 +08:00
const builtin = @import("builtin");
2017-10-22 05:31:06 +08:00
const io = @import("std").io;
const os = @import("std").os;
const heap = @import("std").heap;
2017-12-05 11:05:27 +08:00
const warn = @import("std").debug.warn;
2017-10-22 05:31:06 +08:00
2017-12-05 11:05:27 +08:00
const Token = struct {
2017-10-22 05:31:06 +08:00
2017-12-05 11:05:27 +08:00
};
2017-10-24 22:08:20 +08:00
2017-12-05 11:05:27 +08:00
const Tokenizer = struct {
pub fn next() -> Token {
2017-10-22 05:31:06 +08:00
}
2017-12-05 11:05:27 +08:00
};
2017-10-22 05:31:06 +08:00
2017-12-05 11:05:27 +08:00
pub fn main() -> %void {
main2() %% |err| {
warn("{}\n", @errorName(err));
2017-10-22 05:31:06 +08:00
return err;
};
2017-12-05 11:05:27 +08:00
}
pub fn main2() -> %void {
var incrementing_allocator = %return heap.IncrementingAllocator.init(10 * 1024 * 1024);
2017-10-22 05:31:06 +08:00
defer incrementing_allocator.deinit();
const allocator = &incrementing_allocator.allocator;
2017-10-24 22:08:20 +08:00
2017-12-05 11:05:27 +08:00
const target_file = "input.zig"; // TODO
2017-10-24 22:08:20 +08:00
2017-12-05 11:05:27 +08:00
const target_file_buf = %return io.readFileAlloc(target_file, allocator);
2017-10-22 05:31:06 +08:00
2017-12-05 11:05:27 +08:00
warn("{}", target_file_buf);
2017-10-22 05:31:06 +08:00
}