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