authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-31 15:08:57 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-31 15:08:57 -07:00
logdc138d7f7e7a9d0f0e62e43913dfc28fafe4e800
treeeb3c14f88fae065278dcaa64603c468825208723
parent8ff8f872de3c9a532915be47f3a231ca10f28131

add BidiBrackets, fixes #2


5 files changed, 181 insertions(+), 1 deletions(-)

generate.zig+1
...@@ -3,6 +3,7 @@ const std = @import("std");...@@ -3,6 +3,7 @@ const std = @import("std");
3const files = &[_]type{3const files = &[_]type{
4 @import("scripts/blocks.zig"),4 @import("scripts/blocks.zig"),
5 @import("./scripts/arabic_shaping.zig"),5 @import("./scripts/arabic_shaping.zig"),
6 @import("./scripts/bidi_brackets.zig"),
6};7};
78
8pub fn main() !void {9pub fn main() !void {
scripts/bidi_brackets.zig created+40
...@@ -0,0 +1,40 @@
1const std = @import("std");
2const common = @import("./_common.zig");
3
4pub const default = common.Main(struct {
5 pub const source_url = "https://unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt";
6
7 pub const dest_file = "src/bidi_brackets.zig";
8
9 pub const dest_header =
10 \\pub const BracketPairing = struct {
11 \\ codepoint: u21,
12 \\ pair: u21,
13 \\ type: Type,
14 \\
15 \\ pub const Type = enum {
16 \\ o,
17 \\ c,
18 \\ n,
19 \\ };
20 \\};
21 \\
22 \\pub const data = [_]BracketPairing{
23 \\
24 ;
25
26 pub const dest_footer =
27 \\};
28 \\
29 ;
30
31 pub fn exec(alloc: *std.mem.Allocator, line: []const u8, writer: anytype) !bool {
32 var it = std.mem.split(line, ";");
33 const a = std.mem.trim(u8, it.next().?, " ");
34 const b = std.mem.trim(u8, it.next().?, " ");
35 const c = std.mem.trim(u8, it.next().?, " ");
36
37 try writer.print(" .{{ .codepoint = 0x{s}, .pair = 0x{s}, .type = .{s} }}, // {s}\n", .{ a, b, c[0..1], c[4..] });
38 return true;
39 }
40});
src/bidi_brackets.zig created+138
...@@ -0,0 +1,138 @@
1// This file is part of the Unicode Character Database
2// See http://www.unicode.org/reports/tr44/ for more information.
3//
4
5pub const BracketPairing = struct {
6 codepoint: u21,
7 pair: u21,
8 type: Type,
9
10 pub const Type = enum {
11 o,
12 c,
13 n,
14 };
15};
16
17pub const data = [_]BracketPairing{
18 .{ .codepoint = 0x0028, .pair = 0x0029, .type = .o }, // LEFT PARENTHESIS
19 .{ .codepoint = 0x0029, .pair = 0x0028, .type = .c }, // RIGHT PARENTHESIS
20 .{ .codepoint = 0x005B, .pair = 0x005D, .type = .o }, // LEFT SQUARE BRACKET
21 .{ .codepoint = 0x005D, .pair = 0x005B, .type = .c }, // RIGHT SQUARE BRACKET
22 .{ .codepoint = 0x007B, .pair = 0x007D, .type = .o }, // LEFT CURLY BRACKET
23 .{ .codepoint = 0x007D, .pair = 0x007B, .type = .c }, // RIGHT CURLY BRACKET
24 .{ .codepoint = 0x0F3A, .pair = 0x0F3B, .type = .o }, // TIBETAN MARK GUG RTAGS GYON
25 .{ .codepoint = 0x0F3B, .pair = 0x0F3A, .type = .c }, // TIBETAN MARK GUG RTAGS GYAS
26 .{ .codepoint = 0x0F3C, .pair = 0x0F3D, .type = .o }, // TIBETAN MARK ANG KHANG GYON
27 .{ .codepoint = 0x0F3D, .pair = 0x0F3C, .type = .c }, // TIBETAN MARK ANG KHANG GYAS
28 .{ .codepoint = 0x169B, .pair = 0x169C, .type = .o }, // OGHAM FEATHER MARK
29 .{ .codepoint = 0x169C, .pair = 0x169B, .type = .c }, // OGHAM REVERSED FEATHER MARK
30 .{ .codepoint = 0x2045, .pair = 0x2046, .type = .o }, // LEFT SQUARE BRACKET WITH QUILL
31 .{ .codepoint = 0x2046, .pair = 0x2045, .type = .c }, // RIGHT SQUARE BRACKET WITH QUILL
32 .{ .codepoint = 0x207D, .pair = 0x207E, .type = .o }, // SUPERSCRIPT LEFT PARENTHESIS
33 .{ .codepoint = 0x207E, .pair = 0x207D, .type = .c }, // SUPERSCRIPT RIGHT PARENTHESIS
34 .{ .codepoint = 0x208D, .pair = 0x208E, .type = .o }, // SUBSCRIPT LEFT PARENTHESIS
35 .{ .codepoint = 0x208E, .pair = 0x208D, .type = .c }, // SUBSCRIPT RIGHT PARENTHESIS
36 .{ .codepoint = 0x2308, .pair = 0x2309, .type = .o }, // LEFT CEILING
37 .{ .codepoint = 0x2309, .pair = 0x2308, .type = .c }, // RIGHT CEILING
38 .{ .codepoint = 0x230A, .pair = 0x230B, .type = .o }, // LEFT FLOOR
39 .{ .codepoint = 0x230B, .pair = 0x230A, .type = .c }, // RIGHT FLOOR
40 .{ .codepoint = 0x2329, .pair = 0x232A, .type = .o }, // LEFT-POINTING ANGLE BRACKET
41 .{ .codepoint = 0x232A, .pair = 0x2329, .type = .c }, // RIGHT-POINTING ANGLE BRACKET
42 .{ .codepoint = 0x2768, .pair = 0x2769, .type = .o }, // MEDIUM LEFT PARENTHESIS ORNAMENT
43 .{ .codepoint = 0x2769, .pair = 0x2768, .type = .c }, // MEDIUM RIGHT PARENTHESIS ORNAMENT
44 .{ .codepoint = 0x276A, .pair = 0x276B, .type = .o }, // MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT
45 .{ .codepoint = 0x276B, .pair = 0x276A, .type = .c }, // MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT
46 .{ .codepoint = 0x276C, .pair = 0x276D, .type = .o }, // MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT
47 .{ .codepoint = 0x276D, .pair = 0x276C, .type = .c }, // MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT
48 .{ .codepoint = 0x276E, .pair = 0x276F, .type = .o }, // HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT
49 .{ .codepoint = 0x276F, .pair = 0x276E, .type = .c }, // HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT
50 .{ .codepoint = 0x2770, .pair = 0x2771, .type = .o }, // HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT
51 .{ .codepoint = 0x2771, .pair = 0x2770, .type = .c }, // HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT
52 .{ .codepoint = 0x2772, .pair = 0x2773, .type = .o }, // LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT
53 .{ .codepoint = 0x2773, .pair = 0x2772, .type = .c }, // LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT
54 .{ .codepoint = 0x2774, .pair = 0x2775, .type = .o }, // MEDIUM LEFT CURLY BRACKET ORNAMENT
55 .{ .codepoint = 0x2775, .pair = 0x2774, .type = .c }, // MEDIUM RIGHT CURLY BRACKET ORNAMENT
56 .{ .codepoint = 0x27C5, .pair = 0x27C6, .type = .o }, // LEFT S-SHAPED BAG DELIMITER
57 .{ .codepoint = 0x27C6, .pair = 0x27C5, .type = .c }, // RIGHT S-SHAPED BAG DELIMITER
58 .{ .codepoint = 0x27E6, .pair = 0x27E7, .type = .o }, // MATHEMATICAL LEFT WHITE SQUARE BRACKET
59 .{ .codepoint = 0x27E7, .pair = 0x27E6, .type = .c }, // MATHEMATICAL RIGHT WHITE SQUARE BRACKET
60 .{ .codepoint = 0x27E8, .pair = 0x27E9, .type = .o }, // MATHEMATICAL LEFT ANGLE BRACKET
61 .{ .codepoint = 0x27E9, .pair = 0x27E8, .type = .c }, // MATHEMATICAL RIGHT ANGLE BRACKET
62 .{ .codepoint = 0x27EA, .pair = 0x27EB, .type = .o }, // MATHEMATICAL LEFT DOUBLE ANGLE BRACKET
63 .{ .codepoint = 0x27EB, .pair = 0x27EA, .type = .c }, // MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET
64 .{ .codepoint = 0x27EC, .pair = 0x27ED, .type = .o }, // MATHEMATICAL LEFT WHITE TORTOISE SHELL BRACKET
65 .{ .codepoint = 0x27ED, .pair = 0x27EC, .type = .c }, // MATHEMATICAL RIGHT WHITE TORTOISE SHELL BRACKET
66 .{ .codepoint = 0x27EE, .pair = 0x27EF, .type = .o }, // MATHEMATICAL LEFT FLATTENED PARENTHESIS
67 .{ .codepoint = 0x27EF, .pair = 0x27EE, .type = .c }, // MATHEMATICAL RIGHT FLATTENED PARENTHESIS
68 .{ .codepoint = 0x2983, .pair = 0x2984, .type = .o }, // LEFT WHITE CURLY BRACKET
69 .{ .codepoint = 0x2984, .pair = 0x2983, .type = .c }, // RIGHT WHITE CURLY BRACKET
70 .{ .codepoint = 0x2985, .pair = 0x2986, .type = .o }, // LEFT WHITE PARENTHESIS
71 .{ .codepoint = 0x2986, .pair = 0x2985, .type = .c }, // RIGHT WHITE PARENTHESIS
72 .{ .codepoint = 0x2987, .pair = 0x2988, .type = .o }, // Z NOTATION LEFT IMAGE BRACKET
73 .{ .codepoint = 0x2988, .pair = 0x2987, .type = .c }, // Z NOTATION RIGHT IMAGE BRACKET
74 .{ .codepoint = 0x2989, .pair = 0x298A, .type = .o }, // Z NOTATION LEFT BINDING BRACKET
75 .{ .codepoint = 0x298A, .pair = 0x2989, .type = .c }, // Z NOTATION RIGHT BINDING BRACKET
76 .{ .codepoint = 0x298B, .pair = 0x298C, .type = .o }, // LEFT SQUARE BRACKET WITH UNDERBAR
77 .{ .codepoint = 0x298C, .pair = 0x298B, .type = .c }, // RIGHT SQUARE BRACKET WITH UNDERBAR
78 .{ .codepoint = 0x298D, .pair = 0x2990, .type = .o }, // LEFT SQUARE BRACKET WITH TICK IN TOP CORNER
79 .{ .codepoint = 0x298E, .pair = 0x298F, .type = .c }, // RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
80 .{ .codepoint = 0x298F, .pair = 0x298E, .type = .o }, // LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
81 .{ .codepoint = 0x2990, .pair = 0x298D, .type = .c }, // RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER
82 .{ .codepoint = 0x2991, .pair = 0x2992, .type = .o }, // LEFT ANGLE BRACKET WITH DOT
83 .{ .codepoint = 0x2992, .pair = 0x2991, .type = .c }, // RIGHT ANGLE BRACKET WITH DOT
84 .{ .codepoint = 0x2993, .pair = 0x2994, .type = .o }, // LEFT ARC LESS-THAN BRACKET
85 .{ .codepoint = 0x2994, .pair = 0x2993, .type = .c }, // RIGHT ARC GREATER-THAN BRACKET
86 .{ .codepoint = 0x2995, .pair = 0x2996, .type = .o }, // DOUBLE LEFT ARC GREATER-THAN BRACKET
87 .{ .codepoint = 0x2996, .pair = 0x2995, .type = .c }, // DOUBLE RIGHT ARC LESS-THAN BRACKET
88 .{ .codepoint = 0x2997, .pair = 0x2998, .type = .o }, // LEFT BLACK TORTOISE SHELL BRACKET
89 .{ .codepoint = 0x2998, .pair = 0x2997, .type = .c }, // RIGHT BLACK TORTOISE SHELL BRACKET
90 .{ .codepoint = 0x29D8, .pair = 0x29D9, .type = .o }, // LEFT WIGGLY FENCE
91 .{ .codepoint = 0x29D9, .pair = 0x29D8, .type = .c }, // RIGHT WIGGLY FENCE
92 .{ .codepoint = 0x29DA, .pair = 0x29DB, .type = .o }, // LEFT DOUBLE WIGGLY FENCE
93 .{ .codepoint = 0x29DB, .pair = 0x29DA, .type = .c }, // RIGHT DOUBLE WIGGLY FENCE
94 .{ .codepoint = 0x29FC, .pair = 0x29FD, .type = .o }, // LEFT-POINTING CURVED ANGLE BRACKET
95 .{ .codepoint = 0x29FD, .pair = 0x29FC, .type = .c }, // RIGHT-POINTING CURVED ANGLE BRACKET
96 .{ .codepoint = 0x2E22, .pair = 0x2E23, .type = .o }, // TOP LEFT HALF BRACKET
97 .{ .codepoint = 0x2E23, .pair = 0x2E22, .type = .c }, // TOP RIGHT HALF BRACKET
98 .{ .codepoint = 0x2E24, .pair = 0x2E25, .type = .o }, // BOTTOM LEFT HALF BRACKET
99 .{ .codepoint = 0x2E25, .pair = 0x2E24, .type = .c }, // BOTTOM RIGHT HALF BRACKET
100 .{ .codepoint = 0x2E26, .pair = 0x2E27, .type = .o }, // LEFT SIDEWAYS U BRACKET
101 .{ .codepoint = 0x2E27, .pair = 0x2E26, .type = .c }, // RIGHT SIDEWAYS U BRACKET
102 .{ .codepoint = 0x2E28, .pair = 0x2E29, .type = .o }, // LEFT DOUBLE PARENTHESIS
103 .{ .codepoint = 0x2E29, .pair = 0x2E28, .type = .c }, // RIGHT DOUBLE PARENTHESIS
104 .{ .codepoint = 0x3008, .pair = 0x3009, .type = .o }, // LEFT ANGLE BRACKET
105 .{ .codepoint = 0x3009, .pair = 0x3008, .type = .c }, // RIGHT ANGLE BRACKET
106 .{ .codepoint = 0x300A, .pair = 0x300B, .type = .o }, // LEFT DOUBLE ANGLE BRACKET
107 .{ .codepoint = 0x300B, .pair = 0x300A, .type = .c }, // RIGHT DOUBLE ANGLE BRACKET
108 .{ .codepoint = 0x300C, .pair = 0x300D, .type = .o }, // LEFT CORNER BRACKET
109 .{ .codepoint = 0x300D, .pair = 0x300C, .type = .c }, // RIGHT CORNER BRACKET
110 .{ .codepoint = 0x300E, .pair = 0x300F, .type = .o }, // LEFT WHITE CORNER BRACKET
111 .{ .codepoint = 0x300F, .pair = 0x300E, .type = .c }, // RIGHT WHITE CORNER BRACKET
112 .{ .codepoint = 0x3010, .pair = 0x3011, .type = .o }, // LEFT BLACK LENTICULAR BRACKET
113 .{ .codepoint = 0x3011, .pair = 0x3010, .type = .c }, // RIGHT BLACK LENTICULAR BRACKET
114 .{ .codepoint = 0x3014, .pair = 0x3015, .type = .o }, // LEFT TORTOISE SHELL BRACKET
115 .{ .codepoint = 0x3015, .pair = 0x3014, .type = .c }, // RIGHT TORTOISE SHELL BRACKET
116 .{ .codepoint = 0x3016, .pair = 0x3017, .type = .o }, // LEFT WHITE LENTICULAR BRACKET
117 .{ .codepoint = 0x3017, .pair = 0x3016, .type = .c }, // RIGHT WHITE LENTICULAR BRACKET
118 .{ .codepoint = 0x3018, .pair = 0x3019, .type = .o }, // LEFT WHITE TORTOISE SHELL BRACKET
119 .{ .codepoint = 0x3019, .pair = 0x3018, .type = .c }, // RIGHT WHITE TORTOISE SHELL BRACKET
120 .{ .codepoint = 0x301A, .pair = 0x301B, .type = .o }, // LEFT WHITE SQUARE BRACKET
121 .{ .codepoint = 0x301B, .pair = 0x301A, .type = .c }, // RIGHT WHITE SQUARE BRACKET
122 .{ .codepoint = 0xFE59, .pair = 0xFE5A, .type = .o }, // SMALL LEFT PARENTHESIS
123 .{ .codepoint = 0xFE5A, .pair = 0xFE59, .type = .c }, // SMALL RIGHT PARENTHESIS
124 .{ .codepoint = 0xFE5B, .pair = 0xFE5C, .type = .o }, // SMALL LEFT CURLY BRACKET
125 .{ .codepoint = 0xFE5C, .pair = 0xFE5B, .type = .c }, // SMALL RIGHT CURLY BRACKET
126 .{ .codepoint = 0xFE5D, .pair = 0xFE5E, .type = .o }, // SMALL LEFT TORTOISE SHELL BRACKET
127 .{ .codepoint = 0xFE5E, .pair = 0xFE5D, .type = .c }, // SMALL RIGHT TORTOISE SHELL BRACKET
128 .{ .codepoint = 0xFF08, .pair = 0xFF09, .type = .o }, // FULLWIDTH LEFT PARENTHESIS
129 .{ .codepoint = 0xFF09, .pair = 0xFF08, .type = .c }, // FULLWIDTH RIGHT PARENTHESIS
130 .{ .codepoint = 0xFF3B, .pair = 0xFF3D, .type = .o }, // FULLWIDTH LEFT SQUARE BRACKET
131 .{ .codepoint = 0xFF3D, .pair = 0xFF3B, .type = .c }, // FULLWIDTH RIGHT SQUARE BRACKET
132 .{ .codepoint = 0xFF5B, .pair = 0xFF5D, .type = .o }, // FULLWIDTH LEFT CURLY BRACKET
133 .{ .codepoint = 0xFF5D, .pair = 0xFF5B, .type = .c }, // FULLWIDTH RIGHT CURLY BRACKET
134 .{ .codepoint = 0xFF5F, .pair = 0xFF60, .type = .o }, // FULLWIDTH LEFT WHITE PARENTHESIS
135 .{ .codepoint = 0xFF60, .pair = 0xFF5F, .type = .c }, // FULLWIDTH RIGHT WHITE PARENTHESIS
136 .{ .codepoint = 0xFF62, .pair = 0xFF63, .type = .o }, // HALFWIDTH LEFT CORNER BRACKET
137 .{ .codepoint = 0xFF63, .pair = 0xFF62, .type = .c }, // HALFWIDTH RIGHT CORNER BRACKET
138};
src/lib.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1pub const arabic_shaping = @import("./arabic_shaping.zig");1pub const arabic_shaping = @import("./arabic_shaping.zig");
2//2pub const bidi_brackets = @import("./bidi_brackets.zig");
3//3//
4//4//
5//5//
src/main.zig+1
...@@ -8,6 +8,7 @@ pub fn main() !void {...@@ -8,6 +8,7 @@ pub fn main() !void {
8 const data = .{8 const data = .{
9 ucd.blocks,9 ucd.blocks,
10 ucd.arabic_shaping,10 ucd.arabic_shaping,
11 ucd.bidi_brackets,
11 };12 };
1213
13 inline for (data) |b| {14 inline for (data) |b| {