Home | History | Annotate | Download | only in brkitr
      1 # Copyright (c) 2002-2015  International Business Machines Corporation and
      2 # others. All Rights Reserved.
      3 #
      4 #  file:  line_normal_cj.txt
      5 #
      6 #         Line Breaking Rules
      7 #         Implement default line breaking as defined by 
      8 #         Unicode Standard Annex #14 Revision 29 for Unicode 6.2
      9 #         http://www.unicode.org/reports/tr14/
     10 #         tailored as noted in 2nd paragraph below..
     11 #
     12 #         TODO:  Rule LB 8 remains as it was in Unicode 5.2
     13 #         This is only because of a limitation of ICU break engine implementation,
     14 #         not because the older behavior is desirable.
     15 #
     16 #         This tailors the line break behavior to correspond to CSS
     17 #         line-break=normal (BCP47 -u-lb-normal) as defined for Chinese & Japanese.
     18 #         It sets characters of class CJ to behave like ID.
     19 #         In addition, it allows breaks:
     20 #         * before hyphens 2010 & 2013 (both BA) and 301C, 30A0 (both NS)
     21 
     22 #
     23 #  Character Classes defined by TR 14.
     24 #
     25 
     26 !!chain;
     27 !!LBCMNoChain;
     28 
     29 
     30 !!lookAheadHardBreak;
     31 #
     32 #  !!lookAheadHardBreak    Described here because it is (as yet) undocumented elsewhere
     33 #                          and only used for the line break rules.
     34 #
     35 #           It is used in the implementation of rule LB 10
     36 #           which says to treat any combining mark that is not attached to a base
     37 #           character as if it were of class AL  (alphabetic).
     38 #
     39 #           The problem occurs in the reverse rules.
     40 #
     41 #           Consider a sequence like, with correct breaks as shown
     42 #               LF  ID  CM  AL  AL
     43 #                  ^       ^       ^
     44 #           Then consider the sequence without the initial ID (ideographic)
     45 #                 LF  CM  AL  AL
     46 #                    ^           ^
     47 #           Our CM, which in the first example was attached to the ideograph,
     48 #           is now unattached, becomes an alpha, and joins in with the other
     49 #           alphas.
     50 #
     51 #           When iterating forwards, these sequences do not present any problems
     52 #           When iterating backwards, we need to look ahead when encountering
     53 #           a CM to see whether it attaches to something further on or not.
     54 #           (Look-ahead in a reverse rule is looking towards the start)
     55 #
     56 #           If the CM is unattached, we need to force a break.
     57 #
     58 #           !!lookAheadHardBreak forces the run time state machine to
     59 #           stop immediately when a look ahead rule ( '/' operator) matches,
     60 #           and set the match position to that of the look-ahead operator,
     61 #           no matter what other rules may be in play at the time.
     62 #
     63 #           See rule LB 19 for an example.
     64 #
     65 
     66 $AI = [:LineBreak =  Ambiguous:];
     67 $AL = [:LineBreak =  Alphabetic:];
     68 $BAX = [\u2010 \u2013];
     69 $BA = [[:LineBreak =  Break_After:] - $BAX];
     70 $BB = [:LineBreak =  Break_Before:];
     71 $BK = [:LineBreak =  Mandatory_Break:];
     72 $B2 = [:LineBreak =  Break_Both:];
     73 $CB = [:LineBreak =  Contingent_Break:];
     74 $CJ = [:LineBreak =  Conditional_Japanese_Starter:];
     75 $CL = [:LineBreak =  Close_Punctuation:];
     76 $CM = [:LineBreak =  Combining_Mark:];
     77 $CP = [:LineBreak =  Close_Parenthesis:];
     78 $CR = [:LineBreak =  Carriage_Return:];
     79 $EX = [:LineBreak =  Exclamation:];
     80 $GL = [:LineBreak =  Glue:];
     81 $HL = [:LineBreak =  Hebrew_Letter:];
     82 $HY = [:LineBreak =  Hyphen:];
     83 $H2 = [:LineBreak =  H2:];
     84 $H3 = [:LineBreak =  H3:];
     85 $ID = [[:LineBreak =  Ideographic:] $CJ];
     86 $IN = [:LineBreak =  Inseperable:];
     87 $IS = [:LineBreak =  Infix_Numeric:];
     88 $JL = [:LineBreak =  JL:];
     89 $JV = [:LineBreak =  JV:];
     90 $JT = [:LineBreak =  JT:];
     91 $LF = [:LineBreak =  Line_Feed:];
     92 $NL = [:LineBreak =  Next_Line:];
     93 $NSX = [\u301C \u30A0];
     94 $NS = [[:LineBreak =  Nonstarter:] - $NSX];
     95 $NU = [:LineBreak =  Numeric:];
     96 $OP = [:LineBreak =  Open_Punctuation:];
     97 $PO = [:LineBreak =  Postfix_Numeric:];
     98 $PR = [:LineBreak =  Prefix_Numeric:];
     99 $QU = [:LineBreak =  Quotation:];
    100 $RI = [:LineBreak =  Regional_Indicator:];
    101 $SA = [:LineBreak =  Complex_Context:];
    102 $SG = [:LineBreak =  Surrogate:];
    103 $SP = [:LineBreak =  Space:];
    104 $SY = [:LineBreak =  Break_Symbols:];
    105 $WJ = [:LineBreak =  Word_Joiner:];
    106 $XX = [:LineBreak =  Unknown:];
    107 $ZW = [:LineBreak =  ZWSpace:];
    108 
    109 #   Dictionary character set, for triggering language-based break engines. Currently
    110 #   limited to LineBreak=Complex_Context. Note that this set only works in Unicode
    111 #   5.0 or later as the definition of Complex_Context was corrected to include all
    112 #   characters requiring dictionary break.
    113 
    114 $dictionary = [:LineBreak = Complex_Context:];
    115 
    116 #
    117 #  Rule LB1.  By default, treat AI  (characters with ambiguous east Asian width),
    118 #                               SA  (South East Asian: Thai, Lao, Khmer)
    119 #                               SG  (Unpaired Surrogates)
    120 #                               XX  (Unknown, unassigned)
    121 #                         as $AL  (Alphabetic)
    122 #
    123 $ALPlus = [$AL $AI $SA $SG $XX];
    124 
    125 #
    126 #  Combining Marks.   X $CM*  behaves as if it were X.  Rule LB6.
    127 #
    128 $ALcm = $ALPlus $CM*;
    129 $BAcm = $BA $CM*;
    130 $BAXcm = $BAX $CM*;
    131 $BBcm = $BB $CM*;
    132 $B2cm = $B2 $CM*;
    133 $CLcm = $CL $CM*;
    134 $CPcm = $CP $CM*;
    135 $EXcm = $EX $CM*;
    136 $GLcm = $GL $CM*;
    137 $HLcm = $HL $CM*;
    138 $HYcm = $HY $CM*;
    139 $H2cm = $H2 $CM*;
    140 $H3cm = $H3 $CM*;
    141 $IDcm = $ID $CM*;
    142 $INcm = $IN $CM*;
    143 $IScm = $IS $CM*;
    144 $JLcm = $JL $CM*;
    145 $JVcm = $JV $CM*;
    146 $JTcm = $JT $CM*;
    147 $NScm = $NS $CM*;
    148 $NSXcm = $NSX $CM*;
    149 $NUcm = $NU $CM*;
    150 $OPcm = $OP $CM*;
    151 $POcm = $PO $CM*;
    152 $PRcm = $PR $CM*;
    153 $QUcm = $QU $CM*;
    154 $RIcm = $RI $CM*;
    155 $SYcm = $SY $CM*;
    156 $WJcm = $WJ $CM*;
    157 
    158 ## -------------------------------------------------
    159 
    160 !!forward;
    161 
    162 #
    163 #  Each class of character can stand by itself as an unbroken token, with trailing combining stuff
    164 #
    165 $ALPlus $CM+;
    166 $BA $CM+;
    167 $BAX $CM+;
    168 $BB $CM+;
    169 $B2 $CM+;
    170 $CL $CM+;
    171 $CP $CM+;
    172 $EX $CM+;
    173 $GL $CM+;
    174 $HL $CM+;
    175 $HY $CM+;
    176 $H2 $CM+;
    177 $H3 $CM+;
    178 $ID $CM+;
    179 $IN $CM+;
    180 $IS $CM+;
    181 $JL $CM+;
    182 $JV $CM+;
    183 $JT $CM+;
    184 $NS $CM+;
    185 $NSX $CM+;
    186 $NU $CM+;
    187 $OP $CM+;
    188 $PO $CM+;
    189 $PR $CM+;
    190 $QU $CM+;
    191 $RI $CM+;
    192 $SY $CM+;
    193 $WJ $CM+;
    194 
    195 #
    196 # CAN_CM  is the set of characters that may combine with CM combining chars.
    197 #         Note that Linebreak UAX 14's concept of a combining char and the rules
    198 #         for what they can combine with are _very_ different from the rest of Unicode.
    199 #
    200 #         Note that $CM itself is left out of this set.  If CM is needed as a base
    201 #         it must be listed separately in the rule.
    202 #
    203 $CAN_CM  = [^$SP $BK $CR $LF $NL $ZW $CM];       # Bases that can   take CMs
    204 $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM];       # Bases that can't take CMs
    205 
    206 #
    207 # AL_FOLLOW  set of chars that can unconditionally follow an AL
    208 #            Needed in rules where stand-alone $CM s are treated as AL.
    209 #            Chaining is disabled with CM because it causes other failures,
    210 #            so for this one case we need to manually list out longer sequences.
    211 #
    212 $AL_FOLLOW_NOCM = [$BK $CR $LF $NL $ZW $SP];
    213 $AL_FOLLOW_CM   = [$CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $BAX $HY $NS $NSX $IN $NU $ALPlus];
    214 $AL_FOLLOW      = [$AL_FOLLOW_NOCM $AL_FOLLOW_CM];
    215 
    216 
    217 #
    218 #  Rule LB 4, 5    Mandatory (Hard) breaks.
    219 #
    220 $LB4Breaks    = [$BK $CR $LF $NL];
    221 $LB4NonBreaks = [^$BK $CR $LF $NL];
    222 $CR $LF {100};
    223 
    224 #
    225 #  LB 6    Do not break before hard line breaks.
    226 #
    227 $LB4NonBreaks?  $LB4Breaks {100};    # LB 5  do not break before hard breaks.
    228 $CAN_CM $CM*    $LB4Breaks {100};
    229 $CM+            $LB4Breaks {100};
    230 
    231 # LB 7         x SP
    232 #              x ZW
    233 $LB4NonBreaks [$SP $ZW];
    234 $CAN_CM $CM*  [$SP $ZW];
    235 $CM+          [$SP $ZW];
    236 
    237 #
    238 # LB 8         Break after zero width space
    239 #              TODO:  ZW SP* <break>
    240 #              An engine change is required to write the reverse rule for this.
    241 #              For now, leave the Unicode 5.2 rule, ZW <break>
    242 #
    243 $LB8Breaks    = [$LB4Breaks $ZW];
    244 $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
    245 
    246 
    247 # LB 9     Combining marks.      X   $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL 
    248 #                                $CM not covered by the above needs to behave like $AL   
    249 #                                See definition of $CAN_CM.
    250 
    251 $CAN_CM $CM+;                   #  Stick together any combining sequences that don't match other rules.
    252 $CM+;
    253 
    254 #
    255 # LB 11  Do not break before or after WORD JOINER & related characters.
    256 #
    257 $CAN_CM $CM*  $WJcm;
    258 $LB8NonBreaks $WJcm;
    259 $CM+          $WJcm;
    260 
    261 $WJcm $CANT_CM;
    262 $WJcm $CAN_CM $CM*;
    263 
    264 #
    265 # LB 12  Do not break after NBSP and related characters.
    266 #         GL  x
    267 #
    268 $GLcm $CAN_CM $CM*;
    269 $GLcm $CANT_CM;
    270  
    271 #
    272 # LB 12a  Do not break before NBSP and related characters ...
    273 #            [^SP BA HY] x GL
    274 #
    275 [[$LB8NonBreaks] - [$SP $BA $BAX $HY]] $CM* $GLcm;
    276 $CM+ GLcm;
    277 
    278 
    279 
    280 #
    281 # LB 13   Don't break before ']' or '!' or ';' or '/', even after spaces.
    282 #
    283 $LB8NonBreaks $CL;
    284 $CAN_CM $CM*  $CL;
    285 $CM+          $CL;              # by rule 10, stand-alone CM behaves as AL
    286 
    287 $LB8NonBreaks $CP;
    288 $CAN_CM $CM*  $CP;
    289 $CM+          $CP;              # by rule 10, stand-alone CM behaves as AL
    290 
    291 $LB8NonBreaks $EX;
    292 $CAN_CM $CM*  $EX;
    293 $CM+          $EX;              # by rule 10, stand-alone CM behaves as AL
    294 
    295 $LB8NonBreaks $IS;
    296 $CAN_CM $CM*  $IS;
    297 $CM+          $IS;              # by rule 10, stand-alone CM behaves as AL
    298 
    299 $LB8NonBreaks $SY;
    300 $CAN_CM $CM*  $SY;
    301 $CM+          $SY;              # by rule 10, stand-alone CM behaves as AL
    302 
    303 
    304 #
    305 # LB 14  Do not break after OP, even after spaces
    306 #
    307 $OPcm $SP* $CAN_CM $CM*;
    308 $OPcm $SP* $CANT_CM;
    309 
    310 $OPcm $SP+ $CM+ $AL_FOLLOW?;    # by rule 10, stand-alone CM behaves as AL
    311 
    312 # LB 15
    313 $QUcm $SP* $OPcm;
    314 
    315 # LB 16
    316 # Do not break between closing punctuation and $NS, even with intervening spaces
    317 # But DO allow a break between closing punctuation and $NSX, don't include it here
    318 ($CLcm | $CPcm) $SP* $NScm;
    319 
    320 # LB 17
    321 $B2cm $SP* $B2cm;
    322 
    323 #
    324 # LB 18  Break after spaces.
    325 #
    326 $LB18NonBreaks = [$LB8NonBreaks - [$SP]];
    327 $LB18Breaks    = [$LB8Breaks $SP];
    328 
    329 
    330 # LB 19
    331 #         x QU
    332 $LB18NonBreaks $CM* $QUcm;
    333 $CM+                $QUcm;
    334 
    335 #         QU  x
    336 $QUcm .?;
    337 $QUcm $LB18NonBreaks $CM*;    # Don't let a combining mark go onto $CR, $BK, etc.
    338                               #  TODO:  I don't think this rule is needed.
    339 
    340 
    341 # LB 20
    342 #        <break>  $CB
    343 #        $CB   <break>
    344 
    345 $LB20NonBreaks = [$LB18NonBreaks - $CB];
    346 
    347 # LB 21        x   (BA | HY | NS)
    348 #           BB x
    349 #
    350 # DO allow breaks here before $BAXcm and $NSXcm, so don't include them
    351 $LB20NonBreaks $CM* ($BAcm | $HYcm | $NScm); 
    352 
    353 $BBcm [^$CB];                                  #  $BB  x
    354 $BBcm $LB20NonBreaks $CM*;
    355 
    356 # LB 21a Don't break after Hebrew + Hyphen
    357 #   HL (HY | BA) x
    358 #  
    359 $HLcm ($HYcm | $BAcm | $BAXcm) [^$CB]?;
    360 
    361 # LB 21b (forward) Don't break between SY and HL
    362 # (break between HL and SY already disallowed by LB 13 above)
    363 $SYcm $HLcm;
    364 
    365 # LB 22
    366 ($ALcm | $HLcm) $INcm;
    367 $CM+     $INcm;     #  by rule 10, any otherwise unattached CM behaves as AL
    368 $IDcm    $INcm;
    369 $INcm    $INcm;
    370 $NUcm    $INcm;
    371 
    372 
    373 # $LB 23
    374 $IDcm  $POcm;
    375 $ALcm  $NUcm;       # includes $LB19
    376 $HLcm  $NUcm;
    377 $CM+   $NUcm;       # Rule 10, any otherwise unattached CM behaves as AL
    378 $NUcm  $ALcm;
    379 $NUcm  $HLcm;
    380 
    381 #
    382 # LB 24
    383 #
    384 $PRcm $IDcm;
    385 $PRcm ($ALcm | $HLcm);
    386 $POcm ($ALcm | $HLcm);
    387 
    388 #
    389 # LB 25   Numbers.
    390 #
    391 ($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?;
    392 
    393 # LB 26  Do not break a Korean syllable
    394 #
    395 $JLcm ($JLcm | $JVcm | $H2cm | $H3cm);
    396 ($JVcm | $H2cm) ($JVcm | $JTcm);
    397 ($JTcm | $H3cm) $JTcm;
    398 
    399 # LB 27  Treat korean Syllable Block the same as ID  (don't break it)
    400 ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $INcm;
    401 ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $POcm;
    402 $PRcm ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm);
    403 
    404 
    405 # LB 28   Do not break between alphabetics
    406 #
    407 ($ALcm | $HLcm) ($ALcm | $HLcm);
    408 $CM+ ($ALcm | $HLcm);      # The $CM+ is from rule 10, an unattached CM is treated as AL
    409 
    410 # LB 29
    411 $IScm ($ALcm | $HLcm);
    412 
    413 # LB 30
    414 ($ALcm | $HLcm | $NUcm) $OPcm;
    415 $CM+ $OPcm;         # The $CM+ is from rule 10, an unattached CM is treated as AL.          
    416 $CPcm ($ALcm | $HLcm | $NUcm);
    417 
    418 # LB 30a  Do not break between regional indicators.
    419 $RIcm $RIcm;
    420 
    421 #
    422 #  Reverse Rules.
    423 #
    424 ## -------------------------------------------------
    425 
    426 !!reverse;
    427 
    428 $CM+ $ALPlus;
    429 $CM+ $BA;
    430 $CM+ $BAX;
    431 $CM+ $BB;
    432 $CM+ $B2;
    433 $CM+ $CL;
    434 $CM+ $CP;
    435 $CM+ $EX;
    436 $CM+ $GL;
    437 $CM+ $HL;
    438 $CM+ $HY;
    439 $CM+ $H2;
    440 $CM+ $H3;
    441 $CM+ $ID;
    442 $CM+ $IN;
    443 $CM+ $IS;
    444 $CM+ $JL;
    445 $CM+ $JV;
    446 $CM+ $JT;
    447 $CM+ $NS;
    448 $CM+ $NSX;
    449 $CM+ $NU;
    450 $CM+ $OP;
    451 $CM+ $PO;
    452 $CM+ $PR;
    453 $CM+ $QU;
    454 $CM+ $RI;
    455 $CM+ $SY;
    456 $CM+ $WJ;
    457 $CM+;
    458 
    459 
    460 #
    461 #  Sequences of the form  (shown forwards)
    462 #      [CANT_CM]  <break>  [CM]  [whatever]
    463 #  The CM needs to behave as an AL
    464 #
    465 $AL_FOLLOW $CM+ / (
    466           [$BK $CR $LF $NL $ZW {eof}] |
    467           $SP+ $CM+ $SP |
    468           $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}]));   # if LB 14 will match, need to surpress this break.
    469                                                #  LB14 says    OP SP* x .        
    470                                                #    becomes    OP SP* x AL
    471                                                #    becomes    OP SP* x CM+ AL_FOLLOW
    472                                                #
    473                                                # Further note:  the $AL in [$AL {eof}] is only to work around
    474                                                #                a rule compiler bug which complains about
    475                                                #                empty sets otherwise.
    476           
    477 #
    478 #  Sequences of the form  (shown forwards)
    479 #      [CANT_CM]  <break> [CM]  <break>  [PR]
    480 #  The CM needs to behave as an AL
    481 #  This rule is concerned about getting the second of the two <breaks> in place.
    482 #
    483 
    484 [$PR   ] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}];
    485 
    486 
    487 
    488 # LB 4, 5, 5
    489 
    490 $LB4Breaks [$LB4NonBreaks-$CM];
    491 $LB4Breaks $CM+ $CAN_CM;
    492 $LF $CR;
    493 
    494 
    495 # LB 7         x SP
    496 #              x ZW
    497 [$SP $ZW] [$LB4NonBreaks-$CM];
    498 [$SP $ZW] $CM+ $CAN_CM;
    499 
    500 # LB 8 ZW SP* <break>
    501 #     TODO: to implement this, we need more than one look-ahead hard break in play at a time.
    502 #           Requires an engine enhancement.
    503 #   / $SP* $ZW
    504 
    505 # LB 9,10  Combining marks.
    506 #    X   $CM needs to behave like X, where X is not $SP or controls.
    507 #    $CM not covered by the above needs to behave like $AL
    508 # Stick together any combining sequences that don't match other rules.
    509 $CM+ $CAN_CM;
    510 
    511 
    512 # LB 11
    513 $CM* $WJ $CM* $CAN_CM;
    514 $CM* $WJ      [$LB8NonBreaks-$CM];
    515 
    516      $CANT_CM $CM* $WJ;
    517 $CM* $CAN_CM  $CM* $WJ;
    518 
    519 # LB 12a
    520 #      [^SP BA HY] x GL
    521 #
    522 $CM* $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $BAX $HY]];
    523 
    524 # LB 12
    525 #     GL  x
    526 #
    527 $CANT_CM $CM* $GL;
    528 $CM* $CAN_CM $CM* $GL;
    529 
    530 
    531 # LB 13
    532 $CL $CM+ $CAN_CM;
    533 $CP $CM+ $CAN_CM;
    534 $EX $CM+ $CAN_CM;
    535 $IS $CM+ $CAN_CM;
    536 $SY $CM+ $CAN_CM;
    537 
    538 $CL [$LB8NonBreaks-$CM];
    539 $CP [$LB8NonBreaks-$CM];
    540 $EX [$LB8NonBreaks-$CM];
    541 $IS [$LB8NonBreaks-$CM];
    542 $SY [$LB8NonBreaks-$CM];
    543 
    544 # Rule 13 & 14 taken together for an edge case.
    545 #   Match this, shown forward
    546 #     OP SP+  ($CM+ behaving as $AL) (CL | CP | EX | IS | IY)
    547 #   This really wants to chain at the $CM+ (which is acting as an $AL)
    548 #   except for $CM chaining being disabled.
    549 [$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP;  
    550 
    551 # LB 14    OP SP* x
    552 #
    553 $CM* $CAN_CM    $SP* $CM* $OP;
    554      $CANT_CM   $SP* $CM* $OP;
    555 $AL_FOLLOW? $CM+  $SP $SP* $CM* $OP;     #  by LB 10, behaves like $AL_FOLLOW? $AL $SP* $CM* $OP
    556      
    557      $AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP;
    558 $CM* $AL_FOLLOW_CM   $CM+ $SP+ $CM* $OP;
    559 $SY $CM $SP+ $OP;   # TODO:  Experiment.  Remove.
    560 
    561 
    562 
    563 # LB 15
    564 $CM* $OP $SP* $CM* $QU;
    565 
    566 # LB 16
    567 # Don't include $NSX here
    568 $CM* $NS $SP* $CM* ($CL | $CP);
    569 
    570 # LB 17
    571 $CM* $B2 $SP* $CM* $B2;
    572 
    573 # LB 18  break after spaces
    574 #        Nothing explicit needed here.
    575 
    576 
    577 #
    578 # LB 19
    579 #
    580 $CM* $QU $CM* $CAN_CM;                                #   . x QU
    581 $CM* $QU      $LB18NonBreaks;
    582 
    583 
    584 $CM* $CAN_CM  $CM* $QU;                               #   QU x .
    585      $CANT_CM $CM* $QU;
    586      
    587 #
    588 #  LB 20  Break before and after CB.
    589 #         nothing needed here.
    590 #
    591 
    592 # LB 21
    593 # Don't include $BAX or $NSX here
    594 $CM* ($BA | $HY | $NS) $CM* [$LB20NonBreaks-$CM];     #  . x (BA | HY | NS)
    595 
    596 $CM* [$LB20NonBreaks-$CM] $CM* $BB;                   #  BB x .
    597 [^$CB] $CM* $BB;                                      # 
    598 
    599 # LB21a
    600 [^$CB] $CM* ($HY | $BA | $BAX) $CM* $HL;
    601 
    602 # LB21b (reverse)
    603 $CM* $HL $CM* $SY;
    604 
    605 # LB 22
    606 $CM* $IN $CM* ($ALPlus | $HL);
    607 $CM* $IN $CM* $ID;
    608 $CM* $IN $CM* $IN;
    609 $CM* $IN $CM* $NU;
    610 
    611 # LB 23
    612 $CM* $PO $CM* $ID;
    613 $CM* $NU $CM* ($ALPlus | $HL);
    614 $CM* ($ALPlus | $HL) $CM* $NU;
    615 
    616 # LB 24
    617 $CM* $ID $CM* $PR;
    618 $CM* ($ALPlus | $HL) $CM* $PR;
    619 $CM* ($ALPlus | $HL) $CM* $PO;
    620 
    621 
    622 # LB 25
    623 ($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?;
    624 
    625 # LB 26
    626 $CM* ($H3 | $H2 | $JV | $JL) $CM* $JL;
    627 $CM* ($JT | $JV) $CM* ($H2 | $JV);
    628 $CM* $JT $CM* ($H3 | $JT);
    629 
    630 # LB 27
    631 $CM* $IN $CM* ($H3 | $H2 | $JT | $JV | $JL);
    632 $CM* $PO $CM* ($H3 | $H2 | $JT | $JV | $JL);
    633 $CM* ($H3 | $H2 | $JT | $JV | $JL) $CM* $PR;
    634 
    635 # LB 28
    636 $CM* ($ALPlus | $HL) $CM* ($ALPlus | $HL);
    637 
    638 
    639 # LB 29
    640 $CM* ($ALPlus | $HL) $CM* $IS;
    641 
    642 # LB 30
    643 $CM* $OP $CM* ($ALPlus | $HL | $NU);
    644 $CM* ($ALPlus | $HL | $NU) $CM* $CP;
    645 
    646 # LB 30a
    647 $CM* $RI $CM* $RI;
    648 
    649 ## -------------------------------------------------
    650 
    651 !!safe_reverse;
    652 
    653 # LB 9
    654 $CM+ [^$CM $BK $CR $LF $NL $ZW $SP];
    655 $CM+ $SP / .;
    656 
    657 # LB 14
    658 $SP+ $CM* $OP;
    659 
    660 # LB 15
    661 $SP+ $CM* $QU;
    662 
    663 # LB 16
    664 $SP+ $CM* ($CL | $CP);
    665 
    666 # LB 17
    667 $SP+ $CM* $B2;
    668 
    669 # LB 21
    670 $CM* ($HY | $BA) $CM* $HL;
    671 
    672 # LB 25
    673 ($CM* ($IS | $SY))+ $CM* $NU;
    674 ($CL | $CP) $CM* ($NU | $IS | $SY);
    675 
    676 # For dictionary-based break
    677 $dictionary $dictionary;
    678 
    679 ## -------------------------------------------------
    680 
    681 !!safe_forward;
    682 
    683 # Skip forward over all character classes that are involved in
    684 #   rules containing patterns with possibly more than one char
    685 #   of context.
    686 #
    687 #  It might be slightly more efficient to have specific rules
    688 #  instead of one generic one, but only if we could
    689 #  turn off rule chaining.  We don't want to move more
    690 #  than necessary.
    691 #
    692 [$CM $OP $QU $CL $CP $B2 $PR $HY $BA $SP $dictionary]+ [^$CM $OP $QU $CL $CP $B2 $PR $HY $BA $dictionary];
    693 $dictionary $dictionary;
    694 
    695