1 # Copyright (c) 2002-2016 International Business Machines Corporation and
2 # others. All Rights Reserved.
4 # file: line_normal_fi.txt
7 # Implement default line breaking as defined by
8 # Unicode Standard Annex #14 Revision 35 for Unicode 8.0
9 # http://www.unicode.org/reports/tr14/
11 # Includes the Emoji breaking proposals from Unicode L2/16-011R3.
12 # http://www.unicode.org/L2/L2016/16011r3-break-prop-emoji.pdf
14 # Tailored as noted in 2nd paragraph below.
16 # TODO: Rule LB 8 remains as it was in Unicode 5.2
17 # This is only because of a limitation of ICU break engine implementation,
18 # not because the older behavior is desirable.
20 # This tailors the line break behavior for Finnish, and to correspond to CSS
21 # line-break=normal (BCP47 -u-lb-normal) as defined for languages other than
23 # It sets characters of class CJ to behave like ID.
26 # Character Classes defined by TR 14.
33 # !!lookAheadHardBreak Described here because it is (as yet) undocumented elsewhere
34 # and only used for the line break rules.
36 # It is used in the implementation of rule LB 10
37 # which says to treat any combining mark that is not attached to a base
38 # character as if it were of class AL (alphabetic).
40 # The problem occurs in the reverse rules.
42 # Consider a sequence like, with correct breaks as shown
45 # Then consider the sequence without the initial ID (ideographic)
48 # Our CM, which in the first example was attached to the ideograph,
49 # is now unattached, becomes an alpha, and joins in with the other
52 # When iterating forwards, these sequences do not present any problems
53 # When iterating backwards, we need to look ahead when encountering
54 # a CM to see whether it attaches to something further on or not.
55 # (Look-ahead in a reverse rule is looking towards the start)
57 # If the CM is unattached, we need to force a break.
59 # !!lookAheadHardBreak forces the run time state machine to
60 # stop immediately when a look ahead rule ( '/' operator) matches,
61 # and set the match position to that of the look-ahead operator,
62 # no matter what other rules may be in play at the time.
64 # See rule LB 19 for an example.
67 # Temporary definitions of Emoji Base and Emoji Modifiers, until properties are available.
69 $EB = [\u261D\u26F9\u270A-\u270D\U0001F385\U0001F3C2-\U0001F3C4\U0001F3C7\U0001F3CA-\U0001F3CC\U0001F442-\U0001F443\U0001F446-\U0001F450\U0001F466-\U0001F478\U0001F47C\U0001F481-\U0001F483\U0001F485-\U0001F487\U0001F4AA\U0001F574-\U0001F575\U0001F57A\U0001F590\U0001F595-\U0001F596\U0001F645-\U0001F647\U0001F64B-\U0001F64F\U0001F6A3\U0001F6B4-\U0001F6B6\U0001F6C0\U0001F6CC\U0001F918-\U0001F91E\U0001F926\U0001F930\U0001F933-\U0001F939\U0001F93C-\U0001F93E];
70 $EM = [\U0001F3FB-\U0001F3FF];
72 $AI = [[:LineBreak = Ambiguous:] - [\u2640\u2642]];
73 $AL = [[:LineBreak = Alphabetic:] - [$EM\u2695\u2696\u2764]];
74 $BA = [[:LineBreak = Break_After:]-[\u2010]];
76 $BB = [:LineBreak = Break_Before:];
77 $BK = [:LineBreak = Mandatory_Break:];
78 $B2 = [:LineBreak = Break_Both:];
79 $CB = [:LineBreak = Contingent_Break:];
80 $CJ = [:LineBreak = Conditional_Japanese_Starter:];
81 $CL = [:LineBreak = Close_Punctuation:];
82 $CM = [[:LineBreak = Combining_Mark:] \u200d];
83 $CP = [:LineBreak = Close_Parenthesis:];
84 $CR = [:LineBreak = Carriage_Return:];
85 $EX = [:LineBreak = Exclamation:];
86 $GL = [:LineBreak = Glue:];
87 $HL = [:LineBreak = Hebrew_Letter:];
88 $HY = [:LineBreak = Hyphen:];
89 $H2 = [:LineBreak = H2:];
90 $H3 = [:LineBreak = H3:];
91 $ID = [[:LineBreak = Ideographic:] $CJ [\u2640\u2642\u2695\u2696\u2764] - $EB];
92 $IN = [:LineBreak = Inseperable:];
93 $IS = [:LineBreak = Infix_Numeric:];
94 $JL = [:LineBreak = JL:];
95 $JV = [:LineBreak = JV:];
96 $JT = [:LineBreak = JT:];
97 $LF = [:LineBreak = Line_Feed:];
98 $NL = [:LineBreak = Next_Line:];
99 $NS = [:LineBreak = Nonstarter:];
100 $NU = [:LineBreak = Numeric:];
101 $OP = [:LineBreak = Open_Punctuation:];
102 $PO = [:LineBreak = Postfix_Numeric:];
103 $PR = [:LineBreak = Prefix_Numeric:];
104 $QU = [:LineBreak = Quotation:];
105 $RI = [:LineBreak = Regional_Indicator:];
106 $SA = [:LineBreak = Complex_Context:];
107 $SG = [:LineBreak = Surrogate:];
108 $SP = [:LineBreak = Space:];
109 $SY = [:LineBreak = Break_Symbols:];
110 $WJ = [:LineBreak = Word_Joiner:];
111 $XX = [:LineBreak = Unknown:];
112 $ZW = [:LineBreak = ZWSpace:];
115 # Dictionary character set, for triggering language-based break engines. Currently
116 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
117 # 5.0 or later as the definition of Complex_Context was corrected to include all
118 # characters requiring dictionary break.
120 $dictionary = [:LineBreak = Complex_Context:];
123 # Rule LB1. By default, treat AI (characters with ambiguous east Asian width),
124 # SA (South East Asian: Thai, Lao, Khmer)
125 # SG (Unpaired Surrogates)
126 # XX (Unknown, unassigned)
127 # as $AL (Alphabetic)
129 $ALPlus = [$AL $AI $SA $SG $XX];
132 # Combining Marks. X $CM* behaves as if it were X. Rule LB6.
134 $ALcm = $ALPlus $CM*;
162 ## -------------------------------------------------
167 # Each class of character can stand by itself as an unbroken token, with trailing combining stuff
201 # CAN_CM is the set of characters that may combine with CM combining chars.
202 # Note that Linebreak UAX 14's concept of a combining char and the rules
203 # for what they can combine with are _very_ different from the rest of Unicode.
205 # Note that $CM itself is left out of this set. If CM is needed as a base
206 # it must be listed separately in the rule.
208 $CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM]; # Bases that can take CMs
209 $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM]; # Bases that can't take CMs
212 # AL_FOLLOW set of chars that can unconditionally follow an AL
213 # Needed in rules where stand-alone $CM s are treated as AL.
214 # Chaining is disabled with CM because it causes other failures,
215 # so for this one case we need to manually list out longer sequences.
217 $AL_FOLLOW_NOCM = [$BK $CR $LF $NL $ZW $SP];
218 $AL_FOLLOW_CM = [$CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HH $HY $NS $IN $NU $ALPlus];
219 $AL_FOLLOW = [$AL_FOLLOW_NOCM $AL_FOLLOW_CM];
223 # Rule LB 4, 5 Mandatory (Hard) breaks.
225 $LB4Breaks = [$BK $CR $LF $NL];
226 $LB4NonBreaks = [^$BK $CR $LF $NL $CM];
230 # LB 6 Do not break before hard line breaks.
232 $LB4NonBreaks? $LB4Breaks {100}; # LB 5 do not break before hard breaks.
233 $CAN_CM $CM* $LB4Breaks {100};
234 ^$CM+ $LB4Breaks {100};
238 $LB4NonBreaks [$SP $ZW];
239 $CAN_CM $CM* [$SP $ZW];
243 # LB 8 Break after zero width space
244 # TODO: ZW SP* <break>
245 # An engine change is required to write the reverse rule for this.
246 # For now, leave the Unicode 5.2 rule, ZW <break>
248 $LB8Breaks = [$LB4Breaks $ZW];
249 $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
251 # LB 8a ZWJ x ID Emoji proposal.
253 $ZWJ ($ID | $EB | $EM);
255 # LB 9 Combining marks. X $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL
256 # $CM not covered by the above needs to behave like $AL
257 # See definition of $CAN_CM.
259 $CAN_CM $CM+; # Stick together any combining sequences that don't match other rules.
263 # LB 11 Do not break before or after WORD JOINER & related characters.
273 # LB 12 Do not break after NBSP and related characters.
280 # LB 12a Do not break before NBSP and related characters ...
283 [[$LB8NonBreaks] - [$SP $BA $HH $HY]] $CM* $GLcm;
289 # LB 13 Don't break before ']' or '!' or ';' or '/', even after spaces.
293 ^$CM+ $CL; # by rule 10, stand-alone CM behaves as AL
297 ^$CM+ $CP; # by rule 10, stand-alone CM behaves as AL
301 ^$CM+ $EX; # by rule 10, stand-alone CM behaves as AL
305 ^$CM+ $IS; # by rule 10, stand-alone CM behaves as AL
309 ^$CM+ $SY; # by rule 10, stand-alone CM behaves as AL
313 # LB 14 Do not break after OP, even after spaces
315 $OPcm $SP* $CAN_CM $CM*;
318 $OPcm $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL
324 ($CLcm | $CPcm) $SP* $NScm;
330 # LB 18 Break after spaces.
332 $LB18NonBreaks = [$LB8NonBreaks - [$SP]];
333 $LB18Breaks = [$LB8Breaks $SP];
338 $LB18NonBreaks $CM* $QUcm;
349 $LB20NonBreaks = [$LB18NonBreaks - $CB];
351 # LB 20.09 added rule for Finnish tailoring
352 # LB 21 x (BA | HY | NS)
355 $LB20NonBreaks $CM* ($BAcm | $HHcm | $HYcm | $NScm) / $AL;
356 $LB20NonBreaks $CM* ($BAcm | $HHcm | $HYcm | $NScm);
358 ^$CM+ ($BAcm | $HHcm | $HYcm | $NScm);
360 $BBcm [^$CB]; # $BB x
361 $BBcm $LB20NonBreaks $CM*;
363 # LB 21a Don't break after Hebrew + Hyphen
366 $HLcm ($HYcm | $BAcm | $HHcm) [^$CB]?;
368 # LB 21b (forward) Don't break between SY and HL
369 # (break between HL and SY already disallowed by LB 13 above)
373 ($ALcm | $HLcm) $INcm;
374 ^$CM+ $INcm; # by rule 10, any otherwise unattached CM behaves as AL
376 ($ID | $EB | $EM) $CM* $INcm;
382 ($ID | $EB | $EM) $CM* $POcm;
383 $ALcm $NUcm; # includes $LB19
385 ^$CM+ $NUcm; # Rule 10, any otherwise unattached CM behaves as AL
392 $PRcm ($ID | $EB | $EM);
393 $PRcm ($ALcm | $HLcm);
394 $POcm ($ALcm | $HLcm);
395 ($ALcm | $HLcm) ($PRcm | $POcm);
396 ^$CM+ ($PRcm | $POcm); # Rule 10, any otherwise unattached CM behaves as AL
401 ($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?;
403 # LB 26 Do not break a Korean syllable
405 $JLcm ($JLcm | $JVcm | $H2cm | $H3cm);
406 ($JVcm | $H2cm) ($JVcm | $JTcm);
407 ($JTcm | $H3cm) $JTcm;
409 # LB 27 Treat korean Syllable Block the same as ID (don't break it)
410 ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $INcm;
411 ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $POcm;
412 $PRcm ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm);
415 # LB 28 Do not break between alphabetics
417 ($ALcm | $HLcm) ($ALcm | $HLcm);
418 ^$CM+ ($ALcm | $HLcm); # The $CM+ is from rule 10, an unattached CM is treated as AL
421 $IScm ($ALcm | $HLcm);
424 ($ALcm | $HLcm | $NUcm) $OPcm;
425 ^$CM+ $OPcm; # The $CM+ is from rule 10, an unattached CM is treated as AL.
426 $CPcm ($ALcm | $HLcm | $NUcm);
428 # LB 30a Do not break between regional indicators. Break after pairs of them.
429 # Tricky interaction with LB8a: ZWJ x ID
430 $RIcm $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HH $HY $NS $CM] {eof}];
431 $RIcm $RI $CM* $ZWJ / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HH $HY $NS $CM $ID $EB $EM] {eof}];
432 $RIcm $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HH $HY $NS $CM] {eof}];
434 $RIcm $RIcm [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HH $HY $NS {eof}];
435 $RIcm $RIcm $ZWJ ($ID | $EB | $EM);
437 # LB 30b Do not break between an Emoji Base and an Emoji Modifier
443 ## -------------------------------------------------
481 # Sequences of the form (shown forwards)
482 # [CANT_CM] <break> [CM] [whatever]
483 # The CM needs to behave as an AL
486 [$BK $CR $LF $NL $ZW {eof}] |
488 $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}])); # if LB 14 will match, need to surpress this break.
489 # LB14 says OP SP* x .
490 # becomes OP SP* x AL
491 # becomes OP SP* x CM+ AL_FOLLOW
493 # Further note: the $AL in [$AL {eof}] is only to work around
494 # a rule compiler bug which complains about
495 # empty sets otherwise.
498 # Sequences of the form (shown forwards)
499 # [CANT_CM] <break> [CM] <break> [PR]
500 # The CM needs to behave as an AL
501 # This rule is concerned about getting the second of the two <breaks> in place.
504 # Apple early addition, remove this, superseded by LB24
505 # [$PR ] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}];
511 $LB4Breaks [$LB4NonBreaks-$CM];
512 $LB4Breaks $CM+ $CAN_CM;
518 [$SP $ZW] [$LB4NonBreaks-$CM];
519 [$SP $ZW] $CM+ $CAN_CM;
521 # LB 8 ZW SP* <break>
522 # TODO: to implement this, we need more than one look-ahead hard break in play at a time.
523 # Requires an engine enhancement.
526 # LB 8a ZWJ x ID Unicode Emoji proposal L2/16-011R3
527 # The ZWJ will look like a CM to whatever precedes it.
529 ($ID | $EB | $EM) $ZWJ $CM* $CAN_CM?;
532 # LB 9,10 Combining marks.
533 # X $CM needs to behave like X, where X is not $SP or controls.
534 # $CM not covered by the above needs to behave like $AL
535 # Stick together any combining sequences that don't match other rules.
542 $WJ [$LB8NonBreaks-$CM];
550 $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $HH $HY]];
566 $CL [$LB8NonBreaks-$CM];
567 $CP [$LB8NonBreaks-$CM];
568 $EX [$LB8NonBreaks-$CM];
569 $IS [$LB8NonBreaks-$CM];
570 $SY [$LB8NonBreaks-$CM];
572 # Rule 13 & 14 taken together for an edge case.
573 # Match this, shown forward
574 # OP SP+ ($CM+ behaving as $AL) (CL | CP | EX | IS | IY)
575 # This really wants to chain at the $CM+ (which is acting as an $AL)
576 # except for $CM chaining being disabled.
577 [$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP;
581 $CAN_CM $SP* $CM* $OP;
582 $CANT_CM $SP* $CM* $OP;
583 $AL_FOLLOW? $CM+ $SP $SP* $CM* $OP; # by LB 10, behaves like $AL_FOLLOW? $AL $SP* $CM* $OP
585 $AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP;
586 $AL_FOLLOW_CM $CM+ $SP+ $CM* $OP;
593 $NS $SP* $CM* ($CL | $CP);
598 # LB 18 break after spaces
599 # Nothing explicit needed here.
605 $QU $CM* $CAN_CM; # . x QU
609 $CAN_CM $CM* $QU; # QU x .
613 # LB 20 Break before and after CB.
614 # nothing needed here.
617 # LB 20.09 added rule for Finnish tailoring
618 $AL ($HY | $HH) / $SP;
621 ($BA | $HH | $HY | $NS) $CM* [$LB20NonBreaks-$CM]; # . x (BA | HY | NS)
623 [$LB20NonBreaks-$CM] $CM* $BB; # BB x .
627 [^$CB] $CM* ($HY | $BA | $HH) $CM* $HL;
633 $IN $CM* ($ALPlus | $HL);
635 $IN $CM* ($ID | $EB | $EM);
640 $PO $CM* ($ID | $EB | $EM);
641 $NU $CM* ($ALPlus | $HL);
642 ($ALPlus | $HL) $CM* $NU;
645 ($ID | $EB | $EM) $CM* $PR;
646 ($ALPlus | $HL) $CM* $PR;
647 ($ALPlus | $HL) $CM* $PO;
648 $CM* ($PR | $PO) $CM* ($ALPlus | $HL);
649 $CM* ($PR | $PO) $CM+ / [$BK $CR $LF $NL $ZW $SP {eof}];
652 ($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?;
655 ($H3 | $H2 | $JV | $JL) $CM* $JL;
656 ($JT | $JV) $CM* ($H2 | $JV);
657 $JT $CM* ($H3 | $JT);
660 $IN $CM* ($H3 | $H2 | $JT | $JV | $JL);
661 $PO $CM* ($H3 | $H2 | $JT | $JV | $JL);
662 ($H3 | $H2 | $JT | $JV | $JL) $CM* $PR;
665 ($ALPlus | $HL) $CM* ($ALPlus | $HL);
669 ($ALPlus | $HL) $CM* $IS;
672 $OP $CM* ($ALPlus | $HL | $NU);
673 ($ALPlus | $HL | $NU) $CM* $CP;
676 # Pairs of Regional Indicators.
677 # The following two rules are nearly identical. The first matches only sequences with an odd number of adjacent RIs,
678 # the second with an even number. Stripping away the cruft they look like
679 # [^RI] RI / (RI RI)+ ^RI;
680 # [^RI] RI RI / (RI RI)+ ^RI;
682 [{bof} $NS $HY $BA $HH $QU $CL $CP $EX $IS $SY $WJ $GL $ZW $SP $BK $CR $LF $NL $ZWJ] $CM* $RI / ($CM* $RI $CM* $RI)+ $CM* [{eof}[^$RI $CM]];
683 [{bof} $NS $HY $BA $HH $QU $CL $CP $EX $IS $SY $WJ $GL $ZW $SP $BK $CR $LF $NL $ZWJ] $CM* $RI $CM* $RI / ($CM* $RI $CM* $RI)+ $CM* [{eof}[^$RI $CM]];
685 # In general, adjacent RIs stay together. The hard-break rules, above, overide this, forcing in the boundaries between pairs.
688 # WJ, GL, QU, etc. are classes with rules like "WJ x " which includes "WJ x RI".
689 $RI $CM* ([$WJ $GL $QU $BB] | (($HY | $BA | $HH)$CM* $HL));
692 # LB 30b Do not break between an Emoji Base and an Emoji Modifier
696 ## -------------------------------------------------
701 ^$CM+ [^$CM $BK $CR $LF $NL $ZW $SP];
711 $SP+ $CM* ($CL | $CP);
717 $CM* ($HY | $BA | $HH) $CM* $HL;
720 ($CM* ($IS | $SY))+ $CM* $NU;
721 ($CL | $CP) $CM* ($NU | $IS | $SY);
726 # For dictionary-based break
727 $dictionary $dictionary;
729 ## -------------------------------------------------
733 # Skip forward over all character classes that are involved in
734 # rules containing patterns with possibly more than one char
737 # It might be slightly more efficient to have specific rules
738 # instead of one generic one, but only if we could
739 # turn off rule chaining. We don't want to move more
742 ^[$CM $OP $QU $CL $CP $B2 $PR $HY $BA $HH $SP $RI $ZWJ $dictionary]+ [^$CM $OP $QU $CL $CP $B2 $PR $HY $BA $HH $RI $ZWJ $dictionary];
743 $dictionary $dictionary;