diff --git a/generate.zig b/generate.zig index 664dc336a960deeed6c65bb921e0e71a0cff48ed..aa37fb205214a92e7197841e148ea0a298cb3e5e 100644 --- a/generate.zig +++ b/generate.zig @@ -1,9 +1,9 @@ const std = @import("std"); const files = [_]type{ - @import("./scripts/blocks.zig"), - @import("./scripts/arabic_shaping.zig"), - @import("./scripts/bidi_brackets.zig"), + @import("./scripts/Blocks.zig"), + @import("./scripts/ArabicShaping.zig"), + @import("./scripts/BidiBrackets.zig"), @import("./scripts/BidiMirroring.zig"), @import("./scripts/CJKRadicals.zig"), @import("./scripts/CaseFolding.zig"), diff --git a/scripts/ArabicShaping.zig b/scripts/ArabicShaping.zig new file mode 100644 index 0000000000000000000000000000000000000000..657e3c9644f69a059b32a8ec2aa2e011a4b73625 --- /dev/null +++ b/scripts/ArabicShaping.zig @@ -0,0 +1,156 @@ +const std = @import("std"); +const common = @import("./_common.zig"); + +pub usingnamespace common.Main(struct { + pub const source_file = "ArabicShaping"; + + pub const dest_file = "src/arabic_shaping.zig"; + + pub const dest_header = + \\pub const Shaping = struct { + \\ codepoint: u21, + \\ schematic_name: []const u8, + \\ joining_type: Joining.Type, + \\ joining_group: Joining.Group, + \\}; + \\ + \\pub const Joining = struct { + \\ pub const Type = enum { + \\ U, + \\ D, + \\ R, + \\ C, + \\ T, + \\ L, + \\ }; + \\ + \\ pub const Group = enum { + \\ No_Joining_Group, + \\ YEH, + \\ ALEF, + \\ WAW, + \\ BEH, + \\ TEH_MARBUTA, + \\ HAH, + \\ DAL, + \\ REH, + \\ SEEN, + \\ SAD, + \\ TAH, + \\ AIN, + \\ GAF, + \\ FARSI_YEH, + \\ FEH, + \\ QAF, + \\ KAF, + \\ LAM, + \\ MEEM, + \\ NOON, + \\ HEH, + \\ SWASH_KAF, + \\ NYA, + \\ KNOTTED_HEH, + \\ HEH_GOAL, + \\ TEH_MARBUTA_GOAL, + \\ YEH_WITH_TAIL, + \\ YEH_BARREE, + \\ ALAPH, + \\ BETH, + \\ GAMAL, + \\ DALATH_RISH, + \\ HE, + \\ SYRIAC_WAW, + \\ ZAIN, + \\ HETH, + \\ TETH, + \\ YUDH, + \\ YUDH_HE, + \\ KAPH, + \\ LAMADH, + \\ MIM, + \\ NUN, + \\ SEMKATH, + \\ FINAL_SEMKATH, + \\ E, + \\ PE, + \\ REVERSED_PE, + \\ SADHE, + \\ QAPH, + \\ SHIN, + \\ TAW, + \\ ZHAIN, + \\ KHAPH, + \\ FE, + \\ BURUSHASKI_YEH_BARREE, + \\ MALAYALAM_NGA, + \\ MALAYALAM_JA, + \\ MALAYALAM_NYA, + \\ MALAYALAM_TTA, + \\ MALAYALAM_NNA, + \\ MALAYALAM_NNNA, + \\ MALAYALAM_BHA, + \\ MALAYALAM_RA, + \\ MALAYALAM_LLA, + \\ MALAYALAM_LLLA, + \\ MALAYALAM_SSA, + \\ ROHINGYA_YEH, + \\ STRAIGHT_WAW, + \\ AFRICAN_FEH, + \\ AFRICAN_QAF, + \\ AFRICAN_NOON, + \\ MANICHAEAN_ALEPH, + \\ MANICHAEAN_BETH, + \\ MANICHAEAN_GIMEL, + \\ MANICHAEAN_DALETH, + \\ MANICHAEAN_WAW, + \\ MANICHAEAN_ZAYIN, + \\ MANICHAEAN_HETH, + \\ MANICHAEAN_TETH, + \\ MANICHAEAN_YODH, + \\ MANICHAEAN_KAPH, + \\ MANICHAEAN_LAMEDH, + \\ MANICHAEAN_DHAMEDH, + \\ MANICHAEAN_THAMEDH, + \\ MANICHAEAN_MEM, + \\ MANICHAEAN_NUN, + \\ MANICHAEAN_SAMEKH, + \\ MANICHAEAN_AYIN, + \\ MANICHAEAN_PE, + \\ MANICHAEAN_SADHE, + \\ MANICHAEAN_QOPH, + \\ MANICHAEAN_RESH, + \\ MANICHAEAN_TAW, + \\ MANICHAEAN_ONE, + \\ MANICHAEAN_FIVE, + \\ MANICHAEAN_TEN, + \\ MANICHAEAN_TWENTY, + \\ MANICHAEAN_HUNDRED, + \\ HANIFI_ROHINGYA_PA, + \\ HANIFI_ROHINGYA_KINNA_YA, + \\ }; + \\}; + \\ + \\pub const data = [_]Shaping{ + \\ + ; + + pub const dest_footer = + \\}; + \\ + ; + + pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !bool { + var it = std.mem.split(u8, line, ";"); + const c = std.mem.trim(u8, it.next().?, " "); + const n = std.mem.trim(u8, it.next().?, " "); + const t = std.mem.trim(u8, it.next().?, " "); + const g = std.mem.trim(u8, it.next().?, " "); + const g2 = try std.mem.replaceOwned(u8, alloc, g, " ", "_"); + + try common.stringToEnum(@import("../src/lib.zig").arabic_shaping.Joining.Type, t); + try common.stringToEnum(@import("../src/lib.zig").arabic_shaping.Joining.Group, g2); + + try writer.print(" .{{ .codepoint = 0x{s}, .schematic_name = \"{s}\", .joining_type = .{s}, .joining_group = .{s} }},\n", .{ c, n, t, g2 }); + return true; + } +}); diff --git a/scripts/BidiBrackets.zig b/scripts/BidiBrackets.zig new file mode 100644 index 0000000000000000000000000000000000000000..fc3ed3e24688cd66cb4fe4f1f0b8923862e21da1 --- /dev/null +++ b/scripts/BidiBrackets.zig @@ -0,0 +1,42 @@ +const std = @import("std"); +const common = @import("./_common.zig"); + +pub usingnamespace common.Main(struct { + pub const source_file = "BidiBrackets"; + + pub const dest_file = "src/bidi_brackets.zig"; + + pub const dest_header = + \\pub const BracketPairing = struct { + \\ codepoint: u21, + \\ pair: u21, + \\ type: Type, + \\ + \\ pub const Type = enum { + \\ o, + \\ c, + \\ n, + \\ }; + \\}; + \\ + \\pub const data = [_]BracketPairing{ + \\ + ; + + pub const dest_footer = + \\}; + \\ + ; + + pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !bool { + _ = alloc; + + var it = std.mem.split(u8, line, ";"); + const a = std.mem.trim(u8, it.next().?, " "); + const b = std.mem.trim(u8, it.next().?, " "); + const c = std.mem.trim(u8, it.next().?, " "); + + try writer.print(" .{{ .codepoint = 0x{s}, .pair = 0x{s}, .type = .{s} }}, // {s}\n", .{ a, b, c[0..1], c[4..] }); + return true; + } +}); diff --git a/scripts/Blocks.zig b/scripts/Blocks.zig new file mode 100644 index 0000000000000000000000000000000000000000..cf505c90bcfacbb31c901320a65e1a0b64f3e52c --- /dev/null +++ b/scripts/Blocks.zig @@ -0,0 +1,37 @@ +const std = @import("std"); +const common = @import("./_common.zig"); + +pub usingnamespace common.Main(struct { + pub const source_file = "Blocks"; + + pub const dest_file = "src/blocks.zig"; + + pub const dest_header = + \\pub const Block = struct { + \\ from: u21, + \\ to: u21, + \\ name: []const u8, + \\}; + \\ + \\pub const data = [_]Block{ + \\ + ; + + pub const dest_footer = + \\}; + \\ + ; + + pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !bool { + _ = alloc; + + var it1 = std.mem.split(u8, line, "; "); + var it2 = std.mem.split(u8, it1.next().?, ".."); + const from = it2.next().?; + const to = it2.next().?; + const name = it1.next().?; + + try writer.print(" .{{ .from = 0x{s}, .to = 0x{s}, .name = \"{s}\" }},\n", .{ from, to, name }); + return true; + } +}); diff --git a/scripts/arabic_shaping.zig b/scripts/arabic_shaping.zig deleted file mode 100644 index 657e3c9644f69a059b32a8ec2aa2e011a4b73625..0000000000000000000000000000000000000000 --- a/scripts/arabic_shaping.zig +++ /dev/null @@ -1,156 +0,0 @@ -const std = @import("std"); -const common = @import("./_common.zig"); - -pub usingnamespace common.Main(struct { - pub const source_file = "ArabicShaping"; - - pub const dest_file = "src/arabic_shaping.zig"; - - pub const dest_header = - \\pub const Shaping = struct { - \\ codepoint: u21, - \\ schematic_name: []const u8, - \\ joining_type: Joining.Type, - \\ joining_group: Joining.Group, - \\}; - \\ - \\pub const Joining = struct { - \\ pub const Type = enum { - \\ U, - \\ D, - \\ R, - \\ C, - \\ T, - \\ L, - \\ }; - \\ - \\ pub const Group = enum { - \\ No_Joining_Group, - \\ YEH, - \\ ALEF, - \\ WAW, - \\ BEH, - \\ TEH_MARBUTA, - \\ HAH, - \\ DAL, - \\ REH, - \\ SEEN, - \\ SAD, - \\ TAH, - \\ AIN, - \\ GAF, - \\ FARSI_YEH, - \\ FEH, - \\ QAF, - \\ KAF, - \\ LAM, - \\ MEEM, - \\ NOON, - \\ HEH, - \\ SWASH_KAF, - \\ NYA, - \\ KNOTTED_HEH, - \\ HEH_GOAL, - \\ TEH_MARBUTA_GOAL, - \\ YEH_WITH_TAIL, - \\ YEH_BARREE, - \\ ALAPH, - \\ BETH, - \\ GAMAL, - \\ DALATH_RISH, - \\ HE, - \\ SYRIAC_WAW, - \\ ZAIN, - \\ HETH, - \\ TETH, - \\ YUDH, - \\ YUDH_HE, - \\ KAPH, - \\ LAMADH, - \\ MIM, - \\ NUN, - \\ SEMKATH, - \\ FINAL_SEMKATH, - \\ E, - \\ PE, - \\ REVERSED_PE, - \\ SADHE, - \\ QAPH, - \\ SHIN, - \\ TAW, - \\ ZHAIN, - \\ KHAPH, - \\ FE, - \\ BURUSHASKI_YEH_BARREE, - \\ MALAYALAM_NGA, - \\ MALAYALAM_JA, - \\ MALAYALAM_NYA, - \\ MALAYALAM_TTA, - \\ MALAYALAM_NNA, - \\ MALAYALAM_NNNA, - \\ MALAYALAM_BHA, - \\ MALAYALAM_RA, - \\ MALAYALAM_LLA, - \\ MALAYALAM_LLLA, - \\ MALAYALAM_SSA, - \\ ROHINGYA_YEH, - \\ STRAIGHT_WAW, - \\ AFRICAN_FEH, - \\ AFRICAN_QAF, - \\ AFRICAN_NOON, - \\ MANICHAEAN_ALEPH, - \\ MANICHAEAN_BETH, - \\ MANICHAEAN_GIMEL, - \\ MANICHAEAN_DALETH, - \\ MANICHAEAN_WAW, - \\ MANICHAEAN_ZAYIN, - \\ MANICHAEAN_HETH, - \\ MANICHAEAN_TETH, - \\ MANICHAEAN_YODH, - \\ MANICHAEAN_KAPH, - \\ MANICHAEAN_LAMEDH, - \\ MANICHAEAN_DHAMEDH, - \\ MANICHAEAN_THAMEDH, - \\ MANICHAEAN_MEM, - \\ MANICHAEAN_NUN, - \\ MANICHAEAN_SAMEKH, - \\ MANICHAEAN_AYIN, - \\ MANICHAEAN_PE, - \\ MANICHAEAN_SADHE, - \\ MANICHAEAN_QOPH, - \\ MANICHAEAN_RESH, - \\ MANICHAEAN_TAW, - \\ MANICHAEAN_ONE, - \\ MANICHAEAN_FIVE, - \\ MANICHAEAN_TEN, - \\ MANICHAEAN_TWENTY, - \\ MANICHAEAN_HUNDRED, - \\ HANIFI_ROHINGYA_PA, - \\ HANIFI_ROHINGYA_KINNA_YA, - \\ }; - \\}; - \\ - \\pub const data = [_]Shaping{ - \\ - ; - - pub const dest_footer = - \\}; - \\ - ; - - pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !bool { - var it = std.mem.split(u8, line, ";"); - const c = std.mem.trim(u8, it.next().?, " "); - const n = std.mem.trim(u8, it.next().?, " "); - const t = std.mem.trim(u8, it.next().?, " "); - const g = std.mem.trim(u8, it.next().?, " "); - const g2 = try std.mem.replaceOwned(u8, alloc, g, " ", "_"); - - try common.stringToEnum(@import("../src/lib.zig").arabic_shaping.Joining.Type, t); - try common.stringToEnum(@import("../src/lib.zig").arabic_shaping.Joining.Group, g2); - - try writer.print(" .{{ .codepoint = 0x{s}, .schematic_name = \"{s}\", .joining_type = .{s}, .joining_group = .{s} }},\n", .{ c, n, t, g2 }); - return true; - } -}); diff --git a/scripts/bidi_brackets.zig b/scripts/bidi_brackets.zig deleted file mode 100644 index fc3ed3e24688cd66cb4fe4f1f0b8923862e21da1..0000000000000000000000000000000000000000 --- a/scripts/bidi_brackets.zig +++ /dev/null @@ -1,42 +0,0 @@ -const std = @import("std"); -const common = @import("./_common.zig"); - -pub usingnamespace common.Main(struct { - pub const source_file = "BidiBrackets"; - - pub const dest_file = "src/bidi_brackets.zig"; - - pub const dest_header = - \\pub const BracketPairing = struct { - \\ codepoint: u21, - \\ pair: u21, - \\ type: Type, - \\ - \\ pub const Type = enum { - \\ o, - \\ c, - \\ n, - \\ }; - \\}; - \\ - \\pub const data = [_]BracketPairing{ - \\ - ; - - pub const dest_footer = - \\}; - \\ - ; - - pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !bool { - _ = alloc; - - var it = std.mem.split(u8, line, ";"); - const a = std.mem.trim(u8, it.next().?, " "); - const b = std.mem.trim(u8, it.next().?, " "); - const c = std.mem.trim(u8, it.next().?, " "); - - try writer.print(" .{{ .codepoint = 0x{s}, .pair = 0x{s}, .type = .{s} }}, // {s}\n", .{ a, b, c[0..1], c[4..] }); - return true; - } -}); diff --git a/scripts/blocks.zig b/scripts/blocks.zig deleted file mode 100644 index cf505c90bcfacbb31c901320a65e1a0b64f3e52c..0000000000000000000000000000000000000000 --- a/scripts/blocks.zig +++ /dev/null @@ -1,37 +0,0 @@ -const std = @import("std"); -const common = @import("./_common.zig"); - -pub usingnamespace common.Main(struct { - pub const source_file = "Blocks"; - - pub const dest_file = "src/blocks.zig"; - - pub const dest_header = - \\pub const Block = struct { - \\ from: u21, - \\ to: u21, - \\ name: []const u8, - \\}; - \\ - \\pub const data = [_]Block{ - \\ - ; - - pub const dest_footer = - \\}; - \\ - ; - - pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !bool { - _ = alloc; - - var it1 = std.mem.split(u8, line, "; "); - var it2 = std.mem.split(u8, it1.next().?, ".."); - const from = it2.next().?; - const to = it2.next().?; - const name = it1.next().?; - - try writer.print(" .{{ .from = 0x{s}, .to = 0x{s}, .name = \"{s}\" }},\n", .{ from, to, name }); - return true; - } -});