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