• 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_cj.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=loose (BCP47 -u-lb-loose) as defined for Chinese & Japanese.
21#         It sets characters of class CJ to behave like ID.
22#         In addition, it allows breaks:
23#         * between ID and hyphens 2010 & 2013 (both BA)
24#         * before 301C, 30A0 (both NS)
25#         * before iteration marks 3005, 303B, 309D, 309E, 30FD, 30FE (all NS)
26#         * between characters of LineBreak class IN such as 2026
27#         * before some centered punct 203C, 2047, 2048, 2049, 30FB, FF1A, FF1B,
28#           FF65 (all NS) and FF01, FF1F (both EX).
29#         * before suffix characters with LineBreak class PO and EastAsianWidth A,F,W;
30#           this includes: 00B0 2030 2032 2033 2035 2103 2109 FE6A FF05 FFE0
31#         * after prefix characters with LineBreak class PR and EastAsianWidth A,F,W;
32#           this includes: 00A4 00B1 20AC 2116 FE69 FF04 FFE1 FFE5 FFE6
33#         It allows breaking before 201C and after 201D, for zh_Hans, zh_Hant, and ja.
34
35
36type = line;
37locale = ja@lb=loose;
38
39
40AI = [:LineBreak =  Ambiguous:];
41AL = [:LineBreak =  Alphabetic:];
42BAX = [\u2010 \u2013];
43BA = [[:LineBreak =  Break_After:] - BAX];
44HH = [\u2010];      # \u2010 is HYPHEN, default line break is BA.
45BB = [:LineBreak =  Break_Before:];
46BK = [:LineBreak =  Mandatory_Break:];
47B2 = [:LineBreak =  Break_Both:];
48CB = [:LineBreak =  Contingent_Break:];
49CJ = [:LineBreak =  Conditional_Japanese_Starter:];
50CL = [[:LineBreak =  Close_Punctuation:] \u201d];
51CMS = [:LineBreak =  Combining_Mark:];
52CP = [:LineBreak =  Close_Parenthesis:];
53CR = [:LineBreak =  Carriage_Return:];
54EB = [:LineBreak =  EB:];
55EM = [:LineBreak =  EM:];
56EXX = [\uFF01 \uFF1F];
57EX = [[:LineBreak =  Exclamation:] - EXX];
58GL = [:LineBreak =  Glue:];
59HL = [:LineBreak =  Hebrew_Letter:];
60HY = [:LineBreak =  Hyphen:];
61H2 = [:LineBreak =  H2:];
62H3 = [:LineBreak =  H3:];
63ID = [[:LineBreak =  Ideographic:] CJ];  # CSS Loose tailoring: CJ resolves to ID
64IN = [:LineBreak =  Inseperable:];
65IS = [:LineBreak =  Infix_Numeric:];
66JL = [:LineBreak =  JL:];
67JV = [:LineBreak =  JV:];
68JT = [:LineBreak =  JT:];
69LF = [:LineBreak =  Line_Feed:];
70NL = [:LineBreak =  Next_Line:];
71NSX = [\u301C \u30A0 \u3005 \u303B \u309D \u309E \u30FD \u30FE \u203C \u2047 \u2048 \u2049 \u30FB \uFF1A \uFF1B \uFF65];
72NS = [[:LineBreak =  Nonstarter:] - NSX];
73NU = [:LineBreak =  Numeric:];
74OP = [[:LineBreak =  Open_Punctuation:] \u201c];
75POX = [\u00B0 \u2030 \u2032 \u2033 \u2035 \u2103 \u2109 \uFE6A \uFF05 \uFFE0];
76PO = [[:LineBreak =  Postfix_Numeric:] - POX];
77PRX = [\u00A4 \u00B1 \u20AC \u2116 \uFE69 \uFF04 \uFFE1 \uFFE5 \uFFE6];
78PR = [[:LineBreak =  Prefix_Numeric:] - PRX];
79QU = [[:LineBreak =  Quotation:] - [\u201c\u201d]];
80RI = [:LineBreak =  Regional_Indicator:];
81SA = [:LineBreak =  Complex_Context:];
82SG = [:LineBreak =  Surrogate:];
83SP = [:LineBreak =  Space:];
84SY = [:LineBreak =  Break_Symbols:];
85WJ = [:LineBreak =  Word_Joiner:];
86XX = [:LineBreak =  Unknown:];
87ZW = [:LineBreak =  ZWSpace:];
88ZWJ = [:LineBreak =  ZWJ:];
89
90# OP30 and CP30 are variants of OP and CP that appear in rule LB30 from UAX 14.
91# Limitations of this monkey test rule parser require that these definitions be pulled out
92# rather than appearing in-line in LB 30.
93
94OP30 = [OP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
95CP30 = [CP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
96
97# The redundant-looking inner brackets are required for the current parser in the test code.
98ExtPictUnassigned = [[\p{Extended_Pictographic}]&[\p{Cn}]];
99
100# LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
101AL = [AL AI SG XX ];
102dictionary = SA;
103
104# By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
105#         list it in the numerous rules that use CM.
106CM = [CMS ZWJ];
107
108LB4:        BK ÷;
109LB5:        CR LF;
110LB5.1:      CR ÷;
111LB5.2:      LF ÷;
112LB5.3:      NL ÷;
113
114LB6:        . (BK | CR | LF | NL);
115LB6.1:      [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
116
117# LB8   break after ZW SP*.
118# Precedes LB7 because both rules will match the sequences like ZW SP,
119# and LB8 must take precedence.
120
121LB8:        ZW SP* ÷ [^ZW SP BK CR LF NL];
122
123# Numbers. Equivalent to Tailoring example 8 from UAX 14.
124# Moved up, before LB14, because it can match longer sequences which must take precedence.
125#          Loose_cj tailoring: do not include $PRX at the beginning or $POX at the end.
126LB25:        ((PR | PO | POX)CM*)? ((OP | HY)CM*)? (IS CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PRX | PO))?;
127
128# Rules LB14 - LB17.
129# Moved up, before LB7, because they can match a longer sequence that would also match LB7.
130# For example, the sequence "OP CM SP AL" matches LB14
131# while the prefix of it, "OP CM SP" matches LB7.1
132LB14:        OP CM* SP* .;
133
134# LB 14a Break before an IS that begins a number and follows a space.
135LB14a:       SP ÷ IS CM* NU;
136
137# LB14b       × IS
138LB14b.1:     [^SP] CM* IS;
139LB14b.2:     SP IS;
140
141LB15:        QU CM* SP* OP;
142LB16:        (CL | CP)CM* SP* NS;
143LB17:        B2 CM* SP* B2;
144
145
146# LB7 Do not break before spaces or zero width space.
147
148LB7.1:      [^ZW SP] CM* [SP ZW];
149LB7.2:      [ZW SP] [SP ZW];
150
151# LB8a
152#      ZWJ x
153#      Don't match a CM on the right - let other rules pick up CM sequences, where
154#      the ZWJ behaves as just another generic CM.
155LB8a:       ZWJ [^CM];
156
157
158# LB9:  X CM -> X
159# LB10: Unattached CM -> AL
160
161#LB11:       × WJ;
162#            WJ ×
163
164LB11.1:      [^SP] CM* WJ;
165LB11.2:      SP WJ;
166LB11.3:      WJ CM* [^CM];
167
168LB12:        GL CM* [^CM];
169
170LB12a:       [^SP BA BAX HY] CM* GL;
171
172# LB 13 Do not break before ‘]’ or ‘!’ or ‘/’, even after spaces.
173LB13.1: [^SP] CM* [CL CP EX SY];
174LB13.2: SP [CL CP EX SY];
175
176
177# LB 14-17 are moved above LB 7.
178
179LB18:        SP ÷;
180
181LB19:        . CM* QU;
182LB19.1:      QU CM* [^CM];
183
184# LB 20   Break before and after CB.
185#         Interaction with LB8a:  ZWJ x . is tricky because CM includes ZWJ.
186#                                 ZWJ acts like a CM to the left, combining with CB.
187#                                 ZWJ acts independently to the right, no break after by LB8a.
188LB20.1:      . CM* ZWJ CB;
189LB20.2:      . CM* ÷ CB;
190
191LB20.3:      CB CM* ZWJ [^CM];
192LB20.4:      CB CM* ÷;
193
194# LB 20.09    Don't break between Hyphens and Letters when there is a break preceding the hyphen.
195LB20.09:     ^(HY | HH) CM* AL;
196
197# Note: Rule 21a must come before 21 to prevent 21.1 from matching HL BA, then
198#       not picking up the continuing match after the BA from 21a.
199# LB 21a Don't break after Hebrew + Hyphen
200#   HL (HY | BA) x
201
202LB21a:       HL CM* (HY | BA | BAX) CM* [^CM CB]?;
203
204LB21.1:      [^ID] CM* [BA BAX HY NS];
205LB21.2:      ID CM* [BA HY NS];
206LB21.3:      BB CM* [^CM CB];
207
208LB21b:       SY CM* HL;
209
210
211LB22:        [^IN] CM* IN;   # For CSS Loose, allow breaks between adjacent ellipses characters.
212
213LB23.1:      (AL | HL | CM) CM* NU;
214LB23.2:      NU CM* (AL | HL);
215
216LB23a.1:     PR CM* (ID | EB | EM);
217LB23a.2:     (ID | EB | EM) CM* PO;
218
219LB24.2:      (PR | PO | POX) CM* (AL | HL);
220LB24.3:      (AL | HL | CM) CM* (PR | PO | POX);
221
222
223LB26.1:      JL CM* (JL | JV | H2 | H3);
224LB26.2:      (JV | H2) CM* (JV | JT);
225LB26.3:      (JT | H3) CM* JT;
226
227LB27.1:      (JL | JV | JT | H2 | H3) CM* PO;
228LB27.2:      PR CM* (JL | JV | JT | H2 | H3);
229
230# LB28 Do not break between Alphabetics.
231#      Unattached (leading) CM treated as AL.
232LB28:        (AL | HL | CM)CM* (AL | HL);
233
234LB29:        IS CM* (AL | HL);
235
236# LB30  is adjusted for unattached leading CM being treated as AL.
237LB30.1:      (AL | CM | HL | NU) CM* OP30;
238LB30.2:      CP30 CM* (AL | HL | NU);
239
240# LB30a  keep pairs of RI together.
241LB30a.1:     RI CM* RI         ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA BAX HY NS IN CM];
242LB30a.2:     RI CM* RI CM* CMS ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA BAX HY NS IN CM];
243LB30a.3:     RI CM* RI CM* [BK CR LF NL SP ZW WJ GL CL CP EX IS SY QU BA BAX HY NS IN ZWJ]?;
244
245# LB30b Do not break between Emoji Base (or potential emoji) and Emoji Modifier
246LB30b.1:       EB CM* EM;
247LB30b.2:       ExtPictUnassigned CM* EM;
248
249# LB31 Break Everywhere Else.
250#      Include combining marks
251LB31.1:        . CM* ZWJ [^CM];
252LB31.2:        . CM* ÷;
253