| 1 | const std = @import("std"); |
| 2 | const common = @import("./_common.zig"); |
| 3 | |
| 4 | pub usingnamespace common.Main(struct { |
| 5 | pub const source_file = "ArabicShaping"; |
| 6 | |
| 7 | pub const dest_file = "src/arabic_shaping.zig"; |
| 8 | |
| 9 | pub const dest_header = |
| 10 | \\pub const Shaping = struct { |
| 11 | \\ codepoint: u21, |
| 12 | \\ schematic_name: []const u8, |
| 13 | \\ joining_type: Joining.Type, |
| 14 | \\ joining_group: Joining.Group, |
| 15 | \\}; |
| 16 | \\ |
| 17 | \\pub const Joining = struct { |
| 18 | \\ pub const Type = enum { |
| 19 | \\ U, |
| 20 | \\ D, |
| 21 | \\ R, |
| 22 | \\ C, |
| 23 | \\ T, |
| 24 | \\ L, |
| 25 | \\ }; |
| 26 | \\ |
| 27 | \\ pub const Group = enum { |
| 28 | \\ No_Joining_Group, |
| 29 | \\ YEH, |
| 30 | \\ ALEF, |
| 31 | \\ WAW, |
| 32 | \\ BEH, |
| 33 | \\ TEH_MARBUTA, |
| 34 | \\ HAH, |
| 35 | \\ DAL, |
| 36 | \\ REH, |
| 37 | \\ SEEN, |
| 38 | \\ SAD, |
| 39 | \\ TAH, |
| 40 | \\ AIN, |
| 41 | \\ GAF, |
| 42 | \\ FARSI_YEH, |
| 43 | \\ FEH, |
| 44 | \\ QAF, |
| 45 | \\ KAF, |
| 46 | \\ LAM, |
| 47 | \\ MEEM, |
| 48 | \\ NOON, |
| 49 | \\ HEH, |
| 50 | \\ SWASH_KAF, |
| 51 | \\ NYA, |
| 52 | \\ KNOTTED_HEH, |
| 53 | \\ HEH_GOAL, |
| 54 | \\ TEH_MARBUTA_GOAL, |
| 55 | \\ YEH_WITH_TAIL, |
| 56 | \\ YEH_BARREE, |
| 57 | \\ ALAPH, |
| 58 | \\ BETH, |
| 59 | \\ GAMAL, |
| 60 | \\ DALATH_RISH, |
| 61 | \\ HE, |
| 62 | \\ SYRIAC_WAW, |
| 63 | \\ ZAIN, |
| 64 | \\ HETH, |
| 65 | \\ TETH, |
| 66 | \\ YUDH, |
| 67 | \\ YUDH_HE, |
| 68 | \\ KAPH, |
| 69 | \\ LAMADH, |
| 70 | \\ MIM, |
| 71 | \\ NUN, |
| 72 | \\ SEMKATH, |
| 73 | \\ FINAL_SEMKATH, |
| 74 | \\ E, |
| 75 | \\ PE, |
| 76 | \\ REVERSED_PE, |
| 77 | \\ SADHE, |
| 78 | \\ QAPH, |
| 79 | \\ SHIN, |
| 80 | \\ TAW, |
| 81 | \\ ZHAIN, |
| 82 | \\ KHAPH, |
| 83 | \\ FE, |
| 84 | \\ BURUSHASKI_YEH_BARREE, |
| 85 | \\ MALAYALAM_NGA, |
| 86 | \\ MALAYALAM_JA, |
| 87 | \\ MALAYALAM_NYA, |
| 88 | \\ MALAYALAM_TTA, |
| 89 | \\ MALAYALAM_NNA, |
| 90 | \\ MALAYALAM_NNNA, |
| 91 | \\ MALAYALAM_BHA, |
| 92 | \\ MALAYALAM_RA, |
| 93 | \\ MALAYALAM_LLA, |
| 94 | \\ MALAYALAM_LLLA, |
| 95 | \\ MALAYALAM_SSA, |
| 96 | \\ ROHINGYA_YEH, |
| 97 | \\ STRAIGHT_WAW, |
| 98 | \\ AFRICAN_FEH, |
| 99 | \\ AFRICAN_QAF, |
| 100 | \\ AFRICAN_NOON, |
| 101 | \\ MANICHAEAN_ALEPH, |
| 102 | \\ MANICHAEAN_BETH, |
| 103 | \\ MANICHAEAN_GIMEL, |
| 104 | \\ MANICHAEAN_DALETH, |
| 105 | \\ MANICHAEAN_WAW, |
| 106 | \\ MANICHAEAN_ZAYIN, |
| 107 | \\ MANICHAEAN_HETH, |
| 108 | \\ MANICHAEAN_TETH, |
| 109 | \\ MANICHAEAN_YODH, |
| 110 | \\ MANICHAEAN_KAPH, |
| 111 | \\ MANICHAEAN_LAMEDH, |
| 112 | \\ MANICHAEAN_DHAMEDH, |
| 113 | \\ MANICHAEAN_THAMEDH, |
| 114 | \\ MANICHAEAN_MEM, |
| 115 | \\ MANICHAEAN_NUN, |
| 116 | \\ MANICHAEAN_SAMEKH, |
| 117 | \\ MANICHAEAN_AYIN, |
| 118 | \\ MANICHAEAN_PE, |
| 119 | \\ MANICHAEAN_SADHE, |
| 120 | \\ MANICHAEAN_QOPH, |
| 121 | \\ MANICHAEAN_RESH, |
| 122 | \\ MANICHAEAN_TAW, |
| 123 | \\ MANICHAEAN_ONE, |
| 124 | \\ MANICHAEAN_FIVE, |
| 125 | \\ MANICHAEAN_TEN, |
| 126 | \\ MANICHAEAN_TWENTY, |
| 127 | \\ MANICHAEAN_HUNDRED, |
| 128 | \\ HANIFI_ROHINGYA_PA, |
| 129 | \\ HANIFI_ROHINGYA_KINNA_YA, |
| 130 | \\ THIN_YEH, |
| 131 | \\ VERTICAL_TAIL, |
| 132 | \\ KASHMIRI_YEH, |
| 133 | \\ THIN_NOON, |
| 134 | \\ }; |
| 135 | \\}; |
| 136 | \\ |
| 137 | \\pub const data = [_]Shaping{ |
| 138 | \\ |
| 139 | ; |
| 140 | |
| 141 | pub const dest_footer = |
| 142 | \\}; |
| 143 | \\ |
| 144 | ; |
| 145 | |
| 146 | pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !void { |
| 147 | var it = std.mem.splitScalar(u8, line, ';'); |
| 148 | const c = std.mem.trim(u8, it.next().?, " "); |
| 149 | const n = std.mem.trim(u8, it.next().?, " "); |
| 150 | const t = std.mem.trim(u8, it.next().?, " "); |
| 151 | const g = std.mem.trim(u8, it.next().?, " "); |
| 152 | const g2 = try std.mem.replaceOwned(u8, alloc, g, " ", "_"); |
| 153 | |
| 154 | try writer.print(" .{{ .codepoint = 0x{s}, .schematic_name = \"{s}\", .joining_type = .{s}, .joining_group = .{s} }},\n", .{ c, n, t, g2 }); |
| 155 | } |
| 156 | }); |