jots 0.1.0

Jot Syntax 1.0 RC1 parser (https://jotsyntax.org)
Documentation
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
//! Compiled regex primitives mirroring the Perl reference's "Grammar primitives
//! (§1.7)" block. The Rust `regex` crate has no lookbehind, so the §1.7.1 left
//! boundary is checked in code by [`is_left_boundary`] after each match instead
//! of via `(?<=^|\s)`.

pub use fancy_regex::Regex;
use std::sync::LazyLock;

const WORD: &str = r"[A-Za-z0-9_]+";
// §1.7.2 — one or more chained `..word` segments (tagstring tail).
// Reused by the annotated-suffix rejection regexes so a chained
// `..tag1..tag2::cat` is caught as tags-before-category, not just
// the single-tag `..tag::cat` form.
const TAG_TAIL: &str = r"(?: \.\. [A-Za-z0-9_]+ )+";
const UINT: &str = r"[0-9]+";
const FILENAME: &str =
    r"[A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* (?: \. [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* )*";

const FILEPATH: &str =
    r"[A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* (?: \. [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* )*
       (?: / [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]*
              (?: \. [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* )*
       )*";

// Specifier alternatives. Order matters: `##` must precede `#` (regex
// alternation is leftmost-first); the `:N` form requires a digit lookahead so
// `::` doesn't get mistaken for a fragment intro.
const SPECIFIER: &str = r"(?: \#\# (?: [A-Za-z0-9_]+ , (?:[A-Za-z0-9_]+)? | , [A-Za-z0-9_]+ )
                            | : (?=[0-9]) [0-9]+ (?: [-+] [0-9]+ )?
                            | \# (?!\#) [A-Za-z0-9_]+ )";

const ANNOTATIONS: &str = r"(?: :: [A-Za-z0-9_]+ (?: :: [A-Za-z0-9_]+ )* )?
                            (?: \.\. [A-Za-z0-9_]+ )*";

const ANNOT_NONEMPTY: &str =
    r"(?: \.\. [A-Za-z0-9_]+ | :: [A-Za-z0-9_]+ (?: :: [A-Za-z0-9_]+ )*)+";

const ID_LOCATOR: &str = r"-- (?: [A-Za-z0-9_]+ -- )? [A-Za-z0-9_]+";
const FILE_LOCATOR_SAME: &str = r"// [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]*
       (?: \. [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* )*
       (?: / [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]*
              (?: \. [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* )*
       )*";
const FILE_LOCATOR_CROSS: &str = r"/// [A-Za-z0-9_]+
       / [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]*
              (?: \. [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* )*
       (?: / [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]*
              (?: \. [A-Za-z0-9_~,@!()][A-Za-z0-9_~,@!()\-]* )*
       )*";

const ISO_DATE: &str = r"\d{4}-\d{2}-\d{2} (?: T \d{2}:\d{2} (?: :\d{2} )?
                                              (?: Z | [+\-]\d{2}:\d{2} )? )?";

const EMPTY_BMR: &str = r"\#\#, (?![A-Za-z0-9_])";

/// Build a regex with the `(?x)` extended flag. Format substitutions feed in
/// the named primitives above; `{{`/`}}` escape literal braces (e.g.
/// `\d{{4}}` after substitution becomes `\d{4}`).
fn compile(pattern: &str) -> Regex {
    let body = format!("(?x){}", pattern);
    Regex::new(&body).unwrap_or_else(|e| panic!("regex compile failed: {e}\n---\n{body}\n---"))
}

/// `(?:^|preceded by [ \t\r\n])` — §1.7.1. The regex can't express this
/// natively, so we run it in user code over a candidate match's start byte.
pub fn is_left_boundary(text: &str, start: usize) -> bool {
    if start == 0 {
        return true;
    }
    let bytes = text.as_bytes();
    matches!(bytes[start - 1], b' ' | b'\t' | b'\r' | b'\n')
}

// ── Inter-jot resources ─────────────────────────────────────────────────────

pub static INTER_JOT_CROSS_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"-- ({W}) -- ({W}) ;; ({F}) ({S})? ({A})",
        W = WORD,
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});
pub static INTER_JOT_SAME_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"-- ({W}) ;; ({F}) ({S})? ({A})",
        W = WORD,
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});
pub static INTER_JOT_CROSS_FILE: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"/// ({W}) / ({P}) ;; ({F}) ({S})? ({A})",
        W = WORD,
        P = FILEPATH,
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});
pub static INTER_JOT_SAME_FILE: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"// ({P}) ;; ({F}) ({S})? ({A})",
        P = FILEPATH,
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});

