• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 for Unicode 14.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
25type = line;
26locale = en@lb=normal;
27
28AI = [:LineBreak =  Ambiguous:];
29AL = [:LineBreak =  Alphabetic:];
30BA = [:LineBreak =  Break_After:];
31HH = [\u2010];      # \u2010 is HYPHEN, default line break is BA.
32BB = [:LineBreak =  Break_Before:];
33BK = [:LineBreak =  Mandatory_Break:];
34B2 = [:LineBreak =  Break_Both:];
35CB = [:LineBreak =  Contingent_Break:];
36CJ = [:LineBreak =  Conditional_Japanese_Starter:];
37CL = [:LineBreak =  Close_Punctuation:];
38CMS = [:LineBreak =  Combining_Mark:];
39CP = [:LineBreak =  Close_Parenthesis:];
40CR = [:LineBreak =  Carriage_Return:];
41EB = [:LineBreak =  EB:];
42EM = [:LineBreak =  EM:];
43EX = [:LineBreak =  Exclamation:];
44GL = [:LineBreak =  Glue:];
45HL = [:LineBreak =  Hebrew_Letter:];
46HY = [:LineBreak =  Hyphen:];
47H2 = [:LineBreak =  H2:];
48H3 = [:LineBreak =  H3:];
49ID = [[:LineBreak =  Ideographic:] CJ];  # CSS Normal tailoring: CJ resolves to ID
50IN = [:LineBreak =  Inseperable:];
51IS = [:LineBreak =  Infix_Numeric:];
52JL = [:LineBreak =  JL:];
53JV = [:LineBreak =  JV:];
54JT = [:LineBreak =  JT:];
55LF = [:LineBreak =  Line_Feed:];
56NL = [:LineBreak =  Next_Line:];
57NS = [:LineBreak =  Nonstarter:];
58NU = [:LineBreak =  Numeric:];
59OP = [:LineBreak =  Open_Punctuation:];
60PO = [:LineBreak =  Postfix_Numeric:];
61PR = [:LineBreak =  Prefix_Numeric:];
62QU = [:LineBreak =  Quotation:];
63RI = [:LineBreak =  Regional_Indicator:];
64SA = [:LineBreak =  Complex_Context:];
65SG = [:LineBreak =  Surrogate:];
66SP = [:LineBreak =  Space:];
67SY = [:LineBreak =  Break_Symbols:];
68WJ = [:LineBreak =  Word_Joiner:];
69XX = [:LineBreak =  Unknown:];
70ZW = [:LineBreak =  ZWSpace:];
71ZWJ = [: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
77OP30 = [OP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
78CP30 = [CP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
79
80# The redundant-looking inner brackets are required for the current parser in the test code.
81ExtPictUnassigned = [[\p{Extended_Pictographic}]&[\p{Cn}]];
82
83# LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
84AL = [AL AI SG XX ];
85dictionary = SA;
86
87# By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
88#         list it in the numerous rules that use CM.
89CM = [CMS ZWJ];
90
91LB4:        BK ÷;
92LB5:        CR LF;
93LB5.1:      CR ÷;
94LB5.2:      LF ÷;
95LB5.3:      NL ÷;
96
97LB6:        . (BK | CR | LF | NL);
98LB6.1:      [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
99
100# LB8   break after ZW SP*.
101# Precedes LB7 because both rules will match the sequences like ZW SP,
102# and LB8 must take precedence.
103
104LB8:        ZW SP* ÷ [^ZW SP BK CR LF NL];
105
106# Numbers. Equivalent to Tailoring example 8 from UAX 14.
107# Moved up, before LB14, because it can match longer sequences which must take precedence.
108LB25:        ((PR | PO)CM*)? ((OP | HY)CM*)? (IS CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PO))?;
109
110# Rules LB14 - LB17.
111# Moved up, before LB7, because they can match a longer sequence that would also match LB7.
112# For example, the sequence "OP CM SP AL" matches LB14
113# while the prefix of it, "OP CM SP" matches LB7.1
114LB14:        OP CM* SP* .;
115
116# LB 14a Break before an IS that begins a number and follows a space.
117LB14a:       SP ÷ IS CM* NU;
118
119# LB14b       × IS
120LB14b.1:     [^SP] CM* IS;
121LB14b.2:     SP IS;
122
123LB15:        QU CM* SP* OP;
124LB16:        (CL | CP)CM* SP* NS;
125LB17:        B2 CM* SP* B2;
126
127
128# LB7 Do not break before spaces or zero width space.
129
130LB7.1:      [^ZW SP] CM* [SP ZW];
131LB7.2:      [ZW SP] [SP ZW];
132
133# LB8a
134#      ZWJ x
135#      Don't match a CM on the right - let other rules pick up CM sequences, where
136#      the ZWJ behaves as just another generic CM.
137LB8a:       ZWJ [^CM];
138
139
140# LB9:  X CM -> X
141# LB10: Unattached CM -> AL
142
143#LB11:       × WJ;
144#            WJ ×
145
146LB11.1:      [^SP] CM* WJ;
147LB11.2:      SP WJ;
148LB11.3:      WJ CM* [^CM];
149
150LB12:        GL CM* [^CM];
151
152LB12a:       [^SP BA HY] CM* GL;
153
154# LB 13 Do not break before ‘]’ or ‘!’ or ‘/’, even after spaces.
155LB13.1: [^SP] CM* [CL CP EX SY];
156LB13.2: SP [CL CP EX SY];
157
158# LB 14-17 are moved above LB 7.
159
160LB18:        SP ÷;
161
162LB19:        . CM* QU;
163LB19.1:      QU CM* [^CM];
164
165# LB 20   Break before and after CB.
166#         Interaction with LB8a:  ZWJ x . is tricky because CM includes ZWJ.
167#                                 ZWJ acts like a CM to the left, combining with CB.
168#                                 ZWJ acts independently to the right, no break after by LB8a.
169LB20.1:      . CM* ZWJ CB;
170LB20.2:      . CM* ÷ CB;
171
172LB20.3:      CB CM* ZWJ [^CM];
173LB20.4:      CB CM* ÷;
174
175# LB 20.09    Don't break between Hyphens and Letters when there is a break preceding the hyphen.
176LB20.09:     ^(HY | HH) CM* AL;
177
178# Note: Rule 21a must come before 21 to prevent 21.1 from matching HL BA, then
179#       not picking up the continuing match after the BA from 21a.
180LB21a:       HL CM* (HY | BA) CM* [^CM CB];
181
182LB21.1:      . CM* [BA HY NS];
183LB21.2:      BB CM* [^CM CB];
184
185LB21b:       SY CM* HL;
186
187LB22:        . CM* IN;
188
189LB23.1:      (AL | HL | CM) CM* NU;
190LB23.2:      NU CM* (AL | HL);
191
192LB23a.1:     PR CM* (ID | EB | EM);
193LB23a.2:     (ID | EB | EM) CM* PO;
194
195LB24.2:      (PR | PO) CM* (AL | HL);
196LB24.3:      (AL | HL | CM) CM* (PR | PO);
197
198
199LB26.1:      JL CM* (JL | JV | H2 | H3);
200LB26.2:      (JV | H2) CM* (JV | JT);
201LB26.3:      (JT | H3) CM* JT;
202
203LB27.1:      (JL | JV | JT | H2 | H3) CM* PO;
204LB27.2:      PR CM* (JL | JV | JT | H2 | H3);
205
206# LB28 Do not break between Alphabetics.
207#      Unattached (leading) CM treated as AL.
208LB28:        (AL | HL | CM)CM* (AL | HL);
209
210LB29:        IS CM* (AL | HL);
211
212# LB30  is adjusted for unattached leading CM being treated as AL.
213LB30.1:      (AL | CM | HL | NU) CM* OP30;
214LB30.2:      CP30 CM* (AL | HL | NU);
215
216# LB30a  keep pairs of RI together.
217LB30a.1:     RI CM* RI         ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS IN CM];
218LB30a.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];
219LB30a.3:     RI CM* RI CM* [BK CR LF NL SP ZW WJ GL CL CP EX IS SY QU BA HY NS IN ZWJ]?;
220
221# LB30b Do not break between Emoji Base (or potential emoji) and Emoji Modifier
222LB30b.1:       EB CM* EM;
223LB30b.2:       ExtPictUnassigned CM* EM;
224
225# LB31 Break Everywhere Else.
226#      Include combining marks
227LB31.1:        . CM* ZWJ [^CM];
228LB31.2:        . CM* ÷;
229