aboutsummaryrefslogtreecommitdiffstats
path: root/src/state.rs
blob: 9e1e002e72478e5ac962a5deb161c1511faf803b (plain) (blame)
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
//! States of the state machine.

use crate::construct;
use crate::tokenizer::Tokenizer;
use alloc::string::{String, ToString};

/// Result of a state.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum State {
    /// Syntax error.
    ///
    /// Only used by MDX.
    Error(String),
    /// Move to [`Name`][] next.
    Next(Name),
    /// Retry in [`Name`][].
    Retry(Name),
    /// The state is successful.
    Ok,
    /// The state is not successful.
    Nok,
}

impl State {
    /// Turn a final state into a result.
    ///
    /// This doesn’t work on future states ([`State::Next`], [`State::Retry`]),
    /// or on an attempt ([`State::Nok`]).
    ///
    /// But it turns the final result into an error if crashed.
    pub fn to_result(&self) -> Result<(), String> {
        match self {
            State::Nok | State::Next(_) | State::Retry(_) => {
                unreachable!("cannot turn intermediate state into result")
            }
            State::Ok => Ok(()),
            State::Error(x) => Err(x.to_string()),
        }
    }
}

/// Names of states to move to.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[allow(clippy::enum_variant_names)]
pub enum Name {
    AttentionStart,
    AttentionInside,

    AutolinkStart,
    AutolinkOpen,
    AutolinkSchemeOrEmailAtext,
    AutolinkSchemeInsideOrEmailAtext,
    AutolinkUrlInside,
    AutolinkEmailAtSignOrDot,
    AutolinkEmailAtext,
    AutolinkEmailValue,
    AutolinkEmailLabel,

    BlankLineStart,
    BlankLineAfter,

    BlockQuoteStart,
    BlockQuoteContStart,
    BlockQuoteContBefore,
    BlockQuoteContAfter,

    BomStart,
    BomInside,

    CharacterEscapeStart,
    CharacterEscapeInside,

    CharacterReferenceStart,
    CharacterReferenceOpen,
    CharacterReferenceNumeric,
    CharacterReferenceValue,

    RawFlowStart,
    RawFlowBeforeSequenceOpen,
    RawFlowSequenceOpen,
    RawFlowInfoBefore,
    RawFlowInfo,
    RawFlowMetaBefore,
    RawFlowMeta,
    RawFlowAtNonLazyBreak,
    RawFlowCloseStart,
    RawFlowBeforeSequenceClose,
    RawFlowSequenceClose,
    RawFlowAfterSequenceClose,
    RawFlowContentBefore,
    RawFlowContentStart,
    RawFlowBeforeContentChunk,
    RawFlowContentChunk,
    RawFlowAfter,

    CodeIndentedStart,
    CodeIndentedAtBreak,
    CodeIndentedAfter,
    CodeIndentedFurtherStart,
    CodeIndentedInside,
    CodeIndentedFurtherBegin,
    CodeIndentedFurtherAfter,

    RawTextStart,
    RawTextSequenceOpen,
    RawTextBetween,
    RawTextData,
    RawTextSequenceClose,

    DataStart,
    DataInside,
    DataAtBreak,

    DefinitionStart,
    DefinitionBefore,
    DefinitionLabelAfter,
    DefinitionMarkerAfter,
    DefinitionDestinationBefore,
    DefinitionDestinationAfter,
    DefinitionDestinationMissing,
    DefinitionTitleBefore,
    DefinitionAfter,
    DefinitionAfterWhitespace,
    DefinitionTitleBeforeMarker,
    DefinitionTitleAfter,
    DefinitionTitleAfterOptionalWhitespace,

    DestinationStart,
    DestinationEnclosedBefore,
    DestinationEnclosed,
    DestinationEnclosedEscape,
    DestinationRaw,
    DestinationRawEscape,

    DocumentStart,
    DocumentBeforeFrontmatter,
    DocumentContainerExistingBefore,
    DocumentContainerExistingAfter,
    DocumentContainerNewBefore,
    DocumentContainerNewBeforeNotBlockQuote,
    DocumentContainerNewBeforeNotList,
    DocumentContainerNewBeforeNotGfmFootnoteDefinition,
    DocumentContainerNewAfter,
    DocumentContainersAfter,
    DocumentFlowInside,
    DocumentFlowEnd,

    FlowStart,
    FlowBeforeGfmTable,
    FlowBeforeCodeIndented,
    FlowBeforeRaw,
    FlowBeforeHtml,
    FlowBeforeHeadingAtx,
    FlowBeforeHeadingSetext,
    FlowBeforeThematicBreak,
    FlowBeforeDefinition,
    FlowAfter,
    FlowBlankLineBefore,
    FlowBlankLineAfter,
    FlowBeforeParagraph,

    FrontmatterStart,
    FrontmatterOpenSequence,
    FrontmatterOpenAfter,
    FrontmatterAfter,
    FrontmatterContentStart,
    FrontmatterContentInside,
    FrontmatterContentEnd,
    FrontmatterCloseStart,
    FrontmatterCloseSequence,
    FrontmatterCloseAfter,

    GfmFootnoteDefinitionStart,
    GfmFootnoteDefinitionLabelBefore,
    GfmFootnoteDefinitionLabelAfter,
    GfmFootnoteDefinitionWhitespaceAfter,
    GfmFootnoteDefinitionContStart,
    GfmFootnoteDefinitionContBlank,
    GfmFootnoteDefinitionContFilled,

