-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.ts
More file actions
1557 lines (1557 loc) · 47.2 KB
/
Copy pathparser.ts
File metadata and controls
1557 lines (1557 loc) · 47.2 KB
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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* AutoGenerated Code, changes may be overwritten
* INPUT GRAMMAR:
* mailbox := name_addr | addr_spec
* name_addr := display_name? angle_addr
* addr_spec := local_part '@' domain
* display_name := phrase
* angle_addr := CFWS? '<' addr_spec '>' CFWS? | obs_angle_addr
* local_part := dot_atom | quoted_string | obs_local_part
* domain := dot_atom | domain_literal | obs_domain
* phrase := word+ | obs_phrase
* CFWS := { FWS? comment }+ FWS? | FWS
* obs_angle_addr := CFWS? '<' obs_route addr_spec '>' CFWS?
* dot_atom := CFWS? dot_atom_text CFWS?
* quoted_string := CFWS? DQUOTE { FWS? qcontent }* FWS? DQUOTE CFWS?
* obs_local_part := word { '\.' word }*
* domain_literal := CFWS? '\[' { FWS? dtext }* FWS? '\]' CFWS?
* obs_domain := atom { '\.' atom }*
* word := atom | quoted_string
* obs_phrase := word { word | '.' | CFWS }
* FWS := { WSP* CRLF }? WSP+ | obs_FWS
* comment := '\(' { FWS? ccontent }* FWS? '\)'
* obs_route := obs_domain_list ':'
* dot_atom_text := atext+ { '\.' atext+ }*
* DQUOTE := '\x22' // double quote, i.e. '"'
* qcontent := qtext | quoted_pair
* dtext := '[\x21-\x5a]' | '[\x5e-\x7e]' | obs_dtext
* atom := CFWS? atext+ CFWS?
* WSP := SP | HTAB // white space
* obs_FWS := WSP+ { CRLF WSP+ }*
* CRLF := '\r\n' // Internet standard newline
* ccontent := ctext | quoted_pair | comment
* obs_domain_list := { CFWS | ',' }* '@' domain { ',' CFWS? { '@' domain }? }*
* atext := '[A-Za-z0-9!#$%&\x27\*\+\-\/=?^_`{|}~]'
* qtext := '\x21' | '[\x23-\x5b]' | '[\x5d-\x7e]' | obs_qtext
* quoted_pair := '\\' { VCHAR | WSP } | obs_qp
* obs_dtext := obs_NO_WS_CTL | quoted_pair
* SP := '\x20' // space, i.e. 'Space'
* HTAB := '\x09' // horizontal tab, i.e. 'TAB'
* ctext := '[\x21-\x27]' | '[\x2a-\x5b]' | '[\x5d-\x7e]' | obs_ctext
* obs_qtext := obs_NO_WS_CTL
* obs_qp := '\\' { '\x00' | obs_NO_WS_CTL | LF | CR }
* VCHAR := '[\x21-\x7E]' // visible (printing) characters
* obs_NO_WS_CTL := '[\x01-\x08]' | '\x0B' | '\x0C' | '[\x0E-\x1F]' | '\x7F'
* obs_ctext := obs_NO_WS_CTL
* LF := '\x0A' // linefeed, i.e. '\n'
* CR := '\x0D' // carriage return, i.e. '\r'
*/
type Nullable<T> = T | null
type $$RuleType<T> = () => Nullable<T>
export interface ASTNodeIntf {
kind: ASTKinds
}
export enum ASTKinds {
mailbox_1 = 'mailbox_1',
mailbox_2 = 'mailbox_2',
name_addr = 'name_addr',
addr_spec = 'addr_spec',
display_name = 'display_name',
angle_addr_1 = 'angle_addr_1',
angle_addr_2 = 'angle_addr_2',
local_part_1 = 'local_part_1',
local_part_2 = 'local_part_2',
local_part_3 = 'local_part_3',
domain_1 = 'domain_1',
domain_2 = 'domain_2',
domain_3 = 'domain_3',
phrase_1 = 'phrase_1',
phrase_2 = 'phrase_2',
CFWS_1 = 'CFWS_1',
CFWS_2 = 'CFWS_2',
CFWS_$0 = 'CFWS_$0',
obs_angle_addr = 'obs_angle_addr',
dot_atom = 'dot_atom',
quoted_string = 'quoted_string',
quoted_string_$0 = 'quoted_string_$0',
obs_local_part = 'obs_local_part',
obs_local_part_$0 = 'obs_local_part_$0',
domain_literal = 'domain_literal',
domain_literal_$0 = 'domain_literal_$0',
obs_domain = 'obs_domain',
obs_domain_$0 = 'obs_domain_$0',
word_1 = 'word_1',
word_2 = 'word_2',
obs_phrase = 'obs_phrase',
obs_phrase_$0_1 = 'obs_phrase_$0_1',
obs_phrase_$0_2 = 'obs_phrase_$0_2',
obs_phrase_$0_3 = 'obs_phrase_$0_3',
FWS_1 = 'FWS_1',
FWS_2 = 'FWS_2',
FWS_$0 = 'FWS_$0',
comment = 'comment',
comment_$0 = 'comment_$0',
obs_route = 'obs_route',
dot_atom_text = 'dot_atom_text',
dot_atom_text_$0 = 'dot_atom_text_$0',
DQUOTE = 'DQUOTE',
qcontent_1 = 'qcontent_1',
qcontent_2 = 'qcontent_2',
dtext_1 = 'dtext_1',
dtext_2 = 'dtext_2',
dtext_3 = 'dtext_3',
atom = 'atom',
WSP_1 = 'WSP_1',
WSP_2 = 'WSP_2',
obs_FWS = 'obs_FWS',
obs_FWS_$0 = 'obs_FWS_$0',
CRLF = 'CRLF',
ccontent_1 = 'ccontent_1',
ccontent_2 = 'ccontent_2',
ccontent_3 = 'ccontent_3',
obs_domain_list = 'obs_domain_list',
obs_domain_list_$0_1 = 'obs_domain_list_$0_1',
obs_domain_list_$0_2 = 'obs_domain_list_$0_2',
obs_domain_list_$1 = 'obs_domain_list_$1',
obs_domain_list_$1_$0 = 'obs_domain_list_$1_$0',
atext = 'atext',
qtext_1 = 'qtext_1',
qtext_2 = 'qtext_2',
qtext_3 = 'qtext_3',
qtext_4 = 'qtext_4',
quoted_pair_1 = 'quoted_pair_1',
quoted_pair_2 = 'quoted_pair_2',
quoted_pair_$0_1 = 'quoted_pair_$0_1',
quoted_pair_$0_2 = 'quoted_pair_$0_2',
obs_dtext_1 = 'obs_dtext_1',
obs_dtext_2 = 'obs_dtext_2',
SP = 'SP',
HTAB = 'HTAB',
ctext_1 = 'ctext_1',
ctext_2 = 'ctext_2',
ctext_3 = 'ctext_3',
ctext_4 = 'ctext_4',
obs_qtext = 'obs_qtext',
obs_qp = 'obs_qp',
obs_qp_$0_1 = 'obs_qp_$0_1',
obs_qp_$0_2 = 'obs_qp_$0_2',
obs_qp_$0_3 = 'obs_qp_$0_3',
obs_qp_$0_4 = 'obs_qp_$0_4',
VCHAR = 'VCHAR',
obs_NO_WS_CTL_1 = 'obs_NO_WS_CTL_1',
obs_NO_WS_CTL_2 = 'obs_NO_WS_CTL_2',
obs_NO_WS_CTL_3 = 'obs_NO_WS_CTL_3',
obs_NO_WS_CTL_4 = 'obs_NO_WS_CTL_4',
obs_NO_WS_CTL_5 = 'obs_NO_WS_CTL_5',
obs_ctext = 'obs_ctext',
LF = 'LF',
CR = 'CR',
}
export type mailbox = mailbox_1 | mailbox_2
export type mailbox_1 = name_addr
export type mailbox_2 = addr_spec
export interface name_addr {
kind: ASTKinds.name_addr
}
export interface addr_spec {
kind: ASTKinds.addr_spec
}
export type display_name = phrase
export type angle_addr = angle_addr_1 | angle_addr_2
export interface angle_addr_1 {
kind: ASTKinds.angle_addr_1
}
export type angle_addr_2 = obs_angle_addr
export type local_part = local_part_1 | local_part_2 | local_part_3
export type local_part_1 = dot_atom
export type local_part_2 = quoted_string
export type local_part_3 = obs_local_part
export type domain = domain_1 | domain_2 | domain_3
export type domain_1 = dot_atom
export type domain_2 = domain_literal
export type domain_3 = obs_domain
export type phrase = phrase_1 | phrase_2
export type phrase_1 = [word, ...word[]]
export type phrase_2 = obs_phrase
export type CFWS = CFWS_1 | CFWS_2
export interface CFWS_1 {
kind: ASTKinds.CFWS_1
}
export type CFWS_2 = FWS
export interface CFWS_$0 {
kind: ASTKinds.CFWS_$0
}
export interface obs_angle_addr {
kind: ASTKinds.obs_angle_addr
}
export interface dot_atom {
kind: ASTKinds.dot_atom
}
export interface quoted_string {
kind: ASTKinds.quoted_string
}
export interface quoted_string_$0 {
kind: ASTKinds.quoted_string_$0
}
export interface obs_local_part {
kind: ASTKinds.obs_local_part
}
export interface obs_local_part_$0 {
kind: ASTKinds.obs_local_part_$0
}
export interface domain_literal {
kind: ASTKinds.domain_literal
}
export interface domain_literal_$0 {
kind: ASTKinds.domain_literal_$0
}
export interface obs_domain {
kind: ASTKinds.obs_domain
}
export interface obs_domain_$0 {
kind: ASTKinds.obs_domain_$0
}
export type word = word_1 | word_2
export type word_1 = atom
export type word_2 = quoted_string
export interface obs_phrase {
kind: ASTKinds.obs_phrase
}
export type obs_phrase_$0 = obs_phrase_$0_1 | obs_phrase_$0_2 | obs_phrase_$0_3
export type obs_phrase_$0_1 = word
export type obs_phrase_$0_2 = string
export type obs_phrase_$0_3 = CFWS
export type FWS = FWS_1 | FWS_2
export interface FWS_1 {
kind: ASTKinds.FWS_1
}
export type FWS_2 = obs_FWS
export interface FWS_$0 {
kind: ASTKinds.FWS_$0
}
export interface comment {
kind: ASTKinds.comment
}
export interface comment_$0 {
kind: ASTKinds.comment_$0
}
export interface obs_route {
kind: ASTKinds.obs_route
}
export interface dot_atom_text {
kind: ASTKinds.dot_atom_text
}
export interface dot_atom_text_$0 {
kind: ASTKinds.dot_atom_text_$0
}
export type DQUOTE = string
export type qcontent = qcontent_1 | qcontent_2
export type qcontent_1 = qtext
export type qcontent_2 = quoted_pair
export type dtext = dtext_1 | dtext_2 | dtext_3
export type dtext_1 = string
export type dtext_2 = string
export type dtext_3 = obs_dtext
export interface atom {
kind: ASTKinds.atom
}
export type WSP = WSP_1 | WSP_2
export type WSP_1 = SP
export type WSP_2 = HTAB
export interface obs_FWS {
kind: ASTKinds.obs_FWS
}
export interface obs_FWS_$0 {
kind: ASTKinds.obs_FWS_$0
}
export type CRLF = string
export type ccontent = ccontent_1 | ccontent_2 | ccontent_3
export type ccontent_1 = ctext
export type ccontent_2 = quoted_pair
export type ccontent_3 = comment
export interface obs_domain_list {
kind: ASTKinds.obs_domain_list
}
export type obs_domain_list_$0 = obs_domain_list_$0_1 | obs_domain_list_$0_2
export type obs_domain_list_$0_1 = CFWS
export type obs_domain_list_$0_2 = string
export interface obs_domain_list_$1 {
kind: ASTKinds.obs_domain_list_$1
}
export interface obs_domain_list_$1_$0 {
kind: ASTKinds.obs_domain_list_$1_$0
}
export type atext = string
export type qtext = qtext_1 | qtext_2 | qtext_3 | qtext_4
export type qtext_1 = string
export type qtext_2 = string
export type qtext_3 = string
export type qtext_4 = obs_qtext
export type quoted_pair = quoted_pair_1 | quoted_pair_2
export interface quoted_pair_1 {
kind: ASTKinds.quoted_pair_1
}
export type quoted_pair_2 = obs_qp
export type quoted_pair_$0 = quoted_pair_$0_1 | quoted_pair_$0_2
export type quoted_pair_$0_1 = VCHAR
export type quoted_pair_$0_2 = WSP
export type obs_dtext = obs_dtext_1 | obs_dtext_2
export type obs_dtext_1 = obs_NO_WS_CTL
export type obs_dtext_2 = quoted_pair
export type SP = string
export type HTAB = string
export type ctext = ctext_1 | ctext_2 | ctext_3 | ctext_4
export type ctext_1 = string
export type ctext_2 = string
export type ctext_3 = string
export type ctext_4 = obs_ctext
export type obs_qtext = obs_NO_WS_CTL
export interface obs_qp {
kind: ASTKinds.obs_qp
}
export type obs_qp_$0 = obs_qp_$0_1 | obs_qp_$0_2 | obs_qp_$0_3 | obs_qp_$0_4
export type obs_qp_$0_1 = string
export type obs_qp_$0_2 = obs_NO_WS_CTL
export type obs_qp_$0_3 = LF
export type obs_qp_$0_4 = CR
export type VCHAR = string
export type obs_NO_WS_CTL =
| obs_NO_WS_CTL_1
| obs_NO_WS_CTL_2
| obs_NO_WS_CTL_3
| obs_NO_WS_CTL_4
| obs_NO_WS_CTL_5
export type obs_NO_WS_CTL_1 = string
export type obs_NO_WS_CTL_2 = string
export type obs_NO_WS_CTL_3 = string
export type obs_NO_WS_CTL_4 = string
export type obs_NO_WS_CTL_5 = string
export type obs_ctext = obs_NO_WS_CTL
export type LF = string
export type CR = string
export class Parser {
private readonly input: string
private pos: PosInfo
private negating: boolean = false
private memoSafe: boolean = true
constructor(input: string) {
this.pos = { overallPos: 0, line: 1, offset: 0 }
this.input = input
}
public reset(pos: PosInfo) {
this.pos = pos
}
public finished(): boolean {
return this.pos.overallPos === this.input.length
}
public clearMemos(): void {}
public matchmailbox($$dpth: number, $$cr?: ErrorTracker): Nullable<mailbox> {
return this.choice<mailbox>([
() => this.matchmailbox_1($$dpth + 1, $$cr),
() => this.matchmailbox_2($$dpth + 1, $$cr),
])
}
public matchmailbox_1(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<mailbox_1> {
return this.matchname_addr($$dpth + 1, $$cr)
}
public matchmailbox_2(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<mailbox_2> {
return this.matchaddr_spec($$dpth + 1, $$cr)
}
public matchname_addr(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<name_addr> {
return this.run<name_addr>($$dpth, () => {
let $$res: Nullable<name_addr> = null
if (
true &&
(this.matchdisplay_name($$dpth + 1, $$cr) || true) &&
this.matchangle_addr($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.name_addr }
}
return $$res
})
}
public matchaddr_spec(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<addr_spec> {
return this.run<addr_spec>($$dpth, () => {
let $$res: Nullable<addr_spec> = null
if (
true &&
this.matchlocal_part($$dpth + 1, $$cr) !== null &&
this.regexAccept(String.raw`(?:@)`, '', $$dpth + 1, $$cr) !== null &&
this.matchdomain($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.addr_spec }
}
return $$res
})
}
public matchdisplay_name(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<display_name> {
return this.matchphrase($$dpth + 1, $$cr)
}
public matchangle_addr(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<angle_addr> {
return this.choice<angle_addr>([
() => this.matchangle_addr_1($$dpth + 1, $$cr),
() => this.matchangle_addr_2($$dpth + 1, $$cr),
])
}
public matchangle_addr_1(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<angle_addr_1> {
return this.run<angle_addr_1>($$dpth, () => {
let $$res: Nullable<angle_addr_1> = null
if (
true &&
(this.matchCFWS($$dpth + 1, $$cr) || true) &&
this.regexAccept(String.raw`(?:<)`, '', $$dpth + 1, $$cr) !== null &&
this.matchaddr_spec($$dpth + 1, $$cr) !== null &&
this.regexAccept(String.raw`(?:>)`, '', $$dpth + 1, $$cr) !== null &&
(this.matchCFWS($$dpth + 1, $$cr) || true)
) {
$$res = { kind: ASTKinds.angle_addr_1 }
}
return $$res
})
}
public matchangle_addr_2(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<angle_addr_2> {
return this.matchobs_angle_addr($$dpth + 1, $$cr)
}
public matchlocal_part(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<local_part> {
return this.choice<local_part>([
() => this.matchlocal_part_1($$dpth + 1, $$cr),
() => this.matchlocal_part_2($$dpth + 1, $$cr),
() => this.matchlocal_part_3($$dpth + 1, $$cr),
])
}
public matchlocal_part_1(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<local_part_1> {
return this.matchdot_atom($$dpth + 1, $$cr)
}
public matchlocal_part_2(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<local_part_2> {
return this.matchquoted_string($$dpth + 1, $$cr)
}
public matchlocal_part_3(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<local_part_3> {
return this.matchobs_local_part($$dpth + 1, $$cr)
}
public matchdomain($$dpth: number, $$cr?: ErrorTracker): Nullable<domain> {
return this.choice<domain>([
() => this.matchdomain_1($$dpth + 1, $$cr),
() => this.matchdomain_2($$dpth + 1, $$cr),
() => this.matchdomain_3($$dpth + 1, $$cr),
])
}
public matchdomain_1(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<domain_1> {
return this.matchdot_atom($$dpth + 1, $$cr)
}
public matchdomain_2(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<domain_2> {
return this.matchdomain_literal($$dpth + 1, $$cr)
}
public matchdomain_3(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<domain_3> {
return this.matchobs_domain($$dpth + 1, $$cr)
}
public matchphrase($$dpth: number, $$cr?: ErrorTracker): Nullable<phrase> {
return this.choice<phrase>([
() => this.matchphrase_1($$dpth + 1, $$cr),
() => this.matchphrase_2($$dpth + 1, $$cr),
])
}
public matchphrase_1(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<phrase_1> {
return this.loopPlus<word>(() => this.matchword($$dpth + 1, $$cr))
}
public matchphrase_2(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<phrase_2> {
return this.matchobs_phrase($$dpth + 1, $$cr)
}
public matchCFWS($$dpth: number, $$cr?: ErrorTracker): Nullable<CFWS> {
return this.choice<CFWS>([
() => this.matchCFWS_1($$dpth + 1, $$cr),
() => this.matchCFWS_2($$dpth + 1, $$cr),
])
}
public matchCFWS_1($$dpth: number, $$cr?: ErrorTracker): Nullable<CFWS_1> {
return this.run<CFWS_1>($$dpth, () => {
let $$res: Nullable<CFWS_1> = null
if (
true &&
this.loopPlus<CFWS_$0>(() => this.matchCFWS_$0($$dpth + 1, $$cr)) !==
null &&
(this.matchFWS($$dpth + 1, $$cr) || true)
) {
$$res = { kind: ASTKinds.CFWS_1 }
}
return $$res
})
}
public matchCFWS_2($$dpth: number, $$cr?: ErrorTracker): Nullable<CFWS_2> {
return this.matchFWS($$dpth + 1, $$cr)
}
public matchCFWS_$0($$dpth: number, $$cr?: ErrorTracker): Nullable<CFWS_$0> {
return this.run<CFWS_$0>($$dpth, () => {
let $$res: Nullable<CFWS_$0> = null
if (
true &&
(this.matchFWS($$dpth + 1, $$cr) || true) &&
this.matchcomment($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.CFWS_$0 }
}
return $$res
})
}
public matchobs_angle_addr(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_angle_addr> {
return this.run<obs_angle_addr>($$dpth, () => {
let $$res: Nullable<obs_angle_addr> = null
if (
true &&
(this.matchCFWS($$dpth + 1, $$cr) || true) &&
this.regexAccept(String.raw`(?:<)`, '', $$dpth + 1, $$cr) !== null &&
this.matchobs_route($$dpth + 1, $$cr) !== null &&
this.matchaddr_spec($$dpth + 1, $$cr) !== null &&
this.regexAccept(String.raw`(?:>)`, '', $$dpth + 1, $$cr) !== null &&
(this.matchCFWS($$dpth + 1, $$cr) || true)
) {
$$res = { kind: ASTKinds.obs_angle_addr }
}
return $$res
})
}
public matchdot_atom(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<dot_atom> {
return this.run<dot_atom>($$dpth, () => {
let $$res: Nullable<dot_atom> = null
if (
true &&
(this.matchCFWS($$dpth + 1, $$cr) || true) &&
this.matchdot_atom_text($$dpth + 1, $$cr) !== null &&
(this.matchCFWS($$dpth + 1, $$cr) || true)
) {
$$res = { kind: ASTKinds.dot_atom }
}
return $$res
})
}
public matchquoted_string(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<quoted_string> {
return this.run<quoted_string>($$dpth, () => {
let $$res: Nullable<quoted_string> = null
if (
true &&
(this.matchCFWS($$dpth + 1, $$cr) || true) &&
this.matchDQUOTE($$dpth + 1, $$cr) !== null &&
this.loop<quoted_string_$0>(
() => this.matchquoted_string_$0($$dpth + 1, $$cr),
0,
-1,
) !== null &&
(this.matchFWS($$dpth + 1, $$cr) || true) &&
this.matchDQUOTE($$dpth + 1, $$cr) !== null &&
(this.matchCFWS($$dpth + 1, $$cr) || true)
) {
$$res = { kind: ASTKinds.quoted_string }
}
return $$res
})
}
public matchquoted_string_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<quoted_string_$0> {
return this.run<quoted_string_$0>($$dpth, () => {
let $$res: Nullable<quoted_string_$0> = null
if (
true &&
(this.matchFWS($$dpth + 1, $$cr) || true) &&
this.matchqcontent($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.quoted_string_$0 }
}
return $$res
})
}
public matchobs_local_part(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_local_part> {
return this.run<obs_local_part>($$dpth, () => {
let $$res: Nullable<obs_local_part> = null
if (
true &&
this.matchword($$dpth + 1, $$cr) !== null &&
this.loop<obs_local_part_$0>(
() => this.matchobs_local_part_$0($$dpth + 1, $$cr),
0,
-1,
) !== null
) {
$$res = { kind: ASTKinds.obs_local_part }
}
return $$res
})
}
public matchobs_local_part_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_local_part_$0> {
return this.run<obs_local_part_$0>($$dpth, () => {
let $$res: Nullable<obs_local_part_$0> = null
if (
true &&
this.regexAccept(String.raw`(?:\.)`, '', $$dpth + 1, $$cr) !== null &&
this.matchword($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.obs_local_part_$0 }
}
return $$res
})
}
public matchdomain_literal(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<domain_literal> {
return this.run<domain_literal>($$dpth, () => {
let $$res: Nullable<domain_literal> = null
if (
true &&
(this.matchCFWS($$dpth + 1, $$cr) || true) &&
this.regexAccept(String.raw`(?:\[)`, '', $$dpth + 1, $$cr) !== null &&
this.loop<domain_literal_$0>(
() => this.matchdomain_literal_$0($$dpth + 1, $$cr),
0,
-1,
) !== null &&
(this.matchFWS($$dpth + 1, $$cr) || true) &&
this.regexAccept(String.raw`(?:\])`, '', $$dpth + 1, $$cr) !== null &&
(this.matchCFWS($$dpth + 1, $$cr) || true)
) {
$$res = { kind: ASTKinds.domain_literal }
}
return $$res
})
}
public matchdomain_literal_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<domain_literal_$0> {
return this.run<domain_literal_$0>($$dpth, () => {
let $$res: Nullable<domain_literal_$0> = null
if (
true &&
(this.matchFWS($$dpth + 1, $$cr) || true) &&
this.matchdtext($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.domain_literal_$0 }
}
return $$res
})
}
public matchobs_domain(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_domain> {
return this.run<obs_domain>($$dpth, () => {
let $$res: Nullable<obs_domain> = null
if (
true &&
this.matchatom($$dpth + 1, $$cr) !== null &&
this.loop<obs_domain_$0>(
() => this.matchobs_domain_$0($$dpth + 1, $$cr),
0,
-1,
) !== null
) {
$$res = { kind: ASTKinds.obs_domain }
}
return $$res
})
}
public matchobs_domain_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_domain_$0> {
return this.run<obs_domain_$0>($$dpth, () => {
let $$res: Nullable<obs_domain_$0> = null
if (
true &&
this.regexAccept(String.raw`(?:\.)`, '', $$dpth + 1, $$cr) !== null &&
this.matchatom($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.obs_domain_$0 }
}
return $$res
})
}
public matchword($$dpth: number, $$cr?: ErrorTracker): Nullable<word> {
return this.choice<word>([
() => this.matchword_1($$dpth + 1, $$cr),
() => this.matchword_2($$dpth + 1, $$cr),
])
}
public matchword_1($$dpth: number, $$cr?: ErrorTracker): Nullable<word_1> {
return this.matchatom($$dpth + 1, $$cr)
}
public matchword_2($$dpth: number, $$cr?: ErrorTracker): Nullable<word_2> {
return this.matchquoted_string($$dpth + 1, $$cr)
}
public matchobs_phrase(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_phrase> {
return this.run<obs_phrase>($$dpth, () => {
let $$res: Nullable<obs_phrase> = null
if (
true &&
this.matchword($$dpth + 1, $$cr) !== null &&
this.matchobs_phrase_$0($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.obs_phrase }
}
return $$res
})
}
public matchobs_phrase_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_phrase_$0> {
return this.choice<obs_phrase_$0>([
() => this.matchobs_phrase_$0_1($$dpth + 1, $$cr),
() => this.matchobs_phrase_$0_2($$dpth + 1, $$cr),
() => this.matchobs_phrase_$0_3($$dpth + 1, $$cr),
])
}
public matchobs_phrase_$0_1(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_phrase_$0_1> {
return this.matchword($$dpth + 1, $$cr)
}
public matchobs_phrase_$0_2(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_phrase_$0_2> {
return this.regexAccept(String.raw`(?:.)`, '', $$dpth + 1, $$cr)
}
public matchobs_phrase_$0_3(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_phrase_$0_3> {
return this.matchCFWS($$dpth + 1, $$cr)
}
public matchFWS($$dpth: number, $$cr?: ErrorTracker): Nullable<FWS> {
return this.choice<FWS>([
() => this.matchFWS_1($$dpth + 1, $$cr),
() => this.matchFWS_2($$dpth + 1, $$cr),
])
}
public matchFWS_1($$dpth: number, $$cr?: ErrorTracker): Nullable<FWS_1> {
return this.run<FWS_1>($$dpth, () => {
let $$res: Nullable<FWS_1> = null
if (
true &&
(this.matchFWS_$0($$dpth + 1, $$cr) || true) &&
this.loopPlus<WSP>(() => this.matchWSP($$dpth + 1, $$cr)) !== null
) {
$$res = { kind: ASTKinds.FWS_1 }
}
return $$res
})
}
public matchFWS_2($$dpth: number, $$cr?: ErrorTracker): Nullable<FWS_2> {
return this.matchobs_FWS($$dpth + 1, $$cr)
}
public matchFWS_$0($$dpth: number, $$cr?: ErrorTracker): Nullable<FWS_$0> {
return this.run<FWS_$0>($$dpth, () => {
let $$res: Nullable<FWS_$0> = null
if (
true &&
this.loop<WSP>(() => this.matchWSP($$dpth + 1, $$cr), 0, -1) !== null &&
this.matchCRLF($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.FWS_$0 }
}
return $$res
})
}
public matchcomment($$dpth: number, $$cr?: ErrorTracker): Nullable<comment> {
return this.run<comment>($$dpth, () => {
let $$res: Nullable<comment> = null
if (
true &&
this.regexAccept(String.raw`(?:\()`, '', $$dpth + 1, $$cr) !== null &&
this.loop<comment_$0>(
() => this.matchcomment_$0($$dpth + 1, $$cr),
0,
-1,
) !== null &&
(this.matchFWS($$dpth + 1, $$cr) || true) &&
this.regexAccept(String.raw`(?:\))`, '', $$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.comment }
}
return $$res
})
}
public matchcomment_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<comment_$0> {
return this.run<comment_$0>($$dpth, () => {
let $$res: Nullable<comment_$0> = null
if (
true &&
(this.matchFWS($$dpth + 1, $$cr) || true) &&
this.matchccontent($$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.comment_$0 }
}
return $$res
})
}
public matchobs_route(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_route> {
return this.run<obs_route>($$dpth, () => {
let $$res: Nullable<obs_route> = null
if (
true &&
this.matchobs_domain_list($$dpth + 1, $$cr) !== null &&
this.regexAccept(String.raw`(?::)`, '', $$dpth + 1, $$cr) !== null
) {
$$res = { kind: ASTKinds.obs_route }
}
return $$res
})
}
public matchdot_atom_text(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<dot_atom_text> {
return this.run<dot_atom_text>($$dpth, () => {
let $$res: Nullable<dot_atom_text> = null
if (
true &&
this.loopPlus<atext>(() => this.matchatext($$dpth + 1, $$cr)) !==
null &&
this.loop<dot_atom_text_$0>(
() => this.matchdot_atom_text_$0($$dpth + 1, $$cr),
0,
-1,
) !== null
) {
$$res = { kind: ASTKinds.dot_atom_text }
}
return $$res
})
}
public matchdot_atom_text_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<dot_atom_text_$0> {
return this.run<dot_atom_text_$0>($$dpth, () => {
let $$res: Nullable<dot_atom_text_$0> = null
if (
true &&
this.regexAccept(String.raw`(?:\.)`, '', $$dpth + 1, $$cr) !== null &&
this.loopPlus<atext>(() => this.matchatext($$dpth + 1, $$cr)) !== null
) {
$$res = { kind: ASTKinds.dot_atom_text_$0 }
}
return $$res
})
}
public matchDQUOTE($$dpth: number, $$cr?: ErrorTracker): Nullable<DQUOTE> {
return this.regexAccept(String.raw`(?:\x22)`, '', $$dpth + 1, $$cr)
}
public matchqcontent(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<qcontent> {
return this.choice<qcontent>([
() => this.matchqcontent_1($$dpth + 1, $$cr),
() => this.matchqcontent_2($$dpth + 1, $$cr),
])
}
public matchqcontent_1(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<qcontent_1> {
return this.matchqtext($$dpth + 1, $$cr)
}
public matchqcontent_2(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<qcontent_2> {
return this.matchquoted_pair($$dpth + 1, $$cr)
}
public matchdtext($$dpth: number, $$cr?: ErrorTracker): Nullable<dtext> {
return this.choice<dtext>([
() => this.matchdtext_1($$dpth + 1, $$cr),
() => this.matchdtext_2($$dpth + 1, $$cr),
() => this.matchdtext_3($$dpth + 1, $$cr),
])
}
public matchdtext_1($$dpth: number, $$cr?: ErrorTracker): Nullable<dtext_1> {
return this.regexAccept(String.raw`(?:[\x21-\x5a])`, '', $$dpth + 1, $$cr)
}
public matchdtext_2($$dpth: number, $$cr?: ErrorTracker): Nullable<dtext_2> {
return this.regexAccept(String.raw`(?:[\x5e-\x7e])`, '', $$dpth + 1, $$cr)
}
public matchdtext_3($$dpth: number, $$cr?: ErrorTracker): Nullable<dtext_3> {
return this.matchobs_dtext($$dpth + 1, $$cr)
}
public matchatom($$dpth: number, $$cr?: ErrorTracker): Nullable<atom> {
return this.run<atom>($$dpth, () => {
let $$res: Nullable<atom> = null
if (
true &&
(this.matchCFWS($$dpth + 1, $$cr) || true) &&
this.loopPlus<atext>(() => this.matchatext($$dpth + 1, $$cr)) !==
null &&
(this.matchCFWS($$dpth + 1, $$cr) || true)
) {
$$res = { kind: ASTKinds.atom }
}
return $$res
})
}
public matchWSP($$dpth: number, $$cr?: ErrorTracker): Nullable<WSP> {
return this.choice<WSP>([
() => this.matchWSP_1($$dpth + 1, $$cr),
() => this.matchWSP_2($$dpth + 1, $$cr),
])
}
public matchWSP_1($$dpth: number, $$cr?: ErrorTracker): Nullable<WSP_1> {
return this.matchSP($$dpth + 1, $$cr)
}
public matchWSP_2($$dpth: number, $$cr?: ErrorTracker): Nullable<WSP_2> {
return this.matchHTAB($$dpth + 1, $$cr)
}
public matchobs_FWS($$dpth: number, $$cr?: ErrorTracker): Nullable<obs_FWS> {
return this.run<obs_FWS>($$dpth, () => {
let $$res: Nullable<obs_FWS> = null
if (
true &&
this.loopPlus<WSP>(() => this.matchWSP($$dpth + 1, $$cr)) !== null &&
this.loop<obs_FWS_$0>(
() => this.matchobs_FWS_$0($$dpth + 1, $$cr),
0,
-1,
) !== null
) {
$$res = { kind: ASTKinds.obs_FWS }
}
return $$res
})
}
public matchobs_FWS_$0(
$$dpth: number,
$$cr?: ErrorTracker,
): Nullable<obs_FWS_$0> {