]> git.saurik.com Git - apple/icu.git/blob - icuSources/data/brkitr/rules/line_loose_fi.txt
ICU-62107.0.1.tar.gz
[apple/icu.git] / icuSources / data / brkitr / rules / line_loose_fi.txt
1 # Copyright (C) 2016 and later: Unicode, Inc. and others.
2 # License & terms of use: http://www.unicode.org/copyright.html
3 # Copyright (c) 2002-2016 International Business Machines Corporation and
4 # others. All Rights Reserved.
5 #
6 # file: line_loose_fi.txt
7 #
8 # Line Breaking Rules
9 # Implement default line breaking as defined by
10 # Unicode Standard Annex #14 Revision 40 for Unicode 11.0
11 # http://www.unicode.org/reports/tr14/
12 # tailored as noted in 3rd paragraph below.
13 #
14 # TODO: Rule LB 8 remains as it was in Unicode 5.2
15 # This is only because of a limitation of ICU break engine implementation,
16 # not because the older behavior is desirable.
17 #
18 # This tailors the line break behavior both for Finnish and to correpond to CSS
19 # line-break=loose (BCP47 -u-lb-loose) as defined for languages other than
20 # Chinese & Japanese.
21 # It sets characters of class CJ to behave like ID.
22 # In addition, it allows breaks before 3005, 303B, 309D, 309E, 30FD, 30FE (all NS).
23 #
24 # Character Classes defined by TR 14.
25 #
26
27 !!chain;
28 !!quoted_literals_only;
29
30 $AI = [:LineBreak = Ambiguous:];
31 $AL = [:LineBreak = Alphabetic:];
32 $BA = [:LineBreak = Break_After:];
33 $HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
34 $BB = [:LineBreak = Break_Before:];
35 $BK = [:LineBreak = Mandatory_Break:];
36 $B2 = [:LineBreak = Break_Both:];
37 $CB = [:LineBreak = Contingent_Break:];
38 $CJ = [:LineBreak = Conditional_Japanese_Starter:];
39 $CL = [:LineBreak = Close_Punctuation:];
40 # $CM = [:LineBreak = Combining_Mark:];
41 $CP = [:LineBreak = Close_Parenthesis:];
42 $CR = [:LineBreak = Carriage_Return:];
43 $EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
44 $EM = [:LineBreak = EM:];
45 $EX = [:LineBreak = Exclamation:];
46 $GL = [:LineBreak = Glue:];
47 $HL = [:LineBreak = Hebrew_Letter:];
48 $HY = [:LineBreak = Hyphen:];
49 $H2 = [:LineBreak = H2:];
50 $H3 = [:LineBreak = H3:];
51 # CSS Loose tailoring: CJ resolves to ID
52 $ID = [[:LineBreak = Ideographic:] $CJ];
53 $IN = [:LineBreak = Inseperable:];
54 $IS = [:LineBreak = Infix_Numeric:];
55 $JL = [:LineBreak = JL:];
56 $JV = [:LineBreak = JV:];
57 $JT = [:LineBreak = JT:];
58 $LF = [:LineBreak = Line_Feed:];
59 $NL = [:LineBreak = Next_Line:];
60 $NSX = [\u3005 \u303B \u309D \u309E \u30FD \u30FE];
61 $NS = [[:LineBreak = Nonstarter:] - $NSX];
62 $NU = [:LineBreak = Numeric:];
63 $OP = [:LineBreak = Open_Punctuation:];
64 $PO = [:LineBreak = Postfix_Numeric:];
65 $PR = [:LineBreak = Prefix_Numeric:];
66 $QU = [:LineBreak = Quotation:];
67 $RI = [:LineBreak = Regional_Indicator:];
68 $SA = [:LineBreak = Complex_Context:];
69 $SG = [:LineBreak = Surrogate:];
70 $SP = [:LineBreak = Space:];
71 $SY = [:LineBreak = Break_Symbols:];
72 $WJ = [:LineBreak = Word_Joiner:];
73 $XX = [:LineBreak = Unknown:];
74 $ZW = [:LineBreak = ZWSpace:];
75 $ZWJ = [:LineBreak = ZWJ:];
76
77 # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
78 # list it in the numerous rules that use CM.
79 # By LB1, SA characters with general categor of Mn or Mc also resolve to CM.
80
81 $CM = [[:LineBreak = Combining_Mark:] $ZWJ [$SA & [[:Mn:][:Mc:]]]];
82
83 # Dictionary character set, for triggering language-based break engines. Currently
84 # limited to LineBreak=Complex_Context (SA).
85
86 $dictionary = [$SA];
87
88 #
89 # Rule LB1. By default, treat AI (characters with ambiguous east Asian width),
90 # SA (Dictionary chars, excluding Mn and Mc)
91 # SG (Unpaired Surrogates)
92 # XX (Unknown, unassigned)
93 # as $AL (Alphabetic)
94 #
95 $ALPlus = [$AL $AI $SG $XX [$SA-[[:Mn:][:Mc:]]]];
96
97
98 ## -------------------------------------------------
99
100 #
101 # CAN_CM is the set of characters that may combine with CM combining chars.
102 # Note that Linebreak UAX 14's concept of a combining char and the rules
103 # for what they can combine with are _very_ different from the rest of Unicode.
104 #
105 # Note that $CM itself is left out of this set. If CM is needed as a base
106 # it must be listed separately in the rule.
107 #
108 $CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM]; # Bases that can take CMs
109 $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM]; # Bases that can't take CMs
110
111 #
112 # AL_FOLLOW set of chars that can unconditionally follow an AL
113 # Needed in rules where stand-alone $CM s are treated as AL.
114 #
115 $AL_FOLLOW = [$BK $CR $LF $NL $ZW $SP $CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HH $HY $NS $IN $NU $PR $PO $ALPlus];
116
117
118 #
119 # Rule LB 4, 5 Mandatory (Hard) breaks.
120 #
121 $LB4Breaks = [$BK $CR $LF $NL];
122 $LB4NonBreaks = [^$BK $CR $LF $NL $CM];
123 $CR $LF {100};
124
125 #
126 # LB 6 Do not break before hard line breaks.
127 #
128 $LB4NonBreaks? $LB4Breaks {100}; # LB 5 do not break before hard breaks.
129 $CAN_CM $CM* $LB4Breaks {100};
130 ^$CM+ $LB4Breaks {100};
131
132 # LB 7 x SP
133 # x ZW
134 $LB4NonBreaks [$SP $ZW];
135 $CAN_CM $CM* [$SP $ZW];
136 ^$CM+ [$SP $ZW];
137
138 #
139 # LB 8 Break after zero width space
140 # TODO: ZW SP* <break>
141 # An engine change is required to write the reverse rule for this.
142 # For now, leave the Unicode 5.2 rule, ZW <break>
143 #
144 $LB8Breaks = [$LB4Breaks $ZW];
145 $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
146
147 # LB 8a ZWJ x Do not break Emoji ZWJ sequences.
148 #
149 $ZWJ [^$CM];
150
151 # LB 9 Combining marks. X $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL
152 # $CM not covered by the above needs to behave like $AL
153 # See definition of $CAN_CM.
154
155 $CAN_CM $CM+; # Stick together any combining sequences that don't match other rules.
156 ^$CM+;
157
158 #
159 # LB 11 Do not break before or after WORD JOINER & related characters.
160 #
161 $CAN_CM $CM* $WJ;
162 $LB8NonBreaks $WJ;
163 ^$CM+ $WJ;
164
165 $WJ $CM* .;
166
167 #
168 # LB 12 Do not break after NBSP and related characters.
169 # GL x
170 #
171 $GL $CM* .;
172
173 #
174 # LB 12a Do not break before NBSP and related characters ...
175 # [^SP BA HY] x GL
176 #
177 [[$LB8NonBreaks] - [$SP $BA $HH $HY]] $CM* $GL;
178 ^$CM+ $GL;
179
180
181
182 #
183 # LB 13 Don't break before ']' or '!' or ';' or '/', even after spaces.
184 #
185 $LB8NonBreaks $CL;
186 $CAN_CM $CM* $CL;
187 ^$CM+ $CL; # by rule 10, stand-alone CM behaves as AL
188
189 $LB8NonBreaks $CP;
190 $CAN_CM $CM* $CP;
191 ^$CM+ $CP; # by rule 10, stand-alone CM behaves as AL
192
193 $LB8NonBreaks $EX;
194 $CAN_CM $CM* $EX;
195 ^$CM+ $EX; # by rule 10, stand-alone CM behaves as AL
196
197 $LB8NonBreaks $IS;
198 $CAN_CM $CM* $IS;
199 ^$CM+ $IS; # by rule 10, stand-alone CM behaves as AL
200
201 $LB8NonBreaks $SY;
202 $CAN_CM $CM* $SY;
203 ^$CM+ $SY; # by rule 10, stand-alone CM behaves as AL
204
205
206 #
207 # LB 14 Do not break after OP, even after spaces
208 #
209 $OP $CM* $SP* .;
210
211 $OP $CM* $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL
212 # by rule 8, CM following a SP is stand-alone.
213
214 # LB 15
215 $QU $CM* $SP* $OP;
216
217 # LB 16
218 # Do not break between closing punctuation and $NS, even with intervening spaces
219 # But DO allow a break between closing punctuation and $NSX, don't include it here
220 ($CL | $CP) $CM* $SP* $NS;
221
222 # LB 17
223 $B2 $CM* $SP* $B2;
224
225 #
226 # LB 18 Break after spaces.
227 #
228 $LB18NonBreaks = [$LB8NonBreaks - [$SP]];
229 $LB18Breaks = [$LB8Breaks $SP];
230
231
232 # LB 19
233 # x QU
234 $LB18NonBreaks $CM* $QU;
235 ^$CM+ $QU;
236
237 # QU x
238 $QU $CM* .;
239
240
241 # LB 20
242 # <break> $CB
243 # $CB <break>
244
245 $LB20NonBreaks = [$LB18NonBreaks - $CB];
246
247 # LB 20.09 added rule for Finnish tailoring
248 # LB 21 x (BA | HY | NS)
249 # BB x
250 #
251 # DO allow breaks here before NSX, so don't include it
252 $LB20NonBreaks $CM* ($BA | $HH | $HY | $NS) $CM* / $AL;
253 $LB20NonBreaks $CM* ($BA | $HH | $HY | $NS);
254 ($HY | $HH) $AL;
255 ^$CM+ ($BA | $HY | $HH | $NS);
256
257 $BB $CM* [^$CB]; # $BB x
258 $BB $CM* $LB20NonBreaks;
259
260 # LB 21a Don't break after Hebrew + Hyphen
261 # HL (HY | BA) x
262 #
263 $HL $CM* ($HY | $BA | $HH) $CM* [^$CB]?;
264
265 # LB 21b (forward) Don't break between SY and HL
266 # (break between HL and SY already disallowed by LB 13 above)
267 $SY $CM* $HL;
268
269 # LB 22
270 ($ALPlus | $HL) $CM* $IN;
271 ^$CM+ $IN; # by rule 10, any otherwise unattached CM behaves as AL
272 $EX $CM* $IN;
273 ($ID | $EB | $EM) $CM* $IN;
274 # $IN $CM* $IN; # delete this rule for CSS loose
275 $NU $CM* $IN;
276
277
278 # $LB 23
279 #
280 ($ALPlus | $HL) $CM* $NU;
281 ^$CM+ $NU; # Rule 10, any otherwise unattached CM behaves as AL
282 $NU $CM* ($ALPlus | $HL);
283
284 # LB 23a
285 #
286 $PR $CM* ($ID | $EB | $EM);
287 ($ID | $EB | $EM) $CM* $PO;
288
289
290 #
291 # LB 24
292 #
293 ($PR | $PO) $CM* ($ALPlus | $HL);
294 ($ALPlus | $HL) $CM* ($PR | $PO);
295 ^$CM+ ($PR | $PO); # Rule 10, any otherwise unattached CM behaves as AL
296
297 #
298 # LB 25 Numbers.
299 #
300 (($PR | $PO) $CM*)? (($OP | $HY) $CM*)? $NU ($CM* ($NU | $SY | $IS))*
301 ($CM* ($CL | $CP))? ($CM* ($PR | $PO))?;
302
303 # LB 26 Do not break a Korean syllable
304 #
305 $JL $CM* ($JL | $JV | $H2 | $H3);
306 ($JV | $H2) $CM* ($JV | $JT);
307 ($JT | $H3) $CM* $JT;
308
309 # LB 27 Treat korean Syllable Block the same as ID (don't break it)
310 ($JL | $JV | $JT | $H2 | $H3) $CM* $IN;
311 ($JL | $JV | $JT | $H2 | $H3) $CM* $PO;
312 $PR $CM* ($JL | $JV | $JT | $H2 | $H3);
313
314
315 # LB 28 Do not break between alphabetics
316 #
317 ($ALPlus | $HL) $CM* ($ALPlus | $HL);
318 ^$CM+ ($ALPlus | $HL); # The $CM+ is from rule 10, an unattached CM is treated as AL
319
320 # LB 29
321 $IS $CM* ($ALPlus | $HL);
322
323 # LB 30
324 ($ALPlus | $HL | $NU) $CM* $OP;
325 ^$CM+ $OP; # The $CM+ is from rule 10, an unattached CM is treated as AL.
326 $CP $CM* ($ALPlus | $HL | $NU);
327
328 # LB 30a Do not break between regional indicators. Break after pairs of them.
329 # Tricky interaction with LB8a: ZWJ x . together with ZWJ acting like a CM.
330 $RI $CM* $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM]];
331 $RI $CM* $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM]];
332 $RI $CM* $RI $CM* [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $ZWJ {eof}];
333 # note: the preceding rule includes {eof} rather than having the last [set] term qualified with '?'
334 # because of the chain-out behavior difference. The rule must chain out only from the [set characters],
335 # not from the preceding $RI or $CM, which it would be able to do if the set were optional.
336
337 # LB 30b Do not break between an Emoji Base and an Emoji Modifier
338 $EB $CM* $EM;
339
340 # LB 31 Break everywhere else.
341 # Match a single code point if no other rule applies.
342 .;