    GfmLabelStartFootnoteStart,
    GfmLabelStartFootnoteOpen,

    GfmTaskListItemCheckStart,
    GfmTaskListItemCheckInside,
    GfmTaskListItemCheckClose,
    GfmTaskListItemCheckAfter,
    GfmTaskListItemCheckAfterSpaceOrTab,

    HardBreakEscapeStart,
    HardBreakEscapeAfter,

    HeadingAtxStart,
    HeadingAtxBefore,
    HeadingAtxSequenceOpen,
    HeadingAtxAtBreak,
    HeadingAtxSequenceFurther,
    HeadingAtxData,

    HeadingSetextStart,
    HeadingSetextBefore,
    HeadingSetextInside,
    HeadingSetextAfter,

    HtmlFlowStart,
    HtmlFlowBefore,
    HtmlFlowOpen,
    HtmlFlowDeclarationOpen,
    HtmlFlowCommentOpenInside,
    HtmlFlowCdataOpenInside,
    HtmlFlowTagCloseStart,
    HtmlFlowTagName,
    HtmlFlowBasicSelfClosing,
    HtmlFlowCompleteClosingTagAfter,
    HtmlFlowCompleteEnd,
    HtmlFlowCompleteAttributeNameBefore,
    HtmlFlowCompleteAttributeName,
    HtmlFlowCompleteAttributeNameAfter,
    HtmlFlowCompleteAttributeValueBefore,
    HtmlFlowCompleteAttributeValueQuoted,
    HtmlFlowCompleteAttributeValueQuotedAfter,
    HtmlFlowCompleteAttributeValueUnquoted,
    HtmlFlowCompleteAfter,
    HtmlFlowBlankLineBefore,
    HtmlFlowContinuation,
    HtmlFlowContinuationDeclarationInside,
    HtmlFlowContinuationAfter,
    HtmlFlowContinuationStart,
    HtmlFlowContinuationBefore,
    HtmlFlowContinuationCommentInside,
    HtmlFlowContinuationRawTagOpen,
    HtmlFlowContinuationRawEndTag,
    HtmlFlowContinuationClose,
    HtmlFlowContinuationCdataInside,
    HtmlFlowContinuationStartNonLazy,

    HtmlTextStart,
    HtmlTextOpen,
    HtmlTextDeclarationOpen,
    HtmlTextTagCloseStart,
    HtmlTextTagClose,
    HtmlTextTagCloseBetween,
    HtmlTextTagOpen,
    HtmlTextTagOpenBetween,
    HtmlTextTagOpenAttributeName,
    HtmlTextTagOpenAttributeNameAfter,
    HtmlTextTagOpenAttributeValueBefore,
    HtmlTextTagOpenAttributeValueQuoted,
    HtmlTextTagOpenAttributeValueQuotedAfter,
    HtmlTextTagOpenAttributeValueUnquoted,
    HtmlTextCdata,
    HtmlTextCdataOpenInside,
    HtmlTextCdataClose,
    HtmlTextCdataEnd,
    HtmlTextCommentOpenInside,
    HtmlTextCommentStart,
    HtmlTextCommentStartDash,
    HtmlTextComment,
    HtmlTextCommentClose,
    HtmlTextDeclaration,
    HtmlTextEnd,
    HtmlTextInstruction,
    HtmlTextInstructionClose,
    HtmlTextLineEndingBefore,
    HtmlTextLineEndingAfter,
    HtmlTextLineEndingAfterPrefix,

    LabelStart,
    LabelAtMarker,
    LabelAtBreak,
    LabelEolAfter,
    LabelAtBlankLine,
    LabelEscape,
    LabelInside,

    LabelEndStart,
    LabelEndAfter,
    LabelEndResourceStart,
    LabelEndResourceBefore,
    LabelEndResourceOpen,
    LabelEndResourceDestinationAfter,
    LabelEndResourceDestinationMissing,
    LabelEndResourceBetween,
    LabelEndResourceTitleAfter,
    LabelEndResourceEnd,
    LabelEndOk,
    LabelEndNok,
    LabelEndReferenceFull,
    LabelEndReferenceFullAfter,
    LabelEndReferenceNotFull,
    LabelEndReferenceCollapsed,
    LabelEndReferenceCollapsedOpen,

    LabelStartImageStart,
    LabelStartImageOpen,
    LabelStartImageAfter,

    LabelStartLinkStart,

    ListItemStart,
    ListItemBefore,
    ListItemBeforeOrdered,
    ListItemBeforeUnordered,
    ListItemValue,
    ListItemMarker,
    ListItemMarkerAfter,
    ListItemAfter,
    ListItemMarkerAfterFilled,
    ListItemWhitespace,
    ListItemPrefixOther,
    ListItemWhitespaceAfter,
    ListItemContStart,
    ListItemContBlank,
    ListItemContFilled,

    NonLazyContinuationStart,
    NonLazyContinuationAfter,

    ParagraphStart,
    ParagraphInside,

    SpaceOrTabStart,
    SpaceOrTabInside,
    SpaceOrTabAfter,

    SpaceOrTabEolStart,
    SpaceOrTabEolAfterFirst,
    SpaceOrTabEolAfterEol,
    SpaceOrTabEolAtEol,
    SpaceOrTabEolAfterMore,

    StringStart,
    StringBefore,
    StringBeforeData,

