1const std = @import("std");
2const common = @import("./_common.zig");
3
4pub usingnamespace common.Main(struct {
5 pub const source_file = "IndicPositionalCategory";
6
7 pub const dest_file = "src/indic_positional_category.zig";
8
9 pub const dest_header =
10 \\const ucd = @import("./lib.zig");
11 \\
12 \\pub const IndicPositionalCategory = struct {
13 \\ code: u21,
14 \\ category: ucd.IndicPositionalCategory,
15 \\};
16 \\
17 \\pub const data = [_]IndicPositionalCategory{
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});