// ── File references ─────────────────────────────────────────────────────────

pub static CROSS_FILE_REF: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"/// ({W}) / ({P}) ({S})? ({A})",
        W = WORD,
        P = FILEPATH,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});
pub static FILE_REF: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"// ({P}) ({S})? ({A})",
        P = FILEPATH,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});

// ── ID references ───────────────────────────────────────────────────────────

pub static CROSS_ID_REF: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"-- ({W}) -- ({W}) ({S})? ({A})",
        W = WORD,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});
pub static ID_REF: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"-- ({W}) ({S})? ({A})",
        W = WORD,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});

// ── Resources ───────────────────────────────────────────────────────────────

pub static RESOURCE: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r";; ({F}) ({S})? ({A})",
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});

// ── URLs ────────────────────────────────────────────────────────────────────

pub static URL_RE: LazyLock<Regex> = LazyLock::new(|| {
    compile(
        r#"==
        (?:
            \( ([^)]*) \) (https?://\S+)
          | \[ ([^\]]*) \] (https?://\S+)
          | (https?://\S+)
        )"#,
    )
});

// ── Bookmark / tags / categories ────────────────────────────────────────────

pub static BOOKMARK_DECL: LazyLock<Regex> = LazyLock::new(|| compile(&format!(r"!! ({W})", W = WORD)));
// `<tagstring>` — one or more chained `..word` segments (§1.7.2).
// `TAG` matches a single `..word` tail; the scan loop uses
// `TAGSTRING` to find chain bounds and `TAG` to walk segments inside.
pub static TAGSTRING: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"(?: \.\. {W} )+", W = WORD)));
pub static TAG: LazyLock<Regex> = LazyLock::new(|| compile(&format!(r"\.\. ({W})", W = WORD)));
pub static HASHTAG: LazyLock<Regex> =
    LazyLock::new(|| compile(r"\# (?=[A-Za-z]) ([A-Za-z0-9_]+)"));
pub static CATEGORY: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r":: ({W} (?: :: {W} )*)", W = WORD)));

// ── Todos ───────────────────────────────────────────────────────────────────

pub static TODO_LINE: LazyLock<Regex> = LazyLock::new(|| compile(r"\?\? ([^\r\n]*)"));

// ── Reject patterns ─────────────────────────────────────────────────────────

pub static REJ_ANNOT_BEFORE_SEP_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {ANE} ;; {F} (?:{S})? {A}",
        LOC = ID_LOCATOR,
        ANE = ANNOT_NONEMPTY,
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});
pub static REJ_ANNOT_BEFORE_SEP_FILE_SAME: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {ANE} ;; {F} (?:{S})? {A}",
        LOC = FILE_LOCATOR_SAME,
        ANE = ANNOT_NONEMPTY,
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});
pub static REJ_ANNOT_BEFORE_SEP_FILE_CROSS: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {ANE} ;; {F} (?:{S})? {A}",
        LOC = FILE_LOCATOR_CROSS,
        ANE = ANNOT_NONEMPTY,
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});

pub static REJ_SPEC_ON_LOC_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {S} (?:{ANE})? ;; {F} (?:{S})? {A}",
        LOC = ID_LOCATOR,
        S = SPECIFIER,
        ANE = ANNOT_NONEMPTY,
        F = FILENAME,
        A = ANNOTATIONS,
    ))
});
pub static REJ_SPEC_ON_LOC_FILE_SAME: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {S} (?:{ANE})? ;; {F} (?:{S})? {A}",
        LOC = FILE_LOCATOR_SAME,
        S = SPECIFIER,
        ANE = ANNOT_NONEMPTY,
        F = FILENAME,
        A = ANNOTATIONS,
    ))
});
pub static REJ_SPEC_ON_LOC_FILE_CROSS: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {S} (?:{ANE})? ;; {F} (?:{S})? {A}",
        LOC = FILE_LOCATOR_CROSS,
        S = SPECIFIER,
        ANE = ANNOT_NONEMPTY,
        F = FILENAME,
        A = ANNOTATIONS,
    ))
});

pub static REJ_CAT_RUN: LazyLock<Regex> = LazyLock::new(|| compile(r"(:: [A-Za-z0-9_:]*)"));

