cairo-lang-syntax-codegen 2.21.0

Cairo syntax code generation.
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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
use crate::spec::{EnumBuilder, Node, NodesAggregator, StructBuilder};

/// The syntax specification of Cairo.
pub fn get_spec() -> Vec<Node> {
    NodesAggregator::default()
        .add_list("Trivia", "Trivium")
        .add_enum(
            EnumBuilder::new("Trivium")
                .node_with_explicit_kind("SingleLineComment", "TokenSingleLineComment")
                .node_with_explicit_kind("SingleLineDocComment", "TokenSingleLineDocComment")
                .node_with_explicit_kind("SingleLineInnerComment", "TokenSingleLineInnerComment")
                .node_with_explicit_kind("Whitespace", "TokenWhitespace")
                .node_with_explicit_kind("Newline", "TokenNewline")
                .node_with_explicit_kind("Skipped", "TokenSkipped")
                .node("SkippedNode"),
        )
        // --- Expressions ---
        .add_enum(
            EnumBuilder::new("Expr")
                .include_missing()
                .node("Path")
                .node_with_explicit_kind("Literal", "TerminalLiteralNumber")
                .node_with_explicit_kind("ShortString", "TerminalShortString")
                .node_with_explicit_kind("String", "TerminalString")
                .node_with_explicit_kind("False", "TerminalFalse")
                .node_with_explicit_kind("True", "TerminalTrue")
                .node("Parenthesized")
                .node("Unary")
                .node("Binary")
                .node_with_explicit_kind("Tuple", "ExprListParenthesized")
                .node("FunctionCall")
                .node("StructCtorCall")
                .node("Block")
                .node("Match")
                .node("If")
                .node("Loop")
                .node("While")
                .node("For")
                .node("Closure")
                .node("ErrorPropagate")
                .node("FieldInitShorthand")
                .node("Indexed")
                .node("InlineMacro")
                .node("FixedSizeArray")
                .node_with_explicit_kind("Underscore", "TerminalUnderscore"),
        )
        .add_separated_list("ExprList", "Expr", "TerminalComma")
        .add_struct(
            StructBuilder::new("Arg")
                .node("modifiers", "ModifierList")
                .node("arg_clause", "ArgClause"),
        )
        .add_enum(
            EnumBuilder::new("ArgClause").node("Unnamed").node("Named").node("FieldInitShorthand"),
        )
        .add_struct(
            StructBuilder::new("ArgClauseNamed")
                .node("name", "TerminalIdentifier")
                .node("colon", "TerminalColon")
                .node("value", "Expr"),
        )
        .add_struct(StructBuilder::new("ArgClauseUnnamed").node("value", "Expr"))
        .add_struct(
            StructBuilder::new("ArgClauseFieldInitShorthand")
                .node("colon", "TerminalColon")
                .node("name", "ExprFieldInitShorthand"),
        )
        .add_struct(StructBuilder::new("ExprFieldInitShorthand").node("name", "TerminalIdentifier"))
        .add_separated_list("ArgList", "Arg", "TerminalComma")
        .add_enum(EnumBuilder::new("PathSegment").node("Simple").node("WithGenericArgs"))
        .add_struct(StructBuilder::new("PathSegmentSimple").node("ident", "TerminalIdentifier"))
        .add_option("TerminalColonColon")
        .add_struct(
            StructBuilder::new("PathSegmentWithGenericArgs")
                .node("ident", "TerminalIdentifier")
                .node("separator", "OptionTerminalColonColon")
                .node("generic_args", "GenericArgs"),
        )
        .add_struct(
            StructBuilder::new("ExprPath")
                .node("dollar", "OptionTerminalDollar")
                .node("segments", "ExprPathInner"),
        )
        .add_option("TerminalDollar")
        .add_separated_list("ExprPathInner", "PathSegment", "TerminalColonColon")
        .add_struct(
            StructBuilder::new("ExprParenthesized")
                .node("lparen", "TerminalLParen")
                .node("expr", "Expr")
                .node("rparen", "TerminalRParen"),
        )
        .add_struct(
            StructBuilder::new("ExprUnary").node("op", "UnaryOperator").node("expr", "Expr"),
        )
        .add_enum(
            EnumBuilder::new("UnaryOperator")
                .node_with_explicit_kind("Not", "TerminalNot")
                .node_with_explicit_kind("BitNot", "TerminalBitNot")
                .node_with_explicit_kind("Minus", "TerminalMinus")
                .node_with_explicit_kind("At", "TerminalAt")
                .node_with_explicit_kind("Desnap", "TerminalMul")
                .node_with_explicit_kind("Reference", "TerminalAnd"),
        )
        .add_struct(
            StructBuilder::new("ExprBinary")
                .node("lhs", "Expr")
                .node("op", "BinaryOperator")
                .node("rhs", "Expr"),
        )
        .add_enum(
            EnumBuilder::new("BinaryOperator")
                .node_with_explicit_kind("Dot", "TerminalDot")
                .node_with_explicit_kind("Not", "TerminalNot")
                .node_with_explicit_kind("Mul", "TerminalMul")
                .node_with_explicit_kind("MulEq", "TerminalMulEq")
                .node_with_explicit_kind("Div", "TerminalDiv")
                .node_with_explicit_kind("DivEq", "TerminalDivEq")
                .node_with_explicit_kind("Mod", "TerminalMod")
                .node_with_explicit_kind("ModEq", "TerminalModEq")
                .node_with_explicit_kind("Plus", "TerminalPlus")
                .node_with_explicit_kind("PlusEq", "TerminalPlusEq")
                .node_with_explicit_kind("Minus", "TerminalMinus")
                .node_with_explicit_kind("MinusEq", "TerminalMinusEq")
                .node_with_explicit_kind("EqEq", "TerminalEqEq")
                .node_with_explicit_kind("Neq", "TerminalNeq")
                .node_with_explicit_kind("Eq", "TerminalEq")
                .node_with_explicit_kind("And", "TerminalAnd")
                .node_with_explicit_kind("AndAnd", "TerminalAndAnd")
                .node_with_explicit_kind("Or", "TerminalOr")
                .node_with_explicit_kind("OrOr", "TerminalOrOr")
                .node_with_explicit_kind("Xor", "TerminalXor")
                .node_with_explicit_kind("LE", "TerminalLE")
                .node_with_explicit_kind("GE", "TerminalGE")
                .node_with_explicit_kind("LT", "TerminalLT")
                .node_with_explicit_kind("GT", "TerminalGT")
                .node_with_explicit_kind("DotDot", "TerminalDotDot")
                .node_with_explicit_kind("DotDotEq", "TerminalDotDotEq"),
        )
        .add_struct(
            StructBuilder::new("ExprListParenthesized")
                .node("lparen", "TerminalLParen")
                .node("expressions", "ExprList")
                .node("rparen", "TerminalRParen"),
        )
        .add_struct(
            StructBuilder::new("ExprFunctionCall")
                .node("path", "ExprPath")
                .node("arguments", "ArgListParenthesized"),
        )
        .add_struct(
            StructBuilder::new("ArgListParenthesized")
                .node("lparen", "TerminalLParen")
                .node("arguments", "ArgList")
                .node("rparen", "TerminalRParen"),
        )
        .add_option("ArgListParenthesized")
        .add_struct(
            StructBuilder::new("ExprStructCtorCall")
                .node("path", "ExprPath")
                .node("arguments", "StructArgListBraced"),
        )
        .add_struct(
            StructBuilder::new("StructArgListBraced")
                .node("lbrace", "TerminalLBrace")
                .node("arguments", "StructArgList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("ExprBlock")
                .node("lbrace", "TerminalLBrace")
                .node("statements", "StatementList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("ExprMatch")
                .node("match_kw", "TerminalMatch")
                // TODO(yuval): change to SimpleExpr
                .node("expr", "Expr")
                .node("lbrace", "TerminalLBrace")
                .node("arms", "MatchArms")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_separated_list("MatchArms", "MatchArm", "TerminalComma")
        .add_struct(
            StructBuilder::new("MatchArm")
                .node("patterns", "PatternListOr")
                .node("arrow", "TerminalMatchArrow")
                .node("expression", "Expr"),
        )
        .add_struct(
            StructBuilder::new("ExprIf")
                .node("if_kw", "TerminalIf")
                .node("conditions", "ConditionListAnd")
                .node("if_block", "ExprBlock")
                .node("else_clause", "OptionElseClause"),
        )
        .add_separated_list("ConditionListAnd", "Condition", "TerminalAndAnd")
        .add_enum(EnumBuilder::new("Condition").node("Let").node("Expr"))
        .add_struct(
            StructBuilder::new("ConditionLet")
                .node("let_kw", "TerminalLet")
                .node("patterns", "PatternListOr")
                .node("eq", "TerminalEq")
                .node("expr", "Expr"),
        )
        .add_struct(StructBuilder::new("ConditionExpr").node("expr", "Expr"))
        .add_enum(
            EnumBuilder::new("BlockOrIf")
                .node_with_explicit_kind("Block", "ExprBlock")
                .node_with_explicit_kind("If", "ExprIf"),
        )
        .add_struct(
            StructBuilder::new("ExprLoop")
                .node("loop_kw", "TerminalLoop")
                .node("body", "ExprBlock"),
        )
        .add_struct(
            StructBuilder::new("ExprWhile")
                .node("while_kw", "TerminalWhile")
                .node("conditions", "ConditionListAnd")
                .node("body", "ExprBlock"),
        )
        .add_struct(
            StructBuilder::new("ExprFor")
                .node("for_kw", "TerminalFor")
                .key_node("pattern", "Pattern")
                .key_node("identifier", "TerminalIdentifier")
                .node("expr", "Expr")
                .node("body", "ExprBlock"),
        )
        .add_struct(
            StructBuilder::new("ElseClause")
                .node("else_kw", "TerminalElse")
                .node("else_block_or_if", "BlockOrIf"),
        )
        .add_option("ElseClause")
        .add_struct(
            StructBuilder::new("ExprErrorPropagate")
                .node("expr", "Expr")
                .node("op", "TerminalQuestionMark"),
        )
        .add_struct(
            StructBuilder::new("ExprIndexed")
                .node("expr", "Expr")
                .node("lbrack", "TerminalLBrack")
                .node("index_expr", "Expr")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_struct(
            StructBuilder::new("ExprFixedSizeArray")
                .node("lbrack", "TerminalLBrack")
                .node("exprs", "ExprList")
                .node("size", "OptionFixedSizeArraySize")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_struct(
            StructBuilder::new("FixedSizeArraySize")
                .node("semicolon", "TerminalSemicolon")
                .node("size", "Expr"),
        )
        .add_option("FixedSizeArraySize")
        .add_struct(
            StructBuilder::new("ExprClosure")
                .node("params", "ClosureParams")
                .node("ret_ty", "OptionReturnTypeClause")
                .node("optional_no_panic", "OptionTerminalNoPanic")
                .node("expr", "Expr"),
        )
        .add_struct(
            StructBuilder::new("ClosureParams")
                .node("leftor", "TerminalOr")
                .node("params", "ParamList")
                .node("rightor", "TerminalOr"),
        )
        // --- Struct ctor ---
        .add_struct(
            StructBuilder::new("StructArgExpr").node("colon", "TerminalColon").node("expr", "Expr"),
        )
        .add_option("StructArgExpr")
        .add_struct(
            StructBuilder::new("StructArgSingle")
                .key_node("identifier", "TerminalIdentifier")
                .node("arg_expr", "OptionStructArgExpr"),
        )
        .add_struct(
            StructBuilder::new("StructArgTail")
                .node("dotdot", "TerminalDotDot")
                .node("expression", "Expr"),
        )
        .add_enum(
            EnumBuilder::new("StructArg")
                .node_with_explicit_kind("StructArgSingle", "StructArgSingle")
                .node_with_explicit_kind("StructArgTail", "StructArgTail"),
        )
        .add_separated_list("StructArgList", "StructArg", "TerminalComma")
        .add_struct(
            StructBuilder::new("ArgListBraced")
                .node("lbrace", "TerminalLBrace")
                .node("arguments", "ArgList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("ArgListBracketed")
                .node("lbrack", "TerminalLBrack")
                .node("arguments", "ArgList")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_enum(
            EnumBuilder::new("WrappedArgList")
                .include_missing()
                .node_with_explicit_kind("BracketedArgList", "ArgListBracketed")
                .node_with_explicit_kind("ParenthesizedArgList", "ArgListParenthesized")
                .node_with_explicit_kind("BracedArgList", "ArgListBraced"),
        )
        // ---Patterns ---
        .add_enum(
            EnumBuilder::new("Pattern")
                .node_with_explicit_kind("Underscore", "TerminalUnderscore")
                .node_with_explicit_kind("Literal", "TerminalLiteralNumber")
                .node_with_explicit_kind("False", "TerminalFalse")
                .node_with_explicit_kind("True", "TerminalTrue")
                .node_with_explicit_kind("ShortString", "TerminalShortString")
                .node_with_explicit_kind("String", "TerminalString")
                .node("Identifier")
                .node("Struct")
                .node("Tuple")
                .node("Enum")
                .node("FixedSizeArray")
                .node_with_explicit_kind("Path", "ExprPath"),
        )
        .add_struct(
            StructBuilder::new("PatternIdentifier")
                .node("modifiers", "ModifierList")
                .key_node("name", "TerminalIdentifier"),
        )
        .add_struct(
            StructBuilder::new("PatternStruct")
                // TODO(spapini): Use SimplePath instead - which is not an expr.
                .node("path", "ExprPath")
                .node("lbrace", "TerminalLBrace")
                .node("params", "PatternStructParamList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_separated_list("PatternStructParamList", "PatternStructParam", "TerminalComma")
        .add_struct(
            StructBuilder::new("PatternTuple")
                .node("lparen", "TerminalLParen")
                .node("patterns", "PatternList")
                .node("rparen", "TerminalRParen"),
        )
        .add_struct(
            StructBuilder::new("PatternFixedSizeArray")
                .node("lbrack", "TerminalLBrack")
                .node("patterns", "PatternList")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_separated_list("PatternList", "Pattern", "TerminalComma")
        .add_separated_list("PatternListOr", "Pattern", "TerminalOr")
        .add_enum(
            EnumBuilder::new("PatternStructParam")
                .node_with_explicit_kind("Single", "PatternIdentifier")
                .node("WithExpr")
                .node_with_explicit_kind("Tail", "TerminalDotDot"),
        )
        .add_struct(
            StructBuilder::new("PatternStructParamWithExpr")
                .node("modifiers", "ModifierList")
                .node("name", "TerminalIdentifier")
                .node("colon", "TerminalColon")
                .node("pattern", "Pattern"),
        )
        .add_struct(
            StructBuilder::new("PatternEnum")
                .node("path", "ExprPath")
                .node("pattern", "OptionPatternEnumInnerPattern"),
        )
        .add_struct(
            StructBuilder::new("PatternEnumInnerPattern")
                .node("lparen", "TerminalLParen")
                .node("pattern", "Pattern")
                .node("rparen", "TerminalRParen"),
        )
        .add_option("PatternEnumInnerPattern")
        // --- Type clauses ---
        // TODO(yuval): support SimpleExpr instead of Expr
        .add_struct(
            StructBuilder::new("TypeClause").node("colon", "TerminalColon").node("ty", "Expr"),
        )
        .add_option("TypeClause")
        .add_struct(
            StructBuilder::new("ReturnTypeClause")
                .node("arrow", "TerminalArrow")
                .node("ty", "Expr"),
        )
        .add_option("ReturnTypeClause")
        // --- Statements ---
        .add_enum(
            EnumBuilder::new("Statement")
                .include_missing()
                .node("Let")
                .node("Expr")
                .node("Continue")
                .node("Return")
                .node("Break")
                .node("Item"),
        )
        .add_list("StatementList", "Statement")
        .add_struct(
            StructBuilder::new("StatementLet")
                .node("attributes", "AttributeList")
                .node("let_kw", "TerminalLet")
                .key_node("pattern", "Pattern")
                .node("type_clause", "OptionTypeClause")
                .node("eq", "TerminalEq")
                .node("rhs", "Expr")
                .node("let_else_clause", "OptionLetElseClause")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("LetElseClause")
                .node("else_kw", "TerminalElse")
                .node("else_block", "ExprBlock"),
        )
        .add_option("LetElseClause")
        .add_option("TerminalSemicolon")
        .add_struct(
            StructBuilder::new("StatementExpr")
                .node("attributes", "AttributeList")
                .node("expr", "Expr")
                .node("semicolon", "OptionTerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("StatementContinue")
                .node("attributes", "AttributeList")
                .node("continue_kw", "TerminalContinue")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(StructBuilder::new("ExprClause").node("expr", "Expr"))
        .add_option("ExprClause")
        .add_struct(
            StructBuilder::new("StatementReturn")
                .node("attributes", "AttributeList")
                .node("return_kw", "TerminalReturn")
                .node("expr_clause", "OptionExprClause")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("StatementBreak")
                .node("attributes", "AttributeList")
                .node("break_kw", "TerminalBreak")
                .node("expr_clause", "OptionExprClause")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(StructBuilder::new("StatementItem").node("item", "ModuleItem"))
        // --- Functions ---
        .add_struct(
            StructBuilder::new("Param")
                .node("modifiers", "ModifierList")
                .key_node("name", "TerminalIdentifier")
                .node("type_clause", "OptionTypeClause"),
        )
        .add_list("ModifierList", "Modifier")
        .add_enum(
            EnumBuilder::new("Modifier")
                .node_with_explicit_kind("Ref", "TerminalRef")
                .node_with_explicit_kind("Mut", "TerminalMut"),
        )
        .add_separated_list("ParamList", "Param", "TerminalComma")
        .add_struct(
            StructBuilder::new("ImplicitsClause")
                .node("implicits_kw", "TerminalImplicits")
                .node("lparen", "TerminalLParen")
                .node("implicits", "ImplicitsList")
                .node("rparen", "TerminalRParen"),
        )
        .add_separated_list("ImplicitsList", "ExprPath", "TerminalComma")
        .add_option("ImplicitsClause")
        .add_option("TerminalNoPanic")
        .add_option("TerminalConst")
        // TODO(spapini): Add generic params.
        // This is an unnamed signature, e.g. "() -> Type".
        .add_struct(
            StructBuilder::new("FunctionSignature")
                .node("lparen", "TerminalLParen")
                .node("parameters", "ParamList")
                .node("rparen", "TerminalRParen")
                .node("ret_ty", "OptionReturnTypeClause")
                .node("implicits_clause", "OptionImplicitsClause")
                .node("optional_no_panic", "OptionTerminalNoPanic"),
        )
        // --- Struct Members ---
        // Struct member and enum variant have the same structure.
        .add_struct(
            StructBuilder::new("Member")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .key_node("name", "TerminalIdentifier")
                .node("type_clause", "TypeClause"),
        )
        .add_separated_list("MemberList", "Member", "TerminalComma")
        .add_struct(
            StructBuilder::new("Variant")
                .node("attributes", "AttributeList")
                .key_node("name", "TerminalIdentifier")
                .node("type_clause", "OptionTypeClause"),
        )
        .add_separated_list("VariantList", "Variant", "TerminalComma")
        // --- Items ---
        .add_enum(
            EnumBuilder::new("ModuleItem")
                .include_missing()
                .node_with_explicit_kind("Constant", "ItemConstant")
                .node_with_explicit_kind("Module", "ItemModule")
                .node_with_explicit_kind("Use", "ItemUse")
                .node_with_explicit_kind("FreeFunction", "FunctionWithBody")
                .node_with_explicit_kind("ExternFunction", "ItemExternFunction")
                .node_with_explicit_kind("ExternType", "ItemExternType")
                .node_with_explicit_kind("Trait", "ItemTrait")
                .node_with_explicit_kind("Impl", "ItemImpl")
                .node_with_explicit_kind("ImplAlias", "ItemImplAlias")
                .node_with_explicit_kind("Struct", "ItemStruct")
                .node_with_explicit_kind("Enum", "ItemEnum")
                .node_with_explicit_kind("TypeAlias", "ItemTypeAlias")
                .node_with_explicit_kind("InlineMacro", "ItemInlineMacro")
                .node_with_explicit_kind("MacroDeclaration", "ItemMacroDeclaration")
                .node_with_explicit_kind("HeaderDoc", "ItemHeaderDoc"),
        )
        .add_list("ModuleItemList", "ModuleItem")
        .add_struct(
            StructBuilder::new("Attribute")
                .node("hash", "TerminalHash")
                .node("lbrack", "TerminalLBrack")
                .node("attr", "ExprPath")
                .node("arguments", "OptionArgListParenthesized")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_list("AttributeList", "Attribute")
        .add_struct(StructBuilder::new("VisibilityDefault"))
        .add_struct(
            StructBuilder::new("VisibilityPubArgumentClause")
                .node("lparen", "TerminalLParen")
                .node("argument", "TerminalIdentifier")
                .node("rparen", "TerminalRParen"),
        )
        .add_option("VisibilityPubArgumentClause")
        .add_struct(
            StructBuilder::new("VisibilityPub")
                .node("pub_kw", "TerminalPub")
                .node("argument_clause", "OptionVisibilityPubArgumentClause"),
        )
        .add_enum(EnumBuilder::new("Visibility").node("Default").node("Pub"))
        .add_struct(
            StructBuilder::new("ItemModule")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("module_kw", "TerminalModule")
                .key_node("name", "TerminalIdentifier")
                .node("body", "MaybeModuleBody"),
        )
        .add_enum(
            EnumBuilder::new("MaybeModuleBody")
                .node_with_explicit_kind("Some", "ModuleBody")
                .node_with_explicit_kind("None", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ModuleBody")
                .node("lbrace", "TerminalLBrace")
                .node("items", "ModuleItemList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("FunctionDeclaration")
                .node("optional_const", "OptionTerminalConst")
                .node("function_kw", "TerminalFunction")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("signature", "FunctionSignature"),
        )
        .add_struct(
            StructBuilder::new("ItemConstant")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("const_kw", "TerminalConst")
                .key_node("name", "TerminalIdentifier")
                .node("type_clause", "TypeClause")
                .node("eq", "TerminalEq")
                .node("value", "Expr")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("FunctionWithBody")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                // TODO(ilya): Use only the name as key node.
                .key_node("declaration", "FunctionDeclaration")
                .node("body", "ExprBlock"),
        )
        .add_struct(
            StructBuilder::new("ItemExternFunction")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("extern_kw", "TerminalExtern")
                // TODO(ilya): Use only the name as key node.
                .key_node("declaration", "FunctionDeclaration")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ItemExternType")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("extern_kw", "TerminalExtern")
                .node("type_kw", "TerminalType")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ItemTrait")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("trait_kw", "TerminalTrait")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("body", "MaybeTraitBody"),
        )
        .add_enum(
            EnumBuilder::new("MaybeTraitBody")
                .node_with_explicit_kind("Some", "TraitBody")
                .node_with_explicit_kind("None", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("TraitBody")
                .node("lbrace", "TerminalLBrace")
                .node("items", "TraitItemList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_list("TraitItemList", "TraitItem")
        .add_enum(
            EnumBuilder::new("TraitItem")
                .include_missing()
                .node("Function")
                .node("Type")
                .node("Constant")
                .node("Impl"),
        )
        .add_struct(
            StructBuilder::new("TraitItemFunction")
                .node("attributes", "AttributeList")
                // TODO(ilya): Use only the name as key node.
                .key_node("declaration", "FunctionDeclaration")
                .node("body", "MaybeTraitFunctionBody"),
        )
        .add_struct(
            StructBuilder::new("TraitItemType")
                .node("attributes", "AttributeList")
                .node("type_kw", "TerminalType")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("TraitItemConstant")
                .node("attributes", "AttributeList")
                .node("const_kw", "TerminalConst")
                .key_node("name", "TerminalIdentifier")
                .node("type_clause", "TypeClause")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("TraitItemImpl")
                .node("attributes", "AttributeList")
                .node("impl_kw", "TerminalImpl")
                .key_node("name", "TerminalIdentifier")
                .node("colon", "TerminalColon")
                .node("trait_path", "ExprPath")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_enum(
            EnumBuilder::new("MaybeTraitFunctionBody")
                .node_with_explicit_kind("Some", "ExprBlock")
                .node_with_explicit_kind("None", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ItemImpl")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("impl_kw", "TerminalImpl")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("of_kw", "TerminalOf")
                .node("trait_path", "ExprPath")
                .node("body", "MaybeImplBody"),
        )
        // Empty struct, which is used for separating the first comments in a file or module from
        // the rest of the items. This is needed to prevent the first comments from being
        // moved by the formatter.
        .add_struct(StructBuilder::new("ItemHeaderDoc").node("empty", "TerminalEmpty"))
        .add_enum(
            EnumBuilder::new("MaybeImplBody")
                .node_with_explicit_kind("Some", "ImplBody")
                .node_with_explicit_kind("None", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ImplBody")
                .node("lbrace", "TerminalLBrace")
                .node("items", "ImplItemList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_list("ImplItemList", "ImplItem")
        .add_enum(
            EnumBuilder::new("ImplItem")
                .include_missing()
                .node_with_explicit_kind("Function", "FunctionWithBody")
                .node_with_explicit_kind("Type", "ItemTypeAlias")
                .node_with_explicit_kind("Constant", "ItemConstant")
                .node_with_explicit_kind("Impl", "ItemImplAlias")
                // These are not supported semantically.
                .node_with_explicit_kind("Module", "ItemModule")
                .node_with_explicit_kind("Use", "ItemUse")
                .node_with_explicit_kind("ExternFunction", "ItemExternFunction")
                .node_with_explicit_kind("ExternType", "ItemExternType")
                .node_with_explicit_kind("Trait", "ItemTrait")
                .node_with_explicit_kind("Struct", "ItemStruct")
                .node_with_explicit_kind("Enum", "ItemEnum"),
        )
        .add_struct(
            StructBuilder::new("ItemImplAlias")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("impl_kw", "TerminalImpl")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("eq", "TerminalEq")
                .node("impl_path", "ExprPath")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ItemStruct")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("struct_kw", "TerminalStruct")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("lbrace", "TerminalLBrace")
                .node("members", "MemberList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("ItemEnum")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("enum_kw", "TerminalEnum")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("lbrace", "TerminalLBrace")
                .node("variants", "VariantList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("ItemTypeAlias")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("type_kw", "TerminalType")
                .key_node("name", "TerminalIdentifier")
                .node("generic_params", "OptionWrappedGenericParamList")
                .node("eq", "TerminalEq")
                .node("ty", "Expr")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ItemUse")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("use_kw", "TerminalUse")
                .node("dollar", "OptionTerminalDollar")
                .key_node("use_path", "UsePath")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_enum(
            EnumBuilder::new("UsePath").node("Leaf").node("Single").node("Multi").node("Star"),
        )
        .add_struct(
            StructBuilder::new("UsePathLeaf")
                .key_node("ident", "PathSegment")
                .key_node("alias_clause", "OptionAliasClause"),
        )
        .add_struct(
            StructBuilder::new("UsePathSingle")
                .node("ident", "PathSegment")
                .node("colon_colon", "TerminalColonColon")
                .node("use_path", "UsePath"),
        )
        .add_struct(
            StructBuilder::new("UsePathMulti")
                .node("lbrace", "TerminalLBrace")
                .node("use_paths", "UsePathList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(StructBuilder::new("UsePathStar").node("star", "TerminalMul"))
        .add_separated_list("UsePathList", "UsePath", "TerminalComma")
        .add_struct(
            StructBuilder::new("AliasClause")
                .node("as_kw", "TerminalAs")
                .key_node("alias", "TerminalIdentifier"),
        )
        .add_option("AliasClause")
        // --- Generics ---
        .add_enum(EnumBuilder::new("GenericArg").node("Unnamed").node("Named"))
        .add_struct(
            StructBuilder::new("GenericArgNamed")
                .node("name", "TerminalIdentifier")
                .node("colon", "TerminalColon")
                .node("value", "Expr"),
        )
        .add_struct(StructBuilder::new("GenericArgUnnamed").node("value", "Expr"))
        .add_struct(
            StructBuilder::new("GenericArgs")
                .node("langle", "TerminalLT")
                .node("generic_args", "GenericArgList")
                .node("rangle", "TerminalGT"),
        )
        .add_separated_list("GenericArgList", "GenericArg", "TerminalComma")
        .add_struct(
            StructBuilder::new("AssociatedItemConstraint")
                .node("item", "TerminalIdentifier")
                .node("colon", "TerminalColon")
                .node("value", "Expr"),
        )
        .add_struct(
            StructBuilder::new("AssociatedItemConstraints")
                .node("lbrack", "TerminalLBrack")
                .node("associated_item_constraints", "AssociatedItemConstraintList")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_separated_list(
            "AssociatedItemConstraintList",
            "AssociatedItemConstraint",
            "TerminalComma",
        )
        .add_option("AssociatedItemConstraints")
        .add_option("WrappedGenericParamList")
        .add_struct(
            StructBuilder::new("WrappedGenericParamList")
                .node("langle", "TerminalLT")
                .node("generic_params", "GenericParamList")
                .node("rangle", "TerminalGT"),
        )
        .add_separated_list("GenericParamList", "GenericParam", "TerminalComma")
        // TODO(spapini): Remove this indirection.
        .add_enum(
            EnumBuilder::new("GenericParam")
                .node("Type")
                .node("Const")
                .node("ImplNamed")
                .node("ImplAnonymous")
                .node("NegativeImpl"),
        )
        .add_struct(StructBuilder::new("GenericParamType").key_node("name", "TerminalIdentifier"))
        .add_struct(
            StructBuilder::new("GenericParamConst")
                .node("const_kw", "TerminalConst")
                .key_node("name", "TerminalIdentifier")
                .node("colon", "TerminalColon")
                .node("ty", "Expr"),
        )
        .add_struct(
            StructBuilder::new("GenericParamImplNamed")
                .node("impl_kw", "TerminalImpl")
                .key_node("name", "TerminalIdentifier")
                .node("colon", "TerminalColon")
                .node("trait_path", "ExprPath")
                .node("type_constrains", "OptionAssociatedItemConstraints"),
        )
        .add_struct(
            StructBuilder::new("GenericParamImplAnonymous")
                .node("plus", "TerminalPlus")
                .node("trait_path", "ExprPath")
                .node("type_constrains", "OptionAssociatedItemConstraints"),
        )
        .add_struct(
            StructBuilder::new("GenericParamNegativeImpl")
                .node("minus", "TerminalMinus")
                .node("trait_path", "ExprPath"),
        )
        // --- Macros ---
        // The structure of a token tree is:
        // TokenTree: TokenNode | WrappedTokenTree
        // Where WrappedTokenTree is:
        // WrappedTokenTree: (TokenTree*) | {TokenTree*} | [TokenTree*]
        // TokenTree* is represented as TokenList.
        .add_list("TokenList", "TokenTree")
        .add_struct(StructBuilder::new("TokenTreeLeaf").node("leaf", "TokenNode"))
        .add_struct(StructBuilder::new("TokenTreeNode").node("subtree", "WrappedTokenTree"))
        // TODO(Dean): Remove TokenTreeRepetition and TokenTreeParam (it's redundant).
        .add_struct(
            StructBuilder::new("TokenTreeRepetition")
                .node("dollar", "TerminalDollar")
                .node("lparen", "TerminalLParen")
                .node("elements", "TokenList")
                .node("rparen", "TerminalRParen")
                .node("separator", "OptionTerminalComma")
                .node("operator", "MacroRepetitionOperator"),
        )
        .add_struct(
            StructBuilder::new("TokenTreeParam")
                .node("dollar", "TerminalDollar")
                .node("name", "TerminalIdentifier"),
        )
        .add_enum(
            EnumBuilder::new("TokenTree")
                .include_missing()
                .node_with_explicit_kind("Token", "TokenTreeLeaf")
                .node_with_explicit_kind("Subtree", "TokenTreeNode")
                .node_with_explicit_kind("Repetition", "TokenTreeRepetition")
                .node_with_explicit_kind("Param", "TokenTreeParam"),
        )
        .add_enum(
            EnumBuilder::new("WrappedTokenTree")
                .include_missing()
                .node_with_explicit_kind("Parenthesized", "ParenthesizedTokenTree")
                .node_with_explicit_kind("Braced", "BracedTokenTree")
                .node_with_explicit_kind("Bracketed", "BracketedTokenTree"),
        )
        .add_struct(
            StructBuilder::new("ParenthesizedTokenTree")
                .node("lparen", "TerminalLParen")
                .node("tokens", "TokenList")
                .node("rparen", "TerminalRParen"),
        )
        .add_struct(
            StructBuilder::new("BracedTokenTree")
                .node("lbrace", "TerminalLBrace")
                .node("tokens", "TokenList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("BracketedTokenTree")
                .node("lbrack", "TerminalLBrack")
                .node("tokens", "TokenList")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_struct(
            StructBuilder::new("ExprInlineMacro")
                .node("path", "ExprPath")
                .node("bang", "TerminalNot")
                .node("arguments", "TokenTreeNode"),
        )
        .add_struct(
            StructBuilder::new("ItemInlineMacro")
                .node("attributes", "AttributeList")
                .node("path", "ExprPath")
                .node("bang", "TerminalNot")
                .node("arguments", "TokenTreeNode")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ItemMacroDeclaration")
                .node("attributes", "AttributeList")
                .node("visibility", "Visibility")
                .node("macro_kw", "TerminalMacro")
                .key_node("name", "TerminalIdentifier")
                .node("lbrace", "TerminalLBrace")
                .node("rules", "MacroRulesList")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_list("MacroRulesList", "MacroRule")
        .add_struct(
            StructBuilder::new("MacroRule")
                .node("lhs", "WrappedMacro")
                .node("fat_arrow", "TerminalMatchArrow")
                .node("rhs", "BracedMacro")
                .node("semicolon", "TerminalSemicolon"),
        )
        .add_struct(
            StructBuilder::new("ParamKind")
                .node("colon", "TerminalColon")
                .node("kind", "MacroParamKind"),
        )
        .add_option("ParamKind")
        .add_struct(
            StructBuilder::new("MacroParam")
                .node("dollar", "TerminalDollar")
                .node("name", "TerminalIdentifier")
                .node("kind", "OptionParamKind"),
        )
        .add_struct(
            StructBuilder::new("MacroRepetition")
                .node("dollar", "TerminalDollar")
                .node("lparen", "TerminalLParen")
                .node("elements", "MacroElements")
                .node("rparen", "TerminalRParen")
                // TODO(Dean): Add support for more kinds of separators.
                .node("separator", "OptionTerminalComma")
                .node("operator", "MacroRepetitionOperator"),
        )
        .add_option("TerminalComma")
        .add_enum(
            EnumBuilder::new("MacroRepetitionOperator")
                .node_with_explicit_kind("ZeroOrOne", "TerminalQuestionMark")
                .node_with_explicit_kind("OneOrMore", "TerminalPlus")
                .node_with_explicit_kind("ZeroOrMore", "TerminalMul")
                .include_missing(),
        )
        // TODO(Gil): Add support for more kinds of macro rule parameters.
        .add_struct(StructBuilder::new("ParamIdent").node("ident", "TerminalIdentifier"))
        .add_struct(StructBuilder::new("ParamExpr").node("expr", "TerminalIdentifier"))
        .add_enum(
            EnumBuilder::new("MacroParamKind")
                .node_with_explicit_kind("Identifier", "ParamIdent")
                .node_with_explicit_kind("Expr", "ParamExpr")
                .include_missing(),
        )
        .add_enum(
            EnumBuilder::new("MacroElement")
                .node_with_explicit_kind("Token", "TokenTreeLeaf")
                .node_with_explicit_kind("Param", "MacroParam")
                .node_with_explicit_kind("Subtree", "MacroWrapper")
                .node_with_explicit_kind("Repetition", "MacroRepetition"),
        )
        .add_list("MacroElements", "MacroElement")
        .add_struct(StructBuilder::new("MacroWrapper").node("subtree", "WrappedMacro"))
        .add_enum(
            EnumBuilder::new("WrappedMacro")
                .node_with_explicit_kind("Parenthesized", "ParenthesizedMacro")
                .node_with_explicit_kind("Braced", "BracedMacro")
                .node_with_explicit_kind("Bracketed", "BracketedMacro"),
        )
        .add_struct(
            StructBuilder::new("ParenthesizedMacro")
                .node("lparen", "TerminalLParen")
                .node("elements", "MacroElements")
                .node("rparen", "TerminalRParen"),
        )
        .add_struct(
            StructBuilder::new("BracedMacro")
                .node("lbrace", "TerminalLBrace")
                .node("elements", "MacroElements")
                .node("rbrace", "TerminalRBrace"),
        )
        .add_struct(
            StructBuilder::new("BracketedMacro")
                .node("lbrack", "TerminalLBrack")
                .node("elements", "MacroElements")
                .node("rbrack", "TerminalRBrack"),
        )
        .add_struct(
            StructBuilder::new("LegacyExprInlineMacro")
                .node("path", "ExprPath")
                .node("bang", "TerminalNot")
                .node("arguments", "WrappedArgList"),
        )
        .add_struct(
            StructBuilder::new("LegacyItemInlineMacro")
                .node("attributes", "AttributeList")
                .node("path", "ExprPath")
                .node("bang", "TerminalNot")
                .node("arguments", "WrappedArgList")
                .node("semicolon", "TerminalSemicolon"),
        )
        // --- Skipped nodes ---
        // A wrapper for the skipped node enum as the enum nodes (Trivium) can't have enum as a
        // child directly.
        .add_struct(StructBuilder::new("TriviumSkippedNode").node("node", "SkippedNode"))
        // An enum of all nodes that can be skipped while parsing, new nodes can be added here if
        // needed to be skipped.
        .add_enum(
            EnumBuilder::new("SkippedNode")
                .node_with_explicit_kind("AttributeList", "AttributeList")
                .node_with_explicit_kind("VisibilityPub", "VisibilityPub")
                .node_with_explicit_kind("ExprPath", "ExprPath"),
        )
        // --- Tokens + Terminals ---
        .add_token_and_terminal("Identifier")
        .add_token_and_terminal("LiteralNumber")
        .add_token_and_terminal("ShortString")
        .add_token_and_terminal("String")
        .add_keyword_token_and_terminal("As")
        .add_keyword_token_and_terminal("Const")
        .add_keyword_token_and_terminal("Else")
        .add_keyword_token_and_terminal("Enum")
        .add_keyword_token_and_terminal("Extern")
        .add_keyword_token_and_terminal("False")
        .add_keyword_token_and_terminal("Function")
        .add_keyword_token_and_terminal("If")
        .add_keyword_token_and_terminal("While")
        .add_keyword_token_and_terminal("For")
        .add_keyword_token_and_terminal("Loop")
        .add_keyword_token_and_terminal("Impl")
        .add_keyword_token_and_terminal("Implicits")
        .add_keyword_token_and_terminal("Let")
        .add_keyword_token_and_terminal("Macro")
        .add_keyword_token_and_terminal("Match")
        .add_keyword_token_and_terminal("Module")
        .add_keyword_token_and_terminal("Mut")
        .add_keyword_token_and_terminal("NoPanic")
        .add_keyword_token_and_terminal("Of")
        .add_keyword_token_and_terminal("Ref")
        .add_keyword_token_and_terminal("Continue")
        .add_keyword_token_and_terminal("Return")
        .add_keyword_token_and_terminal("Break")
        .add_keyword_token_and_terminal("Struct")
        .add_keyword_token_and_terminal("Trait")
        .add_keyword_token_and_terminal("True")
        .add_keyword_token_and_terminal("Type")
        .add_keyword_token_and_terminal("Use")
        .add_keyword_token_and_terminal("Pub")
        .add_token_and_terminal("And")
        .add_token_and_terminal("AndAnd")
        .add_token_and_terminal("Arrow")
        .add_token_and_terminal("At")
        .add_token_and_terminal("BadCharacters")
        .add_token_and_terminal("Colon")
        .add_token_and_terminal("ColonColon")
        .add_token_and_terminal("Comma")
        .add_token_and_terminal("Div")
        .add_token_and_terminal("DivEq")
        .add_token_and_terminal("Dollar")
        .add_token_and_terminal("Dot")
        .add_token_and_terminal("DotDot")
        .add_token_and_terminal("DotDotEq")
        .add_token_and_terminal("EndOfFile")
        .add_token_and_terminal("Eq")
        .add_token_and_terminal("EqEq")
        .add_token_and_terminal("GE")
        .add_token_and_terminal("GT")
        .add_token_and_terminal("Hash")
        .add_token_and_terminal("LBrace")
        .add_token_and_terminal("LBrack")
        .add_token_and_terminal("LE")
        .add_token_and_terminal("LParen")
        .add_token_and_terminal("LT")
        .add_token_and_terminal("MatchArrow")
        .add_token_and_terminal("Minus")
        .add_token_and_terminal("MinusEq")
        .add_token_and_terminal("Mod")
        .add_token_and_terminal("ModEq")
        .add_token_and_terminal("Mul")
        .add_token_and_terminal("MulEq")
        .add_token_and_terminal("Neq")
        .add_token_and_terminal("Not")
        .add_token_and_terminal("BitNot")
        .add_token_and_terminal("Or")
        .add_token_and_terminal("OrOr")
        .add_token_and_terminal("Plus")
        .add_token_and_terminal("PlusEq")
        .add_token_and_terminal("QuestionMark")
        .add_token_and_terminal("RBrace")
        .add_token_and_terminal("RBrack")
        .add_token_and_terminal("RParen")
        .add_token_and_terminal("Semicolon")
        .add_token_and_terminal("Underscore")
        .add_token_and_terminal("Xor")
        // --- Meta ---
        .add_struct(
            StructBuilder::new("SyntaxFile")
                .node("items", "ModuleItemList")
                .node("eof", "TerminalEndOfFile"),
        )
        .add_token_and_terminal("Empty")
        .add_token("SingleLineComment")
        .add_token("SingleLineInnerComment")
        .add_token("SingleLineDocComment")
        .add_token("Whitespace")
        .add_token("Newline")
        .add_token("Missing")
        .add_token("Skipped")
        .add_all_tokens_enum("TokenNode")
        .get()
}