]>
Commit | Line | Data |
---|---|---|
2ca993e8 | 1 | # Copyright (c) 2002-2016 International Business Machines Corporation and |
08b89b0a A |
2 | # others. All Rights Reserved. |
3 | # | |
4 | # file: line_normal_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 | # | |
2ca993e8 | 20 | # This tailors the line break behavior for Finnish, and to correspond to CSS |
08b89b0a A |
21 | # line-break=normal (BCP47 -u-lb-normal) as defined for languages other than |
22 | # Chinese & Japanese. | |
23 | # It sets characters of class CJ to behave like ID. | |
24 | ||
25 | # | |
26 | # Character Classes defined by TR 14. | |
27 | # | |
28 | ||
29 | !!chain; | |
08b89b0a A |
30 | |
31 | !!lookAheadHardBreak; | |
32 | # | |
33 | # !!lookAheadHardBreak Described here because it is (as yet) undocumented elsewhere | |
34 | # and only used for the line break rules. | |
35 | # | |
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). | |
39 | # | |
40 | # The problem occurs in the reverse rules. | |
41 | # | |
42 | # Consider a sequence like, with correct breaks as shown | |
43 | # LF ID CM AL AL | |
44 | # ^ ^ ^ | |
45 | # Then consider the sequence without the initial ID (ideographic) | |
46 | # LF CM AL AL | |
47 | # ^ ^ | |
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 | |
50 | # alphas. | |
51 | # | |
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) | |
56 | # | |
57 | # If the CM is unattached, we need to force a break. | |
58 | # | |
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. | |
63 | # | |
64 | # See rule LB 19 for an example. | |
65 | # | |
66 | ||
2ca993e8 A |
67 | # Temporary definitions of Emoji Base and Emoji Modifiers, until properties are available. |
68 | ||
a62d09fc | 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]; |
2ca993e8 A |
70 | $EM = [\U0001F3FB-\U0001F3FF]; |
71 | ||
72 | $AI = [[:LineBreak = Ambiguous:] - [\u2640\u2642]]; | |
a62d09fc | 73 | $AL = [[:LineBreak = Alphabetic:] - [$EM\u2695\u2696\u2764]]; |
2ca993e8 | 74 | $BA = [[:LineBreak = Break_After:]-[\u2010]]; |
08b89b0a A |
75 | $HH = [\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:]; | |
2ca993e8 | 82 | $CM = [[:LineBreak = Combining_Mark:] \u200d]; |
08b89b0a A |
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:]; | |
a62d09fc | 91 | $ID = [[:LineBreak = Ideographic:] $CJ [\u2640\u2642\u2695\u2696\u2764] - $EB]; |
08b89b0a A |
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:]; | |
2ca993e8 | 113 | $ZWJ = [\u200d]; |
08b89b0a A |
114 | |
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. | |
119 | ||
120 | $dictionary = [:LineBreak = Complex_Context:]; | |
121 | ||
122 | # | |
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) | |
128 | # | |
129 | $ALPlus = [$AL $AI $SA $SG $XX]; | |
130 | ||
131 | # | |
132 | # Combining Marks. X $CM* behaves as if it were X. Rule LB6. | |
133 | # | |
134 | $ALcm = $ALPlus $CM*; | |
135 | $BAcm = $BA $CM*; | |
136 | $HHcm = $HH $CM*; | |
137 | $BBcm = $BB $CM*; | |
138 | $B2cm = $B2 $CM*; | |
139 | $CLcm = $CL $CM*; | |
140 | $CPcm = $CP $CM*; | |
141 | $EXcm = $EX $CM*; | |
142 | $GLcm = $GL $CM*; | |
143 | $HLcm = $HL $CM*; | |
144 | $HYcm = $HY $CM*; | |
145 | $H2cm = $H2 $CM*; | |
146 | $H3cm = $H3 $CM*; | |
08b89b0a A |
147 | $INcm = $IN $CM*; |
148 | $IScm = $IS $CM*; | |
149 | $JLcm = $JL $CM*; | |
150 | $JVcm = $JV $CM*; | |
151 | $JTcm = $JT $CM*; | |
152 | $NScm = $NS $CM*; | |
153 | $NUcm = $NU $CM*; | |
154 | $OPcm = $OP $CM*; | |
155 | $POcm = $PO $CM*; | |
156 | $PRcm = $PR $CM*; | |
157 | $QUcm = $QU $CM*; | |
158 | $RIcm = $RI $CM*; | |
159 | $SYcm = $SY $CM*; | |
160 | $WJcm = $WJ $CM*; | |
161 | ||
162 | ## ------------------------------------------------- | |
163 | ||
164 | !!forward; | |
165 | ||
166 | # | |
167 | # Each class of character can stand by itself as an unbroken token, with trailing combining stuff | |
168 | # | |
169 | $ALPlus $CM+; | |
170 | $BA $CM+; | |
171 | $HH $CM+; | |
172 | $BB $CM+; | |
173 | $B2 $CM+; | |
174 | $CL $CM+; | |
175 | $CP $CM+; | |
2ca993e8 A |
176 | $EB $CM+; |
177 | $EM $CM+; | |
08b89b0a A |
178 | $EX $CM+; |
179 | $GL $CM+; | |
180 | $HL $CM+; | |
181 | $HY $CM+; | |
182 | $H2 $CM+; | |
183 | $H3 $CM+; | |
184 | $ID $CM+; | |
185 | $IN $CM+; | |
186 | $IS $CM+; | |
187 | $JL $CM+; | |
188 | $JV $CM+; | |
189 | $JT $CM+; | |
190 | $NS $CM+; | |
191 | $NU $CM+; | |
192 | $OP $CM+; | |
193 | $PO $CM+; | |
194 | $PR $CM+; | |
195 | $QU $CM+; | |
196 | $RI $CM+; | |
197 | $SY $CM+; | |
198 | $WJ $CM+; | |
199 | ||
200 | # | |
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. | |
204 | # | |
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. | |
207 | # | |
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 | |
210 | ||
211 | # | |
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. | |
216 | # | |
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]; | |
220 | ||
221 | ||
222 | # | |
223 | # Rule LB 4, 5 Mandatory (Hard) breaks. | |
224 | # | |
225 | $LB4Breaks = [$BK $CR $LF $NL]; | |
2ca993e8 | 226 | $LB4NonBreaks = [^$BK $CR $LF $NL $CM]; |
08b89b0a A |
227 | $CR $LF {100}; |
228 | ||
229 | # | |
230 | # LB 6 Do not break before hard line breaks. | |
231 | # | |
232 | $LB4NonBreaks? $LB4Breaks {100}; # LB 5 do not break before hard breaks. | |
233 | $CAN_CM $CM* $LB4Breaks {100}; | |
2ca993e8 | 234 | ^$CM+ $LB4Breaks {100}; |
08b89b0a A |
235 | |
236 | # LB 7 x SP | |
237 | # x ZW | |
238 | $LB4NonBreaks [$SP $ZW]; | |
239 | $CAN_CM $CM* [$SP $ZW]; | |
2ca993e8 | 240 | ^$CM+ [$SP $ZW]; |
08b89b0a A |
241 | |
242 | # | |
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> | |
247 | # | |
248 | $LB8Breaks = [$LB4Breaks $ZW]; | |
249 | $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]]; | |
250 | ||
2ca993e8 A |
251 | # LB 8a ZWJ x ID Emoji proposal. |
252 | # | |
253 | $ZWJ ($ID | $EB | $EM); | |
08b89b0a | 254 | |
2ca993e8 A |
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 | |
08b89b0a A |
257 | # See definition of $CAN_CM. |
258 | ||
259 | $CAN_CM $CM+; # Stick together any combining sequences that don't match other rules. | |
2ca993e8 | 260 | ^$CM+; |
08b89b0a A |
261 | |
262 | # | |
263 | # LB 11 Do not break before or after WORD JOINER & related characters. | |
264 | # | |
265 | $CAN_CM $CM* $WJcm; | |
266 | $LB8NonBreaks $WJcm; | |
2ca993e8 | 267 | ^$CM+ $WJcm; |
08b89b0a A |
268 | |
269 | $WJcm $CANT_CM; | |
270 | $WJcm $CAN_CM $CM*; | |
271 | ||
272 | # | |
273 | # LB 12 Do not break after NBSP and related characters. | |
274 | # GL x | |
275 | # | |
276 | $GLcm $CAN_CM $CM*; | |
277 | $GLcm $CANT_CM; | |
2ca993e8 | 278 | |
08b89b0a A |
279 | # |
280 | # LB 12a Do not break before NBSP and related characters ... | |
281 | # [^SP BA HY] x GL | |
282 | # | |
283 | [[$LB8NonBreaks] - [$SP $BA $HH $HY]] $CM* $GLcm; | |
2ca993e8 | 284 | ^$CM+ $GLcm; |
08b89b0a A |
285 | |
286 | ||
287 | ||
288 | # | |
289 | # LB 13 Don't break before ']' or '!' or ';' or '/', even after spaces. | |
290 | # | |
291 | $LB8NonBreaks $CL; | |
292 | $CAN_CM $CM* $CL; | |
2ca993e8 | 293 | ^$CM+ $CL; # by rule 10, stand-alone CM behaves as AL |
08b89b0a A |
294 | |
295 | $LB8NonBreaks $CP; | |
296 | $CAN_CM $CM* $CP; | |
2ca993e8 | 297 | ^$CM+ $CP; # by rule 10, stand-alone CM behaves as AL |
08b89b0a A |
298 | |
299 | $LB8NonBreaks $EX; | |
300 | $CAN_CM $CM* $EX; | |
2ca993e8 | 301 | ^$CM+ $EX; # by rule 10, stand-alone CM behaves as AL |
08b89b0a A |
302 | |
303 | $LB8NonBreaks $IS; | |
304 | $CAN_CM $CM* $IS; | |
2ca993e8 | 305 | ^$CM+ $IS; # by rule 10, stand-alone CM behaves as AL |
08b89b0a A |
306 | |
307 | $LB8NonBreaks $SY; | |
308 | $CAN_CM $CM* $SY; | |
2ca993e8 | 309 | ^$CM+ $SY; # by rule 10, stand-alone CM behaves as AL |
08b89b0a A |
310 | |
311 | ||
312 | # | |
313 | # LB 14 Do not break after OP, even after spaces | |
314 | # | |
315 | $OPcm $SP* $CAN_CM $CM*; | |
316 | $OPcm $SP* $CANT_CM; | |
317 | ||
318 | $OPcm $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL | |
319 | ||
320 | # LB 15 | |
321 | $QUcm $SP* $OPcm; | |
322 | ||
323 | # LB 16 | |
324 | ($CLcm | $CPcm) $SP* $NScm; | |
325 | ||
326 | # LB 17 | |
327 | $B2cm $SP* $B2cm; | |
328 | ||
329 | # | |
330 | # LB 18 Break after spaces. | |
331 | # | |
332 | $LB18NonBreaks = [$LB8NonBreaks - [$SP]]; | |
333 | $LB18Breaks = [$LB8Breaks $SP]; | |
334 | ||
335 | ||
336 | # LB 19 | |
337 | # x QU | |
338 | $LB18NonBreaks $CM* $QUcm; | |
2ca993e8 | 339 | ^$CM+ $QUcm; |
08b89b0a A |
340 | |
341 | # QU x | |
342 | $QUcm .?; | |
08b89b0a A |
343 | |
344 | ||
345 | # LB 20 | |
346 | # <break> $CB | |
347 | # $CB <break> | |
348 | ||
349 | $LB20NonBreaks = [$LB18NonBreaks - $CB]; | |
350 | ||
351 | # LB 20.09 added rule for Finnish tailoring | |
352 | # LB 21 x (BA | HY | NS) | |
353 | # BB x | |
354 | # | |
2ca993e8 A |
355 | $LB20NonBreaks $CM* ($BAcm | $HHcm | $HYcm | $NScm) / $AL; |
356 | $LB20NonBreaks $CM* ($BAcm | $HHcm | $HYcm | $NScm); | |
08b89b0a | 357 | ($HY | $HH) $AL; |
2ca993e8 | 358 | ^$CM+ ($BAcm | $HHcm | $HYcm | $NScm); |
08b89b0a A |
359 | |
360 | $BBcm [^$CB]; # $BB x | |
361 | $BBcm $LB20NonBreaks $CM*; | |
362 | ||
363 | # LB 21a Don't break after Hebrew + Hyphen | |
364 | # HL (HY | BA) x | |
2ca993e8 | 365 | # |
08b89b0a A |
366 | $HLcm ($HYcm | $BAcm | $HHcm) [^$CB]?; |
367 | ||
368 | # LB 21b (forward) Don't break between SY and HL | |
369 | # (break between HL and SY already disallowed by LB 13 above) | |
370 | $SYcm $HLcm; | |
371 | ||
372 | # LB 22 | |
373 | ($ALcm | $HLcm) $INcm; | |
2ca993e8 A |
374 | ^$CM+ $INcm; # by rule 10, any otherwise unattached CM behaves as AL |
375 | $EXcm $INcm; | |
376 | ($ID | $EB | $EM) $CM* $INcm; | |
08b89b0a A |
377 | $INcm $INcm; |
378 | $NUcm $INcm; | |
379 | ||
380 | ||
381 | # $LB 23 | |
2ca993e8 | 382 | ($ID | $EB | $EM) $CM* $POcm; |
08b89b0a A |
383 | $ALcm $NUcm; # includes $LB19 |
384 | $HLcm $NUcm; | |
2ca993e8 | 385 | ^$CM+ $NUcm; # Rule 10, any otherwise unattached CM behaves as AL |
08b89b0a A |
386 | $NUcm $ALcm; |
387 | $NUcm $HLcm; | |
388 | ||
389 | # | |
390 | # LB 24 | |
391 | # | |
2ca993e8 | 392 | $PRcm ($ID | $EB | $EM); |
08b89b0a A |
393 | $PRcm ($ALcm | $HLcm); |
394 | $POcm ($ALcm | $HLcm); | |
2ca993e8 A |
395 | ($ALcm | $HLcm) ($PRcm | $POcm); |
396 | ^$CM+ ($PRcm | $POcm); # Rule 10, any otherwise unattached CM behaves as AL | |
08b89b0a A |
397 | |
398 | # | |
399 | # LB 25 Numbers. | |
400 | # | |
401 | ($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?; | |
402 | ||
403 | # LB 26 Do not break a Korean syllable | |
404 | # | |
405 | $JLcm ($JLcm | $JVcm | $H2cm | $H3cm); | |
406 | ($JVcm | $H2cm) ($JVcm | $JTcm); | |
407 | ($JTcm | $H3cm) $JTcm; | |
408 | ||
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); | |
413 | ||
414 | ||
415 | # LB 28 Do not break between alphabetics | |
416 | # | |
417 | ($ALcm | $HLcm) ($ALcm | $HLcm); | |
2ca993e8 | 418 | ^$CM+ ($ALcm | $HLcm); # The $CM+ is from rule 10, an unattached CM is treated as AL |
08b89b0a A |
419 | |
420 | # LB 29 | |
421 | $IScm ($ALcm | $HLcm); | |
422 | ||
423 | # LB 30 | |
424 | ($ALcm | $HLcm | $NUcm) $OPcm; | |
2ca993e8 | 425 | ^$CM+ $OPcm; # The $CM+ is from rule 10, an unattached CM is treated as AL. |
08b89b0a A |
426 | $CPcm ($ALcm | $HLcm | $NUcm); |
427 | ||
2ca993e8 A |
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}]; | |
08b89b0a | 433 | |
2ca993e8 A |
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); | |
436 | ||
437 | # LB 30b Do not break between an Emoji Base and an Emoji Modifier | |
438 | $EB $CM* $EM; | |
08b89b0a A |
439 | |
440 | # | |
441 | # Reverse Rules. | |
442 | # | |
443 | ## ------------------------------------------------- | |
444 | ||
445 | !!reverse; | |
446 | ||
2ca993e8 A |
447 | ^$CM+ $ALPlus; |
448 | ^$CM+ $BA; | |
449 | ^$CM+ $HH; | |
450 | ^$CM+ $BB; | |
451 | ^$CM+ $B2; | |
452 | ^$CM+ $CL; | |
453 | ^$CM+ $CP; | |
454 | ^$CM+ $EB; | |
455 | ^$CM+ $EM; | |
456 | ^$CM+ $EX; | |
457 | ^$CM+ $GL; | |
458 | ^$CM+ $HL; | |
459 | ^$CM+ $HY; | |
460 | ^$CM+ $H2; | |
461 | ^$CM+ $H3; | |
462 | ^$CM+ $ID; | |
463 | ^$CM+ $IN; | |
464 | ^$CM+ $IS; | |
465 | ^$CM+ $JL; | |
466 | ^$CM+ $JV; | |
467 | ^$CM+ $JT; | |
468 | ^$CM+ $NS; | |
469 | ^$CM+ $NU; | |
470 | ^$CM+ $OP; | |
471 | ^$CM+ $PO; | |
472 | ^$CM+ $PR; | |
473 | ^$CM+ $QU; | |
474 | ^$CM+ $RI; | |
475 | ^$CM+ $SY; | |
476 | ^$CM+ $WJ; | |
477 | ^$CM+; | |
08b89b0a A |
478 | |
479 | ||
480 | # | |
481 | # Sequences of the form (shown forwards) | |
482 | # [CANT_CM] <break> [CM] [whatever] | |
483 | # The CM needs to behave as an AL | |
484 | # | |
485 | $AL_FOLLOW $CM+ / ( | |
486 | [$BK $CR $LF $NL $ZW {eof}] | | |
487 | $SP+ $CM+ $SP | | |
488 | $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}])); # if LB 14 will match, need to surpress this break. | |
2ca993e8 | 489 | # LB14 says OP SP* x . |
08b89b0a A |
490 | # becomes OP SP* x AL |
491 | # becomes OP SP* x CM+ AL_FOLLOW | |
492 | # | |
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. | |
2ca993e8 | 496 | |
08b89b0a A |
497 | # |
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. | |
502 | # | |
503 | ||
2ca993e8 A |
504 | # Apple early addition, remove this, superseded by LB24 |
505 | # [$PR ] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}]; | |
08b89b0a A |
506 | |
507 | ||
508 | ||
2ca993e8 | 509 | # LB 4, 5, 6 |
08b89b0a A |
510 | |
511 | $LB4Breaks [$LB4NonBreaks-$CM]; | |
512 | $LB4Breaks $CM+ $CAN_CM; | |
513 | $LF $CR; | |
514 | ||
515 | ||
516 | # LB 7 x SP | |
517 | # x ZW | |
518 | [$SP $ZW] [$LB4NonBreaks-$CM]; | |
519 | [$SP $ZW] $CM+ $CAN_CM; | |
520 | ||
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. | |
524 | # / $SP* $ZW | |
525 | ||
2ca993e8 A |
526 | # LB 8a ZWJ x ID Unicode Emoji proposal L2/16-011R3 |
527 | # The ZWJ will look like a CM to whatever precedes it. | |
528 | # | |
529 | ($ID | $EB | $EM) $ZWJ $CM* $CAN_CM?; | |
530 | ||
08b89b0a A |
531 | |
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. | |
2ca993e8 | 536 | ^$CM+ $CAN_CM; |
08b89b0a A |
537 | |
538 | ||
539 | # LB 11 | |
2ca993e8 A |
540 | # |
541 | $WJ $CM* $CAN_CM; | |
542 | $WJ [$LB8NonBreaks-$CM]; | |
08b89b0a A |
543 | |
544 | $CANT_CM $CM* $WJ; | |
2ca993e8 | 545 | $CAN_CM $CM* $WJ; |
08b89b0a A |
546 | |
547 | # LB 12a | |
548 | # [^SP BA HY] x GL | |
549 | # | |
2ca993e8 | 550 | $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $HH $HY]]; |
08b89b0a A |
551 | |
552 | # LB 12 | |
553 | # GL x | |
554 | # | |
555 | $CANT_CM $CM* $GL; | |
2ca993e8 | 556 | $CAN_CM $CM* $GL; |
08b89b0a A |
557 | |
558 | ||
559 | # LB 13 | |
560 | $CL $CM+ $CAN_CM; | |
561 | $CP $CM+ $CAN_CM; | |
562 | $EX $CM+ $CAN_CM; | |
563 | $IS $CM+ $CAN_CM; | |
564 | $SY $CM+ $CAN_CM; | |
565 | ||
566 | $CL [$LB8NonBreaks-$CM]; | |
567 | $CP [$LB8NonBreaks-$CM]; | |
568 | $EX [$LB8NonBreaks-$CM]; | |
569 | $IS [$LB8NonBreaks-$CM]; | |
570 | $SY [$LB8NonBreaks-$CM]; | |
571 | ||
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. | |
2ca993e8 | 577 | [$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP; |
08b89b0a A |
578 | |
579 | # LB 14 OP SP* x | |
580 | # | |
2ca993e8 | 581 | $CAN_CM $SP* $CM* $OP; |
08b89b0a A |
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 | |
08b89b0a | 584 | |
2ca993e8 A |
585 | $AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP; |
586 | $AL_FOLLOW_CM $CM+ $SP+ $CM* $OP; | |
08b89b0a A |
587 | |
588 | ||
589 | # LB 15 | |
2ca993e8 | 590 | $OP $SP* $CM* $QU; |
08b89b0a A |
591 | |
592 | # LB 16 | |
2ca993e8 | 593 | $NS $SP* $CM* ($CL | $CP); |
08b89b0a A |
594 | |
595 | # LB 17 | |
2ca993e8 | 596 | $B2 $SP* $CM* $B2; |
08b89b0a A |
597 | |
598 | # LB 18 break after spaces | |
599 | # Nothing explicit needed here. | |
600 | ||
601 | ||
602 | # | |
603 | # LB 19 | |
604 | # | |
2ca993e8 A |
605 | $QU $CM* $CAN_CM; # . x QU |
606 | $QU $LB18NonBreaks; | |
08b89b0a A |
607 | |
608 | ||
2ca993e8 | 609 | $CAN_CM $CM* $QU; # QU x . |
08b89b0a | 610 | $CANT_CM $CM* $QU; |
2ca993e8 | 611 | |
08b89b0a A |
612 | # |
613 | # LB 20 Break before and after CB. | |
614 | # nothing needed here. | |
615 | # | |
616 | ||
617 | # LB 20.09 added rule for Finnish tailoring | |
618 | $AL ($HY | $HH) / $SP; | |
619 | ||
620 | # LB 21 | |
2ca993e8 | 621 | ($BA | $HH | $HY | $NS) $CM* [$LB20NonBreaks-$CM]; # . x (BA | HY | NS) |
08b89b0a | 622 | |
2ca993e8 A |
623 | [$LB20NonBreaks-$CM] $CM* $BB; # BB x . |
624 | [^$CB] $CM* $BB; # | |
08b89b0a A |
625 | |
626 | # LB21a | |
627 | [^$CB] $CM* ($HY | $BA | $HH) $CM* $HL; | |
628 | ||
629 | # LB21b (reverse) | |
2ca993e8 | 630 | $HL $CM* $SY; |
08b89b0a A |
631 | |
632 | # LB 22 | |
2ca993e8 A |
633 | $IN $CM* ($ALPlus | $HL); |
634 | $IN $CM* $EX; | |
635 | $IN $CM* ($ID | $EB | $EM); | |
636 | $IN $CM* $IN; | |
637 | $IN $CM* $NU; | |
08b89b0a A |
638 | |
639 | # LB 23 | |
2ca993e8 A |
640 | $PO $CM* ($ID | $EB | $EM); |
641 | $NU $CM* ($ALPlus | $HL); | |
642 | ($ALPlus | $HL) $CM* $NU; | |
08b89b0a A |
643 | |
644 | # LB 24 | |
2ca993e8 A |
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}]; | |
08b89b0a A |
650 | |
651 | # LB 25 | |
652 | ($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?; | |
653 | ||
654 | # LB 26 | |
2ca993e8 A |
655 | ($H3 | $H2 | $JV | $JL) $CM* $JL; |
656 | ($JT | $JV) $CM* ($H2 | $JV); | |
657 | $JT $CM* ($H3 | $JT); | |
08b89b0a A |
658 | |
659 | # LB 27 | |
2ca993e8 A |
660 | $IN $CM* ($H3 | $H2 | $JT | $JV | $JL); |
661 | $PO $CM* ($H3 | $H2 | $JT | $JV | $JL); | |
662 | ($H3 | $H2 | $JT | $JV | $JL) $CM* $PR; | |
08b89b0a A |
663 | |
664 | # LB 28 | |
2ca993e8 | 665 | ($ALPlus | $HL) $CM* ($ALPlus | $HL); |
08b89b0a A |
666 | |
667 | ||
668 | # LB 29 | |
2ca993e8 | 669 | ($ALPlus | $HL) $CM* $IS; |
08b89b0a A |
670 | |
671 | # LB 30 | |
2ca993e8 A |
672 | $OP $CM* ($ALPlus | $HL | $NU); |
673 | ($ALPlus | $HL | $NU) $CM* $CP; | |
08b89b0a A |
674 | |
675 | # LB 30a | |
2ca993e8 A |
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; | |
681 | # | |
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]]; | |
684 | ||
685 | # In general, adjacent RIs stay together. The hard-break rules, above, overide this, forcing in the boundaries between pairs. | |
686 | $RI $CM* $RI; | |
687 | ||
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)); | |
690 | ||
691 | ||
692 | # LB 30b Do not break between an Emoji Base and an Emoji Modifier | |
693 | $EM $CM* $EB; | |
08b89b0a | 694 | |
08b89b0a A |
695 | |
696 | ## ------------------------------------------------- | |
697 | ||
698 | !!safe_reverse; | |
699 | ||
700 | # LB 9 | |
2ca993e8 A |
701 | ^$CM+ [^$CM $BK $CR $LF $NL $ZW $SP]; |
702 | ^$CM+ $SP / .; | |
08b89b0a A |
703 | |
704 | # LB 14 | |
705 | $SP+ $CM* $OP; | |
706 | ||
707 | # LB 15 | |
708 | $SP+ $CM* $QU; | |
709 | ||
710 | # LB 16 | |
711 | $SP+ $CM* ($CL | $CP); | |
712 | ||
713 | # LB 17 | |
714 | $SP+ $CM* $B2; | |
715 | ||
716 | # LB 21 | |
717 | $CM* ($HY | $BA | $HH) $CM* $HL; | |
718 | ||
719 | # LB 25 | |
720 | ($CM* ($IS | $SY))+ $CM* $NU; | |
721 | ($CL | $CP) $CM* ($NU | $IS | $SY); | |
722 | ||
2ca993e8 A |
723 | # LB 30 |
724 | ($CM* $RI)+; | |
725 | ||
08b89b0a A |
726 | # For dictionary-based break |
727 | $dictionary $dictionary; | |
728 | ||
729 | ## ------------------------------------------------- | |
730 | ||
731 | !!safe_forward; | |
732 | ||
733 | # Skip forward over all character classes that are involved in | |
734 | # rules containing patterns with possibly more than one char | |
735 | # of context. | |
736 | # | |
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 | |
740 | # than necessary. | |
741 | # | |
2ca993e8 | 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]; |
08b89b0a A |
743 | $dictionary $dictionary; |
744 |