my $in_file_pound_if = 0;
+my $max_hdr_len = 3; # In headings, how wide a name is allowed?
+
print $out_fh "/* See the generating file for comments */\n\n";
# The symbols generated by this program are all currently defined only in a
);
# This hash contains the properties with enums that have hard-coded references
-# to them in C code. Its only use is to make sure that if perl is compiled
+# to them in C code. It is neeed to make sure that if perl is compiled
# with an older Unicode data set, that all the enum values the code is
# expecting will still be in the enum typedef. Thus the code doesn't have to
-# change. The Unicode version won't have any code points that have these enum
-# values, so the code that handles them will not get exercised. This is far
-# better than having to #ifdef things.
+# change. The Unicode version won't have any code points that have the enum
+# values not in that version, so the code that handles them will not get
+# exercised. This is far better than having to #ifdef things. The names here
+# should be the long names of the respective property values. The reason for
+# this is because regexec.c uses them as case labels, and the long name is
+# generally more understandable than the short.
my %hard_coded_enums =
( gcb => [
'Control',
'CR',
+ 'E_Base',
+ 'E_Base_GAZ',
+ 'E_Modifier',
'Extend',
+ 'Glue_After_Zwj',
'L',
'LF',
'LV',
'SpacingMark',
'T',
'V',
+ 'ZWJ',
],
lb => [
'Alphabetic',
'Close_Punctuation',
'Combining_Mark',
'Contingent_Break',
+ 'E_Base',
+ 'E_Modifier',
'Exclamation',
'Glue',
'H2',
'Regional_Indicator',
'Space',
'Word_Joiner',
+ 'ZWJ',
'ZWSpace',
],
sb => [
'ALetter',
'CR',
'Double_Quote',
+ 'E_Base',
+ 'E_Base_GAZ',
+ 'E_Modifier',
'Extend',
'ExtendNumLet',
'Format',
+ 'Glue_After_Zwj',
'Hebrew_Letter',
'Katakana',
'LF',
'Perl_Tailored_HSpace',
'Regional_Indicator',
'Single_Quote',
+ 'ZWJ',
],
);
+my %gcb_enums;
+my @gcb_short_enums;
+my %gcb_abbreviations;
my %lb_enums;
my @lb_short_enums;
+my %lb_abbreviations;
+my %wb_enums;
+my @wb_short_enums;
+my %wb_abbreviations;
my @a2n;
else {
@enums = uniques(@$invmap);
}
+
if (! @enums) {
die "Only enum properties are currently handled; '$prop_name' isn't one";
}
else {
-
- # Convert short names to long
- @enums = map { (prop_value_aliases($prop_name, $_))[1] } @enums;
-
my @expected_enums = @{$hard_coded_enums{lc $short_name}};
- die 'You need to update %hard_coded_enums to reflect new entries in this Unicode version'
- if @expected_enums < @enums;
-
- # Remove the enums found in the input from the ones we expect
- for (my $i = @expected_enums - 1; $i >= 0; $i--) {
- splice(@expected_enums, $i, 1)
- if grep { $expected_enums[$i] eq $_ } @enums;
- }
+ my @canonical_input_enums;
+ if (@expected_enums) {
+ if (@expected_enums < @enums) {
+ die 'You need to update %hard_coded_enums to reflect new'
+ . " entries in this Unicode version\n"
+ . "Expected: " . join(", ", sort @expected_enums) . "\n"
+ . " Got: " . join(", ", sort @enums);
+ }
- # The ones remaining must be because we're using an older
- # Unicode version. Add them to the list.
- push @enums, @expected_enums;
+ if (! defined prop_aliases($prop_name)) {
- # Add in the extra values coded into this program, and sort.
- @enums = sort @enums;
+ # Convert the input enums into canonical form and
+ # save for use below
+ @canonical_input_enums = map { lc ($_ =~ s/_//gr) }
+ @enums;
+ }
+ @enums = sort @expected_enums;
+ }
- # The internal enums comes last.
- push @enums, split /,/, $extra_enums if $extra_enums ne "";
+ # The internal enums come last, and in the order specified
+ my @extras;
+ if ($extra_enums ne "") {
+ @extras = split /,/, $extra_enums;
+ push @enums, @extras;
+ }
# Assign a value to each element of the enum. The default
# value always gets 0; the others are arbitrarily assigned.
$enums{$enum} = $enum_val++ unless exists $enums{$enum};
}
- # Calculate the enum values for property _Perl_LB because we
- # output a special table for that
- if ($name eq '_Perl_LB' && ! %lb_enums) {
- while (my ($enum, $value) = each %enums) {
- my ($short) = prop_value_aliases('LB', $enum);
- $short = substr(lc $enum, 0, 2) unless defined $short;
- $lb_enums{$short} = $value;
- @lb_short_enums[$value] = $short;
+ # Calculate the enum values for certain properties like
+ # _Perl_GCB and _Perl_LB, because we output special tables for
+ # them.
+ if ($name =~ / ^ _Perl_ (?: GCB | LB | WB ) $ /x) {
+
+ # We use string evals to allow the same code to work on
+ # all tables we're doing.
+ my $type = lc $prop_name;
+
+ # We use lowercase single letter names for any property
+ # values not in the release of Unicode being compiled now.
+ my $placeholder = "a";
+
+ # Skip if we've already done this code, which populated
+ # this hash
+ if (eval "! \%${type}_enums") {
+
+ # For each enum ...
+ foreach my $enum (sort keys %enums) {
+ my $value = $enums{$enum};
+ my $short;
+ my $abbreviated_from;
+
+ # Special case this wb property value to make the
+ # name more clear
+ if ($enum eq 'Perl_Tailored_HSpace') {
+ $short = 'hs';
+ $abbreviated_from = $enum;
+ }
+ elsif (grep { $_ eq $enum } @extras) {
+
+ # The 'short' name for one of the property
+ # values added by this file is just the
+ # lowercase of it
+ $short = lc $enum;
+ }
+ elsif (grep {$_ eq lc ( $enum =~ s/_//gr) }
+ @canonical_input_enums)
+ { # On Unicode versions that predate the
+ # official property, we have set up this array
+ # to be the canonical form of each enum in the
+ # substitute property. If the enum we're
+ # looking at is canonically the same as one of
+ # these, use its name instead of generating a
+ # placeholder one in the next clause (which
+ # will happen because prop_value_aliases()
+ # will fail because it only works on official
+ # properties)
+ $short = $enum;
+ }
+ else {
+ # Use the official short name for the other
+ # property values, which should all be
+ # official ones.
+ ($short) = prop_value_aliases($type, $enum);
+
+ # But create a placeholder for ones not in
+ # this Unicode version.
+ $short = $placeholder++ unless defined $short;
+ }
+
+ # If our short name is too long, or we already
+ # know that the name is an abbreviation, truncate
+ # to make sure it's short enough, and remember
+ # that we did this so we can later place in a
+ # comment in the generated file
+ if ( $abbreviated_from
+ || length $short > $max_hdr_len)
+ {
+ $short = substr($short, 0, $max_hdr_len);
+ $abbreviated_from = $enum
+ unless $abbreviated_from;
+ # If the name we are to display conflicts, try
+ # another.
+ while (eval "exists
+ \$${type}_abbreviations{$short}")
+ {
+ die $@ if $@;
+ $short++;
+ }
+
+ eval "\$${type}_abbreviations{$short} = '$enum'";
+ die $@ if $@;
+ }
+
+ # Remember the mapping from the property value
+ # (enum) name to its value.
+ eval "\$${type}_enums{$enum} = $value";
+ die $@ if $@;
+
+ # Remember the inverse mapping to the short name
+ # so that we can properly label the generated
+ # table's rows and columns
+ eval "\$${type}_short_enums[$value] = '$short'";
+ die $@ if $@;
+ }
}
}
}
return mk_invlist_from_sorted_cp_list([ 128 .. 255 ]);
}
+sub output_table_common {
+
+ # Common subroutine to actually output the generated rules table.
+
+ my ($property,
+ $table_value_defines_ref,
+ $table_ref,
+ $names_ref,
+ $abbreviations_ref) = @_;
+ my $size = @$table_ref;
+
+ # Output the #define list, sorted by numeric value
+ if ($table_value_defines_ref) {
+ my $max_name_length = 0;
+ my @defines;
+
+ # Put in order, and at the same time find the longest name
+ while (my ($enum, $value) = each %$table_value_defines_ref) {
+ $defines[$value] = $enum;
+
+ my $length = length $enum;
+ $max_name_length = $length if $length > $max_name_length;
+ }
+
+ print $out_fh "\n";
+
+ # Output, so that the values are vertically aligned in a column after
+ # the longest name
+ foreach my $i (0 .. @defines - 1) {
+ next unless defined $defines[$i];
+ printf $out_fh "#define %-*s %2d\n",
+ $max_name_length,
+ $defines[$i],
+ $i;
+ }
+ }
+
+ my $column_width = 2; # We currently allow 2 digits for the number
+
+ # If the maximum value in the table is 1, it can be a bool. (Being above
+ # a U8 is not currently handled
+ my $max_element = 0;
+ for my $i (0 .. $size - 1) {
+ for my $j (0 .. $size - 1) {
+ next if $max_element >= $table_ref->[$i][$j];
+ $max_element = $table_ref->[$i][$j];
+ }
+ }
+ die "Need wider table column width given '$max_element"
+ if length $max_element > $column_width;
+
+ my $table_type = ($max_element == 1)
+ ? 'bool'
+ : 'U8';
+
+ # If a name is longer than the width set aside for a column, its column
+ # needs to have increased spacing so that the name doesn't get truncated
+ # nor run into an adjacent column
+ my @spacers;
+
+ # If we are being compiled on a Unicode version earlier than that which
+ # this file was designed for, it may be that some of the property values
+ # aren't in the current release, and so would be undefined if we didn't
+ # define them ourselves. Earlier code has done this, making them
+ # lowercase characters of length one. We look to see if any exist, so
+ # that we can add an annotation to the output table
+ my $has_placeholder = 0;
+
+ for my $i (0 .. $size - 1) {
+ no warnings 'numeric';
+ $has_placeholder = 1 if $names_ref->[$i] =~ / ^ [[:lower:]] $ /ax;
+ $spacers[$i] = " " x (length($names_ref->[$i]) - $column_width);
+ }
+
+ print $out_fh "\nstatic const $table_type ${property}_table[$size][$size] = {\n";
+
+ # Calculate the column heading line
+ my $header_line = "/* "
+ . (" " x $max_hdr_len) # We let the row heading meld to
+ # the '*/' for those that are at
+ # the max
+ . " " x 3; # Space for '*/ '
+ # Now each column
+ for my $i (0 .. $size - 1) {
+ $header_line .= sprintf "%s%*s",
+ $spacers[$i],
+ $column_width + 1, # 1 for the ','
+ $names_ref->[$i];
+ }
+ $header_line .= " */\n";
+
+ # If we have annotations, output it now.
+ if ($has_placeholder || scalar %$abbreviations_ref) {
+ my $text = "";
+ foreach my $abbr (sort keys %$abbreviations_ref) {
+ $text .= "; " if $text;
+ $text .= "'$abbr' stands for '$abbreviations_ref->{$abbr}'";
+ }
+ if ($has_placeholder) {
+ $text .= "; other " if $text;
+ $text .= "lowercase names are placeholders for"
+ . " property values not defined until a later Unicode"
+ . " release, so are irrelevant in this one, as they are"
+ . " not assigned to any code points";
+ }
+
+ my $indent = " " x 3;
+ $text = $indent . "/* $text */";
+
+ # Wrap the text so that it is no wider than the table, which the
+ # header line gives.
+ my $output_width = length $header_line;
+ while (length $text > $output_width) {
+ my $cur_line = substr($text, 0, $output_width);
+
+ # Find the first blank back from the right end to wrap at.
+ for (my $i = $output_width -1; $i > 0; $i--) {
+ if (substr($text, $i, 1) eq " ") {
+ print $out_fh substr($text, 0, $i), "\n";
+
+ # Set so will look at just the remaining tail (which will
+ # be indented and have a '*' after the indent
+ $text = $indent . " * " . substr($text, $i + 1);
+ last;
+ }
+ }
+ }
+
+ # And any remaining
+ print $out_fh $text, "\n" if $text;
+ }
+
+ # We calculated the header line earlier just to get its width so that we
+ # could make sure the annotations fit into that.
+ print $out_fh $header_line;
+
+ # Now output the bulk of the table.
+ for my $i (0 .. $size - 1) {
+
+ # First the row heading.
+ printf $out_fh "/* %-*s*/ ", $max_hdr_len, $names_ref->[$i];
+ print $out_fh "{"; # Then the brace for this row
+
+ # Then each column
+ for my $j (0 .. $size -1) {
+ print $out_fh $spacers[$j];
+ printf $out_fh "%*d", $column_width, $table_ref->[$i][$j];
+ print $out_fh "," if $j < $size - 1;
+ }
+ print $out_fh " }";
+ print $out_fh "," if $i < $size - 1;
+ print $out_fh "\n";
+ }
+
+ print $out_fh "};\n";
+}
+
+sub output_GCB_table() {
+
+ # Create and output the pair table for use in determining Grapheme Cluster
+ # Breaks, given in http://www.unicode.org/reports/tr29/.
+ my %gcb_actions = (
+ GCB_NOBREAK => 0,
+ GCB_BREAKABLE => 1,
+ GCB_RI_then_RI => 2, # Rules 12 and 13
+ GCB_EX_then_EM => 3, # Rule 10
+ );
+
+ # The table is constructed in reverse order of the rules, to make the
+ # lower-numbered, higher priority ones override the later ones, as the
+ # algorithm stops at the earliest matching rule
+
+ my @gcb_table;
+ my $table_size = @gcb_short_enums;
+
+ # Otherwise, break everywhere.
+ # GB99 Any ÷ Any
+ for my $i (0 .. $table_size - 1) {
+ for my $j (0 .. $table_size - 1) {
+ $gcb_table[$i][$j] = 1;
+ }
+ }
+
+ # Do not break within emoji flag sequences. That is, do not break between
+ # regional indicator (RI) symbols if there is an odd number of RI
+ # characters before the break point. Must be resolved in runtime code.
+ #
+ # GB12 ^ (RI RI)* RI × RI
+ # GB13 [^RI] (RI RI)* RI × RI
+ $gcb_table[$gcb_enums{'Regional_Indicator'}]
+ [$gcb_enums{'Regional_Indicator'}] = $gcb_actions{GCB_RI_then_RI};
+
+ # Do not break within emoji modifier sequences or emoji zwj sequences.
+ # GB11 ZWJ × ( Glue_After_Zwj | E_Base_GAZ )
+ $gcb_table[$gcb_enums{'ZWJ'}][$gcb_enums{'Glue_After_Zwj'}] = 0;
+ $gcb_table[$gcb_enums{'ZWJ'}][$gcb_enums{'E_Base_GAZ'}] = 0;
+
+ # GB10 ( E_Base | E_Base_GAZ ) Extend* × E_Modifier
+ $gcb_table[$gcb_enums{'Extend'}][$gcb_enums{'E_Modifier'}]
+ = $gcb_actions{GCB_EX_then_EM};
+ $gcb_table[$gcb_enums{'E_Base'}][$gcb_enums{'E_Modifier'}] = 0;
+ $gcb_table[$gcb_enums{'E_Base_GAZ'}][$gcb_enums{'E_Modifier'}] = 0;
+
+ # Do not break before extending characters or ZWJ.
+ # Do not break before SpacingMarks, or after Prepend characters.
+ # GB9b Prepend ×
+ # GB9a × SpacingMark
+ # GB9 × ( Extend | ZWJ )
+ for my $i (0 .. @gcb_table - 1) {
+ $gcb_table[$gcb_enums{'Prepend'}][$i] = 0;
+ $gcb_table[$i][$gcb_enums{'SpacingMark'}] = 0;
+ $gcb_table[$i][$gcb_enums{'Extend'}] = 0;
+ $gcb_table[$i][$gcb_enums{'ZWJ'}] = 0;
+ }
+
+ # Do not break Hangul syllable sequences.
+ # GB8 ( LVT | T) × T
+ $gcb_table[$gcb_enums{'LVT'}][$gcb_enums{'T'}] = 0;
+ $gcb_table[$gcb_enums{'T'}][$gcb_enums{'T'}] = 0;
+
+ # GB7 ( LV | V ) × ( V | T )
+ $gcb_table[$gcb_enums{'LV'}][$gcb_enums{'V'}] = 0;
+ $gcb_table[$gcb_enums{'LV'}][$gcb_enums{'T'}] = 0;
+ $gcb_table[$gcb_enums{'V'}][$gcb_enums{'V'}] = 0;
+ $gcb_table[$gcb_enums{'V'}][$gcb_enums{'T'}] = 0;
+
+ # GB6 L × ( L | V | LV | LVT )
+ $gcb_table[$gcb_enums{'L'}][$gcb_enums{'L'}] = 0;
+ $gcb_table[$gcb_enums{'L'}][$gcb_enums{'V'}] = 0;
+ $gcb_table[$gcb_enums{'L'}][$gcb_enums{'LV'}] = 0;
+ $gcb_table[$gcb_enums{'L'}][$gcb_enums{'LVT'}] = 0;
+
+ # Do not break between a CR and LF. Otherwise, break before and after
+ # controls.
+ # GB5 ÷ ( Control | CR | LF )
+ # GB4 ( Control | CR | LF ) ÷
+ for my $i (0 .. @gcb_table - 1) {
+ $gcb_table[$i][$gcb_enums{'Control'}] = 1;
+ $gcb_table[$i][$gcb_enums{'CR'}] = 1;
+ $gcb_table[$i][$gcb_enums{'LF'}] = 1;
+ $gcb_table[$gcb_enums{'Control'}][$i] = 1;
+ $gcb_table[$gcb_enums{'CR'}][$i] = 1;
+ $gcb_table[$gcb_enums{'LF'}][$i] = 1;
+ }
+
+ # GB3 CR × LF
+ $gcb_table[$gcb_enums{'CR'}][$gcb_enums{'LF'}] = 0;
+
+ # Break at the start and end of text, unless the text is empty
+ # GB1 sot ÷
+ # GB2 ÷ eot
+ for my $i (0 .. @gcb_table - 1) {
+ $gcb_table[$i][$gcb_enums{'EDGE'}] = 1;
+ $gcb_table[$gcb_enums{'EDGE'}][$i] = 1;
+ }
+ $gcb_table[$gcb_enums{'EDGE'}][$gcb_enums{'EDGE'}] = 0;
+
+ output_table_common('GCB', \%gcb_actions,
+ \@gcb_table, \@gcb_short_enums, \%gcb_abbreviations);
+}
+
sub output_LB_table() {
# Create and output the enums, #defines, and pair table for use in
# given in http://www.unicode.org/reports/tr14/, but tailored by example 7
# in that page, as the Unicode-furnished tests assume that tailoring.
- switch_pound_if('LB_table', 'PERL_IN_REGEXEC_C');
-
# The result is really just true or false. But we follow along with tr14,
# creating a rule which is false for something like X SP* X. That gets
# encoding 2. The rest of the actions are synthetic ones that indicate
LB_BREAKABLE => 1,
LB_NOBREAK_EVEN_WITH_SP_BETWEEN => 2,
- LB_CM_foo => 3, # Rule 9
+ LB_CM_ZWJ_foo => 3, # Rule 9
LB_SP_foo => 6, # Rule 18
LB_PR_or_PO_then_OP_or_HY => 9, # Rule 25
LB_SY_or_IS_then_various => 11, # Rule 25
LB_HY_or_BA_then_foo => 13, # Rule 21
+ LB_RI_then_RI => 15, # Rule 30a
- LB_various_then_PO_or_PR => (1<<4), # Rule 25
+ LB_various_then_PO_or_PR => (1<<5), # Rule 25
);
- # Output the #define list, sorted by numeric value
- my @defines;
- while (my ($enum, $value) = each %lb_actions) {
- $defines[$value] = $enum;
- }
-
- print $out_fh "\n";
-
- foreach my $i (0 .. @defines - 1) {
- next unless defined $defines[$i];
- print $out_fh "#define $defines[$i]\t$i\n";
- }
-
# Construct the LB pair table. This is based on the rules in
# http://www.unicode.org/reports/tr14/, but modified as those rules are
# designed for someone taking a string of text and sequentially going
}
}
- # LB30a. Don't break between Regional Indicators
- $lb_table[$lb_enums{'RI'}][$lb_enums{'RI'}] = $lb_actions{'LB_NOBREAK'};
+ # LB30b Do not break between an emoji base and an emoji modifier.
+ # EB × EM
+ $lb_table[$lb_enums{'E_Base'}][$lb_enums{'E_Modifier'}]
+ = $lb_actions{'LB_NOBREAK'};
+
+ # LB30a Break between two regional indicator symbols if and only if there
+ # are an even number of regional indicators preceding the position of the
+ # break.
+ # sot (RI RI)* RI × RI
+ # [^RI] (RI RI)* RI × RI
+ $lb_table[$lb_enums{'Regional_Indicator'}]
+ [$lb_enums{'Regional_Indicator'}] = $lb_actions{'LB_RI_then_RI'};
# LB30 Do not break between letters, numbers, or ordinary symbols and
# opening or closing parentheses.
# (AL | HL | NU) × OP
- $lb_table[$lb_enums{'AL'}][$lb_enums{'OP'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'HL'}][$lb_enums{'OP'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'NU'}][$lb_enums{'OP'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Alphabetic'}][$lb_enums{'Open_Punctuation'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hebrew_Letter'}][$lb_enums{'Open_Punctuation'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Open_Punctuation'}]
+ = $lb_actions{'LB_NOBREAK'};
# CP × (AL | HL | NU)
- $lb_table[$lb_enums{'CP'}][$lb_enums{'AL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'CP'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'CP'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Close_Parenthesis'}][$lb_enums{'Alphabetic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Close_Parenthesis'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Close_Parenthesis'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB29 Do not break between numeric punctuation and alphabetics (“e.g.”).
# IS × (AL | HL)
- $lb_table[$lb_enums{'IS'}][$lb_enums{'AL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Alphabetic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB28 Do not break between alphabetics (“at”).
# (AL | HL) × (AL | HL)
- $lb_table[$lb_enums{'AL'}][$lb_enums{'AL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'HL'}][$lb_enums{'AL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'AL'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'HL'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Alphabetic'}][$lb_enums{'Alphabetic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hebrew_Letter'}][$lb_enums{'Alphabetic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Alphabetic'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hebrew_Letter'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB27 Treat a Korean Syllable Block the same as ID.
# (JL | JV | JT | H2 | H3) × IN
- $lb_table[$lb_enums{'JL'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'JV'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'JT'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'H2'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'H3'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'JL'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'JV'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'JT'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'H2'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'H3'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
# (JL | JV | JT | H2 | H3) × PO
- $lb_table[$lb_enums{'JL'}][$lb_enums{'PO'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'JV'}][$lb_enums{'PO'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'JT'}][$lb_enums{'PO'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'H2'}][$lb_enums{'PO'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'H3'}][$lb_enums{'PO'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'JL'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'JV'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'JT'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'H2'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'H3'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
# PR × (JL | JV | JT | H2 | H3)
- $lb_table[$lb_enums{'PR'}][$lb_enums{'JL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'PR'}][$lb_enums{'JV'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'PR'}][$lb_enums{'JT'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'PR'}][$lb_enums{'H2'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'PR'}][$lb_enums{'H3'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'JL'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'JV'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'JT'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'H2'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'H3'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB26 Do not break a Korean syllable.
# JL × (JL | JV | H2 | H3)
# http://www.unicode.org/reports/tr14/#Examples
# We follow that tailoring because Unicode's test cases expect it
# (PR | PO) × ( OP | HY )? NU
- $lb_table[$lb_enums{'PR'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'PO'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Postfix_Numeric'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
# Given that (OP | HY )? is optional, we have to test for it in code.
# We add in the action (instead of overriding) for this, so that in
# the code we can recover the underlying break value.
- $lb_table[$lb_enums{'PR'}][$lb_enums{'OP'}]
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'Open_Punctuation'}]
+= $lb_actions{'LB_PR_or_PO_then_OP_or_HY'};
- $lb_table[$lb_enums{'PO'}][$lb_enums{'OP'}]
+ $lb_table[$lb_enums{'Postfix_Numeric'}][$lb_enums{'Open_Punctuation'}]
+= $lb_actions{'LB_PR_or_PO_then_OP_or_HY'};
- $lb_table[$lb_enums{'PR'}][$lb_enums{'HY'}]
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'Hyphen'}]
+= $lb_actions{'LB_PR_or_PO_then_OP_or_HY'};
- $lb_table[$lb_enums{'PO'}][$lb_enums{'HY'}]
+ $lb_table[$lb_enums{'Postfix_Numeric'}][$lb_enums{'Hyphen'}]
+= $lb_actions{'LB_PR_or_PO_then_OP_or_HY'};
# ( OP | HY ) × NU
- $lb_table[$lb_enums{'OP'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'HY'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Open_Punctuation'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hyphen'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
# NU (NU | SY | IS)* × (NU | SY | IS | CL | CP )
# which can be rewritten as:
# NU (SY | IS)* × (NU | SY | IS | CL | CP )
- $lb_table[$lb_enums{'NU'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'NU'}][$lb_enums{'SY'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'NU'}][$lb_enums{'IS'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'NU'}][$lb_enums{'CL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'NU'}][$lb_enums{'CP'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Break_Symbols'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Infix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Close_Punctuation'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Close_Parenthesis'}]
+ = $lb_actions{'LB_NOBREAK'};
# Like earlier where we have to test in code, we add in the action so
# that we can recover the underlying values. This is done in rules
# below, as well. The code assumes that we haven't added 2 actions.
# Shoul a later Unicode release break that assumption, then tests
# should start failing.
- $lb_table[$lb_enums{'SY'}][$lb_enums{'NU'}]
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Numeric'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'SY'}][$lb_enums{'SY'}]
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Break_Symbols'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'SY'}][$lb_enums{'IS'}]
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Infix_Numeric'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'SY'}][$lb_enums{'CL'}]
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Close_Punctuation'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'SY'}][$lb_enums{'CP'}]
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Close_Parenthesis'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'NU'}]
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Numeric'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'SY'}]
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Break_Symbols'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'IS'}]
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Infix_Numeric'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'CL'}]
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Close_Punctuation'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'CP'}]
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Close_Parenthesis'}]
+= $lb_actions{'LB_SY_or_IS_then_various'};
# NU (NU | SY | IS)* (CL | CP)? × (PO | PR)
# which can be rewritten as:
# NU (SY | IS)* (CL | CP)? × (PO | PR)
- $lb_table[$lb_enums{'NU'}][$lb_enums{'PO'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'NU'}][$lb_enums{'PR'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Prefix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'CP'}][$lb_enums{'PO'}]
+ $lb_table[$lb_enums{'Close_Parenthesis'}][$lb_enums{'Postfix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- $lb_table[$lb_enums{'CL'}][$lb_enums{'PO'}]
+ $lb_table[$lb_enums{'Close_Punctuation'}][$lb_enums{'Postfix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'PO'}]
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Postfix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- $lb_table[$lb_enums{'SY'}][$lb_enums{'PO'}]
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Postfix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- $lb_table[$lb_enums{'CP'}][$lb_enums{'PR'}]
+ $lb_table[$lb_enums{'Close_Parenthesis'}][$lb_enums{'Prefix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- $lb_table[$lb_enums{'CL'}][$lb_enums{'PR'}]
+ $lb_table[$lb_enums{'Close_Punctuation'}][$lb_enums{'Prefix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- $lb_table[$lb_enums{'IS'}][$lb_enums{'PR'}]
+ $lb_table[$lb_enums{'Infix_Numeric'}][$lb_enums{'Prefix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- $lb_table[$lb_enums{'SY'}][$lb_enums{'PR'}]
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Prefix_Numeric'}]
+= $lb_actions{'LB_various_then_PO_or_PR'};
- # LB24 Do not break between prefix and letters or ideographs.
- # PR × ID
- $lb_table[$lb_enums{'PR'}][$lb_enums{'ID'}] = $lb_actions{'LB_NOBREAK'};
-
- # PR × (AL | HL)
- $lb_table[$lb_enums{'PR'}][$lb_enums{'AL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'PR'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
-
- # PO × (AL | HL)
- $lb_table[$lb_enums{'PO'}][$lb_enums{'AL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'PO'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
-
- # LB23 Do not break within ‘a9’, ‘3a’, or ‘H%’.
- # ID × PO
- $lb_table[$lb_enums{'ID'}][$lb_enums{'PO'}] = $lb_actions{'LB_NOBREAK'};
-
+ # LB24 Do not break between numeric prefix/postfix and letters, or between
+ # letters and prefix/postfix.
+ # (PR | PO) × (AL | HL)
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'Alphabetic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Postfix_Numeric'}][$lb_enums{'Alphabetic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Postfix_Numeric'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
+
+ # (AL | HL) × (PR | PO)
+ $lb_table[$lb_enums{'Alphabetic'}][$lb_enums{'Prefix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hebrew_Letter'}][$lb_enums{'Prefix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Alphabetic'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hebrew_Letter'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+
+ # LB23a Do not break between numeric prefixes and ideographs, or between
+ # ideographs and numeric postfixes.
+ # PR × (ID | EB | EM)
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'Ideographic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'E_Base'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Prefix_Numeric'}][$lb_enums{'E_Modifier'}]
+ = $lb_actions{'LB_NOBREAK'};
+
+ # (ID | EB | EM) × PO
+ $lb_table[$lb_enums{'Ideographic'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'E_Base'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'E_Modifier'}][$lb_enums{'Postfix_Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+
+ # LB23 Do not break between digits and letters
# (AL | HL) × NU
- $lb_table[$lb_enums{'AL'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'HL'}][$lb_enums{'NU'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Alphabetic'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hebrew_Letter'}][$lb_enums{'Numeric'}]
+ = $lb_actions{'LB_NOBREAK'};
# NU × (AL | HL)
- $lb_table[$lb_enums{'NU'}][$lb_enums{'AL'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'NU'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Alphabetic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB22 Do not break between two ellipses, or between letters, numbers or
# exclamations and ellipsis.
# (AL | HL) × IN
- $lb_table[$lb_enums{'AL'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'HL'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
-
- # EX × IN
- $lb_table[$lb_enums{'EX'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
-
- # ID × IN
- $lb_table[$lb_enums{'ID'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Alphabetic'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Hebrew_Letter'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+
+ # Exclamation × IN
+ $lb_table[$lb_enums{'Exclamation'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+
+ # (ID | EB | EM) × IN
+ $lb_table[$lb_enums{'Ideographic'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'E_Base'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'E_Modifier'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
# IN × IN
- $lb_table[$lb_enums{'IN'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Inseparable'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
# NU × IN
- $lb_table[$lb_enums{'NU'}][$lb_enums{'IN'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Numeric'}][$lb_enums{'Inseparable'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB21b Don’t break between Solidus and Hebrew letters.
# SY × HL
- $lb_table[$lb_enums{'SY'}][$lb_enums{'HL'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Break_Symbols'}][$lb_enums{'Hebrew_Letter'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB21a Don't break after Hebrew + Hyphen.
# HL (HY | BA) ×
for my $i (0 .. @lb_table - 1) {
- $lb_table[$lb_enums{'HY'}][$i] += $lb_actions{'LB_HY_or_BA_then_foo'};
- $lb_table[$lb_enums{'BA'}][$i] += $lb_actions{'LB_HY_or_BA_then_foo'};
+ $lb_table[$lb_enums{'Hyphen'}][$i]
+ += $lb_actions{'LB_HY_or_BA_then_foo'};
+ $lb_table[$lb_enums{'Break_After'}][$i]
+ += $lb_actions{'LB_HY_or_BA_then_foo'};
}
# LB21 Do not break before hyphen-minus, other hyphens, fixed-width
# × NS
# BB ×
for my $i (0 .. @lb_table - 1) {
- $lb_table[$i][$lb_enums{'BA'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$i][$lb_enums{'HY'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$i][$lb_enums{'NS'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'BB'}][$i] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Break_After'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Hyphen'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Nonstarter'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Break_Before'}][$i] = $lb_actions{'LB_NOBREAK'};
}
# LB20 Break before and after unresolved CB.
# rules. However, the default action is to treat unresolved CB as breaking
# before and after.
for my $i (0 .. @lb_table - 1) {
- $lb_table[$i][$lb_enums{'CB'}] = $lb_actions{'LB_BREAKABLE'};
- $lb_table[$lb_enums{'CB'}][$i] = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$i][$lb_enums{'Contingent_Break'}]
+ = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'Contingent_Break'}][$i]
+ = $lb_actions{'LB_BREAKABLE'};
}
# LB19 Do not break before or after quotation marks, such as ‘ ” ’.
# × QU
# QU ×
for my $i (0 .. @lb_table - 1) {
- $lb_table[$i][$lb_enums{'QU'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$lb_enums{'QU'}][$i] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Quotation'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Quotation'}][$i] = $lb_actions{'LB_NOBREAK'};
}
# LB18 Break after spaces
# SP ÷
for my $i (0 .. @lb_table - 1) {
- $lb_table[$lb_enums{'SP'}][$i] = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'Space'}][$i] = $lb_actions{'LB_BREAKABLE'};
}
# LB17 Do not break within ‘——’, even with intervening spaces.
# B2 SP* × B2
- $lb_table[$lb_enums{'B2'}][$lb_enums{'B2'}]
+ $lb_table[$lb_enums{'Break_Both'}][$lb_enums{'Break_Both'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
# LB16 Do not break between closing punctuation and a nonstarter even with
# intervening spaces.
# (CL | CP) SP* × NS
- $lb_table[$lb_enums{'CL'}][$lb_enums{'NS'}]
+ $lb_table[$lb_enums{'Close_Punctuation'}][$lb_enums{'Nonstarter'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
- $lb_table[$lb_enums{'CP'}][$lb_enums{'NS'}]
+ $lb_table[$lb_enums{'Close_Parenthesis'}][$lb_enums{'Nonstarter'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
# LB15 Do not break within ‘”[’, even with intervening spaces.
# QU SP* × OP
- $lb_table[$lb_enums{'QU'}][$lb_enums{'OP'}]
+ $lb_table[$lb_enums{'Quotation'}][$lb_enums{'Open_Punctuation'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
# LB14 Do not break after ‘[’, even after spaces.
# OP SP* ×
for my $i (0 .. @lb_table - 1) {
- $lb_table[$lb_enums{'OP'}][$i]
+ $lb_table[$lb_enums{'Open_Punctuation'}][$i]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
}
# [^NU] × IS
# [^NU] × SY
for my $i (0 .. @lb_table - 1) {
- $lb_table[$i][$lb_enums{'EX'}]
+ $lb_table[$i][$lb_enums{'Exclamation'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
- next if $i == $lb_enums{'NU'};
+ next if $i == $lb_enums{'Numeric'};
- $lb_table[$i][$lb_enums{'CL'}]
+ $lb_table[$i][$lb_enums{'Close_Punctuation'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
- $lb_table[$i][$lb_enums{'CP'}]
+ $lb_table[$i][$lb_enums{'Close_Parenthesis'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
- $lb_table[$i][$lb_enums{'IS'}]
+ $lb_table[$i][$lb_enums{'Infix_Numeric'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
- $lb_table[$i][$lb_enums{'SY'}]
+ $lb_table[$i][$lb_enums{'Break_Symbols'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
}
# spaces and hyphens.
# [^SP BA HY] × GL
for my $i (0 .. @lb_table - 1) {
- next if $i == $lb_enums{'SP'}
- || $i == $lb_enums{'BA'}
- || $i == $lb_enums{'HY'};
+ next if $i == $lb_enums{'Space'}
+ || $i == $lb_enums{'Break_After'}
+ || $i == $lb_enums{'Hyphen'};
# We don't break, but if a property above has said don't break even
# with space between, don't override that (also in the next few rules)
- next if $lb_table[$i][$lb_enums{'GL'}]
+ next if $lb_table[$i][$lb_enums{'Glue'}]
== $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
- $lb_table[$i][$lb_enums{'GL'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Glue'}] = $lb_actions{'LB_NOBREAK'};
}
# LB12 Do not break after NBSP and related characters.
# GL ×
for my $i (0 .. @lb_table - 1) {
- next if $lb_table[$lb_enums{'GL'}][$i]
+ next if $lb_table[$lb_enums{'Glue'}][$i]
== $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
- $lb_table[$lb_enums{'GL'}][$i] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Glue'}][$i] = $lb_actions{'LB_NOBREAK'};
}
# LB11 Do not break before or after Word joiner and related characters.
# × WJ
# WJ ×
for my $i (0 .. @lb_table - 1) {
- if ($lb_table[$i][$lb_enums{'WJ'}]
+ if ($lb_table[$i][$lb_enums{'Word_Joiner'}]
!= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'})
{
- $lb_table[$i][$lb_enums{'WJ'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Word_Joiner'}] = $lb_actions{'LB_NOBREAK'};
}
- if ($lb_table[$lb_enums{'WJ'}][$i]
+ if ($lb_table[$lb_enums{'Word_Joiner'}][$i]
!= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'})
{
- $lb_table[$lb_enums{'WJ'}][$i] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Word_Joiner'}][$i] = $lb_actions{'LB_NOBREAK'};
}
}
# Special case this here to avoid having to do a special case in the code,
# by making this the same as other things with a SP in front of them that
# don't break, we avoid an extra test
- $lb_table[$lb_enums{'SP'}][$lb_enums{'WJ'}]
+ $lb_table[$lb_enums{'Space'}][$lb_enums{'Word_Joiner'}]
= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'};
# LB9 and LB10 are done in the same loop
#
# LB9 Do not break a combining character sequence; treat it as if it has
# the line breaking class of the base character in all of the
- # higher-numbered rules.
- # Treat X CM* as if it were X.
+ # higher-numbered rules. Treat ZWJ as if it were CM
+ # Treat X (CM|ZWJ)* as if it were X.
# where X is any line break class except BK, CR, LF, NL, SP, or ZW.
- # LB10 Treat any remaining combining mark as AL. This catches the case
- # where a CM is the first character on the line or follows SP, BK, CR, LF,
- # NL, or ZW.
+ # LB10 Treat any remaining combining mark or ZWJ as AL. This catches the
+ # case where a CM or ZWJ is the first character on the line or follows SP,
+ # BK, CR, LF, NL, or ZW.
for my $i (0 .. @lb_table - 1) {
- # When the CM is the first in the pair, we don't know without looking
- # behind whether the CM is going to inherit from an earlier character,
- # or not. So have to figure this out in the code
- $lb_table[$lb_enums{'CM'}][$i] = $lb_actions{'LB_CM_foo'};
-
- if ( $i == $lb_enums{'BK'}
- || $i == $lb_enums{'ed'}
- || $i == $lb_enums{'CR'}
- || $i == $lb_enums{'LF'}
- || $i == $lb_enums{'NL'}
- || $i == $lb_enums{'SP'}
- || $i == $lb_enums{'ZW'})
+ # When the CM or ZWJ is the first in the pair, we don't know without
+ # looking behind whether the CM or ZWJ is going to attach to an
+ # earlier character, or not. So have to figure this out at runtime in
+ # the code
+ $lb_table[$lb_enums{'Combining_Mark'}][$i]
+ = $lb_actions{'LB_CM_ZWJ_foo'};
+ $lb_table[$lb_enums{'ZWJ'}][$i] = $lb_actions{'LB_CM_ZWJ_foo'};
+
+ if ( $i == $lb_enums{'Mandatory_Break'}
+ || $i == $lb_enums{'EDGE'}
+ || $i == $lb_enums{'Carriage_Return'}
+ || $i == $lb_enums{'Line_Feed'}
+ || $i == $lb_enums{'Next_Line'}
+ || $i == $lb_enums{'Space'}
+ || $i == $lb_enums{'ZWSpace'})
{
# For these classes, a following CM doesn't combine, and should do
- # whatever 'AL' would do.
- $lb_table[$i][$lb_enums{'CM'}] = $lb_table[$i][$lb_enums{'AL'}];
+ # whatever 'Alphabetic' would do.
+ $lb_table[$i][$lb_enums{'Combining_Mark'}]
+ = $lb_table[$i][$lb_enums{'Alphabetic'}];
+ $lb_table[$i][$lb_enums{'ZWJ'}]
+ = $lb_table[$i][$lb_enums{'Alphabetic'}];
}
else {
- # For these classes, the CM combines, so doesn't break, inheriting
- # the type of nobreak from the master character.
- if ($lb_table[$i][$lb_enums{'CM'}]
+ # For these classes, the CM or ZWJ combines, so doesn't break,
+ # inheriting the type of nobreak from the master character.
+ if ($lb_table[$i][$lb_enums{'Combining_Mark'}]
+ != $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'})
+ {
+ $lb_table[$i][$lb_enums{'Combining_Mark'}]
+ = $lb_actions{'LB_NOBREAK'};
+ }
+ if ($lb_table[$i][$lb_enums{'ZWJ'}]
!= $lb_actions{'LB_NOBREAK_EVEN_WITH_SP_BETWEEN'})
{
- $lb_table[$i][$lb_enums{'CM'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'ZWJ'}]
+ = $lb_actions{'LB_NOBREAK'};
}
}
}
+ # LB8a Do not break between a zero width joiner and an ideograph, emoji
+ # base or emoji modifier. This rule prevents breaks within emoji joiner
+ # sequences.
+ # ZWJ × (ID | EB | EM)
+ $lb_table[$lb_enums{'ZWJ'}][$lb_enums{'Ideographic'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'ZWJ'}][$lb_enums{'E_Base'}]
+ = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'ZWJ'}][$lb_enums{'E_Modifier'}]
+ = $lb_actions{'LB_NOBREAK'};
+
# LB8 Break before any character following a zero-width space, even if one
# or more spaces intervene.
# ZW SP* ÷
for my $i (0 .. @lb_table - 1) {
- $lb_table[$lb_enums{'ZW'}][$i] = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'ZWSpace'}][$i] = $lb_actions{'LB_BREAKABLE'};
}
# Because of LB8-10, we need to look at context for "SP x", and this must
# context. By adding this action instead of replacing the existing one,
# we can get back to the original rule if necessary.
for my $i (0 .. @lb_table - 1) {
- $lb_table[$lb_enums{'SP'}][$i] += $lb_actions{'LB_SP_foo'};
+ $lb_table[$lb_enums{'Space'}][$i] += $lb_actions{'LB_SP_foo'};
}
# LB7 Do not break before spaces or zero width space.
# × SP
# × ZW
for my $i (0 .. @lb_table - 1) {
- $lb_table[$i][$lb_enums{'SP'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$i][$lb_enums{'ZW'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Space'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'ZWSpace'}] = $lb_actions{'LB_NOBREAK'};
}
# LB6 Do not break before hard line breaks.
# × ( BK | CR | LF | NL )
for my $i (0 .. @lb_table - 1) {
- $lb_table[$i][$lb_enums{'BK'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$i][$lb_enums{'CR'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$i][$lb_enums{'LF'}] = $lb_actions{'LB_NOBREAK'};
- $lb_table[$i][$lb_enums{'NL'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Mandatory_Break'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Carriage_Return'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Line_Feed'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'Next_Line'}] = $lb_actions{'LB_NOBREAK'};
}
# LB5 Treat CR followed by LF, as well as CR, LF, and NL as hard line breaks.
# LF !
# NL !
for my $i (0 .. @lb_table - 1) {
- $lb_table[$lb_enums{'CR'}][$i] = $lb_actions{'LB_BREAKABLE'};
- $lb_table[$lb_enums{'LF'}][$i] = $lb_actions{'LB_BREAKABLE'};
- $lb_table[$lb_enums{'NL'}][$i] = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'Carriage_Return'}][$i]
+ = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'Line_Feed'}][$i] = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'Next_Line'}][$i] = $lb_actions{'LB_BREAKABLE'};
}
- $lb_table[$lb_enums{'CR'}][$lb_enums{'LF'}] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$lb_enums{'Carriage_Return'}][$lb_enums{'Line_Feed'}]
+ = $lb_actions{'LB_NOBREAK'};
# LB4 Always break after hard line breaks.
# BK !
for my $i (0 .. @lb_table - 1) {
- $lb_table[$lb_enums{'BK'}][$i] = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'Mandatory_Break'}][$i]
+ = $lb_actions{'LB_BREAKABLE'};
}
- # LB2 Never break at the start of text.
- # sot ×
# LB3 Always break at the end of text.
# ! eot
- # but these are reversed in the loop below, so that won't break if there
- # is no text
+ # LB2 Never break at the start of text.
+ # sot ×
for my $i (0 .. @lb_table - 1) {
- $lb_table[$i][$lb_enums{'ed'}] = $lb_actions{'LB_BREAKABLE'};
- $lb_table[$lb_enums{'ed'}][$i] = $lb_actions{'LB_NOBREAK'};
+ $lb_table[$i][$lb_enums{'EDGE'}] = $lb_actions{'LB_BREAKABLE'};
+ $lb_table[$lb_enums{'EDGE'}][$i] = $lb_actions{'LB_NOBREAK'};
}
# LB1 Assign a line breaking class to each code point of the input.
# This is done in mktables, so we never see any of the remapped-from
# classes.
- print $out_fh "\nstatic const U8 LB_table[$table_size][$table_size] = {\n";
- print $out_fh "\n/* 'ed' stands for 'edge' */\n";
- print $out_fh "/* ";
- for my $i (0 .. @lb_table - 1) {
- print $out_fh " $lb_short_enums[$i]";
+ output_table_common('LB', \%lb_actions,
+ \@lb_table, \@lb_short_enums, \%lb_abbreviations);
+}
+
+sub output_WB_table() {
+
+ # Create and output the enums, #defines, and pair table for use in
+ # determining Word Breaks, given in http://www.unicode.org/reports/tr29/.
+
+ # This uses the same mechanism in the other bounds tables generated by
+ # this file. The actions that could override a 0 or 1 are added to those
+ # numbers; the actions that clearly don't depend on the underlying rule
+ # simply overwrite
+ my %wb_actions = (
+ WB_NOBREAK => 0,
+ WB_BREAKABLE => 1,
+ WB_hs_then_hs => 2,
+ WB_Ex_or_FO_or_ZWJ_then_foo => 3,
+ WB_DQ_then_HL => 4,
+ WB_HL_then_DQ => 6,
+ WB_LE_or_HL_then_MB_or_ML_or_SQ => 8,
+ WB_MB_or_ML_or_SQ_then_LE_or_HL => 10,
+ WB_MB_or_MN_or_SQ_then_NU => 12,
+ WB_NU_then_MB_or_MN_or_SQ => 14,
+ WB_RI_then_RI => 16,
+ );
+
+ # Construct the WB pair table.
+ # The table is constructed in reverse order of the rules, to make the
+ # lower-numbered, higher priority ones override the later ones, as the
+ # algorithm stops at the earliest matching rule
+
+ my @wb_table;
+ my $table_size = @wb_short_enums - 1; # -1 because we don't use UNKNOWN
+
+ # Otherwise, break everywhere (including around ideographs).
+ # WB99 Any ÷ Any
+ for my $i (0 .. $table_size - 1) {
+ for my $j (0 .. $table_size - 1) {
+ $wb_table[$i][$j] = $wb_actions{'WB_BREAKABLE'};
+ }
}
- print $out_fh " */\n";
- for my $i (0 .. @lb_table - 1) {
- print $out_fh "/* $lb_short_enums[$i] */ ";
- for my $j (0 .. @lb_table - 1) {
- printf $out_fh "%2d", $lb_table[$i][$j];
- print $out_fh "," if $i < @lb_table - 1 || $j < @lb_table - 1;
- print $out_fh " " if $j < @lb_table - 1;
+ # Do not break within emoji flag sequences. That is, do not break between
+ # regional indicator (RI) symbols if there is an odd number of RI
+ # characters before the break point.
+ # WB16 [^RI] (RI RI)* RI × RI
+ # WB15 ^ (RI RI)* RI × RI
+ $wb_table[$wb_enums{'Regional_Indicator'}]
+ [$wb_enums{'Regional_Indicator'}] = $wb_actions{'WB_RI_then_RI'};
+
+ # Do not break within emoji modifier sequences.
+ # WB14 ( E_Base | EBG ) × E_Modifier
+ $wb_table[$wb_enums{'E_Base'}][$wb_enums{'E_Modifier'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'E_Base_GAZ'}][$wb_enums{'E_Modifier'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # Do not break from extenders.
+ # WB13b ExtendNumLet × (ALetter | Hebrew_Letter | Numeric | Katakana)
+ $wb_table[$wb_enums{'ExtendNumLet'}][$wb_enums{'ALetter'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'ExtendNumLet'}][$wb_enums{'Hebrew_Letter'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'ExtendNumLet'}][$wb_enums{'Numeric'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'ExtendNumLet'}][$wb_enums{'Katakana'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # WB13a (ALetter | Hebrew_Letter | Numeric | Katakana | ExtendNumLet)
+ # × # ExtendNumLet
+ $wb_table[$wb_enums{'ALetter'}][$wb_enums{'ExtendNumLet'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'ExtendNumLet'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Numeric'}][$wb_enums{'ExtendNumLet'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Katakana'}][$wb_enums{'ExtendNumLet'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'ExtendNumLet'}][$wb_enums{'ExtendNumLet'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # Do not break between Katakana.
+ # WB13 Katakana × Katakana
+ $wb_table[$wb_enums{'Katakana'}][$wb_enums{'Katakana'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # Do not break within sequences, such as “3.2” or “3,456.789”.
+ # WB12 Numeric × (MidNum | MidNumLet | Single_Quote) Numeric
+ $wb_table[$wb_enums{'Numeric'}][$wb_enums{'MidNumLet'}]
+ += $wb_actions{'WB_NU_then_MB_or_MN_or_SQ'};
+ $wb_table[$wb_enums{'Numeric'}][$wb_enums{'MidNum'}]
+ += $wb_actions{'WB_NU_then_MB_or_MN_or_SQ'};
+ $wb_table[$wb_enums{'Numeric'}][$wb_enums{'Single_Quote'}]
+ += $wb_actions{'WB_NU_then_MB_or_MN_or_SQ'};
+
+ # WB11 Numeric (MidNum | (MidNumLet | Single_Quote)) × Numeric
+ $wb_table[$wb_enums{'MidNumLet'}][$wb_enums{'Numeric'}]
+ += $wb_actions{'WB_MB_or_MN_or_SQ_then_NU'};
+ $wb_table[$wb_enums{'MidNum'}][$wb_enums{'Numeric'}]
+ += $wb_actions{'WB_MB_or_MN_or_SQ_then_NU'};
+ $wb_table[$wb_enums{'Single_Quote'}][$wb_enums{'Numeric'}]
+ += $wb_actions{'WB_MB_or_MN_or_SQ_then_NU'};
+
+ # Do not break within sequences of digits, or digits adjacent to letters
+ # (“3a”, or “A3”).
+ # WB10 Numeric × (ALetter | Hebrew_Letter)
+ $wb_table[$wb_enums{'Numeric'}][$wb_enums{'ALetter'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Numeric'}][$wb_enums{'Hebrew_Letter'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # WB9 (ALetter | Hebrew_Letter) × Numeric
+ $wb_table[$wb_enums{'ALetter'}][$wb_enums{'Numeric'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'Numeric'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # WB8 Numeric × Numeric
+ $wb_table[$wb_enums{'Numeric'}][$wb_enums{'Numeric'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # Do not break letters across certain punctuation.
+ # WB7c Hebrew_Letter Double_Quote × Hebrew_Letter
+ $wb_table[$wb_enums{'Double_Quote'}][$wb_enums{'Hebrew_Letter'}]
+ += $wb_actions{'WB_DQ_then_HL'};
+
+ # WB7b Hebrew_Letter × Double_Quote Hebrew_Letter
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'Double_Quote'}]
+ += $wb_actions{'WB_HL_then_DQ'};
+
+ # WB7a Hebrew_Letter × Single_Quote
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'Single_Quote'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # WB7 (ALetter | Hebrew_Letter) (MidLetter | MidNumLet | Single_Quote)
+ # × (ALetter | Hebrew_Letter)
+ $wb_table[$wb_enums{'MidNumLet'}][$wb_enums{'ALetter'}]
+ += $wb_actions{'WB_MB_or_ML_or_SQ_then_LE_or_HL'};
+ $wb_table[$wb_enums{'MidNumLet'}][$wb_enums{'Hebrew_Letter'}]
+ += $wb_actions{'WB_MB_or_ML_or_SQ_then_LE_or_HL'};
+ $wb_table[$wb_enums{'MidLetter'}][$wb_enums{'ALetter'}]
+ += $wb_actions{'WB_MB_or_ML_or_SQ_then_LE_or_HL'};
+ $wb_table[$wb_enums{'MidLetter'}][$wb_enums{'Hebrew_Letter'}]
+ += $wb_actions{'WB_MB_or_ML_or_SQ_then_LE_or_HL'};
+ $wb_table[$wb_enums{'Single_Quote'}][$wb_enums{'ALetter'}]
+ += $wb_actions{'WB_MB_or_ML_or_SQ_then_LE_or_HL'};
+ $wb_table[$wb_enums{'Single_Quote'}][$wb_enums{'Hebrew_Letter'}]
+ += $wb_actions{'WB_MB_or_ML_or_SQ_then_LE_or_HL'};
+
+ # WB6 (ALetter | Hebrew_Letter) × (MidLetter | MidNumLet
+ # | Single_Quote) (ALetter | Hebrew_Letter)
+ $wb_table[$wb_enums{'ALetter'}][$wb_enums{'MidNumLet'}]
+ += $wb_actions{'WB_LE_or_HL_then_MB_or_ML_or_SQ'};
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'MidNumLet'}]
+ += $wb_actions{'WB_LE_or_HL_then_MB_or_ML_or_SQ'};
+ $wb_table[$wb_enums{'ALetter'}][$wb_enums{'MidLetter'}]
+ += $wb_actions{'WB_LE_or_HL_then_MB_or_ML_or_SQ'};
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'MidLetter'}]
+ += $wb_actions{'WB_LE_or_HL_then_MB_or_ML_or_SQ'};
+ $wb_table[$wb_enums{'ALetter'}][$wb_enums{'Single_Quote'}]
+ += $wb_actions{'WB_LE_or_HL_then_MB_or_ML_or_SQ'};
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'Single_Quote'}]
+ += $wb_actions{'WB_LE_or_HL_then_MB_or_ML_or_SQ'};
+
+ # Do not break between most letters.
+ # WB5 (ALetter | Hebrew_Letter) × (ALetter | Hebrew_Letter)
+ $wb_table[$wb_enums{'ALetter'}][$wb_enums{'ALetter'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'ALetter'}][$wb_enums{'Hebrew_Letter'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'ALetter'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Hebrew_Letter'}][$wb_enums{'Hebrew_Letter'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # Ignore Format and Extend characters, except after sot, CR, LF, and
+ # Newline. This also has the effect of: Any × (Format | Extend | ZWJ)
+ # WB4 X (Extend | Format | ZWJ)* → X
+ for my $i (0 .. @wb_table - 1) {
+ $wb_table[$wb_enums{'Extend'}][$i]
+ = $wb_actions{'WB_Ex_or_FO_or_ZWJ_then_foo'};
+ $wb_table[$wb_enums{'Format'}][$i]
+ = $wb_actions{'WB_Ex_or_FO_or_ZWJ_then_foo'};
+ $wb_table[$wb_enums{'ZWJ'}][$i]
+ = $wb_actions{'WB_Ex_or_FO_or_ZWJ_then_foo'};
+ }
+ for my $i (0 .. @wb_table - 1) {
+ $wb_table[$i][$wb_enums{'Extend'}] = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$i][$wb_enums{'Format'}] = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$i][$wb_enums{'ZWJ'}] = $wb_actions{'WB_NOBREAK'};
+ }
+
+ # Implied is that these attach to the character before them, except for
+ # the characters that mark the end of a region of text. The rules below
+ # override the ones set up here, for all the characters that need
+ # overriding.
+ for my $i (0 .. @wb_table - 1) {
+ $wb_table[$i][$wb_enums{'Extend'}] = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$i][$wb_enums{'Format'}] = $wb_actions{'WB_NOBREAK'};
+ }
+
+ # Do not break within emoji zwj sequences.
+ # WB3c ZWJ × ( Glue_After_Zwj | EBG )
+ $wb_table[$wb_enums{'ZWJ'}][$wb_enums{'Glue_After_Zwj'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'ZWJ'}][$wb_enums{'E_Base_GAZ'}]
+ = $wb_actions{'WB_NOBREAK'};
+
+ # Break before and after white space
+ # WB3b ÷ (Newline | CR | LF)
+ # WB3a (Newline | CR | LF) ÷
+ # et. al.
+ for my $i ('CR', 'LF', 'Newline', 'Perl_Tailored_HSpace') {
+ for my $j (0 .. @wb_table - 1) {
+ $wb_table[$j][$wb_enums{$i}] = $wb_actions{'WB_BREAKABLE'};
+ $wb_table[$wb_enums{$i}][$j] = $wb_actions{'WB_BREAKABLE'};
}
- print $out_fh "\n";
}
- print $out_fh "};\n";
+ # But do not break within white space.
+ # WB3 CR × LF
+ # et.al.
+ for my $i ('CR', 'LF', 'Newline', 'Perl_Tailored_HSpace') {
+ for my $j ('CR', 'LF', 'Newline', 'Perl_Tailored_HSpace') {
+ $wb_table[$wb_enums{$i}][$wb_enums{$j}] = $wb_actions{'WB_NOBREAK'};
+ }
+ }
- end_file_pound_if;
+ # And do not break horizontal space followed by Extend or Format or ZWJ
+ $wb_table[$wb_enums{'Perl_Tailored_HSpace'}][$wb_enums{'Extend'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Perl_Tailored_HSpace'}][$wb_enums{'Format'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Perl_Tailored_HSpace'}][$wb_enums{'ZWJ'}]
+ = $wb_actions{'WB_NOBREAK'};
+ $wb_table[$wb_enums{'Perl_Tailored_HSpace'}]
+ [$wb_enums{'Perl_Tailored_HSpace'}]
+ = $wb_actions{'WB_hs_then_hs'};
+
+ # Break at the start and end of text, unless the text is empty
+ # WB2 Any ÷ eot
+ # WB1 sot ÷ Any
+ for my $i (0 .. @wb_table - 1) {
+ $wb_table[$i][$wb_enums{'EDGE'}] = $wb_actions{'WB_BREAKABLE'};
+ $wb_table[$wb_enums{'EDGE'}][$i] = $wb_actions{'WB_BREAKABLE'};
+ }
+ $wb_table[$wb_enums{'EDGE'}][$wb_enums{'EDGE'}] = 0;
+
+ output_table_common('WB', \%wb_actions,
+ \@wb_table, \@wb_short_enums, \%wb_abbreviations);
}
output_invlist("Latin1", [ 0, 256 ]);
my $to_adjust;
if ($is_local_sub) {
@invlist = eval $lookup_prop;
+ die $@ if $@;
}
else {
@invlist = prop_invlist($lookup_prop, '_perl_core_internal_ok');
print $out_fh "\n" . get_conditional_compile_line_end();
}
+switch_pound_if('Boundary_pair_tables', 'PERL_IN_REGEXEC_C');
+
+output_GCB_table();
output_LB_table();
+output_WB_table();
+
+end_file_pound_if;
my $sources_list = "lib/unicore/mktables.lst";
my @sources = ($0, qw(lib/unicore/mktables