| author | |
| committer | |
| log | 30ff725e47a66dbfeae96e64257c161bae181bf8 |
| tree | ad18108b5db1484d3cfb333e9defdc3ed82fa195 |
| parent | 5315f98e71b7ee82fea0a83844263d701419ef1a |
2 files changed, 41 insertions(+), 34 deletions(-)
generate.zig+6-34| ... | @@ -1,39 +1,11 @@ | ... | @@ -1,39 +1,11 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | const common = @import("scripts/_common.zig"); | 3 | const files = &[_]type{ |
| 4 | @import("scripts/blocks.zig"), | ||
| 5 | }; | ||
| 4 | 6 | ||
| 5 | pub fn main() !void { | 7 | pub fn main() !void { |
| 6 | // Blocks | 8 | inline for (files) |f| { |
| 7 | try common.Main(struct { | 9 | try f.default.do(); |
| 8 | pub const source_url = "https://unicode.org/Public/UCD/latest/ucd/Blocks.txt"; | 10 | } |
| 9 | |||
| 10 | pub const dest_file = "src/blocks.zig"; | ||
| 11 | |||
| 12 | pub const dest_header = | ||
| 13 | \\pub const Block = struct { | ||
| 14 | \\ from: u21, | ||
| 15 | \\ to: u21, | ||
| 16 | \\ name: []const u8, | ||
| 17 | \\}; | ||
| 18 | \\ | ||
| 19 | \\pub const blocks: []Block = &.{ | ||
| 20 | \\ | ||
| 21 | ; | ||
| 22 | |||
| 23 | pub const dest_footer = | ||
| 24 | \\}; | ||
| 25 | \\ | ||
| 26 | ; | ||
| 27 | |||
| 28 | pub fn exec(alloc: *std.mem.Allocator, line: []const u8, writer: anytype) !bool { | ||
| 29 | var it1 = std.mem.split(line, "; "); | ||
| 30 | var it2 = std.mem.split(it1.next().?, ".."); | ||
| 31 | const from = it2.next().?; | ||
| 32 | const to = it2.next().?; | ||
| 33 | const name = it1.next().?; | ||
| 34 | |||
| 35 | try writer.print(" .{{ 0x{s}, 0x{s}, \"{s}\" }},\n", .{ from, to, name }); | ||
| 36 | return true; | ||
| 37 | } | ||
| 38 | }).do(); | ||
| 39 | } | 11 | } |
scripts/blocks.zig created+35| ... | @@ -0,0 +1,35 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("./_common.zig"); | ||
| 3 | |||
| 4 | pub const default = common.Main(struct { | ||
| 5 | pub const source_url = "https://unicode.org/Public/UCD/latest/ucd/Blocks.txt"; | ||
| 6 | |||
| 7 | pub const dest_file = "src/blocks.zig"; | ||
| 8 | |||
| 9 | pub const dest_header = | ||
| 10 | \\pub const Block = struct { | ||
| 11 | \\ from: u21, | ||
| 12 | \\ to: u21, | ||
| 13 | \\ name: []const u8, | ||
| 14 | \\}; | ||
| 15 | \\ | ||
| 16 | \\pub const blocks: []Block = &.{ | ||
| 17 | \\ | ||
| 18 | ; | ||
| 19 | |||
| 20 | pub const dest_footer = | ||
| 21 | \\}; | ||
| 22 | \\ | ||
| 23 | ; | ||
| 24 | |||
| 25 | pub fn exec(alloc: *std.mem.Allocator, line: []const u8, writer: anytype) !bool { | ||
| 26 | var it1 = std.mem.split(line, "; "); | ||
| 27 | var it2 = std.mem.split(it1.next().?, ".."); | ||
| 28 | const from = it2.next().?; | ||
| 29 | const to = it2.next().?; | ||
| 30 | const name = it1.next().?; | ||
| 31 | |||
| 32 | try writer.print(" .{{ 0x{s}, 0x{s}, \"{s}\" }},\n", .{ from, to, name }); | ||
| 33 | return true; | ||
| 34 | } | ||
| 35 | }); | ||