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