| 1 | const std = @import("std"); |
| 2 | const common = @import("./_common.zig"); |
| 3 | |
| 4 | pub usingnamespace common.Main(struct { |
| 5 | pub const source_file = "DerivedCoreProperties"; |
| 6 | |
| 7 | pub const dest_file = "src/derived_core_properties.zig"; |
| 8 | |
| 9 | pub const dest_header = |
| 10 | \\pub const CoreProperty = struct { |
| 11 | \\ from: u21, |
| 12 | \\ to: u21, |
| 13 | \\ property: Property, |
| 14 | \\ |
| 15 | \\ pub const Property = enum { |
| 16 | \\ Math, |
| 17 | \\ Alphabetic, |
| 18 | \\ Lowercase, |
| 19 | \\ Uppercase, |
| 20 | \\ Cased, |
| 21 | \\ Case_Ignorable, |
| 22 | \\ Changes_When_Lowercased, |
| 23 | \\ Changes_When_Uppercased, |
| 24 | \\ Changes_When_Titlecased, |
| 25 | \\ Changes_When_Casefolded, |
| 26 | \\ Changes_When_Casemapped, |
| 27 | \\ ID_Start, |
| 28 | \\ ID_Continue, |
| 29 | \\ XID_Start, |
| 30 | \\ XID_Continue, |
| 31 | \\ Default_Ignorable_Code_Point, |
| 32 | \\ Grapheme_Extend, |
| 33 | \\ Grapheme_Base, |
| 34 | \\ Grapheme_Link, |
| 35 | \\ InCB, |
| 36 | \\ }; |
| 37 | \\}; |
| 38 | \\ |
| 39 | \\pub const data = [_]CoreProperty{ |
| 40 | \\ |
| 41 | ; |
| 42 | |
| 43 | pub const dest_footer = |
| 44 | \\}; |
| 45 | \\ |
| 46 | ; |
| 47 | |
| 48 | pub fn exec(alloc: std.mem.Allocator, line: []const u8, writer: anytype) !void { |
| 49 | _ = alloc; |
| 50 | var it = std.mem.tokenizeAny(u8, line, "; "); |
| 51 | |
| 52 | { |
| 53 | const range = it.next().?; |
| 54 | if (std.mem.indexOf(u8, range, "..")) |index| { |
| 55 | try writer.print(" .{{ .from = 0x{s}, .to = 0x{s},", .{ range[0..index], range[index + 2 ..] }); |
| 56 | } else { |
| 57 | try writer.print(" .{{ .from = 0x{s}, .to = 0x{s},", .{ range, range }); |
| 58 | } |
| 59 | } |
| 60 | { |
| 61 | const prop = it.next().?; |
| 62 | try writer.print(" .property = .{s} }},\n", .{prop}); |
| 63 | } |
| 64 | } |
| 65 | }); |