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