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