]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/testdata/break_rules/line_normal.txt
ICU-62141.0.1.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 40 for Unicode 11.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 Revision 34 for Unicode 8.0
17 # http://www.unicode.org/reports/tr14/
18 # tailored as noted in 2nd paragraph below.
19 #
20 # TODO: Rule LB 8 remains as it was in Unicode 5.2
21 # This is only because of a limitation of ICU break engine implementation,
22 # not because the older behavior is desirable.
23 #
24 # This tailors the line break behavior to correspond to CSS
25 # line-break=normal (BCP47 -u-lb-normal) as defined for languages other than
26 # Chinese & Japanese.
27 # It sets characters of class CJ to behave like ID.
28
29
30 type = line;
31 locale = en@lb=normal;
32
33 AI = [:LineBreak = Ambiguous:];
34 AL = [:LineBreak = Alphabetic:];
35 BA = [:LineBreak = Break_After:];
36 BB = [:LineBreak = Break_Before:];
37 BK = [:LineBreak = Mandatory_Break:];
38 B2 = [:LineBreak = Break_Both:];
39 CB = [:LineBreak = Contingent_Break:];
40 CJ = [:LineBreak = Conditional_Japanese_Starter:];
41 CL = [:LineBreak = Close_Punctuation:];
42 CM = [:LineBreak = Combining_Mark:];
43 CP = [:LineBreak = Close_Parenthesis:];
44 CR = [:LineBreak = Carriage_Return:];
45 EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
46 EM = [:LineBreak = EM:];
47 EX = [:LineBreak = Exclamation:];
48 GL = [:LineBreak = Glue:];
49 HL = [:LineBreak = Hebrew_Letter:];
50 HY = [:LineBreak = Hyphen:];
51 H2 = [:LineBreak = H2:];
52 H3 = [:LineBreak = H3:];
53 ID = [[:LineBreak = Ideographic:] CJ]; # CSS Normal tailoring: CJ resolves to ID
54 IN = [:LineBreak = Inseperable:];
55 IS = [:LineBreak = Infix_Numeric:];
56 JL = [:LineBreak = JL:];
57 JV = [:LineBreak = JV:];
58 JT = [:LineBreak = JT:];
59 LF = [:LineBreak = Line_Feed:];
60 NL = [:LineBreak = Next_Line:];
61 NS = [:LineBreak = Nonstarter:];
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 # LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
78 AL = [AL AI SG XX ];
79 dictionary = SA;
80
81 # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
82 # list it in the numerous rules that use CM.
83 CM = [CM ZWJ];
84
85 LB4: BK ÷;
86 LB5: CR LF;
87 LB5.1: CR ÷;
88 LB5.2: LF ÷;
89 LB5.3: NL ÷;
90
91 LB6: . (BK | CR | LF | NL);
92 LB6.1: [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
93
94 # Rules LB14 - LB17.
95 # Moved before LB7, because they can match a longer sequence that would also match LB7,
96 # for example, the sequence "OP CM SP AL" matches LB14 while the prefix of it,
97 # "while only the prefix "OP CM SP" matches LB7.1
98 LB14: OP CM* SP* .;
99 LB15: QU CM* SP* OP;
100 LB16: (CL | CP)CM* SP* NS;
101 LB17: B2 CM* SP* B2;
102
103 LB7.1: [^ZW SP] CM* [SP ZW];
104 LB7.2: [ZW SP] [SP ZW];
105
106 # LB8, ICU differs from UAX-14,
107 # ICU: ZW ÷;
108 # UAX 14: ZW SP* ÷;
109 LB8: ZW ÷;
110
111 # LB8a
112 # ZWJ x
113 # Don't match a CM on the right - let other rules pick up CM sequences, where
114 # the ZWJ behaves as just another generic CM.
115 LB8a: ZWJ [^CM];
116
117
118 # LB9: X CM -> X
119 # LB10: Unattached CM -> AL
120
121 #LB11: × WJ;
122 # WJ ×
123
124 LB11.1: [^SP] CM* WJ;
125 LB11.2: SP WJ;
126 LB11.3: WJ CM* [^CM];
127
128 LB12: GL CM* [^CM];
129
130 LB12a: [^SP BA HY] CM* GL;
131
132 # LB 13 ICU Tailoring, matches tailoring exmaple 8 from UAX 14.
133 #
134 # LB13.1 [^SP] CM* [CL CP EX IS SY] # original UAX 14 rule.
135 # LB13.2 SP CM* [CL CP EX IS SY]
136
137 LB13.1: [^NU SP] CM* [CL CP IS SY];
138 LB13.2: [^SP] CM* EX;
139 LB13.2: SP [CL CP EX IS SY];
140
141
142 # LB 14-17 are moved above LB 7.
143
144 LB18: SP ÷;
145
146 LB19: . CM* QU;
147 LB19.1: QU CM* [^CM];
148
149 # LB 20 Break before and after CB.
150 # Interaction with LB8a: ZWJ x . is tricky because CM includes ZWJ.
151 # ZWJ acts like a CM to the left, combining with CB.
152 # ZWJ acts independently to the right, no break after by LB8a.
153 LB20.1: . CM* ZWJ CB;
154 LB20.2: . CM* ÷ CB;
155
156 LB20.3: CB CM* ZWJ [^CM];
157 LB20.4: CB CM* ÷;
158
159 # Note: Rule 21a must come before 21 to prevent 21.1 from matching HL BA, then
160 # not picking up the continuing match after the BA from 21a.
161 LB21a: HL CM* (HY | BA) CM* [^CM CB];
162
163 LB21.1: . CM* [BA HY NS];
164 LB21.2: BB CM* [^CM CB];
165
166 LB21b: SY CM* HL;
167
168 LB22.1: (AL | HL | CM) CM* IN; # The CM is from LB10, treat an unattached CM as AL.
169 LB22.2: EX CM* IN;
170 LB22.3: (ID | EB | EM) CM* IN;
171 LB22.4: IN CM* IN;
172 LB22.5: NU CM* IN;
173
174 LB23.1: (AL | HL | CM) CM* NU;
175 LB23.2: NU CM* (AL | HL);
176
177 LB23a.1: PR CM* (ID | EB | EM);
178 LB23a.2: (ID | EB | EM) CM* PO;
179
180 LB24.2: (PR | PO) CM* (AL | HL);
181 LB24.3: (AL | HL | CM) CM* (PR | PO);
182
183 # Numbers. Equivalent to Tailoring example 8 from UAx 14.
184 LB25: ((PR | PO)CM*)? ((OP | HY)CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PO))?;
185
186 LB26.1: JL CM* (JL | JV | H2 | H3);
187 LB26.2: (JV | H2) CM* (JV | JT);
188 LB26.3: (JT | H3) CM* JT;
189
190 LB27.1: (JL | JV | JT | H2 | H3) CM* IN;
191 LB27.2: (JL | JV | JT | H2 | H3) CM* PO;
192 LB27.3: PR CM* (JL | JV | JT | H2 | H3);
193
194 # LB28 Do not break between Alphabetics.
195 # Unattached (leading) CM treated as AL.
196 LB28: (AL | HL | CM)CM* (AL | HL);
197
198 LB29: IS CM* (AL | HL);
199
200 # LB30 is adjusted for unattached leading CM being treated as AL.
201 LB30.1: (AL | CM | HL | NU) CM* OP;
202 LB30.2: CP CM* (AL | HL | NU);
203
204 # LB30a keep pairs of RI together.
205 LB30a.1: RI CM* RI ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS CM];
206 LB30a.2: RI CM* RI CM* [CM-ZWJ] ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS CM];
207 LB30a.3: RI CM* RI CM* [BK CR LF NL SP ZW WJ GL CL CP EX IS SY QU BA HY NS ZWJ]?;
208
209 # LB30b Do not break between Emoji Base and Emoji Modifier
210 LB30b: EB CM* EM;
211
212 # LB31 Break Everywhere Else.
213 # Include combining marks
214 LB31.1: . CM* ZWJ [^CM];
215 LB31.2: . CM* ÷;