yaml-z

git clone git://git.electrosoup.com/yaml-z
Log | Files | Refs | Submodules

main.zig (1639B)


      1 const std = @import("std");
      2 
      3 const Scanner = @import("Scanner.zig");
      4 const parseFromSlice = @import("static.zig").parseFromSlice;
      5 
      6 const Api = struct {
      7     copyright: []const u8,
      8     name: []const u8,
      9     enum_prefix: i64,
     10     doc: []const u8,
     11 };
     12 
     13 pub fn main() !void {
     14     var gpa = std.heap.GeneralPurposeAllocator(.{}){};
     15     defer _ = gpa.deinit();
     16     const allocator = gpa.allocator();
     17 
     18     const data = try std.fs.cwd().readFileAlloc(
     19         allocator,
     20         "webgpu.yml",
     21         std.math.maxInt(usize),
     22     );
     23     defer allocator.free(data);
     24 
     25     _ = try parseFromSlice(Api, allocator, data, .{});
     26 
     27     //var scanner = Scanner.initCompleteInput(data);
     28     //while (true) {
     29     //    const token = try scanner.next();
     30     //    switch (token) {
     31     //        .string => |s| std.debug.print("string = {s}\n", .{s}),
     32     //        .partial_string => |s| std.debug.print("partial string = {s}\n", .{s}),
     33     //        .partial_string_escaped_1 => |s| std.debug.print("escaped = {x}\n", .{s[0]}),
     34     //        .block_entry => std.debug.print("block entry\n", .{}),
     35     //        .flow_sequence_start => std.debug.print("flow sequence start\n", .{}),
     36     //        .flow_sequence_end => std.debug.print("flow sequence end\n", .{}),
     37     //        .null => std.debug.print("null\n", .{}),
     38     //        .value => std.debug.print(":\n", .{}),
     39     //        .document_end => {
     40     //            std.debug.print("document end\n", .{});
     41     //            break;
     42     //        },
     43     //        else => {
     44     //            std.debug.print("unexpected token returned\n", .{});
     45     //            break;
     46     //        },
     47     //    }
     48     //}
     49 }