diff --git a/generate.zig b/generate.zig index 1019499b45d95c883e1fade08cbe122a3b286c19..dbc1d348583c3c5c2101542c4095c0061c72689a 100644 --- a/generate.zig +++ b/generate.zig @@ -1,39 +1,11 @@ const std = @import("std"); -const common = @import("scripts/_common.zig"); +const files = &[_]type{ + @import("scripts/blocks.zig"), +}; pub fn main() !void { - // Blocks - try common.Main(struct { - pub const source_url = "https://unicode.org/Public/UCD/latest/ucd/Blocks.txt"; - - pub const dest_file = "src/blocks.zig"; - - pub const dest_header = - \\pub const Block = struct { - \\ from: u21, - \\ to: u21, - \\ name: []const u8, - \\}; - \\ - \\pub const blocks: []Block = &.{ - \\ - ; - - pub const dest_footer = - \\}; - \\ - ; - - pub fn exec(alloc: *std.mem.Allocator, line: []const u8, writer: anytype) !bool { - var it1 = std.mem.split(line, "; "); - var it2 = std.mem.split(it1.next().?, ".."); - const from = it2.next().?; - const to = it2.next().?; - const name = it1.next().?; - - try writer.print(" .{{ 0x{s}, 0x{s}, \"{s}\" }},\n", .{ from, to, name }); - return true; - } - }).do(); + inline for (files) |f| { + try f.default.do(); + } } diff --git a/scripts/blocks.zig b/scripts/blocks.zig new file mode 100644 index 0000000000000000000000000000000000000000..d1b36f669c7ba73100e8558979388ce3df23337f --- /dev/null +++ b/scripts/blocks.zig @@ -0,0 +1,35 @@ +const std = @import("std"); +const common = @import("./_common.zig"); + +pub const default = common.Main(struct { + pub const source_url = "https://unicode.org/Public/UCD/latest/ucd/Blocks.txt"; + + pub const dest_file = "src/blocks.zig"; + + pub const dest_header = + \\pub const Block = struct { + \\ from: u21, + \\ to: u21, + \\ name: []const u8, + \\}; + \\ + \\pub const blocks: []Block = &.{ + \\ + ; + + pub const dest_footer = + \\}; + \\ + ; + + pub fn exec(alloc: *std.mem.Allocator, line: []const u8, writer: anytype) !bool { + var it1 = std.mem.split(line, "; "); + var it2 = std.mem.split(it1.next().?, ".."); + const from = it2.next().?; + const to = it2.next().?; + const name = it1.next().?; + + try writer.print(" .{{ 0x{s}, 0x{s}, \"{s}\" }},\n", .{ from, to, name }); + return true; + } +});