Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Function

depTokenizer

Private Function
std.Build.Cache.DepTokenizer.depTokenizer
fn depTokenizer(input: []const u8, expect: []const u8) !void
  • tokenize input, emit textual representation, and compare to expect

Params

  • input: []const u8
  • expect: []const u8

File

Build/Cache/DepTokenizer.zig:1024
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
fn depTokenizer(input: []const u8, expect: []const u8) !void {
    var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
    const arena = arena_allocator.allocator();
    defer arena_allocator.deinit();

    var it: Tokenizer = .{ .bytes = input };
    var buffer: std.ArrayList(u8) = .empty;
    var resolve_buf: std.ArrayList(u8) = .empty;
    var i: usize = 0;
    while (it.next()) |token| {
        if (i != 0) try buffer.appendSlice(arena, "\n");
        switch (token) {
            .target, .prereq => |bytes| {
                try buffer.appendSlice(arena, @tagName(token));
                try buffer.appendSlice(arena, " = {");
                for (bytes) |b| {
                    try buffer.append(arena, printable_char_tab[b]);
                }
                try buffer.appendSlice(arena, "}");
            },
            .target_must_resolve => {
                try buffer.appendSlice(arena, "target = {");
                try token.resolve(arena, &resolve_buf);
                for (resolve_buf.items) |b| {
                    try buffer.append(arena, printable_char_tab[b]);
                }
                resolve_buf.items.len = 0;
                try buffer.appendSlice(arena, "}");
            },
            .prereq_must_resolve => {
                try buffer.appendSlice(arena, "prereq = {");
                try token.resolve(arena, &resolve_buf);
                for (resolve_buf.items) |b| {
                    try buffer.append(arena, printable_char_tab[b]);
                }
                resolve_buf.items.len = 0;
                try buffer.appendSlice(arena, "}");
            },
            else => {
                try buffer.appendSlice(arena, "ERROR: ");
                try token.printError(arena, &buffer);
                break;
            },
        }
        i += 1;
    }

    if (std.mem.eql(u8, expect, buffer.items)) {
        try testing.expect(true);
        return;
    }

    try testing.expectEqualStrings(expect, buffer.items);
}