| 1 | const std = @import("std"); |
| 2 | const common = @import("./_common.zig"); |
| 3 | |
| 4 | pub usingnamespace common.Main(struct { |
| 5 | pub const source_file = "IndicSyllabicCategory"; |
| 6 | |
| 7 | pub const dest_file = "src/indic_syllabic_category.zig"; |
| 8 | |
| 9 | pub const dest_header = |
| 10 | \\const ucd = @import("./lib.zig"); |
| 11 | \\ |
| 12 | \\pub const IndicSyllabicCategory = struct { |
| 13 | \\ code: u21, |
| 14 | \\ category: ucd.IndicSyllabicCategory, |
| 15 | \\}; |
| 16 | \\ |
| 17 | \\pub const data = [_]IndicSyllabicCategory{ |
| 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.tokenizeAny(u8, line, "; "); |
| 29 | |
| 30 | const first = it.next().?; |
| 31 | const next = it.next().?; |
| 32 | |
| 33 | if (std.mem.indexOf(u8, first, "..")) |index| { |
| 34 | const start = try std.fmt.parseInt(u21, first[0..index], 16); |
| 35 | const end = try std.fmt.parseInt(u21, first[index + 2 ..], 16); |
| 36 | var i = start; |
| 37 | while (i <= end) : (i += 1) { |
| 38 | try writer.print(" .{{ .code = 0x{X}, .category = .{s} }},\n", .{ i, next }); |
| 39 | } |
| 40 | } else { |
| 41 | try writer.print(" .{{ .code = 0x{s}, .category = .{s} }},\n", .{ first, next }); |
| 42 | } |
| 43 | } |
| 44 | }); |