all repos — pba-zig @ 7380b30e39aad95714215d2a1bc9b6583168f442

Protobufs But Awesomer as rewritten in Zig

src/main.zig (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
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.items.len});
}