| 1 | const std = @import("std"); |
| 2 | const common = @import("./_common.zig"); |
| 3 | |
| 4 | pub usingnamespace common.Main(struct { |
| 5 | pub const source_file = "Blocks"; |
| 6 | |
| 7 | pub const dest_file = "src/blocks.zig"; |
| 8 | |
| 9 | pub const dest_header = |
| 10 | \\pub const Block = struct { |
| 11 | \\ from: u21, |
| 12 | \\ to: u21, |
| 13 | \\ name: []const u8, |
| 14 | \\}; |
| 15 | \\ |
| 16 | \\pub const data = [_]Block{ |
| 17 | \\ |
| 18 | ; |
| 19 | |
| 20 | pub const dest_footer = |
| 21 | \\}; |
| 22 | \\ |
| 23 | ; |
| 24 | |
| 25 | pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !void { |
| 26 | _ = alloc; |
| 27 | |
| 28 | var it1 = std.mem.splitSequence(u8, line, "; "); |
| 29 | var it2 = std.mem.splitSequence(u8, it1.next().?, ".."); |
| 30 | const from = it2.next().?; |
| 31 | const to = it2.next().?; |
| 32 | const name = it1.next().?; |
| 33 | |
| 34 | try writer.print(" .{{ .from = 0x{s}, .to = 0x{s}, .name = \"{s}\" }},\n", .{ from, to, name }); |
| 35 | } |
| 36 | }); |