1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
//! The builtin sets: one that is CODE, the rest DATA.
//!
//! Every preset but `ascii` ships as a data file written in the
//! `.ctrm-sets` grammar and compiled in with `include_str!` (V22), so the
//! contents a user reads and the contents the tool enforces are the same
//! bytes. `sets.ctrm-sets` holds the hand-written presets and
//! `hazard.ctrm-sets` the ones GENERATED from Unicode data (`src/lint/hazard:V34`),
//! and `locale/locales.ctrm-sets` the CLDR letter presets
//! (`src/charset/locale:V30`), generated by `cldr-letters.sh` beside it
//! and read lazily by `super::locale` (`src/charset/locale:V61`).
//!
//! `ascii` is the exception on purpose. `src/rules:V21` requires a run with
//! `--no-files --no-builtin-map --no-builtin-sets` to still resolve a
//! default set, so the one set that every path falls back to (`src/rules`
//! V1) cannot itself be a file that the flags remove.
use ;
/// The name of the intrinsic set, and the ONE spelling of `ascii` in code:
/// the set every unmatched path gets (`src/rules:V1`) and the root of the
/// fidelity tree (`src/fix:V27`) are this name, so they cannot drift apart.
pub const ASCII: &str = "ascii";
/// Tab and newline: the two control characters ASCII text is made of.
const WHITESPACE: CharRange = CharRange ;
/// Space through tilde: every printable ASCII character.
const PRINTABLE: CharRange = CharRange ;
/// `ascii` as a definition, so it composes like any other set (V25).
///
/// Stated in the same shape a data file would state it, so that a rule
/// naming `ascii` alongside a file-declared set takes one path through
/// resolution rather than two.
pub
/// `ascii` resolved: printable ASCII plus tab and newline.
///
/// Carriage return is NOT here. It is the separate `cr` set, because a file
/// that grants it is making a decision about line endings rather than about
/// characters.
pub
/// A catalog declaring the intrinsic set and nothing else.
///
/// The floor of the precedence chain in `src/rules:V19`: the builtin data
/// files, then discovered dotfiles, then flags are inserted over this, each
/// replacing a name the last one declared. Starting from `ascii` rather
/// than from nothing is what makes `--no-builtin-sets` survivable.
pub
/// The preset data, in the `.ctrm-sets` grammar (V22): the hand-written
/// presets, then the generated hazard file last. The generated locale
/// letters (`src/charset/locale:V30`) are NOT here: they resolve lazily,
/// see `super::locale`.
///
/// Public as TEXT because that is what the precedence chain takes: the
/// builtin is the lowest source in `src/rules:V19` and arrives there the
/// same way a dotfile or a `--sets-file` does. One grammar, one parser,
/// and a preset a user overrides by declaring the name again.
///
/// TWO FILES, ONE TEXT. The chain holds a single builtin source, and the
/// hazard file is generated (`src/lint/hazard:V34`) so it cannot share a file
/// with presets written by hand. Joining them at compile time keeps the
/// chain's shape; the cost is that a builtin line number counts from the
/// top of the joined text, which only a defect in this crate would ever
/// show and which the parse test below keeps from shipping.
pub const SETS: &str = concat!;
/// The curated presets in the order `ctrm sets` lists them, each with its
/// one-line description (`src/cli/explain:V127`): the `#: <name> <text>`
/// lines of the preset file. Kept beside the sets they describe, so a
/// preset and the sentence about it are reviewed in one diff.
pub
/// The generated hazard file alone (`src/lint/hazard:V34`).
///
/// Kept apart from [`SETS`] because the lint node reads it DIRECTLY: a
/// hazard fires from these compiled-in bytes, never from the catalog a run
/// assembled, so neither a `.ctrm-sets` redeclaring a hazard name nor a
/// run without the builtin sets can empty the set that forbids.
pub const HAZARD: &str = include_str!;
/// The RGI emoji sequences, vendored from Unicode emoji data
/// (`src/fix/emoji:V62`): one `<kind> <sequence> [name]` line each. Not a set
/// file -- a set holds code points and a sequence is not one -- so it is
/// read through [`emoji_sequences`], by the lint node for its exemption
/// (`src/lint/hazard:V63`), compiled in so no configuration can widen it.
const EMOJI_SEQUENCES: &str = include_str!;
/// What a vendored RGI sequence is, per the list's first word.
pub
/// One vendored RGI emoji sequence, decoded.
pub
/// Every sequence in the vendored list, in file order. A line this cannot
/// read is skipped rather than guessed at: `src/lint`'s test counts the
/// lines it needs, so a skipped one cannot ship.
pub
/// One `<kind> <sequence> [name]` line; `None` for a comment.
/// The hazard file's sets, and nothing else.
///
/// # Errors
///
/// As [`definitions`]: only a defect in the compiled-in file.
pub
/// The presets the data file declares, unresolved.
///
/// Members stay unresolved for the reason [`SetDefinition`] states: a
/// preset here may name another, and `any` would otherwise expand in
/// every catalog that never uses it.
///
/// # Errors
///
/// Returns a [`ParseError`] if a line of the compiled-in file cannot be
/// read. That is a defect in THIS crate, not in anyone's configuration --
/// the test below is what keeps it from shipping -- but it is returned
/// rather than panicked, because a library that kills the process leaves
/// its caller no way to say which set was wrong.
pub
/// The intrinsic set plus every preset the data file declares.
///
/// This is the floor of `src/rules:V19` with the builtin source present,
/// as [`intrinsic_catalog`] is the floor with it removed. The data file
/// is inserted OVER `ascii`, which costs nothing today and is the right
/// order the moment the file has anything to say about it.
///
/// # Errors
///
/// As [`definitions`].
pub