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_loose.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=loose (BCP47 -u-lb-loose) as defined for languages other than 
     18 #         Chinese & Japanese.
     19 #         It sets characters of class CJ to behave like ID.
     20 #         In addition, it allows breaks:
     21 #         * before iteration marks 3005, 303B, 309D, 309E, 30FD, 30FE (all NS)
     22 #         * between characters of LineBreak class IN
     23 
     24 #
     25 #  Character Classes defined by TR 14.
     26 #
     27 
     28 !!chain;
     29 !!LBCMNoChain;
     30 
     31 
     32 !!lookAheadHardBreak;
     33 #
     34 #  !!lookAheadHardBreak    Described here because it is (as yet) undocumented elsewhere
     35 #                          and only used for the line break rules.
     36 #
     37 #           It is used in the implementation of rule LB 10
     38 #           which says to treat any combining mark that is not attached to a base
     39 #           character as if it were of class AL  (alphabetic).
     40 #
     41 #           The problem occurs in the reverse rules.
     42 #
     43 #           Consider a sequence like, with correct breaks as shown
     44 #               LF  ID  CM  AL  AL
     45 #                  ^       ^       ^
     46 #           Then consider the sequence without the initial ID (ideographic)
     47 #                 LF  CM  AL  AL
     48 #                    ^           ^
     49 #           Our CM, which in the first example was attached to the ideograph,
     50 #           is now unattached, becomes an alpha, and joins in with the other
     51 #           alphas.
     52 #
     53 #           When iterating forwards, these sequences do not present any problems
     54 #           When iterating backwards, we need to look ahead when encountering
     55 #           a CM to see whether it attaches to something further on or not.
     56 #           (Look-ahead in a reverse rule is looking towards the start)
     57 #
     58 #           If the CM is unattached, we need to force a break.
     59 #
     60 #           !!lookAheadHardBreak forces the run time state machine to
     61 #           stop immediately when a look ahead rule ( '/' operator) matches,
     62 #           and set the match position to that of the look-ahead operator,
     63 #           no matter what other rules may be in play at the time.
     64 #
     65 #           See rule LB 19 for an example.
     66 #
     67 
     68 $AI = [:LineBreak =  Ambiguous:];
     69 $AL = [:LineBreak =  Alphabetic:];
     70 $BA = [:LineBreak =  Break_After:];
     71 $BB = [:LineBreak =  Break_Before:];
     72 $BK = [:LineBreak =  Mandatory_Break:];
     73 $B2 = [:LineBreak =  Break_Both:];
     74 $CB = [:LineBreak =  Contingent_Break:];
     75 $CJ = [:LineBreak =  Conditional_Japanese_Starter:];
     76 $CL = [:LineBreak =  Close_Punctuation:];
     77 $CM = [:LineBreak =  Combining_Mark:];
     78 $CP = [:LineBreak =  Close_Parenthesis:];
     79 $CR = [:LineBreak =  Carriage_Return:];
     80 $EX = [:LineBreak =  Exclamation:];
     81 $GL = [:LineBreak =  Glue:];
     82 $HL = [:LineBreak =  Hebrew_Letter:];
     83 $HY = [:LineBreak =  Hyphen:];
     84 $H2 = [:LineBreak =  H2:];
     85 $H3 = [:LineBreak =  H3:];
     86 $ID = [[:LineBreak =  Ideographic:] $CJ];
     87 $IN = [:LineBreak =  Inseperable:];
     88 $IS = [:LineBreak =  Infix_Numeric:];
     89 $JL = [:LineBreak =  JL:];
     90 $JV = [:LineBreak =  JV:];
     91 $JT = [:LineBreak =  JT:];
     92 $LF = [:LineBreak =  Line_Feed:];
     93 $NL = [:LineBreak =  Next_Line:];
     94 $NSX = [\u3005 \u303B \u309D \u309E \u30FD \u30FE];
     95 $NS = [[:LineBreak =  Nonstarter:] - $NSX];
     96 $NU = [:LineBreak =  Numeric:];
     97 $OP = [:LineBreak =  Open_Punctuation:];
     98 $PO = [:LineBreak =  Postfix_Numeric:];
     99 $PR = [:LineBreak =  Prefix_Numeric:];
    100 $QU = [:LineBreak =  Quotation:];
    101 $RI = [:LineBreak =  Regional_Indicator:];
    102 $SA = [:LineBreak =  Complex_Context:];
    103 $SG = [:LineBreak =  Surrogate:];
    104 $SP = [:LineBreak =  Space:];
    105 $SY = [:LineBreak =  Break_Symbols:];
    106 $WJ = [:LineBreak =  Word_Joiner:];
    107 $XX = [:LineBreak =  Unknown:];
    108 $ZW = [:LineBreak =  ZWSpace:];
    109 
    110 #   Dictionary character set, for triggering language-based break engines. Currently
    111 #   limited to LineBreak=Complex_Context. Note that this set only works in Unicode
    112 #   5.0 or later as the definition of Complex_Context was corrected to include all
    113 #   characters requiring dictionary break.
    114 
    115 $dictionary = [:LineBreak = Complex_Context:];
    116 
    117 #
    118 #  Rule LB1.  By default, treat AI  (characters with ambiguous east Asian width),
    119 #                               SA  (South East Asian: Thai, Lao, Khmer)
    120 #                               SG  (Unpaired Surrogates)
    121 #                               XX  (Unknown, unassigned)
    122 #                         as $AL  (Alphabetic)
    123 #
    124 $ALPlus = [$AL $AI $SA $SG $XX];
    125 
    126 #
    127 #  Combining Marks.   X $CM*  behaves as if it were X.  Rule LB6.
    128 #
    129 $ALcm = $ALPlus $CM*;
    130 $BAcm = $BA $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 $BB $CM+;
    168 $B2 $CM+;
    169 $CL $CM+;
    170 $CP $CM+;
    171 $EX $CM+;
    172 $GL $CM+;
    173 $HL $CM+;
    174 $HY $CM+;
    175 $H2 $CM+;
    176 $H3 $CM+;
    177 $ID $CM+;
    178 $IN $CM+;
    179 $IS $CM+;
    180 $JL $CM+;
    181 $JV $CM+;
    182 $JT $CM+;
    183 $NS $CM+;
    184 $NSX $CM+;
    185 $NU $CM+;
    186 $OP $CM+;
    187 $PO $CM+;
    188 $PR $CM+;
    189 $QU $CM+;
    190 $RI $CM+;
    191 $SY $CM+;
    192 $WJ $CM+;
    193 
    194 #
    195 # CAN_CM  is the set of characters that may combine with CM combining chars.
    196 #         Note that Linebreak UAX 14's concept of a combining char and the rules
    197 #         for what they can combine with are _very_ different from the rest of Unicode.
    198 #
    199 #         Note that $CM itself is left out of this set.  If CM is needed as a base
    200 #         it must be listed separately in the rule.
    201 #
    202 $CAN_CM  = [^$SP $BK $CR $LF $NL $ZW $CM];       # Bases that can   take CMs
    203 $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM];       # Bases that can't take CMs
    204 
    205 #
    206 # AL_FOLLOW  set of chars that can unconditionally follow an AL
    207 #            Needed in rules where stand-alone $CM s are treated as AL.
    208 #            Chaining is disabled with CM because it causes other failures,
    209 #            so for this one case we need to manually list out longer sequences.
    210 #
    211 $AL_FOLLOW_NOCM = [$BK $CR $LF $NL $ZW $SP];
    212 $AL_FOLLOW_CM   = [$CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HY $NS $IN $NU $ALPlus];
    213 $AL_FOLLOW      = [$AL_FOLLOW_NOCM $AL_FOLLOW_CM];
    214 
    215 
    216 #
    217 #  Rule LB 4, 5    Mandatory (Hard) breaks.
    218 #
    219 $LB4Breaks    = [$BK $CR $LF $NL];
    220 $LB4NonBreaks = [^$BK $CR $LF $NL];
    221 $CR $LF {100};
    222 
    223 #
    224 #  LB 6    Do not break before hard line breaks.
    225 #
    226 $LB4NonBreaks?  $LB4Breaks {100};    # LB 5  do not break before hard breaks.
    227 $CAN_CM $CM*    $LB4Breaks {100};
    228 $CM+            $LB4Breaks {100};
    229 
    230 # LB 7         x SP
    231 #              x ZW
    232 $LB4NonBreaks [$SP $ZW];
    233 $CAN_CM $CM*  [$SP $ZW];
    234 $CM+          [$SP $ZW];
    235 
    236 #
    237 # LB 8         Break after zero width space
    238 #              TODO:  ZW SP* <break>
    239 #              An engine change is required to write the reverse rule for this.
    240 #              For now, leave the Unicode 5.2 rule, ZW <break>
    241 #
    242 $LB8Breaks    = [$LB4Breaks $ZW];
    243 $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
    244 
    245 
    246 # LB 9     Combining marks.      X   $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL 
    247 #                                $CM not covered by the above needs to behave like $AL   
    248 #                                See definition of $CAN_CM.
    249 
    250 $CAN_CM $CM+;                   #  Stick together any combining sequences that don't match other rules.
    251 $CM+;
    252 
    253 #
    254 # LB 11  Do not break before or after WORD JOINER & related characters.
    255 #
    256 $CAN_CM $CM*  $WJcm;
    257 $LB8NonBreaks $WJcm;
    258 $CM+          $WJcm;
    259 
    260 $WJcm $CANT_CM;
    261 $WJcm $CAN_CM $CM*;
    262 
    263 #
    264 # LB 12  Do not break after NBSP and related characters.
    265 #         GL  x
    266 #
    267 $GLcm $CAN_CM $CM*;
    268 $GLcm $CANT_CM;
    269  
    270 #
    271 # LB 12a  Do not break before NBSP and related characters ...
    272 #            [^SP BA HY] x GL
    273 #
    274 [[$LB8NonBreaks] - [$SP $BA $HY]] $CM* $GLcm;
    275 $CM+ GLcm;
    276 
    277 
    278 
    279 #
    280 # LB 13   Don't break before ']' or '!' or ';' or '/', even after spaces.
    281 #
    282 $LB8NonBreaks $CL;
    283 $CAN_CM $CM*  $CL;
    284 $CM+          $CL;              # by rule 10, stand-alone CM behaves as AL
    285 
    286 $LB8NonBreaks $CP;
    287 $CAN_CM $CM*  $CP;
    288 $CM+          $CP;              # by rule 10, stand-alone CM behaves as AL
    289 
    290 $LB8NonBreaks $EX;
    291 $CAN_CM $CM*  $EX;
    292 $CM+          $EX;              # by rule 10, stand-alone CM behaves as AL
    293 
    294 $LB8NonBreaks $IS;
    295 $CAN_CM $CM*  $IS;
    296 $CM+          $IS;              # by rule 10, stand-alone CM behaves as AL
    297 
    298 $LB8NonBreaks $SY;
    299 $CAN_CM $CM*  $SY;
    300 $CM+          $SY;              # by rule 10, stand-alone CM behaves as AL
    301 
    302 
    303 #
    304 # LB 14  Do not break after OP, even after spaces
    305 #
    306 $OPcm $SP* $CAN_CM $CM*;
    307 $OPcm $SP* $CANT_CM;
    308 
    309 $OPcm $SP+ $CM+ $AL_FOLLOW?;    # by rule 10, stand-alone CM behaves as AL
    310 
    311 # LB 15
    312 $QUcm $SP* $OPcm;
    313 
    314 # LB 16
    315 # Do not break between closing punctuation and $NS, even with intervening spaces
    316 # But DO allow a break between closing punctuation and $NSX, don't include it here
    317 ($CLcm | $CPcm) $SP* $NScm;
    318 
    319 # LB 17
    320 $B2cm $SP* $B2cm;
    321 
    322 #
    323 # LB 18  Break after spaces.
    324 #
    325 $LB18NonBreaks = [$LB8NonBreaks - [$SP]];
    326 $LB18Breaks    = [$LB8Breaks $SP];
    327 
    328 
    329 # LB 19
    330 #         x QU
    331 $LB18NonBreaks $CM* $QUcm;
    332 $CM+                $QUcm;
    333 
    334 #         QU  x
    335 $QUcm .?;
    336 $QUcm $LB18NonBreaks $CM*;    # Don't let a combining mark go onto $CR, $BK, etc.
    337                               #  TODO:  I don't think this rule is needed.
    338 
    339 
    340 # LB 20
    341 #        <break>  $CB
    342 #        $CB   <break>
    343 
    344 $LB20NonBreaks = [$LB18NonBreaks - $CB];
    345 
    346 # LB 21        x   (BA | HY | NS)
    347 #           BB x
    348 #
    349 # DO allow breaks here before NSXcm, so don't include it
    350 $LB20NonBreaks $CM* ($BAcm | $HYcm | $NScm); 
    351 
    352 $BBcm [^$CB];                                  #  $BB  x
    353 $BBcm $LB20NonBreaks $CM*;
    354 
    355 # LB 21a Don't break after Hebrew + Hyphen
    356 #   HL (HY | BA) x
    357 #  
    358 $HLcm ($HYcm | $BAcm) [^$CB]?;
    359 
    360 # LB 21b (forward) Don't break between SY and HL
    361 # (break between HL and SY already disallowed by LB 13 above)
    362 $SYcm $HLcm;
    363 
    364 # LB 22
    365 ($ALcm | $HLcm) $INcm;
    366 $CM+     $INcm;     #  by rule 10, any otherwise unattached CM behaves as AL
    367 $EXcm    $INcm;
    368 $IDcm    $INcm;
    369 # $INcm  $INcm; # delete this rule for CSS loose
    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+ $BB;
    431 $CM+ $B2;
    432 $CM+ $CL;
    433 $CM+ $CP;
    434 $CM+ $EX;
    435 $CM+ $GL;
    436 $CM+ $HL;
    437 $CM+ $HY;
    438 $CM+ $H2;
    439 $CM+ $H3;
    440 $CM+ $ID;
    441 $CM+ $IN;
    442 $CM+ $IS;
    443 $CM+ $JL;
    444 $CM+ $JV;
    445 $CM+ $JT;
    446 $CM+ $NS;
    447 $CM+ $NSX;
    448 $CM+ $NU;
    449 $CM+ $OP;
    450 $CM+ $PO;
    451 $CM+ $PR;
    452 $CM+ $QU;
    453 $CM+ $RI;
    454 $CM+ $SY;
    455 $CM+ $WJ;
    456 $CM+;
    457 
    458 
    459 #
    460 #  Sequences of the form  (shown forwards)
    461 #      [CANT_CM]  <break>  [CM]  [whatever]
    462 #  The CM needs to behave as an AL
    463 #
    464 $AL_FOLLOW $CM+ / (
    465           [$BK $CR $LF $NL $ZW {eof}] |
    466           $SP+ $CM+ $SP |
    467           $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}]));   # if LB 14 will match, need to surpress this break.
    468                                                #  LB14 says    OP SP* x .        
    469                                                #    becomes    OP SP* x AL
    470                                                #    becomes    OP SP* x CM+ AL_FOLLOW
    471                                                #
    472                                                # Further note:  the $AL in [$AL {eof}] is only to work around
    473                                                #                a rule compiler bug which complains about
    474                                                #                empty sets otherwise.
    475           
    476 #
    477 #  Sequences of the form  (shown forwards)
    478 #      [CANT_CM]  <break> [CM]  <break>  [PR]
    479 #  The CM needs to behave as an AL
    480 #  This rule is concerned about getting the second of the two <breaks> in place.
    481 #
    482 
    483 [$PR   ] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}];
    484 
    485 
    486 
    487 # LB 4, 5, 5
    488 
    489 $LB4Breaks [$LB4NonBreaks-$CM];
    490 $LB4Breaks $CM+ $CAN_CM;
    491 $LF $CR;
    492 
    493 
    494 # LB 7         x SP
    495 #              x ZW
    496 [$SP $ZW] [$LB4NonBreaks-$CM];
    497 [$SP $ZW] $CM+ $CAN_CM;
    498 
    499 # LB 8 ZW SP* <break>
    500 #     TODO: to implement this, we need more than one look-ahead hard break in play at a time.
    501 #           Requires an engine enhancement.
    502 #   / $SP* $ZW
    503 
    504 # LB 9,10  Combining marks.
    505 #    X   $CM needs to behave like X, where X is not $SP or controls.
    506 #    $CM not covered by the above needs to behave like $AL
    507 # Stick together any combining sequences that don't match other rules.
    508 $CM+ $CAN_CM;
    509 
    510 
    511 # LB 11
    512 $CM* $WJ $CM* $CAN_CM;
    513 $CM* $WJ      [$LB8NonBreaks-$CM];
    514 
    515      $CANT_CM $CM* $WJ;
    516 $CM* $CAN_CM  $CM* $WJ;
    517 
    518 # LB 12a
    519 #      [^SP BA HY] x GL
    520 #
    521 $CM* $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $HY]];
    522 
    523 # LB 12
    524 #     GL  x
    525 #
    526 $CANT_CM $CM* $GL;
    527 $CM* $CAN_CM $CM* $GL;
    528 
    529 
    530 # LB 13
    531 $CL $CM+ $CAN_CM;
    532 $CP $CM+ $CAN_CM;
    533 $EX $CM+ $CAN_CM;
    534 $IS $CM+ $CAN_CM;
    535 $SY $CM+ $CAN_CM;
    536 
    537 $CL [$LB8NonBreaks-$CM];
    538 $CP [$LB8NonBreaks-$CM];
    539 $EX [$LB8NonBreaks-$CM];
    540 $IS [$LB8NonBreaks-$CM];
    541 $SY [$LB8NonBreaks-$CM];
    542 
    543 # Rule 13 & 14 taken together for an edge case.
    544 #   Match this, shown forward
    545 #     OP SP+  ($CM+ behaving as $AL) (CL | CP | EX | IS | IY)
    546 #   This really wants to chain at the $CM+ (which is acting as an $AL)
    547 #   except for $CM chaining being disabled.
    548 [$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP;  
    549 
    550 # LB 14    OP SP* x
    551 #
    552 $CM* $CAN_CM    $SP* $CM* $OP;
    553      $CANT_CM   $SP* $CM* $OP;
    554 $AL_FOLLOW? $CM+  $SP $SP* $CM* $OP;     #  by LB 10, behaves like $AL_FOLLOW? $AL $SP* $CM* $OP
    555      
    556      $AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP;
    557 $CM* $AL_FOLLOW_CM   $CM+ $SP+ $CM* $OP;
    558 $SY $CM $SP+ $OP;   # TODO:  Experiment.  Remove.
    559 
    560 
    561 
    562 # LB 15
    563 $CM* $OP $SP* $CM* $QU;
    564 
    565 # LB 16
    566 # Don't include $NSX here
    567 $CM* $NS $SP* $CM* ($CL | $CP);
    568 
    569 # LB 17
    570 $CM* $B2 $SP* $CM* $B2;
    571 
    572 # LB 18  break after spaces
    573 #        Nothing explicit needed here.
    574 
    575 
    576 #
    577 # LB 19
    578 #
    579 $CM* $QU $CM* $CAN_CM;                                #   . x QU
    580 $CM* $QU      $LB18NonBreaks;
    581 
    582 
    583 $CM* $CAN_CM  $CM* $QU;                               #   QU x .
    584      $CANT_CM $CM* $QU;
    585      
    586 #
    587 #  LB 20  Break before and after CB.
    588 #         nothing needed here.
    589 #
    590 
    591 # LB 21
    592 # Don't include $NSX here
    593 $CM* ($BA | $HY | $NS) $CM* [$LB20NonBreaks-$CM];     #  . x (BA | HY | NS)
    594 
    595 $CM* [$LB20NonBreaks-$CM] $CM* $BB;                   #  BB x .
    596 [^$CB] $CM* $BB;                                      # 
    597 
    598 # LB21a
    599 [^$CB] $CM* ($HY | $BA) $CM* $HL;
    600 
    601 # LB21b (reverse)
    602 $CM* $HL $CM* $SY;
    603 
    604 # LB 22
    605 $CM* $IN $CM* ($ALPlus | $HL);
    606 $CM* $IN $CM* $EX;
    607 $CM* $IN $CM* $ID;
    608 # $CM* $IN $CM* $IN; # delete this rule for CSS loose
    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