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