| 1 | const std = @import("std"); |
| 2 | const common = @import("./_common.zig"); |
| 3 | |
| 4 | pub usingnamespace common.Main(struct { |
| 5 | pub const source_file = "SpecialCasing"; |
| 6 | |
| 7 | pub const dest_file = "src/special_casing.zig"; |
| 8 | |
| 9 | pub const dest_header = |
| 10 | \\pub const SpecialCasing = struct { |
| 11 | \\ code: u21, |
| 12 | \\ lower: []const u21, |
| 13 | \\ title: []const u21, |
| 14 | \\ upper: []const u21, |
| 15 | \\ condition: []const u8, |
| 16 | \\}; |
| 17 | \\ |
| 18 | \\pub const data = [_]SpecialCasing{ |
| 19 | \\ |
| 20 | ; |
| 21 | |
| 22 | pub const dest_footer = |
| 23 | \\}; |
| 24 | \\ |
| 25 | ; |
| 26 | |
| 27 | pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !void { |
| 28 | _ = alloc; |
| 29 | const end = std.mem.indexOfScalar(u8, line, '#') orelse line.len; |
| 30 | var it = std.mem.splitSequence(u8, line[0..end], "; "); |
| 31 | |
| 32 | try writer.writeAll(" .{"); |
| 33 | try writer.writeAll(" .code ="); |
| 34 | try common.printCodepoint(writer, it.next().?); |
| 35 | try writer.writeAll(" .lower ="); |
| 36 | try common.printSeq(writer, it.next().?); |
| 37 | try writer.writeAll(" .title ="); |
| 38 | try common.printSeq(writer, it.next().?); |
| 39 | try writer.writeAll(" .upper ="); |
| 40 | try common.printSeq(writer, it.next().?); |
| 41 | try writer.print(" .condition = \"{}\"", .{std.zig.fmtEscapes(it.next().?)}); |
| 42 | try writer.writeAll(" },\n"); |
| 43 | } |
| 44 | }); |