pub static REJ_FILENAME_DOUBLEDOT: LazyLock<Regex> = LazyLock::new(|| {
    compile(r";; ([A-Za-z0-9_~,@!()] [A-Za-z0-9_~,@!()\-]* \.\. \S*)")
});

pub static REJ_URL_BARE: LazyLock<Regex> = LazyLock::new(|| compile(r"== (\S+)"));
pub static REJ_URL_UNMATCHED_PAREN: LazyLock<Regex> =
    LazyLock::new(|| compile(r"== \( [^)]* \) (?!https?://) [^\s)]* \) \S*"));
pub static REJ_URL_UNMATCHED_BRACKET: LazyLock<Regex> =
    LazyLock::new(|| compile(r"== \[ [^\]]* \] (?!https?://) [^\s\]]* \] \S*"));

// Empty payload — caller uses caps[1] for the sigil span.
pub static REJ_EMPTY_DOT: LazyLock<Regex> = LazyLock::new(|| compile(r"(\.\.) (?:[ \t\r\n]|\z)"));
pub static REJ_EMPTY_COLON: LazyLock<Regex> = LazyLock::new(|| compile(r"(::) (?:[ \t\r\n]|\z)"));
pub static REJ_EMPTY_DASH: LazyLock<Regex> = LazyLock::new(|| compile(r"(--) (?:[ \t\r\n]|\z)"));
pub static REJ_EMPTY_SLASH: LazyLock<Regex> = LazyLock::new(|| compile(r"(//) (?:[ \t\r\n]|\z)"));
pub static REJ_EMPTY_SEMI: LazyLock<Regex> = LazyLock::new(|| compile(r"(;;) (?:[ \t\r\n]|\z)"));
pub static REJ_EMPTY_EQ: LazyLock<Regex> = LazyLock::new(|| compile(r"(==) (?:[ \t\r\n]|\z)"));

pub static REJ_EMPTY_BANG: LazyLock<Regex> = LazyLock::new(|| compile(r"!! (?:[ \t\r\n]|\z)"));

pub static REJ_FILENAME_START_RES: LazyLock<Regex> =
    LazyLock::new(|| compile(r";; ([-.] \S*)"));
pub static REJ_FILENAME_START_FILE_SAME: LazyLock<Regex> =
    LazyLock::new(|| compile(r"// ([-.] \S*)"));
pub static REJ_FILENAME_START_FILE_CROSS: LazyLock<Regex> =
    LazyLock::new(|| compile(r"/// [A-Za-z0-9_]+ / ([-.] \S*)"));

pub static REJ_FRAG_NONNUM_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} : (?![0-9:]) [^\s]+",
        LOC = ID_LOCATOR
    ))
});
pub static REJ_FRAG_NONNUM_FILE_SAME: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} : (?![0-9:]) [^\s]+",
        LOC = FILE_LOCATOR_SAME
    ))
});
pub static REJ_FRAG_NONNUM_FILE_CROSS: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} : (?![0-9:]) [^\s]+",
        LOC = FILE_LOCATOR_CROSS
    ))
});
pub static REJ_FRAG_NONNUM_RES: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r";; {F} : (?![0-9:]) [^\s]+",
        F = FILENAME
    ))
});

pub static REJ_MUTEX_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {S} {S}",
        LOC = ID_LOCATOR,
        S = SPECIFIER,
    ))
});
pub static REJ_MUTEX_FILE_SAME: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {S} {S}",
        LOC = FILE_LOCATOR_SAME,
        S = SPECIFIER,
    ))
});
pub static REJ_MUTEX_FILE_CROSS: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} {S} {S}",
        LOC = FILE_LOCATOR_CROSS,
        S = SPECIFIER,
    ))
});
pub static REJ_MUTEX_RES: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r";; {F} {S} {S}",
        F = FILENAME,
        S = SPECIFIER,
    ))
});
pub static REJ_MUTEX_INTER_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} ;; {F} {S} {S}",
        LOC = ID_LOCATOR,
        F = FILENAME,
        S = SPECIFIER,
    ))
});
pub static REJ_MUTEX_INTER_FILE_SAME: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} ;; {F} {S} {S}",
        LOC = FILE_LOCATOR_SAME,
        F = FILENAME,
        S = SPECIFIER,
    ))
});
pub static REJ_MUTEX_INTER_FILE_CROSS: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} ;; {F} {S} {S}",
        LOC = FILE_LOCATOR_CROSS,
        F = FILENAME,
        S = SPECIFIER,
    ))
});

