| 1 | const std = @import("std"); |
| 2 | const common = @import("./_common.zig"); |
| 3 | |
| 4 | pub usingnamespace common.Main(struct { |
| 5 | pub const source_file = "CJKRadicals"; |
| 6 | |
| 7 | pub const dest_file = "src/cjk_radicals.zig"; |
| 8 | |
| 9 | pub const dest_header = |
| 10 | \\pub const CJKRadical = struct { |
| 11 | \\ number: u8, |
| 12 | \\ simplified: bool, |
| 13 | \\ character: ?u21, |
| 14 | \\ ideograph: u21, |
| 15 | \\}; |
| 16 | \\ |
| 17 | \\pub const data = [_]CJKRadical{ |
| 18 | \\ |
| 19 | ; |
| 20 | |
| 21 | pub const dest_footer = |
| 22 | \\}; |
| 23 | \\ |
| 24 | ; |
| 25 | |
| 26 | pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !void { |
| 27 | _ = alloc; |
| 28 | var it = std.mem.splitSequence(u8, line, "; "); |
| 29 | var n = it.next().?; |
| 30 | const s = std.mem.endsWith(u8, n, "'"); |
| 31 | const c = it.next().?; |
| 32 | const i = it.next().?; |
| 33 | n = std.mem.trimRight(u8, n, "'"); |
| 34 | |
| 35 | try writer.writeAll(" .{"); |
| 36 | try writer.print(" .number = {s},", .{n}); |
| 37 | try writer.print(" .simplified = {},", .{s}); |
| 38 | try writer.writeAll(" .character ="); |
| 39 | if (common.nullify(c)) |res| try common.printCodepoint(writer, res) else try writer.writeAll(" null,"); |
| 40 | try writer.print(" .ideograph = 0x{s}", .{i}); |
| 41 | try writer.writeAll(" },\n"); |
| 42 | } |
| 43 | }); |