5 $UnicodeData = "Unicode.300";
6 $SyllableData = "syllables.txt";
7 $PropData = "Props.txt";
10 # Note: we try to keep filenames unique within first 8 chars. Using
11 # subdirectories for the following helps.
19 ['IsWord', '$cat =~ /^L[ulot]|^Nd/ or $code eq "005F"', ''],
20 ['IsAlnum', '$cat =~ /^L[ulot]|^Nd/', ''],
21 ['IsAlpha', '$cat =~ /^L[ulot]/', ''],
22 ['IsSpace', 'White space', $PropData],
23 ['IsDigit', '$cat =~ /^Nd$/', ''],
24 ['IsUpper', '$cat =~ /^L[ut]$/', ''],
25 ['IsLower', '$cat =~ /^Ll$/', ''],
26 ['IsASCII', 'hex $code <= 127', ''],
27 ['IsCntrl', '$cat =~ /^C/', ''],
28 ['IsGraph', '$cat =~ /^[^C]/ and ($cat !~ /^Z/ and $code ne "0020" or chr(hex $code) !~ /^\s/)', ''],
29 ['IsPrint', '$cat =~ /^[^C]/', ''],
30 ['IsPunct', 'Punctuation', $PropData],
31 ['IsXDigit', '$code =~ /^00(3[0-9]|[46][1-6])$/', ''],
32 ['ToUpper', '$up', '$up'],
33 ['ToLower', '$down', '$down'],
34 ['ToTitle', '$title', '$title'],
35 ['ToDigit', '$dec ne ""', '$dec'],
39 ['Name', '$name', '$name'],
43 ['Category', '$cat', '$cat'],
47 ['IsM', '$cat =~ /^M/', ''], # Mark
48 ['IsMn', '$cat eq "Mn"', ''], # Mark, Non-Spacing
49 ['IsMc', '$cat eq "Mc"', ''], # Mark, Combining
50 ['IsMe', '$cat eq "Me"', ''], # Mark, Enclosing
52 ['IsN', '$cat =~ /^N/', ''], # Number
53 ['IsNd', '$cat eq "Nd"', ''], # Number, Decimal Digit
54 ['IsNo', '$cat eq "No"', ''], # Number, Other
55 ['IsNl', '$cat eq "Nl"', ''], # Number, Letter
57 ['IsZ', '$cat =~ /^Z/', ''], # Separator
58 ['IsZs', '$cat eq "Zs"', ''], # Separator, Space
59 ['IsZl', '$cat eq "Zl"', ''], # Separator, Line
60 ['IsZp', '$cat eq "Zp"', ''], # Separator, Paragraph
62 ['IsC', '$cat =~ /^C/', ''], # Crazy
63 ['IsCc', '$cat eq "Cc"', ''], # Other, Control or Format
64 ['IsCo', '$cat eq "Co"', ''], # Other, Private Use
65 ['IsCn', '$cat eq "Cn"', ''], # Other, Not Assigned
66 ['IsCf', '$cat eq "Cf"', ''], # Other, Format
67 ['IsCs', '$cat eq "Cs"', ''], # Other, Surrogate
68 ['IsCn', 'Unassigned Code Value',$PropData], # Other, Not Assigned
72 ['IsL', '$cat =~ /^L/', ''], # Letter
73 ['IsLu', '$cat eq "Lu"', ''], # Letter, Uppercase
74 ['IsLl', '$cat eq "Ll"', ''], # Letter, Lowercase
75 ['IsLt', '$cat eq "Lt"', ''], # Letter, Titlecase
76 ['IsLm', '$cat eq "Lm"', ''], # Letter, Modifier
77 ['IsLo', '$cat eq "Lo"', ''], # Letter, Other
79 ['IsP', '$cat =~ /^P/', ''], # Punctuation
80 ['IsPd', '$cat eq "Pd"', ''], # Punctuation, Dash
81 ['IsPs', '$cat eq "Ps"', ''], # Punctuation, Open
82 ['IsPe', '$cat eq "Pe"', ''], # Punctuation, Close
83 ['IsPo', '$cat eq "Po"', ''], # Punctuation, Other
84 ['IsPc', '$cat eq "Pc"', ''], # Punctuation, Connector
85 ['IsPi', '$cat eq "Pi"', ''], # Punctuation, Initial quote
86 ['IsPf', '$cat eq "Pf"', ''], # Punctuation, Final quote
88 ['IsS', '$cat =~ /^S/', ''], # Symbol
89 ['IsSm', '$cat eq "Sm"', ''], # Symbol, Math
90 ['IsSk', '$cat eq "Sk"', ''], # Symbol, Modifier
91 ['IsSc', '$cat eq "Sc"', ''], # Symbol, Currency
92 ['IsSo', '$cat eq "So"', ''], # Symbol, Other
95 ['CombiningClass', '$comb', '$comb'],
97 # BIDIRECTIONAL PROPERTIES
99 ['Bidirectional', '$bid', '$bid'],
103 ['IsBidiL', '$bid eq "L"', ''], # Left-Right; Most alphabetic,
104 # syllabic, and logographic
105 # characters (e.g., CJK
107 ['IsBidiR', '$bid eq "R"', ''], # Right-Left; Arabic, Hebrew,
108 # and punctuation specific to
111 ['IsBidiLRE', '$bid eq "LRE"', ''], # Left-to-Right Embedding
112 ['IsBidiLRO', '$bid eq "LRO"', ''], # Left-to-Right Override
113 ['IsBidiAL', '$bid eq "AL"', ''], # Right-to-Left Arabic
114 ['IsBidiRLE', '$bid eq "RLE"', ''], # Right-to-Left Embedding
115 ['IsBidiRLO', '$bid eq "RLO"', ''], # Right-to-Left Override
116 ['IsBidiPDF', '$bid eq "PDF"', ''], # Pop Directional Format
117 ['IsBidiNSM', '$bid eq "NSM"', ''], # Non-Spacing Mark
118 ['IsBidiBN', '$bid eq "BN"', ''], # Boundary Neutral
122 ['IsBidiEN','$bid eq "EN"', ''], # European Number
123 ['IsBidiES','$bid eq "ES"', ''], # European Number Separator
124 ['IsBidiET','$bid eq "ET"', ''], # European Number Terminator
125 ['IsBidiAN','$bid eq "AN"', ''], # Arabic Number
126 ['IsBidiCS','$bid eq "CS"', ''], # Common Number Separator
130 ['IsBidiB', '$bid eq "B"', ''], # Block Separator
131 ['IsBidiS', '$bid eq "S"', ''], # Segment Separator
135 ['IsBidiWS','$bid eq "WS"', ''], # Whitespace
136 ['IsBidiON','$bid eq "ON"', ''], # Other Neutrals ; All other
137 # characters: punctuation,
142 ['Decomposition', '$decomp', '$decomp'],
143 ['IsDecoCanon', '$decomp && $decomp !~ /^</', ''],
144 ['IsDecoCompat', '$decomp =~ /^</', ''],
145 ['IsDCfont', '$decomp =~ /^<font>/', ''],
146 ['IsDCnoBreak', '$decomp =~ /^<noBreak>/', ''],
147 ['IsDCinitial', '$decomp =~ /^<initial>/', ''],
148 ['IsDCinital', '$decomp =~ /^<medial>/', ''],
149 ['IsDCfinal', '$decomp =~ /^<final>/', ''],
150 ['IsDCisolated', '$decomp =~ /^<isolated>/', ''],
151 ['IsDCcircle', '$decomp =~ /^<circle>/', ''],
152 ['IsDCsuper', '$decomp =~ /^<super>/', ''],
153 ['IsDCsub', '$decomp =~ /^<sub>/', ''],
154 ['IsDCvertical', '$decomp =~ /^<vertical>/', ''],
155 ['IsDCwide', '$decomp =~ /^<wide>/', ''],
156 ['IsDCnarrow', '$decomp =~ /^<narrow>/', ''],
157 ['IsDCsmall', '$decomp =~ /^<small>/', ''],
158 ['IsDCsquare', '$decomp =~ /^<square>/', ''],
159 ['IsDCfraction', '$decomp =~ /^<fraction>/', ''],
160 ['IsDCcompat', '$decomp =~ /^<compat>/', ''],
164 ['Number', '$num ne ""', '$num'],
168 ['IsMirrored', '$mir eq "Y"', ''],
172 ['ArabLink', '1', '$link'],
173 ['ArabLnkGrp', '1', '$linkgroup'],
177 ['JamoShort', '1', '$short'],
183 # Line break properties - Normative
185 ['IsLbrkBK','$brk eq "BK"', ''], # Mandatory Break
186 ['IsLbrkCR','$brk eq "CR"', ''], # Carriage Return
187 ['IsLbrkLF','$brk eq "LF"', ''], # Line Feed
188 ['IsLbrkCM','$brk eq "CM"', ''], # Attached Characters and Combining Marks
189 ['IsLbrkSG','$brk eq "SG"', ''], # Surrogates
190 ['IsLbrkGL','$brk eq "GL"', ''], # Non-breaking (Glue)
191 ['IsLbrkCB','$brk eq "CB"', ''], # Contingent Break Opportunity
192 ['IsLbrkSP','$brk eq "SP"', ''], # Space
193 ['IsLbrkZW','$brk eq "ZW"', ''], # Zero Width Space
195 # Line break properties - Informative
196 ['IsLbrkXX','$brk eq "XX"', ''], # Unknown
197 ['IsLbrkOP','$brk eq "OP"', ''], # Opening Punctuation
198 ['IsLbrkCL','$brk eq "CL"', ''], # Closing Punctuation
199 ['IsLbrkQU','$brk eq "QU"', ''], # Ambiguous Quotation
200 ['IsLbrkNS','$brk eq "NS"', ''], # Non Starter
201 ['IsLbrkEX','$brk eq "EX"', ''], # Exclamation/Interrogation
202 ['IsLbrkSY','$brk eq "SY"', ''], # Symbols Allowing Breaks
203 ['IsLbrkIS','$brk eq "IS"', ''], # Infix Separator (Numeric)
204 ['IsLbrkPR','$brk eq "PR"', ''], # Prefix (Numeric)
205 ['IsLbrkPO','$brk eq "PO"', ''], # Postfix (Numeric)
206 ['IsLbrkNU','$brk eq "NU"', ''], # Numeric
207 ['IsLbrkAL','$brk eq "AL"', ''], # Ordinary Alphabetic and Symbol Characters
208 ['IsLbrkID','$brk eq "ID"', ''], # Ideographic
209 ['IsLbrkIN','$brk eq "IN"', ''], # Inseparable
210 ['IsLbrkHY','$brk eq "HY"', ''], # Hyphen
211 ['IsLbrkBB','$brk eq "BB"', ''], # Break Opportunity Before
212 ['IsLbrkBA','$brk eq "BA"', ''], # Break Opportunity After
213 ['IsLbrkSA','$brk eq "SA"', ''], # Complex Context (South East Asian)
214 ['IsLbrkAI','$brk eq "AI"', ''], # Ambiguous (Alphabetic or Ideographic)
215 ['IsLbrkB2','$brk eq "B2"', ''], # Break Opportunity Before and After
218 # This is not written for speed...
220 foreach $file (@todo) {
221 my ($table, $wanted, $val) = @$file;
222 next if @ARGV and not grep { $_ eq $table } @ARGV;
224 if ($table =~ /^(Is|In|To)(.*)/) {
225 open(OUT, ">$1/$2.pl") or die "Can't create $1/$2.pl: $!\n";
228 open(OUT, ">$table.pl") or die "Can't create $table.pl: $!\n";
231 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
232 # This file is built by $0 from e.g. $UnicodeData.
233 # Any changes made here will be lost!
238 print OUT proplist($table, $wanted, $val);
243 # Must treat blocks specially.
245 exit if @ARGV and not grep { $_ eq Block } @ARGV;
247 open(UD, 'Blocks.txt') or die "Can't open Blocks.txt: $!\n";
248 open(OUT, ">Block.pl") or die "Can't create Block.pl: $!\n";
250 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
251 # This file is built by $0 from e.g. $UnicodeData.
252 # Any changes made here will be lost!
262 ($code, $last, $name) = split(/; */);
264 print OUT "$code $last $name\n";
266 open(BLOCK, ">In/$name.pl");
268 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
269 # This file is built by $0 from e.g. $UnicodeData.
270 # Any changes made here will be lost!
272 print BLOCK <<"END2";
284 ##################################################
287 my ($table, $wanted, $val) = @_;
292 return listFromPropFile($wanted) if $val eq $PropData;
294 if ($table =~ /^Arab/) {
295 open(UD, "ArabShap.txt") or warn "Can't open $table: $!";
297 $split = '($code, $name, $link, $linkgroup) = split(/; */);';
299 elsif ($table =~ /^Jamo/) {
300 open(UD, "Jamo.txt") or warn "Can't open $table: $!";
302 $split = '($code, $short, $name) = split(/; */); $code =~ s/^U\+//;';
304 elsif ($table =~ /^IsSyl/) {
305 open(UD, $SyllableData) or warn "Can't open $table: $!";
307 $split = '($code, $short, $syl) = split(/; */); $code =~ s/^U\+//;';
309 elsif ($table =~ /^IsLbrk/) {
310 open(UD, "LineBrk.txt") or warn "Can't open $table: $!";
312 $split = '($code, $brk, $name) = split(/;/);';
315 open(UD, $UnicodeData) or warn "Can't open $UnicodeData: $!";
317 $split = '($code, $name, $cat, $comb, $bid, $decomp, $dec, $dig, $num, $mir, $uni1,
318 $comment, $up, $down, $title) = split(/;/);';
321 if ($table =~ /^(?:To|Is)[A-Z]/) {
329 push(\@wanted, [hex \$code, hex $val, \$name =~ /, First>\$/]);
336 $beg = shift @wanted;
338 while (@wanted and $wanted[0]->[0] == $last->[0] + 1 and
339 (not $val or $wanted[0]->[1] == $last->[1] + 1)) {
340 $last = shift @wanted;
342 $out .= sprintf "%04x", $beg->[0];
344 $last = shift @wanted;
350 $out .= sprintf "\t%04x", $last->[0];
352 $out .= sprintf "\t%04x", $beg->[1] if $val;
364 push(\@wanted, [hex \$code, $val, \$name =~ /, First>\$/]);
371 $beg = shift @wanted;
373 while (@wanted and $wanted[0]->[0] == $last->[0] + 1 and
374 ($wanted[0]->[1] eq $last->[1])) {
375 $last = shift @wanted;
377 $out .= sprintf "%04x", $beg->[0];
379 $last = shift @wanted;
385 $out .= sprintf "\t%04x", $last->[0];
387 $out .= sprintf "\t%s\n", $beg->[1];
393 sub listFromPropFile {
397 open (UD, $PropData) or die "Can't open $PropData: $!\n";
398 local($/) = "\n" . '*' x 43 . "\n\nProperty dump for:"; # not 42?
403 if (s/0x[\d\w]+\s+\((.*?)\)// and $wanted eq $1) {
420 open (SD, $SyllableData) or die "Can't open $SyllableData: $!\n";
424 ($code, $name, $syl) = split /; */;
426 push (@defs, ["IsSyl$syl", qq{\$syl eq "$syl"}, ''])
427 unless $seen{$syl}++;