src/main.zig (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
const std = @import("std");
const Io = std.Io;
const pba_zig = @import("pba_zig");
const ingest = @import("ingest.zig");
const lex = @import("lex.zig");
pub fn main(init: std.process.Init) !void {
const arena = init.arena.allocator();
const cwd = std.Io.Dir.cwd();
const max_bytes = 10 * 1024 * 1024;
const buf = try cwd.readFileAlloc(init.io, "example.pba", arena, .limited(max_bytes));
defer arena.free(buf);
const tokens = try lex.tokenize(buf, arena);
std.log.info("{d} tokens ingested", .{tokens.items.len});
const protocol = ingest.Protocol.parse(tokens.items, arena);
std.log.info("Protocol '{s}' has MTU {d}", .{ protocol.name, protocol.mtu });
}
|