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.
8 # Reference Line Break rules for intltest rbbi/RBBIMonkeyTest.
9 # Rules derived from Unicode Standard Annex #14 Revision 40 for Unicode 11.0
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.
19 AI = [:LineBreak = Ambiguous:];
20 AL = [:LineBreak = Alphabetic:];
21 BA = [:LineBreak = Break_After:];
22 HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
23 BB = [:LineBreak = Break_Before:];
24 BK = [:LineBreak = Mandatory_Break:];
25 B2 = [:LineBreak = Break_Both:];
26 CB = [:LineBreak = Contingent_Break:];
27 CJ = [:LineBreak = Conditional_Japanese_Starter:];
28 CL = [:LineBreak = Close_Punctuation:];
29 CMS = [:LineBreak = Combining_Mark:];
30 CP = [:LineBreak = Close_Parenthesis:];
31 CR = [:LineBreak = Carriage_Return:];
32 EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
33 EM = [:LineBreak = EM:];
34 EX = [:LineBreak = Exclamation:];
35 GL = [:LineBreak = Glue:];
36 HL = [:LineBreak = Hebrew_Letter:];
37 HY = [:LineBreak = Hyphen:];
38 H2 = [:LineBreak = H2:];
39 H3 = [:LineBreak = H3:];
40 ID = [:LineBreak = Ideographic:];
41 IN = [:LineBreak = Inseperable:];
42 IS = [:LineBreak = Infix_Numeric:];
43 JL = [:LineBreak = JL:];
44 JV = [:LineBreak = JV:];
45 JT = [:LineBreak = JT:];
46 LF = [:LineBreak = Line_Feed:];
47 NL = [:LineBreak = Next_Line:];
48 NS = [[:LineBreak = Nonstarter:] CJ]; # CSS Strict tailoring: CJ resolves to NS.
49 NU = [:LineBreak = Numeric:];
50 OP = [:LineBreak = Open_Punctuation:];
51 PO = [:LineBreak = Postfix_Numeric:];
52 PR = [:LineBreak = Prefix_Numeric:];
53 QU = [:LineBreak = Quotation:];
54 RI = [:LineBreak = Regional_Indicator:];
55 SA = [:LineBreak = Complex_Context:];
56 SG = [:LineBreak = Surrogate:];
57 SP = [:LineBreak = Space:];
58 SY = [:LineBreak = Break_Symbols:];
59 WJ = [:LineBreak = Word_Joiner:];
60 XX = [:LineBreak = Unknown:];
61 ZW = [:LineBreak = ZWSpace:];
62 ZWJ = [:LineBreak = ZWJ:];
64 # LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
68 # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
69 # list it in the numerous rules that use CM.
78 LB6: . (BK | CR | LF | NL);
79 LB6.1: [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
81 # LB8 break after ZW SP*.
82 # Precedes LB7 because both rules will match the sequences like ZW SP,
83 # and LB8 must take precedence.
85 LB8: ZW SP* ÷ [^ZW SP BK CR LF NL];
87 # Numbers. Equivalent to Tailoring example 8 from UAX 14.
88 # Moved up, before LB14, because it can match longer sequences which must take precedence.
89 LB25: ((PR | PO)CM*)? ((OP | HY)CM*)? (IS CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PO))?;
92 # Moved up, before LB7, because they can match a longer sequence that would also match LB7.
93 # For example, the sequence "OP CM SP AL" matches LB14
94 # while the prefix of it, "OP CM SP" matches LB7.1
97 # LB 14a Break before an IS that begins a number and follows a space.
98 LB14a: SP ÷ IS CM* NU;
101 LB14b.1: [^SP] CM* IS;
105 LB16: (CL | CP)CM* SP* NS;
109 # LB7 Do not break before spaces or zero width space.
111 LB7.1: [^ZW SP] CM* [SP ZW];
112 LB7.2: [ZW SP] [SP ZW];
116 # Don't match a CM on the right - let other rules pick up CM sequences, where
117 # the ZWJ behaves as just another generic CM.
122 # LB10: Unattached CM -> AL
127 LB11.1: [^SP] CM* WJ;
129 LB11.3: WJ CM* [^CM];
133 LB12a: [^SP BA HY] CM* GL;
135 # LB 13 Do not break before ‘]’ or ‘!’ or ‘/’, even after spaces.
136 LB13.1: [^SP] CM* [CL CP EX SY];
137 LB13.2: SP [CL CP EX SY];
139 # LB 14-17 are moved above LB 7.
144 LB19.1: QU CM* [^CM];
146 # LB 20 Break before and after CB.
147 # Interaction with LB8a: ZWJ x . is tricky because CM includes ZWJ.
148 # ZWJ acts like a CM to the left, combining with CB.
149 # ZWJ acts independently to the right, no break after by LB8a.
150 LB20.1: . CM* ZWJ CB;
153 LB20.3: CB CM* ZWJ [^CM];
156 # LB 20.09 Don't break between Hyphens and Letters when there is a break preceding the hyphen.
157 LB20.09: ^(HY | HH) CM* AL;
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];
163 LB21.1: . CM* [BA HY NS];
164 LB21.2: BB CM* [^CM CB];
168 LB22.1: (AL | HL | CM) CM* IN; # The CM is from LB10, treat an unattached CM as AL.
170 LB22.3: (ID | EB | EM) CM* IN;
174 LB23.1: (AL | HL | CM) CM* NU;
175 LB23.2: NU CM* (AL | HL);
177 LB23a.1: PR CM* (ID | EB | EM);
178 LB23a.2: (ID | EB | EM) CM* PO;
180 LB24.2: (PR | PO) CM* (AL | HL);
181 LB24.3: (AL | HL | CM) CM* (PR | PO);
184 LB26.1: JL CM* (JL | JV | H2 | H3);
185 LB26.2: (JV | H2) CM* (JV | JT);
186 LB26.3: (JT | H3) CM* JT;
188 LB27.1: (JL | JV | JT | H2 | H3) CM* IN;
189 LB27.2: (JL | JV | JT | H2 | H3) CM* PO;
190 LB27.3: PR CM* (JL | JV | JT | H2 | H3);
192 # LB28 Do not break between Alphabetics.
193 # Unattached (leading) CM treated as AL.
194 LB28: (AL | HL | CM)CM* (AL | HL);
196 LB29: IS CM* (AL | HL);
198 # LB30 is adjusted for unattached leading CM being treated as AL.
199 LB30.1: (AL | CM | HL | NU) CM* OP;
200 LB30.2: CP CM* (AL | HL | NU);
202 # LB30a keep pairs of RI together.
203 LB30a.1: RI CM* RI ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS CM];
204 LB30a.2: RI CM* RI CM* CMS ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS CM];
205 LB30a.3: RI CM* RI CM* [BK CR LF NL SP ZW WJ GL CL CP EX IS SY QU BA HY NS ZWJ]?;
207 # LB30b Do not break between Emoji Base and Emoji Modifier
210 # LB31 Break Everywhere Else.
211 # Include combining marks
212 LB31.1: . CM* ZWJ [^CM];