pub static REJ_EMPTY_BMR_ID: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"{LOC} {E}", LOC = ID_LOCATOR, E = EMPTY_BMR)));
pub static REJ_EMPTY_BMR_FILE_SAME: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"{LOC} {E}", LOC = FILE_LOCATOR_SAME, E = EMPTY_BMR)));
pub static REJ_EMPTY_BMR_FILE_CROSS: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"{LOC} {E}", LOC = FILE_LOCATOR_CROSS, E = EMPTY_BMR)));
pub static REJ_EMPTY_BMR_RES: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r";; {F} {E}", F = FILENAME, E = EMPTY_BMR)));

pub static REJ_TAGS_BEFORE_CAT_ID: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} (?:{S})? {T} ::{W} [^\s]*",
        LOC = ID_LOCATOR,
        S = SPECIFIER,
        T = TAG_TAIL,
        W = WORD,
    ))
});
pub static REJ_TAGS_BEFORE_CAT_FILE_SAME: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} (?:{S})? {T} ::{W} [^\s]*",
        LOC = FILE_LOCATOR_SAME,
        S = SPECIFIER,
        T = TAG_TAIL,
        W = WORD,
    ))
});
pub static REJ_TAGS_BEFORE_CAT_FILE_CROSS: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"{LOC} (?:{S})? {T} ::{W} [^\s]*",
        LOC = FILE_LOCATOR_CROSS,
        S = SPECIFIER,
        T = TAG_TAIL,
        W = WORD,
    ))
});
pub static REJ_TAGS_BEFORE_CAT_RES: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r";; {F} (?:{S})? {T} ::{W} [^\s]*",
        F = FILENAME,
        S = SPECIFIER,
        T = TAG_TAIL,
        W = WORD,
    ))
});

pub static REJ_TAGS_BEFORE_CAT_TODO: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"\?\? [ \t]* (?:!{{1,3}})? {W} (?:[ \t]*@{D})? {T} ::{W} [^\r\n]*",
        W = WORD,
        D = ISO_DATE,
        T = TAG_TAIL,
    ))
});

pub static REJ_INVALID_FILENAME_CHARS: LazyLock<Regex> =
    LazyLock::new(|| compile(r";; ([A-Za-z0-9_~,@!()] \S*)"));

pub static VALID_RES_TOKEN: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"\A {F} (?:{S})? {A} \z",
        F = FILENAME,
        S = SPECIFIER,
        A = ANNOTATIONS,
    ))
});

// ── Decoders ────────────────────────────────────────────────────────────────

pub static DECODE_BMR_RANGE: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"\A \#\# ({W})? , ({W})? \z",
        W = WORD
    ))
});
pub static DECODE_BM: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"\A \# ({W}) \z", W = WORD)));
pub static DECODE_FRAG_RANGE: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"\A : ({U}) - ({U}) \z", U = UINT)));
pub static DECODE_FRAG_OFFSET: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"\A : ({U}) \+ ({U}) \z", U = UINT)));
pub static DECODE_FRAG_SINGLE: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"\A : ({U}) \z", U = UINT)));

pub static DECODE_CATEGORY_PREFIX: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"\A :: ({W} (?: :: {W} )*)",
        W = WORD
    ))
});
pub static DECODE_TAG_PREFIX: LazyLock<Regex> =
    LazyLock::new(|| compile(&format!(r"\A \.\. ({W})", W = WORD)));

pub static DECODE_TODO_BODY: LazyLock<Regex> = LazyLock::new(|| {
    compile(&format!(
        r"\A
          (!{{1,3}})?
          ({W})
          (?: [ \t]* @ ({D}) )?
          (
              (?: :: {W} (?: :: {W} )* )?
              (?: \.\. {W} )*
          )
          (?:
              (?: : [ \t]* | [ \t]+ :? [ \t]* ) (.*)
          )?
          \z",
        W = WORD,
        D = ISO_DATE,
    ))
});

pub static ISO_DATE_VALIDATOR: LazyLock<Regex> = LazyLock::new(|| {
    compile(
        r"\A (\d{4}) - (\d{2}) - (\d{2})
          (?: T (\d{2}) : (\d{2}) (?: : (\d{2}) )? )?",
    )
});