    GfmAutolinkLiteralProtocolStart,
    GfmAutolinkLiteralProtocolAfter,
    GfmAutolinkLiteralProtocolPrefixInside,
    GfmAutolinkLiteralProtocolSlashesInside,

    GfmAutolinkLiteralWwwStart,
    GfmAutolinkLiteralWwwAfter,
    GfmAutolinkLiteralWwwPrefixInside,
    GfmAutolinkLiteralWwwPrefixAfter,

    GfmAutolinkLiteralDomainInside,
    GfmAutolinkLiteralDomainAtPunctuation,
    GfmAutolinkLiteralDomainAfter,

    GfmAutolinkLiteralPathInside,
    GfmAutolinkLiteralPathAtPunctuation,
    GfmAutolinkLiteralPathAfter,

    GfmAutolinkLiteralTrail,
    GfmAutolinkLiteralTrailCharRefInside,
    GfmAutolinkLiteralTrailCharRefStart,
    GfmAutolinkLiteralTrailBracketAfter,

    GfmTableStart,
    GfmTableHeadRowBefore,
    GfmTableHeadRowStart,
    GfmTableHeadRowBreak,
    GfmTableHeadRowData,
    GfmTableHeadRowEscape,
    GfmTableHeadDelimiterStart,
    GfmTableHeadDelimiterBefore,
    GfmTableHeadDelimiterCellBefore,
    GfmTableHeadDelimiterValueBefore,
    GfmTableHeadDelimiterLeftAlignmentAfter,
    GfmTableHeadDelimiterFiller,
    GfmTableHeadDelimiterRightAlignmentAfter,
    GfmTableHeadDelimiterCellAfter,
    GfmTableHeadDelimiterNok,

    GfmTableBodyRowBefore,
    GfmTableBodyRowStart,
    GfmTableBodyRowBreak,
    GfmTableBodyRowData,
    GfmTableBodyRowEscape,

    TextStart,
    TextBefore,
    TextBeforeHtml,
    TextBeforeMdxJsx,
    TextBeforeHardBreakEscape,
    TextBeforeLabelStartLink,
    TextBeforeData,

    ThematicBreakStart,
    ThematicBreakBefore,
    ThematicBreakSequence,
    ThematicBreakAtBreak,

    TitleStart,
    TitleBegin,
    TitleAfterEol,
    TitleAtBreak,
    TitleAtBlankLine,
    TitleEscape,
    TitleInside,

    // To do: sort.
    MdxJsxTextStart,
    MdxJsxTextAfter,
    MdxJsxTextNok,
    MdxJsxEsWhitespaceStart,
    MdxJsxEsWhitespaceInside,
    MdxJsxStart,
    MdxJsxStartAfter,
    MdxJsxNameBefore,
    MdxJsxClosingTagNameBefore,
    MdxJsxTagEnd,
    MdxJsxPrimaryName,
    MdxJsxPrimaryNameAfter,
    MdxJsxMemberNameBefore,
    MdxJsxMemberName,
    MdxJsxMemberNameAfter,
    MdxJsxLocalNameBefore,
    MdxJsxLocalName,
    MdxJsxLocalNameAfter,
    MdxJsxAttributeBefore,
    MdxJsxSelfClosing,
    MdxJsxAttributePrimaryName,
    MdxJsxAttributePrimaryNameAfter,
    MdxJsxAttributeLocalNameBefore,
    MdxJsxAttributeLocalName,
    MdxJsxAttributeLocalNameAfter,
    MdxJsxAttributeValueBefore,
    MdxJsxAttributeValueQuotedStart,
    MdxJsxAttributeValueQuoted,
}

