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