• 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_loose.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#         This tailors the line break behavior to correspond to CSS
15#         line-break=loose (BCP47 -u-lb-loose) as defined for languages other than
16#         Chinese & Japanese.
17#         It sets characters of class CJ to behave like ID.
18#         In addition, it allows breaks:
19#         * before iteration marks 3005, 303B, 309D, 309E, 30FD, 30FE (all NS)
20#         * between characters of LineBreak class IN
21
22type = line;
23locale = en@lb=loose;
24
25
26AI = [:LineBreak =  Ambiguous:];
27AL = [:LineBreak =  Alphabetic:];
28BA = [:LineBreak =  Break_After:];
29HH = [\u2010];      # \u2010 is HYPHEN, default line break is BA.
30BB = [:LineBreak =  Break_Before:];
31BK = [:LineBreak =  Mandatory_Break:];
32B2 = [:LineBreak =  Break_Both:];
33CB = [:LineBreak =  Contingent_Break:];
34CJ = [:LineBreak =  Conditional_Japanese_Starter:];
35CL = [:LineBreak =  Close_Punctuation:];
36CMS = [:LineBreak =  Combining_Mark:];
37CP = [:LineBreak =  Close_Parenthesis:];
38CR = [:LineBreak =  Carriage_Return:];
39EB = [:LineBreak =  EB:];
40EM = [:LineBreak =  EM:];
41EX = [:LineBreak =  Exclamation:];
42GL = [:LineBreak =  Glue:];
43HL = [:LineBreak =  Hebrew_Letter:];
44HY = [:LineBreak =  Hyphen:];
45H2 = [:LineBreak =  H2:];
46H3 = [:LineBreak =  H3:];
47ID = [[:LineBreak =  Ideographic:] CJ];  # CSS Normal tailoring: CJ resolves to ID
48IN = [:LineBreak =  Inseperable:];
49IS = [:LineBreak =  Infix_Numeric:];
50JL = [:LineBreak =  JL:];
51JV = [:LineBreak =  JV:];
52JT = [:LineBreak =  JT:];
53LF = [:LineBreak =  Line_Feed:];
54NL = [:LineBreak =  Next_Line:];
55NSX = [\u3005 \u303B \u309D \u309E \u30FD \u30FE];
56NS = [[:LineBreak =  Nonstarter:] - NSX];
57NU = [:LineBreak =  Numeric:];
58OP = [:LineBreak =  Open_Punctuation:];
59PO = [:LineBreak =  Postfix_Numeric:];
60PR = [:LineBreak =  Prefix_Numeric:];
61QU = [:LineBreak =  Quotation:];
62RI = [:LineBreak =  Regional_Indicator:];
63SA = [:LineBreak =  Complex_Context:];
64SG = [:LineBreak =  Surrogate:];
65SP = [:LineBreak =  Space:];
66SY = [:LineBreak =  Break_Symbols:];
67WJ = [:LineBreak =  Word_Joiner:];
68XX = [:LineBreak =  Unknown:];
69ZW = [:LineBreak =  ZWSpace:];
70ZWJ = [:LineBreak =  ZWJ:];
71
72# OP30 and CP30 are variants of OP and CP that appear in rule LB30 from UAX 14.
73# Limitations of this monkey test rule parser require that these definitions be pulled out
74# rather than appearing in-line in LB 30.
75
76OP30 = [OP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
77CP30 = [CP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
78
79# The redundant-looking inner brackets are required for the current parser in the test code.
80ExtPictUnassigned = [[\p{Extended_Pictographic}]&[\p{Cn}]];
81
82# LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
83AL = [AL AI SG XX ];
84dictionary = SA;
85
86# By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
87#         list it in the numerous rules that use CM.
88CM = [CMS ZWJ];
89
90LB4:        BK ÷;
91LB5:        CR LF;
92LB5.1:      CR ÷;
93LB5.2:      LF ÷;
94LB5.3:      NL ÷;
95
96LB6:        . (BK | CR | LF | NL);
97LB6.1:      [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
98
99# LB8   break after ZW SP*.
100# Precedes LB7 because both rules will match the sequences like ZW SP,
101# and LB8 must take precedence.
102
103LB8:        ZW SP* ÷ [^ZW SP BK CR LF NL];
104
105# Numbers. Equivalent to Tailoring example 8 from UAX 14.
106# Moved up, before LB14, because it can match longer sequences which must take precedence.
107LB25:        ((PR | PO)CM*)? ((OP | HY)CM*)? (IS CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PO))?;
108
109# Rules LB14 - LB17.
110# Moved up, before LB7, because they can match a longer sequence that would also match LB7.
111# For example, the sequence "OP CM SP AL" matches LB14
112# while the prefix of it, "OP CM SP" matches LB7.1
113LB14:        OP CM* SP* .;
114
115# LB 14a Break before an IS that begins a number and follows a space.
116LB14a:       SP ÷ IS CM* NU;
117
118# LB14b       × IS
119LB14b.1:     [^SP] CM* IS;
120LB14b.2:     SP IS;
121
122LB15:        QU CM* SP* OP;
123LB16:        (CL | CP)CM* SP* NS;
124LB17:        B2 CM* SP* B2;
125
126
127# LB7 Do not break before spaces or zero width space.
128
129LB7.1:      [^ZW SP] CM* [SP ZW];
130LB7.2:      [ZW SP] [SP ZW];
131
132# LB8a
133#      ZWJ x
134#      Don't match a CM on the right - let other rules pick up CM sequences, where
135#      the ZWJ behaves as just another generic CM.
136LB8a:       ZWJ [^CM];
137
138
139# LB9:  X CM -> X
140# LB10: Unattached CM -> AL
141
142#LB11:       × WJ;
143#            WJ ×
144
145LB11.1:      [^SP] CM* WJ;
146LB11.2:      SP WJ;
147LB11.3:      WJ CM* [^CM];
148
149LB12:        GL CM* [^CM];
150
151LB12a:       [^SP BA HY] CM* GL;
152
153# LB 13 Do not break before ‘]’ or ‘!’ or ‘/’, even after spaces.
154LB13.1: [^SP] CM* [CL CP EX SY];
155LB13.2: SP [CL CP EX SY];
156
157# LB 14-17 are moved above LB 7.
158
159LB18:        SP ÷;
160
161LB19:        . CM* QU;
162LB19.1:      QU CM* [^CM];
163
164# LB 20   Break before and after CB.
165#         Interaction with LB8a:  ZWJ x . is tricky because CM includes ZWJ.
166#                                 ZWJ acts like a CM to the left, combining with CB.
167#                                 ZWJ acts independently to the right, no break after by LB8a.
168LB20.1:      . CM* ZWJ CB;
169LB20.2:      . CM* ÷ CB;
170
171LB20.3:      CB CM* ZWJ [^CM];
172LB20.4:      CB CM* ÷;
173
174# LB 20.09    Don't break between Hyphens and Letters when there is a break preceding the hyphen.
175LB20.09:     ^(HY | HH) CM* AL;
176
177# Note: Rule 21a must come before 21 to prevent 21.1 from matching HL BA, then
178#       not picking up the continuing match after the BA from 21a.
179LB21a:       HL CM* (HY | BA) CM* [^CM CB];
180
181LB21.1:      . CM* [BA HY NS];
182LB21.2:      BB CM* [^CM CB];
183
184LB21b:       SY CM* HL;
185
186
187LB22:        [^IN] CM* IN;   # For CSS Loose, allow breaks between adjacent ellipses characters.
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