authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-12-22 12:08:26 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-12-22 12:08:26 -08:00
logb6f875d3682664a981dd91ce345c5f4be96069cd
tree84048ca895b80e4a4cc64d73531dd8f0d4df7e77
parent01599798487f15f7cc2e4fe3b17fa035516014f0

add Jamo, closes #20


5 files changed, 120 insertions(+), 0 deletions(-)

generate.zig+1
...@@ -16,6 +16,7 @@ const files = [_]type{...@@ -16,6 +16,7 @@ const files = [_]type{
16 @import("./scripts/HangulSyllableType.zig"),16 @import("./scripts/HangulSyllableType.zig"),
17 @import("./scripts/IndicPositionalCategory.zig"),17 @import("./scripts/IndicPositionalCategory.zig"),
18 @import("./scripts/IndicSyllabicCategory.zig"),18 @import("./scripts/IndicSyllabicCategory.zig"),
19 @import("./scripts/Jamo.zig"),
19};20};
2021
21pub fn main() !void {22pub fn main() !void {
scripts/Jamo.zig created+36
...@@ -0,0 +1,36 @@
1const std = @import("std");
2const common = @import("./_common.zig");
3
4pub usingnamespace common.Main(struct {
5 pub const source_file = "Jamo";
6
7 pub const dest_file = "src/jamo.zig";
8
9 pub const dest_header =
10 \\pub const Jamo = struct {
11 \\ code: u21,
12 \\ short_name: []const u8,
13 \\};
14 \\
15 \\pub const data = [_]Jamo{
16 \\
17 ;
18
19 pub const dest_footer =
20 \\};
21 \\
22 ;
23
24 pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !bool {
25 _ = alloc;
26 var it = std.mem.tokenize(u8, line, "; ");
27
28 const first = it.next().?;
29 const next = it.next().?;
30 const actual = if (std.mem.eql(u8, next, "#")) "" else next;
31
32 try writer.print(" .{{ .code = 0x{s}, .short_name = \"{}\" }},\n", .{ first, std.zig.fmtEscapes(actual) });
33
34 return true;
35 }
36});
src/jamo.zig created+81
...@@ -0,0 +1,81 @@
1// This file is part of the Unicode Character Database
2// For documentation, see http://www.unicode.org/reports/tr44/
3//
4// Based on the source file: https://unicode.org/Public/13.0.0/ucd/Jamo.txt
5//
6// zig fmt: off
7
8pub const Jamo = struct {
9 code: u21,
10 short_name: []const u8,
11};
12
13pub const data = [_]Jamo{
14 .{ .code = 0x1100, .short_name = "G" },
15 .{ .code = 0x1101, .short_name = "GG" },
16 .{ .code = 0x1102, .short_name = "N" },
17 .{ .code = 0x1103, .short_name = "D" },
18 .{ .code = 0x1104, .short_name = "DD" },
19 .{ .code = 0x1105, .short_name = "R" },
20 .{ .code = 0x1106, .short_name = "M" },
21 .{ .code = 0x1107, .short_name = "B" },
22 .{ .code = 0x1108, .short_name = "BB" },
23 .{ .code = 0x1109, .short_name = "S" },
24 .{ .code = 0x110A, .short_name = "SS" },
25 .{ .code = 0x110B, .short_name = "" },
26 .{ .code = 0x110C, .short_name = "J" },
27 .{ .code = 0x110D, .short_name = "JJ" },
28 .{ .code = 0x110E, .short_name = "C" },
29 .{ .code = 0x110F, .short_name = "K" },
30 .{ .code = 0x1110, .short_name = "T" },
31 .{ .code = 0x1111, .short_name = "P" },
32 .{ .code = 0x1112, .short_name = "H" },
33 .{ .code = 0x1161, .short_name = "A" },
34 .{ .code = 0x1162, .short_name = "AE" },
35 .{ .code = 0x1163, .short_name = "YA" },
36 .{ .code = 0x1164, .short_name = "YAE" },
37 .{ .code = 0x1165, .short_name = "EO" },
38 .{ .code = 0x1166, .short_name = "E" },
39 .{ .code = 0x1167, .short_name = "YEO" },
40 .{ .code = 0x1168, .short_name = "YE" },
41 .{ .code = 0x1169, .short_name = "O" },
42 .{ .code = 0x116A, .short_name = "WA" },
43 .{ .code = 0x116B, .short_name = "WAE" },
44 .{ .code = 0x116C, .short_name = "OE" },
45 .{ .code = 0x116D, .short_name = "YO" },
46 .{ .code = 0x116E, .short_name = "U" },
47 .{ .code = 0x116F, .short_name = "WEO" },
48 .{ .code = 0x1170, .short_name = "WE" },
49 .{ .code = 0x1171, .short_name = "WI" },
50 .{ .code = 0x1172, .short_name = "YU" },
51 .{ .code = 0x1173, .short_name = "EU" },
52 .{ .code = 0x1174, .short_name = "YI" },
53 .{ .code = 0x1175, .short_name = "I" },
54 .{ .code = 0x11A8, .short_name = "G" },
55 .{ .code = 0x11A9, .short_name = "GG" },
56 .{ .code = 0x11AA, .short_name = "GS" },
57 .{ .code = 0x11AB, .short_name = "N" },
58 .{ .code = 0x11AC, .short_name = "NJ" },
59 .{ .code = 0x11AD, .short_name = "NH" },
60 .{ .code = 0x11AE, .short_name = "D" },
61 .{ .code = 0x11AF, .short_name = "L" },
62 .{ .code = 0x11B0, .short_name = "LG" },
63 .{ .code = 0x11B1, .short_name = "LM" },
64 .{ .code = 0x11B2, .short_name = "LB" },
65 .{ .code = 0x11B3, .short_name = "LS" },
66 .{ .code = 0x11B4, .short_name = "LT" },
67 .{ .code = 0x11B5, .short_name = "LP" },
68 .{ .code = 0x11B6, .short_name = "LH" },
69 .{ .code = 0x11B7, .short_name = "M" },
70 .{ .code = 0x11B8, .short_name = "B" },
71 .{ .code = 0x11B9, .short_name = "BS" },
72 .{ .code = 0x11BA, .short_name = "S" },
73 .{ .code = 0x11BB, .short_name = "SS" },
74 .{ .code = 0x11BC, .short_name = "NG" },
75 .{ .code = 0x11BD, .short_name = "J" },
76 .{ .code = 0x11BE, .short_name = "C" },
77 .{ .code = 0x11BF, .short_name = "K" },
78 .{ .code = 0x11C0, .short_name = "T" },
79 .{ .code = 0x11C1, .short_name = "P" },
80 .{ .code = 0x11C2, .short_name = "H" },
81};
src/lib.zig+1
...@@ -17,3 +17,4 @@ pub const hangul_syllable_type = @import("./hangul_syllable_type.zig");...@@ -17,3 +17,4 @@ pub const hangul_syllable_type = @import("./hangul_syllable_type.zig");
17// Index.txt17// Index.txt
18pub const indic_positional_category = @import("./indic_positional_category.zig");18pub const indic_positional_category = @import("./indic_positional_category.zig");
19pub const indic_syllabic_category = @import("./indic_syllabic_category.zig");19pub const indic_syllabic_category = @import("./indic_syllabic_category.zig");
20pub const jamo = @import("./jamo.zig");
src/main.zig+1
...@@ -21,6 +21,7 @@ pub fn main() !void {...@@ -21,6 +21,7 @@ pub fn main() !void {
21 ucd.hangul_syllable_type,21 ucd.hangul_syllable_type,
22 ucd.indic_positional_category,22 ucd.indic_positional_category,
23 ucd.indic_syllabic_category,23 ucd.indic_syllabic_category,
24 ucd.jamo,
24 };25 };
2526
26 inline for (data) |b| {27 inline for (data) |b| {