#[allow(clippy::too_many_lines)]
/// Call the corresponding state for a state name.
pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State {
    let func = match name {
        // To do: sort.
        Name::MdxJsxTextStart => construct::mdx_jsx_text::start,
        Name::MdxJsxTextAfter => construct::mdx_jsx_text::after,
        Name::MdxJsxTextNok => construct::mdx_jsx_text::nok,
        Name::MdxJsxEsWhitespaceStart => construct::partial_mdx_jsx::es_whitespace_start,
        Name::MdxJsxEsWhitespaceInside => construct::partial_mdx_jsx::es_whitespace_inside,
        Name::MdxJsxStart => construct::partial_mdx_jsx::start,
        Name::MdxJsxStartAfter => construct::partial_mdx_jsx::start_after,
        Name::MdxJsxNameBefore => construct::partial_mdx_jsx::name_before,
        Name::MdxJsxClosingTagNameBefore => construct::partial_mdx_jsx::closing_tag_name_before,
        Name::MdxJsxTagEnd => construct::partial_mdx_jsx::tag_end,
        Name::MdxJsxPrimaryName => construct::partial_mdx_jsx::primary_name,
        Name::MdxJsxPrimaryNameAfter => construct::partial_mdx_jsx::primary_name_after,
        Name::MdxJsxMemberNameBefore => construct::partial_mdx_jsx::member_name_before,
        Name::MdxJsxMemberName => construct::partial_mdx_jsx::member_name,
        Name::MdxJsxMemberNameAfter => construct::partial_mdx_jsx::member_name_after,
        Name::MdxJsxLocalNameBefore => construct::partial_mdx_jsx::local_name_before,
        Name::MdxJsxLocalName => construct::partial_mdx_jsx::local_name,
        Name::MdxJsxLocalNameAfter => construct::partial_mdx_jsx::local_name_after,
        Name::MdxJsxAttributeBefore => construct::partial_mdx_jsx::attribute_before,
        Name::MdxJsxSelfClosing => construct::partial_mdx_jsx::self_closing,
        Name::MdxJsxAttributePrimaryName => construct::partial_mdx_jsx::attribute_primary_name,
        Name::MdxJsxAttributePrimaryNameAfter => {
            construct::partial_mdx_jsx::attribute_primary_name_after
        }
        Name::MdxJsxAttributeLocalNameBefore => {
            construct::partial_mdx_jsx::attribute_local_name_before
        }
        Name::MdxJsxAttributeLocalName => construct::partial_mdx_jsx::attribute_local_name,
        Name::MdxJsxAttributeLocalNameAfter => construct::partial_mdx_jsx::attribute_local_name_after,
        Name::MdxJsxAttributeValueBefore => construct::partial_mdx_jsx::attribute_value_before,
        Name::MdxJsxAttributeValueQuotedStart => {
            construct::partial_mdx_jsx::attribute_value_quoted_start
        }
        Name::MdxJsxAttributeValueQuoted => construct::partial_mdx_jsx::attribute_value_quoted,

        Name::AttentionStart => construct::attention::start,
        Name::AttentionInside => construct::attention::inside,

        Name::AutolinkStart => construct::autolink::start,
        Name::AutolinkOpen => construct::autolink::open,
        Name::AutolinkSchemeOrEmailAtext => construct::autolink::scheme_or_email_atext,
        Name::AutolinkSchemeInsideOrEmailAtext => construct::autolink::scheme_inside_or_email_atext,
        Name::AutolinkUrlInside => construct::autolink::url_inside,
        Name::AutolinkEmailAtSignOrDot => construct::autolink::email_at_sign_or_dot,
        Name::AutolinkEmailAtext => construct::autolink::email_atext,
        Name::AutolinkEmailValue => construct::autolink::email_value,
        Name::AutolinkEmailLabel => construct::autolink::email_label,

        Name::BlankLineStart => construct::blank_line::start,
        Name::BlankLineAfter => construct::blank_line::after,

        Name::BlockQuoteStart => construct::block_quote::start,
        Name::BlockQuoteContStart => construct::block_quote::cont_start,
        Name::BlockQuoteContBefore => construct::block_quote::cont_before,
        Name::BlockQuoteContAfter => construct::block_quote::cont_after,

        Name::BomStart => construct::partial_bom::start,
        Name::BomInside => construct::partial_bom::inside,

        Name::CharacterEscapeStart => construct::character_escape::start,
        Name::CharacterEscapeInside => construct::character_escape::inside,

        Name::CharacterReferenceStart => construct::character_reference::start,
        Name::CharacterReferenceOpen => construct::character_reference::open,
        Name::CharacterReferenceNumeric => construct::character_reference::numeric,
        Name::CharacterReferenceValue => construct::character_reference::value,

        Name::RawFlowStart => construct::raw_flow::start,
        Name::RawFlowBeforeSequenceOpen => construct::raw_flow::before_sequence_open,
        Name::RawFlowSequenceOpen => construct::raw_flow::sequence_open,
        Name::RawFlowInfoBefore => construct::raw_flow::info_before,
        Name::RawFlowInfo => construct::raw_flow::info,
        Name::RawFlowMetaBefore => construct::raw_flow::meta_before,
        Name::RawFlowMeta => construct::raw_flow::meta,
        Name::RawFlowAtNonLazyBreak => construct::raw_flow::at_non_lazy_break,
        Name::RawFlowCloseStart => construct::raw_flow::close_start,
        Name::RawFlowBeforeSequenceClose => construct::raw_flow::before_sequence_close,
        Name::RawFlowSequenceClose => construct::raw_flow::sequence_close,
        Name::RawFlowAfterSequenceClose => construct::raw_flow::sequence_close_after,
        Name::RawFlowContentBefore => construct::raw_flow::content_before,
        Name::RawFlowContentStart => construct::raw_flow::content_start,
        Name::RawFlowBeforeContentChunk => construct::raw_flow::before_content_chunk,
        Name::RawFlowContentChunk => construct::raw_flow::content_chunk,
        Name::RawFlowAfter => construct::raw_flow::after,

        Name::CodeIndentedStart => construct::code_indented::start,
        Name::CodeIndentedAtBreak => construct::code_indented::at_break,
        Name::CodeIndentedAfter => construct::code_indented::after,
        Name::CodeIndentedFurtherStart => construct::code_indented::further_start,
        Name::CodeIndentedInside => construct::code_indented::inside,
        Name::CodeIndentedFurtherBegin => construct::code_indented::further_begin,
        Name::CodeIndentedFurtherAfter => construct::code_indented::further_after,

        Name::RawTextStart => construct::raw_text::start,
        Name::RawTextSequenceOpen => construct::raw_text::sequence_open,
        Name::RawTextBetween => construct::raw_text::between,
        Name::RawTextData => construct::raw_text::data,
        Name::RawTextSequenceClose => construct::raw_text::sequence_close,

        Name::DataStart => construct::partial_data::start,
        Name::DataInside => construct::partial_data::inside,
        Name::DataAtBreak => construct::partial_data::at_break,

        Name::DefinitionStart => construct::definition::start,
        Name::DefinitionBefore => construct::definition::before,
        Name::DefinitionLabelAfter => construct::definition::label_after,
        Name::DefinitionMarkerAfter => construct::definition::marker_after,
        Name::DefinitionDestinationBefore => construct::definition::destination_before,
        Name::DefinitionDestinationAfter => construct::definition::destination_after,
        Name::DefinitionDestinationMissing => construct::definition::destination_missing,
        Name::DefinitionTitleBefore => construct::definition::title_before,
        Name::DefinitionAfter => construct::definition::after,
        Name::DefinitionAfterWhitespace => construct::definition::after_whitespace,
        Name::DefinitionTitleBeforeMarker => construct::definition::title_before_marker,
        Name::DefinitionTitleAfter => construct::definition::title_after,
        Name::DefinitionTitleAfterOptionalWhitespace => {
            construct::definition::title_after_optional_whitespace
        }

        Name::DestinationStart => construct::partial_destination::start,
        Name::DestinationEnclosedBefore => construct::partial_destination::enclosed_before,
        Name::DestinationEnclosed => construct::partial_destination::enclosed,
        Name::DestinationEnclosedEscape => construct::partial_destination::enclosed_escape,
        Name::DestinationRaw => construct::partial_destination::raw,
        Name::DestinationRawEscape => construct::partial_destination::raw_escape,

        Name::DocumentStart => construct::document::start,
        Name::DocumentBeforeFrontmatter => construct::document::before_frontmatter,
        Name::DocumentContainerExistingBefore => construct::document::container_existing_before,
        Name::DocumentContainerExistingAfter => construct::document::container_existing_after,
        Name::DocumentContainerNewBefore => construct::document::container_new_before,
        Name::DocumentContainerNewBeforeNotBlockQuote => {
            construct::document::container_new_before_not_block_quote
        }
        Name::DocumentContainerNewBeforeNotList => {
            construct::document::container_new_before_not_list
        }
        Name::DocumentContainerNewBeforeNotGfmFootnoteDefinition => {
            construct::document::container_new_before_not_footnote_definition
        }
        Name::DocumentContainerNewAfter => construct::document::container_new_after,
        Name::DocumentContainersAfter => construct::document::containers_after,
        Name::DocumentFlowEnd => construct::document::flow_end,
        Name::DocumentFlowInside => construct::document::flow_inside,

        Name::FlowStart => construct::flow::start,
        Name::FlowBeforeGfmTable => construct::flow::before_gfm_table,
        Name::FlowBeforeCodeIndented => construct::flow::before_code_indented,
        Name::FlowBeforeRaw => construct::flow::before_raw,
        Name::FlowBeforeHtml => construct::flow::before_html,
        Name::FlowBeforeHeadingAtx => construct::flow::before_heading_atx,
        Name::FlowBeforeHeadingSetext => construct::flow::before_heading_setext,
        Name::FlowBeforeThematicBreak => construct::flow::before_thematic_break,
        Name::FlowBeforeDefinition => construct::flow::before_definition,
        Name::FlowAfter => construct::flow::after,
        Name::FlowBlankLineBefore => construct::flow::blank_line_before,
        Name::FlowBlankLineAfter => construct::flow::blank_line_after,
        Name::FlowBeforeParagraph => construct::flow::before_paragraph,

        Name::FrontmatterStart => construct::frontmatter::start,
        Name::FrontmatterOpenSequence => construct::frontmatter::open_sequence,
        Name::FrontmatterOpenAfter => construct::frontmatter::open_after,
        Name::FrontmatterAfter => construct::frontmatter::after,
        Name::FrontmatterContentStart => construct::frontmatter::content_start,
        Name::FrontmatterContentInside => construct::frontmatter::content_inside,
        Name::FrontmatterContentEnd => construct::frontmatter::content_end,
        Name::FrontmatterCloseStart => construct::frontmatter::close_start,
        Name::FrontmatterCloseSequence => construct::frontmatter::close_sequence,
        Name::FrontmatterCloseAfter => construct::frontmatter::close_after,

        Name::GfmFootnoteDefinitionStart => construct::gfm_footnote_definition::start,
        Name::GfmFootnoteDefinitionLabelBefore => construct::gfm_footnote_definition::label_before,
        Name::GfmFootnoteDefinitionLabelAfter => construct::gfm_footnote_definition::label_after,
        Name::GfmFootnoteDefinitionWhitespaceAfter => {
            construct::gfm_footnote_definition::whitespace_after
        }
        Name::GfmFootnoteDefinitionContStart => construct::gfm_footnote_definition::cont_start,
        Name::GfmFootnoteDefinitionContBlank => construct::gfm_footnote_definition::cont_blank,
        Name::GfmFootnoteDefinitionContFilled => construct::gfm_footnote_definition::cont_filled,

        Name::GfmLabelStartFootnoteStart => construct::gfm_label_start_footnote::start,
        Name::GfmLabelStartFootnoteOpen => construct::gfm_label_start_footnote::open,

        Name::GfmTaskListItemCheckStart => construct::gfm_task_list_item_check::start,
        Name::GfmTaskListItemCheckInside => construct::gfm_task_list_item_check::inside,
        Name::GfmTaskListItemCheckClose => construct::gfm_task_list_item_check::close,
        Name::GfmTaskListItemCheckAfter => construct::gfm_task_list_item_check::after,
        Name::GfmTaskListItemCheckAfterSpaceOrTab => {
            construct::gfm_task_list_item_check::after_space_or_tab
        }

        Name::HardBreakEscapeStart => construct::hard_break_escape::start,
        Name::HardBreakEscapeAfter => construct::hard_break_escape::after,

        Name::HeadingAtxStart => construct::heading_atx::start,
        Name::HeadingAtxBefore => construct::heading_atx::before,
        Name::HeadingAtxSequenceOpen => construct::heading_atx::sequence_open,
        Name::HeadingAtxAtBreak => construct::heading_atx::at_break,
        Name::HeadingAtxSequenceFurther => construct::heading_atx::sequence_further,
        Name::HeadingAtxData => construct::heading_atx::data,

        Name::HeadingSetextStart => construct::heading_setext::start,
        Name::HeadingSetextBefore => construct::heading_setext::before,
        Name::HeadingSetextInside => construct::heading_setext::inside,
        Name::HeadingSetextAfter => construct::heading_setext::after,

        Name::HtmlFlowStart => construct::html_flow::start,
        Name::HtmlFlowBefore => construct::html_flow::before,
        Name::HtmlFlowOpen => construct::html_flow::open,
        Name::HtmlFlowDeclarationOpen => construct::html_flow::declaration_open,
        Name::HtmlFlowCommentOpenInside => construct::html_flow::comment_open_inside,
        Name::HtmlFlowCdataOpenInside => construct::html_flow::cdata_open_inside,
        Name::HtmlFlowTagCloseStart => construct::html_flow::tag_close_start,
        Name::HtmlFlowTagName => construct::html_flow::tag_name,
        Name::HtmlFlowBasicSelfClosing => construct::html_flow::basic_self_closing,
        Name::HtmlFlowCompleteClosingTagAfter => construct::html_flow::complete_closing_tag_after,
        Name::HtmlFlowCompleteEnd => construct::html_flow::complete_end,
        Name::HtmlFlowCompleteAttributeNameBefore => {
            construct::html_flow::complete_attribute_name_before
        }
        Name::HtmlFlowCompleteAttributeName => construct::html_flow::complete_attribute_name,
        Name::HtmlFlowCompleteAttributeNameAfter => {
            construct::html_flow::complete_attribute_name_after
        }
        Name::HtmlFlowCompleteAttributeValueBefore => {
            construct::html_flow::complete_attribute_value_before
        }
        Name::HtmlFlowCompleteAttributeValueQuoted => {
            construct::html_flow::complete_attribute_value_quoted
        }
        Name::HtmlFlowCompleteAttributeValueQuotedAfter => {
            construct::html_flow::complete_attribute_value_quoted_after
        }
        Name::HtmlFlowCompleteAttributeValueUnquoted => {
            construct::html_flow::complete_attribute_value_unquoted
        }
        Name::HtmlFlowCompleteAfter => construct::html_flow::complete_after,
        Name::HtmlFlowBlankLineBefore => construct::html_flow::blank_line_before,
        Name::HtmlFlowContinuation => construct::html_flow::continuation,
        Name::HtmlFlowContinuationDeclarationInside => {
            construct::html_flow::continuation_declaration_inside
        }
        Name::HtmlFlowContinuationAfter => construct::html_flow::continuation_after,
        Name::HtmlFlowContinuationStart => construct::html_flow::continuation_start,
        Name::HtmlFlowContinuationBefore => construct::html_flow::continuation_before,
        Name::HtmlFlowContinuationCommentInside => {
            construct::html_flow::continuation_comment_inside
        }
        Name::HtmlFlowContinuationRawTagOpen => construct::html_flow::continuation_raw_tag_open,
        Name::HtmlFlowContinuationRawEndTag => construct::html_flow::continuation_raw_end_tag,
        Name::HtmlFlowContinuationClose => construct::html_flow::continuation_close,
        Name::HtmlFlowContinuationCdataInside => construct::html_flow::continuation_cdata_inside,
        Name::HtmlFlowContinuationStartNonLazy => construct::html_flow::continuation_start_non_lazy,

        Name::HtmlTextStart => construct::html_text::start,
        Name::HtmlTextOpen => construct::html_text::open,
        Name::HtmlTextDeclarationOpen => construct::html_text::declaration_open,
        Name::HtmlTextTagCloseStart => construct::html_text::tag_close_start,
        Name::HtmlTextTagClose => construct::html_text::tag_close,
        Name::HtmlTextTagCloseBetween => construct::html_text::tag_close_between,
        Name::HtmlTextTagOpen => construct::html_text::tag_open,
        Name::HtmlTextTagOpenBetween => construct::html_text::tag_open_between,
        Name::HtmlTextTagOpenAttributeName => construct::html_text::tag_open_attribute_name,
        Name::HtmlTextTagOpenAttributeNameAfter => {
            construct::html_text::tag_open_attribute_name_after
        }
        Name::HtmlTextTagOpenAttributeValueBefore => {
            construct::html_text::tag_open_attribute_value_before
        }
        Name::HtmlTextTagOpenAttributeValueQuoted => {
            construct::html_text::tag_open_attribute_value_quoted
        }
        Name::HtmlTextTagOpenAttributeValueQuotedAfter => {
            construct::html_text::tag_open_attribute_value_quoted_after
        }
        Name::HtmlTextTagOpenAttributeValueUnquoted => {
            construct::html_text::tag_open_attribute_value_unquoted
        }
        Name::HtmlTextCdata => construct::html_text::cdata,
        Name::HtmlTextCdataOpenInside => construct::html_text::cdata_open_inside,
        Name::HtmlTextCdataClose => construct::html_text::cdata_close,
        Name::HtmlTextCdataEnd => construct::html_text::cdata_end,
        Name::HtmlTextCommentOpenInside => construct::html_text::comment_open_inside,
        Name::HtmlTextCommentStart => construct::html_text::comment_start,
        Name::HtmlTextCommentStartDash => construct::html_text::comment_start_dash,
        Name::HtmlTextComment => construct::html_text::comment,
        Name::HtmlTextCommentClose => construct::html_text::comment_close,
        Name::HtmlTextDeclaration => construct::html_text::declaration,
        Name::HtmlTextEnd => construct::html_text::end,
        Name::HtmlTextInstruction => construct::html_text::instruction,
        Name::HtmlTextInstructionClose => construct::html_text::instruction_close,
        Name::HtmlTextLineEndingBefore => construct::html_text::line_ending_before,
        Name::HtmlTextLineEndingAfter => construct::html_text::line_ending_after,
        Name::HtmlTextLineEndingAfterPrefix => construct::html_text::line_ending_after_prefix,

        Name::LabelStart => construct::partial_label::start,
        Name::LabelAtMarker => construct::partial_label::at_marker,
        Name::LabelAtBreak => construct::partial_label::at_break,
        Name::LabelEolAfter => construct::partial_label::eol_after,
        Name::LabelAtBlankLine => construct::partial_label::at_blank_line,
        Name::LabelEscape => construct::partial_label::escape,
        Name::LabelInside => construct::partial_label::inside,

        Name::LabelEndStart => construct::label_end::start,
        Name::LabelEndAfter => construct::label_end::after,
        Name::LabelEndResourceStart => construct::label_end::resource_start,
        Name::LabelEndResourceBefore => construct::label_end::resource_before,
        Name::LabelEndResourceOpen => construct::label_end::resource_open,
        Name::LabelEndResourceDestinationAfter => construct::label_end::resource_destination_after,
        Name::LabelEndResourceDestinationMissing => {
            construct::label_end::resource_destination_missing
        }
        Name::LabelEndResourceBetween => construct::label_end::resource_between,
        Name::LabelEndResourceTitleAfter => construct::label_end::resource_title_after,
        Name::LabelEndResourceEnd => construct::label_end::resource_end,
        Name::LabelEndOk => construct::label_end::ok,
        Name::LabelEndNok => construct::label_end::nok,
        Name::LabelEndReferenceFull => construct::label_end::reference_full,
        Name::LabelEndReferenceFullAfter => construct::label_end::reference_full_after,
        Name::LabelEndReferenceNotFull => construct::label_end::reference_not_full,
        Name::LabelEndReferenceCollapsed => construct::label_end::reference_collapsed,
        Name::LabelEndReferenceCollapsedOpen => construct::label_end::reference_collapsed_open,

        Name::LabelStartImageStart => construct::label_start_image::start,
        Name::LabelStartImageOpen => construct::label_start_image::open,
        Name::LabelStartImageAfter => construct::label_start_image::after,
        Name::LabelStartLinkStart => construct::label_start_link::start,

        Name::ListItemStart => construct::list_item::start,
        Name::ListItemBefore => construct::list_item::before,
        Name::ListItemBeforeOrdered => construct::list_item::before_ordered,
        Name::ListItemBeforeUnordered => construct::list_item::before_unordered,
        Name::ListItemValue => construct::list_item::value,
        Name::ListItemMarker => construct::list_item::marker,
        Name::ListItemMarkerAfter => construct::list_item::marker_after,
        Name::ListItemAfter => construct::list_item::after,
        Name::ListItemMarkerAfterFilled => construct::list_item::marker_after_filled,
        Name::ListItemWhitespace => construct::list_item::whitespace,
        Name::ListItemWhitespaceAfter => construct::list_item::whitespace_after,
        Name::ListItemPrefixOther => construct::list_item::prefix_other,
        Name::ListItemContStart => construct::list_item::cont_start,
        Name::ListItemContBlank => construct::list_item::cont_blank,
        Name::ListItemContFilled => construct::list_item::cont_filled,

        Name::NonLazyContinuationStart => construct::partial_non_lazy_continuation::start,
        Name::NonLazyContinuationAfter => construct::partial_non_lazy_continuation::after,

        Name::ParagraphStart => construct::paragraph::start,
        Name::ParagraphInside => construct::paragraph::inside,

        Name::SpaceOrTabStart => construct::partial_space_or_tab::start,
        Name::SpaceOrTabInside => construct::partial_space_or_tab::inside,
        Name::SpaceOrTabAfter => construct::partial_space_or_tab::after,

        Name::SpaceOrTabEolStart => construct::partial_space_or_tab_eol::start,
        Name::SpaceOrTabEolAfterFirst => construct::partial_space_or_tab_eol::after_first,
        Name::SpaceOrTabEolAfterEol => construct::partial_space_or_tab_eol::after_eol,
        Name::SpaceOrTabEolAtEol => construct::partial_space_or_tab_eol::at_eol,
        Name::SpaceOrTabEolAfterMore => construct::partial_space_or_tab_eol::after_more,

        Name::StringStart => construct::string::start,
        Name::StringBefore => construct::string::before,
        Name::StringBeforeData => construct::string::before_data,

        Name::GfmAutolinkLiteralProtocolStart => construct::gfm_autolink_literal::protocol_start,
        Name::GfmAutolinkLiteralProtocolAfter => construct::gfm_autolink_literal::protocol_after,
        Name::GfmAutolinkLiteralProtocolPrefixInside => {
            construct::gfm_autolink_literal::protocol_prefix_inside
        }
        Name::GfmAutolinkLiteralProtocolSlashesInside => {
            construct::gfm_autolink_literal::protocol_slashes_inside
        }

        Name::GfmAutolinkLiteralWwwAfter => construct::gfm_autolink_literal::www_after,
        Name::GfmAutolinkLiteralWwwStart => construct::gfm_autolink_literal::www_start,
        Name::GfmAutolinkLiteralWwwPrefixInside => {
            construct::gfm_autolink_literal::www_prefix_inside
        }
        Name::GfmAutolinkLiteralWwwPrefixAfter => construct::gfm_autolink_literal::www_prefix_after,
        Name::GfmAutolinkLiteralDomainInside => construct::gfm_autolink_literal::domain_inside,
        Name::GfmAutolinkLiteralDomainAtPunctuation => {
            construct::gfm_autolink_literal::domain_at_punctuation
        }
        Name::GfmAutolinkLiteralDomainAfter => construct::gfm_autolink_literal::domain_after,

        Name::GfmAutolinkLiteralPathInside => construct::gfm_autolink_literal::path_inside,
        Name::GfmAutolinkLiteralPathAtPunctuation => {
            construct::gfm_autolink_literal::path_at_punctuation
        }
        Name::GfmAutolinkLiteralPathAfter => construct::gfm_autolink_literal::path_after,
        Name::GfmAutolinkLiteralTrail => construct::gfm_autolink_literal::trail,
        Name::GfmAutolinkLiteralTrailCharRefStart => {
            construct::gfm_autolink_literal::trail_char_ref_start
        }
        Name::GfmAutolinkLiteralTrailCharRefInside => {
            construct::gfm_autolink_literal::trail_char_ref_inside
        }
        Name::GfmAutolinkLiteralTrailBracketAfter => {
            construct::gfm_autolink_literal::trail_bracket_after
        }

        Name::GfmTableStart => construct::gfm_table::start,
        Name::GfmTableHeadRowBefore => construct::gfm_table::head_row_before,
        Name::GfmTableHeadRowStart => construct::gfm_table::head_row_start,
        Name::GfmTableHeadRowBreak => construct::gfm_table::head_row_break,
        Name::GfmTableHeadRowData => construct::gfm_table::head_row_data,
        Name::GfmTableHeadRowEscape => construct::gfm_table::head_row_escape,

        Name::GfmTableHeadDelimiterStart => construct::gfm_table::head_delimiter_start,
        Name::GfmTableHeadDelimiterBefore => construct::gfm_table::head_delimiter_before,
        Name::GfmTableHeadDelimiterCellBefore => construct::gfm_table::head_delimiter_cell_before,
        Name::GfmTableHeadDelimiterValueBefore => construct::gfm_table::head_delimiter_value_before,
        Name::GfmTableHeadDelimiterLeftAlignmentAfter => {
            construct::gfm_table::head_delimiter_left_alignment_after
        }
        Name::GfmTableHeadDelimiterFiller => construct::gfm_table::head_delimiter_filler,
        Name::GfmTableHeadDelimiterRightAlignmentAfter => {
            construct::gfm_table::head_delimiter_right_alignment_after
        }
        Name::GfmTableHeadDelimiterCellAfter => construct::gfm_table::head_delimiter_cell_after,
        Name::GfmTableHeadDelimiterNok => construct::gfm_table::head_delimiter_nok,

        Name::GfmTableBodyRowBefore => construct::gfm_table::body_row_before,
        Name::GfmTableBodyRowStart => construct::gfm_table::body_row_start,
        Name::GfmTableBodyRowBreak => construct::gfm_table::body_row_break,
        Name::GfmTableBodyRowData => construct::gfm_table::body_row_data,
        Name::GfmTableBodyRowEscape => construct::gfm_table::body_row_escape,

        Name::TextStart => construct::text::start,
        Name::TextBefore => construct::text::before,
        Name::TextBeforeHtml => construct::text::before_html,
        Name::TextBeforeMdxJsx => construct::text::before_mdx_jsx,
        Name::TextBeforeHardBreakEscape => construct::text::before_hard_break_escape,
        Name::TextBeforeLabelStartLink => construct::text::before_label_start_link,
        Name::TextBeforeData => construct::text::before_data,

        Name::ThematicBreakStart => construct::thematic_break::start,
        Name::ThematicBreakBefore => construct::thematic_break::before,
        Name::ThematicBreakSequence => construct::thematic_break::sequence,
        Name::ThematicBreakAtBreak => construct::thematic_break::at_break,

        Name::TitleStart => construct::partial_title::start,
        Name::TitleBegin => construct::partial_title::begin,
        Name::TitleAfterEol => construct::partial_title::after_eol,
        Name::TitleAtBreak => construct::partial_title::at_break,
        Name::TitleAtBlankLine => construct::partial_title::at_blank_line,
        Name::TitleEscape => construct::partial_title::escape,
        Name::TitleInside => construct::partial_title::inside,
    };

    func(tokenizer)
}