]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/testdata/break_rules/line_normal.txt
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / testdata / break_rules / line_normal.txt
1 #
2 # Copyright (C) 2016 and later: Unicode, Inc. and others.
3 # License & terms of use: http://www.unicode.org/copyright.html
4 # Copyright (c) 2016, International Business Machines Corporation and others. All Rights Reserved.
5 #
6 # file: line_normal.txt
7 #
8 # Reference Line Break rules for intltest rbbi/RBBIMonkeyTest.
9 # Rules derived from Unicode Standard Annex #14 Revision 44 for Unicode 13.0
10 #
11 # Note: Rule syntax and the monkey test itself are still a work in progress.
12 # They are expected to change with review and the addition of support for rule tailoring.
13 #
14 # Line Breaking Rules
15 # Implement default line breaking as defined by
16 # Unicode Standard Annex #14
17 # http://www.unicode.org/reports/tr14/, tailored as noted below.
18 #
19 # This tailors the line break behavior to correspond to CSS
20 # line-break=normal (BCP47 -u-lb-normal) as defined for languages other than
21 # Chinese & Japanese.
22 # It sets characters of class CJ to behave like ID.
23
24
25 type = line;
26 locale = en@lb=normal;
27
28 AI = [:LineBreak = Ambiguous:];
29 AL = [:LineBreak = Alphabetic:];
30 BA = [:LineBreak = Break_After:];
31 HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
32 BB = [:LineBreak = Break_Before:];
33 BK = [:LineBreak = Mandatory_Break:];
34 B2 = [:LineBreak = Break_Both:];
35 CB = [:LineBreak = Contingent_Break:];
36 CJ = [:LineBreak = Conditional_Japanese_Starter:];
37 CL = [:LineBreak = Close_Punctuation:];
38 CMS = [:LineBreak = Combining_Mark:];
39 CP = [:LineBreak = Close_Parenthesis:];
40 CR = [:LineBreak = Carriage_Return:];
41 EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
42 EM = [:LineBreak = EM:];
43 EX = [:LineBreak = Exclamation:];
44 GL = [:LineBreak = Glue:];
45 HL = [:LineBreak = Hebrew_Letter:];
46 HY = [:LineBreak = Hyphen:];
47 H2 = [:LineBreak = H2:];
48 H3 = [:LineBreak = H3:];
49 ID = [[:LineBreak = Ideographic:] CJ]; # CSS Normal tailoring: CJ resolves to ID
50 IN = [:LineBreak = Inseperable:];
51 IS = [:LineBreak = Infix_Numeric:];
52 JL = [:LineBreak = JL:];
53 JV = [:LineBreak = JV:];
54 JT = [:LineBreak = JT:];
55 LF = [:LineBreak = Line_Feed:];
56 NL = [:LineBreak = Next_Line:];
57 NS = [:LineBreak = Nonstarter:];
58 NU = [:LineBreak = Numeric:];
59 OP = [:LineBreak = Open_Punctuation:];
60 PO = [:LineBreak = Postfix_Numeric:];
61 PR = [:LineBreak = Prefix_Numeric:];
62 QU = [:LineBreak = Quotation:];
63 RI = [:LineBreak = Regional_Indicator:];
64 SA = [:LineBreak = Complex_Context:];
65 SG = [:LineBreak = Surrogate:];
66 SP = [:LineBreak = Space:];
67 SY = [:LineBreak = Break_Symbols:];
68 WJ = [:LineBreak = Word_Joiner:];
69 XX = [:LineBreak = Unknown:];
70 ZW = [:LineBreak = ZWSpace:];
71 ZWJ = [:LineBreak = ZWJ:];
72
73 # OP30 and CP30 are variants of OP and CP that appear in rule LB30 from UAX 14.
74 # Limitations of this monkey test rule parser require that these definitions be pulled out
75 # rather than appearing in-line in LB 30.
76
77 OP30 = [OP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
78 CP30 = [CP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
79
80 # LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
81 AL = [AL AI SG XX ];
82 dictionary = SA;
83
84 # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
85 # list it in the numerous rules that use CM.
86 CM = [CMS ZWJ];
87
88 LB4: BK ÷;
89 LB5: CR LF;
90 LB5.1: CR ÷;
91 LB5.2: LF ÷;
92 LB5.3: NL ÷;
93
94 LB6: . (BK | CR | LF | NL);
95 LB6.1: [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
96
97 # LB8 break after ZW SP*.
98 # Precedes LB7 because both rules will match the sequences like ZW SP,
99 # and LB8 must take precedence.
100
101 LB8: ZW SP* ÷ [^ZW SP BK CR LF NL];
102
103 # Numbers. Equivalent to Tailoring example 8 from UAX 14.
104 # Moved up, before LB14, because it can match longer sequences which must take precedence.
105 LB25: ((PR | PO)CM*)? ((OP | HY)CM*)? (IS CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PO))?;
106
107 # Rules LB14 - LB17.
108 # Moved up, before LB7, because they can match a longer sequence that would also match LB7.
109 # For example, the sequence "OP CM SP AL" matches LB14
110 # while the prefix of it, "OP CM SP" matches LB7.1
111 LB14: OP CM* SP* .;
112
113 # LB 14a Break before an IS that begins a number and follows a space.
114 LB14a: SP ÷ IS CM* NU;
115
116 # LB14b × IS
117 LB14b.1: [^SP] CM* IS;
118 LB14b.2: SP IS;
119
120 LB15: QU CM* SP* OP;
121 LB16: (CL | CP)CM* SP* NS;
122 LB17: B2 CM* SP* B2;
123
124
125 # LB7 Do not break before spaces or zero width space.
126
127 LB7.1: [^ZW SP] CM* [SP ZW];
128 LB7.2: [ZW SP] [SP ZW];
129
130 # LB8a
131 # ZWJ x
132 # Don't match a CM on the right - let other rules pick up CM sequences, where
133 # the ZWJ behaves as just another generic CM.
134 LB8a: ZWJ [^CM];
135
136
137 # LB9: X CM -> X
138 # LB10: Unattached CM -> AL
139
140 #LB11: × WJ;
141 # WJ ×
142
143 LB11.1: [^SP] CM* WJ;
144 LB11.2: SP WJ;
145 LB11.3: WJ CM* [^CM];
146
147 LB12: GL CM* [^CM];
148
149 LB12a: [^SP BA HY] CM* GL;
150
151 # LB 13 Do not break before ‘]’ or ‘!’ or ‘/’, even after spaces.
152 LB13.1: [^SP] CM* [CL CP EX SY];
153 LB13.2: SP [CL CP EX SY];
154
155 # LB 14-17 are moved above LB 7.
156
157 LB18: SP ÷;
158
159 LB19: . CM* QU;
160 LB19.1: QU CM* [^CM];
161
162 # LB 20 Break before and after CB.
163 # Interaction with LB8a: ZWJ x . is tricky because CM includes ZWJ.
164 # ZWJ acts like a CM to the left, combining with CB.
165 # ZWJ acts independently to the right, no break after by LB8a.
166 LB20.1: . CM* ZWJ CB;
167 LB20.2: . CM* ÷ CB;
168
169 LB20.3: CB CM* ZWJ [^CM];
170 LB20.4: CB CM* ÷;
171
172 # LB 20.09 Don't break between Hyphens and Letters when there is a break preceding the hyphen.
173 LB20.09: ^(HY | HH) CM* AL;
174
175 # Note: Rule 21a must come before 21 to prevent 21.1 from matching HL BA, then
176 # not picking up the continuing match after the BA from 21a.
177 LB21a: HL CM* (HY | BA) CM* [^CM CB];
178
179 LB21.1: . CM* [BA HY NS];
180 LB21.2: BB CM* [^CM CB];
181
182 LB21b: SY CM* HL;
183
184 LB22: . CM* IN;
185
186 LB23.1: (AL | HL | CM) CM* NU;
187 LB23.2: NU CM* (AL | HL);
188
189 LB23a.1: PR CM* (ID | EB | EM);
190 LB23a.2: (ID | EB | EM) CM* PO;
191
192 LB24.2: (PR | PO) CM* (AL | HL);
193 LB24.3: (AL | HL | CM) CM* (PR | PO);
194
195
196 LB26.1: JL CM* (JL | JV | H2 | H3);
197 LB26.2: (JV | H2) CM* (JV | JT);
198 LB26.3: (JT | H3) CM* JT;
199
200 LB27.1: (JL | JV | JT | H2 | H3) CM* IN;
201 LB27.2: (JL | JV | JT | H2 | H3) CM* PO;
202 LB27.3: PR CM* (JL | JV | JT | H2 | H3);
203
204 # LB28 Do not break between Alphabetics.
205 # Unattached (leading) CM treated as AL.
206 LB28: (AL | HL | CM)CM* (AL | HL);
207
208 LB29: IS CM* (AL | HL);
209
210 # LB30 is adjusted for unattached leading CM being treated as AL.
211 LB30.1: (AL | CM | HL | NU) CM* OP30;
212 LB30.2: CP30 CM* (AL | HL | NU);
213
214 # LB30a keep pairs of RI together.
215 LB30a.1: RI CM* RI ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS IN CM];
216 LB30a.2: RI CM* RI CM* CMS ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS IN CM];
217 LB30a.3: RI CM* RI CM* [BK CR LF NL SP ZW WJ GL CL CP EX IS SY QU BA HY NS IN ZWJ]?;
218
219 # LB30b Do not break between Emoji Base and Emoji Modifier
220 LB30b: EB CM* EM;
221
222 # LB31 Break Everywhere Else.
223 # Include combining marks
224 LB31.1: . CM* ZWJ [^CM];
225 LB31.2: . CM* ÷;