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