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 34 for Unicode 8.0
      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 $HY $NS $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 $EXcm    $INcm;
    369 $IDcm    $INcm;
    370 $INcm    $INcm;
    371 $NUcm    $INcm;
    372 
    373 
    374 # $LB 23
    375 $IDcm  $POcm;
    376 $ALcm  $NUcm;       # includes $LB19
    377 $HLcm  $NUcm;
    378 $CM+   $NUcm;       # Rule 10, any otherwise unattached CM behaves as AL
    379 $NUcm  $ALcm;
    380 $NUcm  $HLcm;
    381 
    382 #
    383 # LB 24
    384 #
    385 $PRcm $IDcm;
    386 $PRcm ($ALcm | $HLcm);
    387 $POcm ($ALcm | $HLcm);
    388 
    389 #
    390 # LB 25   Numbers.
    391 #
    392 ($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?;
    393 
    394 # LB 26  Do not break a Korean syllable
    395 #
    396 $JLcm ($JLcm | $JVcm | $H2cm | $H3cm);
    397 ($JVcm | $H2cm) ($JVcm | $JTcm);
    398 ($JTcm | $H3cm) $JTcm;
    399 
    400 # LB 27  Treat korean Syllable Block the same as ID  (don't break it)
    401 ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $INcm;
    402 ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $POcm;
    403 $PRcm ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm);
    404 
    405 
    406 # LB 28   Do not break between alphabetics
    407 #
    408 ($ALcm | $HLcm) ($ALcm | $HLcm);
    409 $CM+ ($ALcm | $HLcm);      # The $CM+ is from rule 10, an unattached CM is treated as AL
    410 
    411 # LB 29
    412 $IScm ($ALcm | $HLcm);
    413 
    414 # LB 30
    415 ($ALcm | $HLcm | $NUcm) $OPcm;
    416 $CM+ $OPcm;         # The $CM+ is from rule 10, an unattached CM is treated as AL.          
    417 $CPcm ($ALcm | $HLcm | $NUcm);
    418 
    419 # LB 30a  Do not break between regional indicators.
    420 $RIcm $RIcm;
    421 
    422 #
    423 #  Reverse Rules.
    424 #
    425 ## -------------------------------------------------
    426 
    427 !!reverse;
    428 
    429 $CM+ $ALPlus;
    430 $CM+ $BA;
    431 $CM+ $BAX;
    432 $CM+ $BB;
    433 $CM+ $B2;
    434 $CM+ $CL;
    435 $CM+ $CP;
    436 $CM+ $EX;
    437 $CM+ $GL;
    438 $CM+ $HL;
    439 $CM+ $HY;
    440 $CM+ $H2;
    441 $CM+ $H3;
    442 $CM+ $ID;
    443 $CM+ $IN;
    444 $CM+ $IS;
    445 $CM+ $JL;
    446 $CM+ $JV;
    447 $CM+ $JT;
    448 $CM+ $NS;
    449 $CM+ $NSX;
    450 $CM+ $NU;
    451 $CM+ $OP;
    452 $CM+ $PO;
    453 $CM+ $PR;
    454 $CM+ $QU;
    455 $CM+ $RI;
    456 $CM+ $SY;
    457 $CM+ $WJ;
    458 $CM+;
    459 
    460 
    461 #
    462 #  Sequences of the form  (shown forwards)
    463 #      [CANT_CM]  <break>  [CM]  [whatever]
    464 #  The CM needs to behave as an AL
    465 #
    466 $AL_FOLLOW $CM+ / (
    467           [$BK $CR $LF $NL $ZW {eof}] |
    468           $SP+ $CM+ $SP |
    469           $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}]));   # if LB 14 will match, need to surpress this break.
    470                                                #  LB14 says    OP SP* x .        
    471                                                #    becomes    OP SP* x AL
    472                                                #    becomes    OP SP* x CM+ AL_FOLLOW
    473                                                #
    474                                                # Further note:  the $AL in [$AL {eof}] is only to work around
    475                                                #                a rule compiler bug which complains about
    476                                                #                empty sets otherwise.
    477           
    478 #
    479 #  Sequences of the form  (shown forwards)
    480 #      [CANT_CM]  <break> [CM]  <break>  [PR]
    481 #  The CM needs to behave as an AL
    482 #  This rule is concerned about getting the second of the two <breaks> in place.
    483 #
    484 
    485 [$PR   ] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}];
    486 
    487 
    488 
    489 # LB 4, 5, 5
    490 
    491 $LB4Breaks [$LB4NonBreaks-$CM];
    492 $LB4Breaks $CM+ $CAN_CM;
    493 $LF $CR;
    494 
    495 
    496 # LB 7         x SP
    497 #              x ZW
    498 [$SP $ZW] [$LB4NonBreaks-$CM];
    499 [$SP $ZW] $CM+ $CAN_CM;
    500 
    501 # LB 8 ZW SP* <break>
    502 #     TODO: to implement this, we need more than one look-ahead hard break in play at a time.
    503 #           Requires an engine enhancement.
    504 #   / $SP* $ZW
    505 
    506 # LB 9,10  Combining marks.
    507 #    X   $CM needs to behave like X, where X is not $SP or controls.
    508 #    $CM not covered by the above needs to behave like $AL
    509 # Stick together any combining sequences that don't match other rules.
    510 $CM+ $CAN_CM;
    511 
    512 
    513 # LB 11
    514 $CM* $WJ $CM* $CAN_CM;
    515 $CM* $WJ      [$LB8NonBreaks-$CM];
    516 
    517      $CANT_CM $CM* $WJ;
    518 $CM* $CAN_CM  $CM* $WJ;
    519 
    520 # LB 12a
    521 #      [^SP BA HY] x GL
    522 #
    523 $CM* $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $BAX $HY]];
    524 
    525 # LB 12
    526 #     GL  x
    527 #
    528 $CANT_CM $CM* $GL;
    529 $CM* $CAN_CM $CM* $GL;
    530 
    531 
    532 # LB 13
    533 $CL $CM+ $CAN_CM;
    534 $CP $CM+ $CAN_CM;
    535 $EX $CM+ $CAN_CM;
    536 $IS $CM+ $CAN_CM;
    537 $SY $CM+ $CAN_CM;
    538 
    539 $CL [$LB8NonBreaks-$CM];
    540 $CP [$LB8NonBreaks-$CM];
    541 $EX [$LB8NonBreaks-$CM];
    542 $IS [$LB8NonBreaks-$CM];
    543 $SY [$LB8NonBreaks-$CM];
    544 
    545 # Rule 13 & 14 taken together for an edge case.
    546 #   Match this, shown forward
    547 #     OP SP+  ($CM+ behaving as $AL) (CL | CP | EX | IS | IY)
    548 #   This really wants to chain at the $CM+ (which is acting as an $AL)
    549 #   except for $CM chaining being disabled.
    550 [$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP;  
    551 
    552 # LB 14    OP SP* x
    553 #
    554 $CM* $CAN_CM    $SP* $CM* $OP;
    555      $CANT_CM   $SP* $CM* $OP;
    556 $AL_FOLLOW? $CM+  $SP $SP* $CM* $OP;     #  by LB 10, behaves like $AL_FOLLOW? $AL $SP* $CM* $OP
    557      
    558      $AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP;
    559 $CM* $AL_FOLLOW_CM   $CM+ $SP+ $CM* $OP;
    560 $SY $CM $SP+ $OP;   # TODO:  Experiment.  Remove.
    561 
    562 
    563 
    564 # LB 15
    565 $CM* $OP $SP* $CM* $QU;
    566 
    567 # LB 16
    568 # Don't include $NSX here
    569 $CM* $NS $SP* $CM* ($CL | $CP);
    570 
    571 # LB 17
    572 $CM* $B2 $SP* $CM* $B2;
    573 
    574 # LB 18  break after spaces
    575 #        Nothing explicit needed here.
    576 
    577 
    578 #
    579 # LB 19
    580 #
    581 $CM* $QU $CM* $CAN_CM;                                #   . x QU
    582 $CM* $QU      $LB18NonBreaks;
    583 
    584 
    585 $CM* $CAN_CM  $CM* $QU;                               #   QU x .
    586      $CANT_CM $CM* $QU;
    587      
    588 #
    589 #  LB 20  Break before and after CB.
    590 #         nothing needed here.
    591 #
    592 
    593 # LB 21
    594 # Don't include $BAX or $NSX here
    595 $CM* ($BA | $HY | $NS) $CM* [$LB20NonBreaks-$CM];     #  . x (BA | HY | NS)
    596 
    597 $CM* [$LB20NonBreaks-$CM] $CM* $BB;                   #  BB x .
    598 [^$CB] $CM* $BB;                                      # 
    599 
    600 # LB21a
    601 [^$CB]? $CM* ($HY | $BA | $BAX) $CM* $HL;
    602 
    603 # LB21b (reverse)
    604 $CM* $HL $CM* $SY;
    605 
    606 # LB 22
    607 $CM* $IN $CM* ($ALPlus | $HL);
    608 $CM* $IN $CM* $EX;
    609 $CM* $IN $CM* $ID;
    610 $CM* $IN $CM* $IN;
    611 $CM* $IN $CM* $NU;
    612 
    613 # LB 23
    614 $CM* $PO $CM* $ID;
    615 $CM* $NU $CM* ($ALPlus | $HL);
    616 $CM* ($ALPlus | $HL) $CM* $NU;
    617 
    618 # LB 24
    619 $CM* $ID $CM* $PR;
    620 $CM* ($ALPlus | $HL) $CM* $PR;
    621 $CM* ($ALPlus | $HL) $CM* $PO;
    622 
    623 
    624 # LB 25
    625 ($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?;
    626 
    627 # LB 26
    628 $CM* ($H3 | $H2 | $JV | $JL) $CM* $JL;
    629 $CM* ($JT | $JV) $CM* ($H2 | $JV);
    630 $CM* $JT $CM* ($H3 | $JT);
    631 
    632 # LB 27
    633 $CM* $IN $CM* ($H3 | $H2 | $JT | $JV | $JL);
    634 $CM* $PO $CM* ($H3 | $H2 | $JT | $JV | $JL);
    635 $CM* ($H3 | $H2 | $JT | $JV | $JL) $CM* $PR;
    636 
    637 # LB 28
    638 $CM* ($ALPlus | $HL) $CM* ($ALPlus | $HL);
    639 
    640 
    641 # LB 29
    642 $CM* ($ALPlus | $HL) $CM* $IS;
    643 
    644 # LB 30
    645 $CM* $OP $CM* ($ALPlus | $HL | $NU);
    646 $CM* ($ALPlus | $HL | $NU) $CM* $CP;
    647 
    648 # LB 30a
    649 $CM* $RI $CM* $RI;
    650 
    651 ## -------------------------------------------------
    652 
    653 !!safe_reverse;
    654 
    655 # LB 9
    656 $CM+ [^$CM $BK $CR $LF $NL $ZW $SP];
    657 $CM+ $SP / .;
    658 
    659 # LB 14
    660 $SP+ $CM* $OP;
    661 
    662 # LB 15
    663 $SP+ $CM* $QU;
    664 
    665 # LB 16
    666 $SP+ $CM* ($CL | $CP);
    667 
    668 # LB 17
    669 $SP+ $CM* $B2;
    670 
    671 # LB 21
    672 $CM* ($HY | $BA | $BAX) $CM* $HL;
    673 
    674 # LB 25
    675 ($CM* ($IS | $SY))+ $CM* $NU;
    676 ($CL | $CP) $CM* ($NU | $IS | $SY);
    677 
    678 # For dictionary-based break
    679 $dictionary $dictionary;
    680 
    681 ## -------------------------------------------------
    682 
    683 !!safe_forward;
    684 
    685 # Skip forward over all character classes that are involved in
    686 #   rules containing patterns with possibly more than one char
    687 #   of context.
    688 #
    689 #  It might be slightly more efficient to have specific rules
    690 #  instead of one generic one, but only if we could
    691 #  turn off rule chaining.  We don't want to move more
    692 #  than necessary.
    693 #
    694 [$CM $OP $QU $CL $CP $B2 $PR $HY $BA $BAX $SP $dictionary]+ [^$CM $OP $QU $CL $CP $B2 $PR $HY $BA $BAX $dictionary];
    695 $dictionary $dictionary;
    696 
    697