cairo_lang_syntax_codegen/
cairo_spec.rs

1use crate::spec::{EnumBuilder, Node, NodesAggregator, StructBuilder};
2
3/// The syntax specification of Cairo.
4pub fn get_spec() -> Vec<Node> {
5    NodesAggregator::default()
6    .add_list("Trivia", "Trivium")
7    .add_enum(
8        EnumBuilder::new("Trivium")
9            .node_with_explicit_kind("SingleLineComment", "TokenSingleLineComment")
10            .node_with_explicit_kind("SingleLineDocComment", "TokenSingleLineDocComment")
11            .node_with_explicit_kind("SingleLineInnerComment", "TokenSingleLineInnerComment")
12            .node_with_explicit_kind("Whitespace", "TokenWhitespace")
13            .node_with_explicit_kind("Newline", "TokenNewline")
14            .node_with_explicit_kind("Skipped", "TokenSkipped")
15            .node("SkippedNode"),
16    )
17    // --- Expressions ---
18    .add_enum(EnumBuilder::new("Expr")
19        .missing("Missing")
20        .node("Path")
21        .node_with_explicit_kind("Literal", "TerminalLiteralNumber")
22        .node_with_explicit_kind("ShortString", "TerminalShortString")
23        .node_with_explicit_kind("String", "TerminalString")
24        .node_with_explicit_kind("False", "TerminalFalse")
25        .node_with_explicit_kind("True", "TerminalTrue")
26        .node("Parenthesized")
27        .node("Unary")
28        .node("Binary")
29        .node_with_explicit_kind("Tuple", "ExprListParenthesized")
30        .node("FunctionCall")
31        .node("StructCtorCall")
32        .node("Block")
33        .node("Match")
34        .node("If")
35        .node("Loop")
36        .node("While")
37        .node("For")
38        .node("Closure")
39        .node("ErrorPropagate")
40        .node("FieldInitShorthand")
41        .node("Indexed")
42        .node("InlineMacro")
43        .node("FixedSizeArray")
44        .node_with_explicit_kind("Underscore", "TerminalUnderscore")
45    )
46    .add_separated_list("ExprList", "Expr", "TerminalComma")
47    .add_struct(StructBuilder::new("Arg")
48        .node("modifiers", "ModifierList")
49        .node("arg_clause", "ArgClause")
50    )
51    .add_enum(EnumBuilder::new("ArgClause")
52        .node("Unnamed")
53        .node("Named")
54        .node("FieldInitShorthand")
55    )
56    .add_struct(StructBuilder::new("ArgClauseNamed")
57        .node("name", "TerminalIdentifier")
58        .node("colon", "TerminalColon")
59        .node("value", "Expr")
60    )
61    .add_struct(StructBuilder::new("ArgClauseUnnamed")
62        .node("value", "Expr")
63    )
64    .add_struct(StructBuilder::new("ArgClauseFieldInitShorthand")
65        .node("colon", "TerminalColon")
66        .node("name", "ExprFieldInitShorthand")
67    )
68    .add_struct(StructBuilder::new("ExprFieldInitShorthand")
69        .node("name", "TerminalIdentifier")
70    )
71    .add_separated_list("ArgList", "Arg", "TerminalComma")
72    .add_struct(StructBuilder::new("ExprMissing"))
73    .add_enum(EnumBuilder::new("PathSegment")
74        .node("Simple")
75        .node("WithGenericArgs")
76        .missing("Missing")
77    )
78    .add_struct(StructBuilder::new("PathSegmentSimple").node("ident", "TerminalIdentifier"))
79    .add_option("TerminalColonColon")
80    .add_struct(StructBuilder::new("PathSegmentWithGenericArgs")
81        .node("ident", "TerminalIdentifier")
82        .node("separator", "OptionTerminalColonColon")
83        .node("generic_args", "GenericArgs")
84    )
85    .add_struct(StructBuilder::new("ExprPath")
86        .node("dollar", "OptionTerminalDollar")
87        .node("segments", "ExprPathInner")
88    )
89    .add_option("TerminalDollar")
90    // When a segment is missing, we parse a missing token, to point to from other
91    // parts of the code. This simplifies the handling of paths.
92    .add_struct(StructBuilder::new("PathSegmentMissing").node("ident","TerminalIdentifier"))
93    .add_separated_list("ExprPathInner", "PathSegment", "TerminalColonColon")
94    .add_struct(StructBuilder::new("ExprParenthesized")
95        .node("lparen", "TerminalLParen")
96        .node("expr", "Expr")
97        .node("rparen", "TerminalRParen")
98    )
99    .add_struct(StructBuilder::new("ExprUnary").node("op", "UnaryOperator").node("expr", "Expr"))
100    .add_enum(EnumBuilder::new("UnaryOperator")
101        .node_with_explicit_kind("Not", "TerminalNot")
102        .node_with_explicit_kind("BitNot", "TerminalBitNot")
103        .node_with_explicit_kind("Minus", "TerminalMinus")
104        .node_with_explicit_kind("At", "TerminalAt")
105        .node_with_explicit_kind("Desnap", "TerminalMul")
106        .node_with_explicit_kind("Reference", "TerminalAnd")
107    )
108    .add_struct(StructBuilder::new("ExprBinary")
109        .node("lhs", "Expr")
110        .node("op", "BinaryOperator")
111        .node("rhs", "Expr")
112    )
113    .add_enum(EnumBuilder::new("BinaryOperator")
114        .node_with_explicit_kind("Dot", "TerminalDot")
115        .node_with_explicit_kind("Not", "TerminalNot")
116        .node_with_explicit_kind("Mul", "TerminalMul")
117        .node_with_explicit_kind("MulEq", "TerminalMulEq")
118        .node_with_explicit_kind("Div", "TerminalDiv")
119        .node_with_explicit_kind("DivEq", "TerminalDivEq")
120        .node_with_explicit_kind("Mod", "TerminalMod")
121        .node_with_explicit_kind("ModEq", "TerminalModEq")
122        .node_with_explicit_kind("Plus", "TerminalPlus")
123        .node_with_explicit_kind("PlusEq", "TerminalPlusEq")
124        .node_with_explicit_kind("Minus", "TerminalMinus")
125        .node_with_explicit_kind("MinusEq", "TerminalMinusEq")
126        .node_with_explicit_kind("EqEq", "TerminalEqEq")
127        .node_with_explicit_kind("Neq", "TerminalNeq")
128        .node_with_explicit_kind("Eq", "TerminalEq")
129        .node_with_explicit_kind("And", "TerminalAnd")
130        .node_with_explicit_kind("AndAnd", "TerminalAndAnd")
131        .node_with_explicit_kind("Or", "TerminalOr")
132        .node_with_explicit_kind("OrOr", "TerminalOrOr")
133        .node_with_explicit_kind("Xor", "TerminalXor")
134        .node_with_explicit_kind("LE", "TerminalLE")
135        .node_with_explicit_kind("GE", "TerminalGE")
136        .node_with_explicit_kind("LT", "TerminalLT")
137        .node_with_explicit_kind("GT", "TerminalGT")
138        .node_with_explicit_kind("DotDot", "TerminalDotDot")
139        .node_with_explicit_kind("DotDotEq", "TerminalDotDotEq")
140    )
141    .add_struct(StructBuilder::new("ExprListParenthesized")
142        .node("lparen", "TerminalLParen")
143        .node("expressions", "ExprList")
144        .node("rparen", "TerminalRParen")
145    )
146    .add_struct(StructBuilder::new("ExprFunctionCall")
147        .node("path", "ExprPath")
148        .node("arguments", "ArgListParenthesized")
149    )
150    .add_struct(StructBuilder::new("ArgListParenthesized")
151        .node("lparen", "TerminalLParen")
152        .node("arguments", "ArgList")
153        .node("rparen", "TerminalRParen")
154    )
155    .add_option("ArgListParenthesized")
156    .add_struct(StructBuilder::new("ExprStructCtorCall")
157        .node("path", "ExprPath")
158        .node("arguments", "StructArgListBraced")
159    )
160    .add_struct(StructBuilder::new("StructArgListBraced")
161        .node("lbrace", "TerminalLBrace")
162        .node("arguments", "StructArgList")
163        .node("rbrace", "TerminalRBrace")
164    )
165    .add_struct(StructBuilder::new("ExprBlock")
166        .node("lbrace", "TerminalLBrace")
167        .node("statements", "StatementList")
168        .node("rbrace", "TerminalRBrace")
169    )
170    .add_struct(StructBuilder::new("ExprMatch")
171        .node("match_kw", "TerminalMatch")
172        // TODO(yuval): change to SimpleExpr
173        .node("expr", "Expr")
174        .node("lbrace", "TerminalLBrace")
175        .node("arms", "MatchArms")
176        .node("rbrace", "TerminalRBrace")
177    )
178    .add_separated_list("MatchArms", "MatchArm", "TerminalComma")
179    .add_struct(StructBuilder::new("MatchArm")
180        .node("patterns", "PatternListOr")
181        .node("arrow", "TerminalMatchArrow")
182        .node("expression", "Expr")
183    )
184    .add_struct(StructBuilder::new("ExprIf")
185        .node("if_kw", "TerminalIf")
186        .node("conditions", "ConditionListAnd")
187        .node("if_block", "ExprBlock")
188        .node("else_clause", "OptionElseClause")
189    )
190    .add_separated_list("ConditionListAnd", "Condition", "TerminalAndAnd")
191    .add_enum(EnumBuilder::new("Condition")
192        .node("Let")
193        .node("Expr")
194    )
195    .add_struct(StructBuilder::new("ConditionLet")
196        .node("let_kw", "TerminalLet")
197        .node("patterns", "PatternListOr")
198        .node("eq", "TerminalEq")
199        .node("expr", "Expr")
200    )
201    .add_struct(StructBuilder::new("ConditionExpr")
202        .node("expr", "Expr")
203    )
204    .add_enum(EnumBuilder::new("BlockOrIf")
205        .node_with_explicit_kind("Block", "ExprBlock")
206        .node_with_explicit_kind("If", "ExprIf")
207    )
208    .add_struct(StructBuilder::new("ExprLoop")
209        .node("loop_kw", "TerminalLoop")
210        .node("body", "ExprBlock")
211    )
212    .add_struct(StructBuilder::new("ExprWhile")
213        .node("while_kw", "TerminalWhile")
214        .node("conditions", "ConditionListAnd")
215        .node("body", "ExprBlock")
216    )
217    .add_struct(StructBuilder::new("ExprFor")
218        .node("for_kw", "TerminalFor")
219        .key_node("pattern", "Pattern")
220        .key_node("identifier", "TerminalIdentifier")
221        .node("expr", "Expr")
222        .node("body", "ExprBlock")
223    )
224    .add_struct(StructBuilder::new("ElseClause")
225        .node("else_kw", "TerminalElse")
226        .node("else_block_or_if", "BlockOrIf")
227    )
228    .add_option("ElseClause")
229    .add_struct(StructBuilder::new("ExprErrorPropagate").node("expr", "Expr").node("op", "TerminalQuestionMark"))
230    .add_struct(StructBuilder::new("ExprIndexed")
231        .node("expr", "Expr")
232        .node("lbrack", "TerminalLBrack")
233        .node("index_expr", "Expr")
234        .node("rbrack", "TerminalRBrack")
235    )
236    .add_struct(StructBuilder::new("ExprFixedSizeArray")
237        .node("lbrack", "TerminalLBrack")
238        .node("exprs", "ExprList")
239        .node("size", "OptionFixedSizeArraySize")
240        .node("rbrack", "TerminalRBrack")
241    )
242    .add_struct(StructBuilder::new("FixedSizeArraySize")
243        .node("semicolon", "TerminalSemicolon")
244        .node("size", "Expr")
245    )
246    .add_option("FixedSizeArraySize")
247    .add_struct(StructBuilder::new("ExprClosure")
248        .node("params", "ClosureParams")
249        .node("ret_ty", "OptionReturnTypeClause")
250        .node("optional_no_panic", "OptionTerminalNoPanic")
251        .node("expr", "Expr")
252    )
253    .add_struct(StructBuilder::new("ClosureParams")
254        .node("leftor","TerminalOr")
255        .node("params", "ParamList")
256        .node("rightor", "TerminalOr")
257    )
258    // --- Struct ctor ---
259    .add_struct(StructBuilder::new("StructArgExpr")
260        .node("colon", "TerminalColon")
261        .node("expr", "Expr")
262    )
263    .add_option("StructArgExpr")
264    .add_struct(StructBuilder::new("StructArgSingle")
265        .key_node("identifier", "TerminalIdentifier")
266        .node("arg_expr", "OptionStructArgExpr")
267    )
268    .add_struct(StructBuilder::new("StructArgTail")
269        .node("dotdot", "TerminalDotDot")
270        .node("expression", "Expr")
271    )
272    .add_enum(EnumBuilder::new("StructArg")
273        .node_with_explicit_kind("StructArgSingle", "StructArgSingle")
274        .node_with_explicit_kind("StructArgTail", "StructArgTail")
275    )
276    .add_separated_list("StructArgList", "StructArg", "TerminalComma")
277    .add_struct(StructBuilder::new("ArgListBraced")
278        .node("lbrace", "TerminalLBrace")
279        .node("arguments", "ArgList")
280        .node("rbrace", "TerminalRBrace")
281    )
282    .add_struct(StructBuilder::new("ArgListBracketed")
283        .node("lbrack", "TerminalLBrack")
284        .node("arguments", "ArgList")
285        .node("rbrack", "TerminalRBrack")
286    )
287    .add_enum(EnumBuilder::new("WrappedArgList")
288        .missing("Missing")
289        .node_with_explicit_kind("BracketedArgList", "ArgListBracketed")
290        .node_with_explicit_kind("ParenthesizedArgList", "ArgListParenthesized")
291        .node_with_explicit_kind("BracedArgList", "ArgListBraced")
292    )
293    .add_struct(StructBuilder::new("WrappedArgListMissing"))
294    // ---Patterns ---
295    .add_enum(EnumBuilder::new("Pattern")
296        .node_with_explicit_kind("Underscore", "TerminalUnderscore")
297        .node_with_explicit_kind("Literal", "TerminalLiteralNumber")
298        .node_with_explicit_kind("False", "TerminalFalse")
299        .node_with_explicit_kind("True", "TerminalTrue")
300        .node_with_explicit_kind("ShortString", "TerminalShortString")
301        .node_with_explicit_kind("String", "TerminalString")
302        .node("Identifier")
303        .node("Struct")
304        .node("Tuple")
305        .node("Enum")
306        .node("FixedSizeArray")
307        .node_with_explicit_kind("Path", "ExprPath")
308    )
309    .add_struct(StructBuilder::new("PatternIdentifier")
310        .node("modifiers", "ModifierList")
311        .key_node("name", "TerminalIdentifier")
312    )
313    .add_struct(StructBuilder::new("PatternStruct")
314        // TODO(spapini): Use SimplePath instead - which is not an expr.
315        .node("path", "ExprPath")
316        .node("lbrace", "TerminalLBrace")
317        .node("params", "PatternStructParamList")
318        .node("rbrace", "TerminalRBrace")
319    )
320    .add_separated_list("PatternStructParamList", "PatternStructParam", "TerminalComma")
321    .add_struct(StructBuilder::new("PatternTuple")
322        .node("lparen", "TerminalLParen")
323        .node("patterns", "PatternList")
324        .node("rparen", "TerminalRParen")
325    )
326    .add_struct(StructBuilder::new("PatternFixedSizeArray")
327        .node("lbrack", "TerminalLBrack")
328        .node("patterns", "PatternList")
329        .node("rbrack", "TerminalRBrack"))
330    .add_separated_list("PatternList", "Pattern", "TerminalComma")
331    .add_separated_list("PatternListOr", "Pattern", "TerminalOr")
332    .add_enum(EnumBuilder::new("PatternStructParam")
333        .node_with_explicit_kind("Single", "PatternIdentifier")
334        .node("WithExpr")
335        .node_with_explicit_kind("Tail", "TerminalDotDot")
336    )
337    .add_struct(StructBuilder::new("PatternStructParamWithExpr")
338        .node("modifiers", "ModifierList")
339        .node("name", "TerminalIdentifier")
340        .node("colon", "TerminalColon")
341        .node("pattern", "Pattern")
342    )
343    .add_struct(StructBuilder::new("PatternEnum")
344        .node("path", "ExprPath")
345        .node("pattern", "OptionPatternEnumInnerPattern")
346    )
347    .add_struct(StructBuilder::new("PatternEnumInnerPattern")
348        .node("lparen", "TerminalLParen")
349        .node("pattern", "Pattern")
350        .node("rparen", "TerminalRParen")
351    )
352    .add_option("PatternEnumInnerPattern")
353    // --- Type clauses ---
354    // TODO(yuval): support SimpleExpr instead of Expr
355    .add_struct(StructBuilder::new("TypeClause").node("colon", "TerminalColon").node("ty", "Expr"))
356    .add_option("TypeClause")
357    .add_struct(StructBuilder::new("ReturnTypeClause")
358        .node("arrow", "TerminalArrow")
359        .node("ty", "Expr")
360    )
361    .add_option("ReturnTypeClause")
362    // --- Statements ---
363    .add_enum(EnumBuilder::new("Statement")
364        .missing("Missing")
365        .node("Let")
366        .node("Expr")
367        .node("Continue")
368        .node("Return")
369        .node("Break")
370        .node("Item")
371    )
372    .add_list("StatementList", "Statement")
373    .add_struct(StructBuilder::new("StatementMissing"))
374    .add_struct(StructBuilder::new("StatementLet")
375        .node("attributes" ,"AttributeList")
376        .node("let_kw", "TerminalLet")
377        .key_node("pattern", "Pattern")
378        .node("type_clause", "OptionTypeClause")
379        .node("eq", "TerminalEq")
380        .node("rhs", "Expr")
381        .node("let_else_clause", "OptionLetElseClause")
382        .node("semicolon", "TerminalSemicolon")
383    )
384    .add_struct(StructBuilder::new("LetElseClause")
385        .node("else_kw", "TerminalElse")
386        .node("else_block", "ExprBlock")
387    )
388    .add_option("LetElseClause")
389    .add_option("TerminalSemicolon")
390    .add_struct(StructBuilder::new("StatementExpr")
391        .node("attributes" ,"AttributeList")
392        .node("expr", "Expr")
393        .node("semicolon", "OptionTerminalSemicolon")
394    )
395    .add_struct(StructBuilder::new("StatementContinue")
396        .node("attributes" ,"AttributeList")
397        .node("continue_kw", "TerminalContinue")
398        .node("semicolon", "TerminalSemicolon")
399    )
400    .add_struct(StructBuilder::new("ExprClause")
401        .node("expr", "Expr"))
402    .add_option("ExprClause")
403    .add_struct(StructBuilder::new("StatementReturn")
404        .node("attributes" ,"AttributeList")
405        .node("return_kw", "TerminalReturn")
406        .node("expr_clause", "OptionExprClause")
407        .node("semicolon", "TerminalSemicolon")
408    )
409    .add_struct(StructBuilder::new("StatementBreak")
410        .node("attributes" ,"AttributeList")
411        .node("break_kw", "TerminalBreak")
412        .node("expr_clause", "OptionExprClause")
413        .node("semicolon", "TerminalSemicolon")
414    )
415    .add_struct(StructBuilder::new("StatementItem")
416        .node("item", "ModuleItem")
417    )
418    // --- Functions ---
419    .add_struct(StructBuilder::new("Param")
420        .node("modifiers", "ModifierList")
421        .key_node("name", "TerminalIdentifier")
422        .node("type_clause", "OptionTypeClause")
423    )
424    .add_list("ModifierList", "Modifier")
425    .add_enum(EnumBuilder::new("Modifier")
426        .node_with_explicit_kind("Ref", "TerminalRef")
427        .node_with_explicit_kind("Mut", "TerminalMut")
428    )
429    .add_separated_list("ParamList", "Param", "TerminalComma")
430    .add_struct(StructBuilder::new("ImplicitsClause")
431        .node("implicits_kw", "TerminalImplicits")
432        .node("lparen", "TerminalLParen")
433        .node("implicits", "ImplicitsList")
434        .node("rparen", "TerminalRParen")
435    )
436    .add_separated_list("ImplicitsList", "ExprPath", "TerminalComma")
437    .add_option("ImplicitsClause")
438    .add_option("TerminalNoPanic")
439    .add_option("TerminalConst")
440    // TODO(spapini): Add generic params.
441    // This is an unnamed signature, e.g. "() -> Type".
442    .add_struct(StructBuilder::new("FunctionSignature")
443        .node("lparen", "TerminalLParen")
444        .node("parameters", "ParamList")
445        .node("rparen", "TerminalRParen")
446        .node("ret_ty", "OptionReturnTypeClause")
447        .node("implicits_clause", "OptionImplicitsClause")
448        .node("optional_no_panic", "OptionTerminalNoPanic")
449    )
450    // --- Struct Members ---
451    // Struct member and enum variant have the same structure.
452    .add_struct(StructBuilder::new("Member")
453        .node("attributes" ,"AttributeList")
454        .node("visibility", "Visibility")
455        .key_node("name", "TerminalIdentifier")
456        .node("type_clause", "TypeClause")
457    )
458    .add_separated_list("MemberList", "Member", "TerminalComma")
459    .add_struct(StructBuilder::new("Variant")
460        .node("attributes" ,"AttributeList")
461        .key_node("name", "TerminalIdentifier")
462        .node("type_clause", "OptionTypeClause")
463    )
464    .add_separated_list("VariantList", "Variant", "TerminalComma")
465    // --- Items ---
466    .add_enum(EnumBuilder::new("ModuleItem")
467        .missing("Missing")
468        .node_with_explicit_kind("Constant", "ItemConstant")
469        .node_with_explicit_kind("Module", "ItemModule")
470        .node_with_explicit_kind("Use", "ItemUse")
471        .node_with_explicit_kind("FreeFunction", "FunctionWithBody")
472        .node_with_explicit_kind("ExternFunction", "ItemExternFunction")
473        .node_with_explicit_kind("ExternType", "ItemExternType")
474        .node_with_explicit_kind("Trait", "ItemTrait")
475        .node_with_explicit_kind("Impl", "ItemImpl")
476        .node_with_explicit_kind("ImplAlias", "ItemImplAlias")
477        .node_with_explicit_kind("Struct", "ItemStruct")
478        .node_with_explicit_kind("Enum", "ItemEnum")
479        .node_with_explicit_kind("TypeAlias", "ItemTypeAlias")
480        .node_with_explicit_kind("InlineMacro", "ItemInlineMacro")
481        .node_with_explicit_kind("MacroDeclaration", "ItemMacroDeclaration")
482        .node_with_explicit_kind("HeaderDoc", "ItemHeaderDoc")
483    )
484    .add_list("ModuleItemList", "ModuleItem")
485    .add_struct(StructBuilder::new("ModuleItemMissing"))
486    .add_struct(StructBuilder::new("Attribute")
487        .node("hash", "TerminalHash")
488        .node("lbrack", "TerminalLBrack")
489        .node("attr", "ExprPath")
490        .node("arguments", "OptionArgListParenthesized")
491        .node("rbrack", "TerminalRBrack")
492    )
493    .add_list("AttributeList", "Attribute")
494    .add_struct(StructBuilder::new("VisibilityDefault"))
495    .add_struct(StructBuilder::new("VisibilityPubArgumentClause")
496        .node("lparen", "TerminalLParen")
497        .node("argument", "TerminalIdentifier")
498        .node("rparen", "TerminalRParen")
499    )
500    .add_option("VisibilityPubArgumentClause")
501    .add_struct(StructBuilder::new("VisibilityPub")
502        .node("pub_kw", "TerminalPub")
503        .node("argument_clause", "OptionVisibilityPubArgumentClause")
504    )
505    .add_enum(EnumBuilder::new("Visibility")
506        .node("Default")
507        .node("Pub")
508    )
509    .add_struct(StructBuilder::new("ItemModule")
510        .node("attributes" ,"AttributeList")
511        .node("visibility", "Visibility")
512        .node("module_kw", "TerminalModule")
513        .key_node("name", "TerminalIdentifier")
514        .node("body", "MaybeModuleBody")
515    )
516    .add_enum(EnumBuilder::new("MaybeModuleBody")
517        .node_with_explicit_kind("Some", "ModuleBody")
518        .node_with_explicit_kind("None", "TerminalSemicolon")
519    )
520    .add_struct(StructBuilder::new("ModuleBody")
521        .node("lbrace", "TerminalLBrace")
522        .node("items", "ModuleItemList")
523        .node("rbrace", "TerminalRBrace")
524    )
525    .add_struct(StructBuilder::new("FunctionDeclaration")
526        .node("optional_const", "OptionTerminalConst")
527        .node("function_kw", "TerminalFunction")
528        .key_node("name", "TerminalIdentifier")
529        .node("generic_params", "OptionWrappedGenericParamList")
530        .node("signature", "FunctionSignature")
531    )
532    .add_struct(StructBuilder::new("ItemConstant")
533        .node("attributes" ,"AttributeList")
534        .node("visibility", "Visibility")
535        .node("const_kw", "TerminalConst")
536        .key_node("name", "TerminalIdentifier")
537        .node("type_clause", "TypeClause")
538        .node("eq", "TerminalEq")
539        .node("value", "Expr")
540        .node("semicolon", "TerminalSemicolon")
541    )
542    .add_struct(StructBuilder::new("FunctionWithBody")
543        .node("attributes" ,"AttributeList")
544        .node("visibility", "Visibility")
545         // TODO(ilya): Use only the name as key node.
546        .key_node("declaration", "FunctionDeclaration")
547        .node("body", "ExprBlock")
548    )
549    .add_struct(StructBuilder::new("ItemExternFunction")
550        .node("attributes" ,"AttributeList")
551        .node("visibility", "Visibility")
552        .node("extern_kw", "TerminalExtern")
553         // TODO(ilya): Use only the name as key node.
554        .key_node("declaration", "FunctionDeclaration")
555        .node("semicolon", "TerminalSemicolon")
556    )
557    .add_struct(StructBuilder::new("ItemExternType")
558        .node("attributes" ,"AttributeList")
559        .node("visibility", "Visibility")
560        .node("extern_kw", "TerminalExtern")
561        .node("type_kw", "TerminalType")
562        .key_node("name", "TerminalIdentifier")
563        .node("generic_params", "OptionWrappedGenericParamList")
564        .node("semicolon", "TerminalSemicolon")
565    )
566    .add_struct(StructBuilder::new("ItemTrait")
567        .node("attributes" ,"AttributeList")
568        .node("visibility", "Visibility")
569        .node("trait_kw", "TerminalTrait")
570        .key_node("name", "TerminalIdentifier")
571        .node("generic_params", "OptionWrappedGenericParamList")
572        .node("body", "MaybeTraitBody")
573    )
574    .add_enum(EnumBuilder::new("MaybeTraitBody")
575        .node_with_explicit_kind("Some", "TraitBody")
576        .node_with_explicit_kind("None", "TerminalSemicolon")
577    )
578    .add_struct(StructBuilder::new("TraitBody")
579        .node("lbrace", "TerminalLBrace")
580        .node("items", "TraitItemList")
581        .node("rbrace", "TerminalRBrace")
582    )
583    .add_list("TraitItemList", "TraitItem")
584    .add_enum(EnumBuilder::new("TraitItem")
585        .missing("Missing")
586        .node("Function")
587        .node("Type")
588        .node("Constant")
589        .node("Impl")
590    )
591    .add_struct(StructBuilder::new("TraitItemMissing"))
592    .add_struct(StructBuilder::new("TraitItemFunction")
593        .node("attributes" ,"AttributeList")
594         // TODO(ilya): Use only the name as key node.
595        .key_node("declaration", "FunctionDeclaration")
596        .node("body", "MaybeTraitFunctionBody")
597    )
598    .add_struct(StructBuilder::new("TraitItemType")
599        .node("attributes" ,"AttributeList")
600        .node("type_kw", "TerminalType")
601        .key_node("name", "TerminalIdentifier")
602        .node("generic_params", "OptionWrappedGenericParamList")
603        .node("semicolon", "TerminalSemicolon")
604    )
605    .add_struct(StructBuilder::new("TraitItemConstant")
606        .node("attributes" ,"AttributeList")
607        .node("const_kw", "TerminalConst")
608        .key_node("name", "TerminalIdentifier")
609        .node("type_clause", "TypeClause")
610        .node("semicolon", "TerminalSemicolon")
611    )
612    .add_struct(StructBuilder::new("TraitItemImpl")
613        .node("attributes" ,"AttributeList")
614        .node("impl_kw", "TerminalImpl")
615        .key_node("name", "TerminalIdentifier")
616        .node("colon", "TerminalColon")
617        .node("trait_path", "ExprPath")
618        .node("semicolon", "TerminalSemicolon")
619    )
620    .add_enum(EnumBuilder::new("MaybeTraitFunctionBody")
621        .node_with_explicit_kind("Some", "ExprBlock")
622        .node_with_explicit_kind("None", "TerminalSemicolon")
623    )
624    .add_struct(StructBuilder::new("ItemImpl")
625        .node("attributes" ,"AttributeList")
626        .node("visibility", "Visibility")
627        .node("impl_kw", "TerminalImpl")
628        .key_node("name", "TerminalIdentifier")
629        .node("generic_params", "OptionWrappedGenericParamList")
630        .node("of_kw", "TerminalOf")
631        .node("trait_path", "ExprPath")
632        .node("body", "MaybeImplBody")
633    )
634    // Empty struct, which is used for separating the first comments in a file or module from the
635    // rest of the items. This is needed to prevent the first comments from being moved by the
636    // formatter.
637    .add_struct(StructBuilder::new("ItemHeaderDoc")
638        .node("empty", "TerminalEmpty"))
639    .add_enum(EnumBuilder::new("MaybeImplBody")
640        .node_with_explicit_kind("Some", "ImplBody")
641        .node_with_explicit_kind("None", "TerminalSemicolon")
642    )
643    .add_struct(StructBuilder::new("ImplBody")
644            .node("lbrace", "TerminalLBrace")
645            .node("items", "ImplItemList")
646            .node("rbrace", "TerminalRBrace")
647    )
648    .add_list("ImplItemList", "ImplItem")
649    .add_enum(EnumBuilder::new("ImplItem")
650        .missing("Missing")
651        .node_with_explicit_kind("Function", "FunctionWithBody")
652        .node_with_explicit_kind("Type", "ItemTypeAlias")
653        .node_with_explicit_kind("Constant", "ItemConstant")
654        .node_with_explicit_kind("Impl", "ItemImplAlias")
655        // These are not supported semantically.
656        .node_with_explicit_kind("Module", "ItemModule")
657        .node_with_explicit_kind("Use", "ItemUse")
658        .node_with_explicit_kind("ExternFunction", "ItemExternFunction")
659        .node_with_explicit_kind("ExternType", "ItemExternType")
660        .node_with_explicit_kind("Trait", "ItemTrait")
661        .node_with_explicit_kind("Struct", "ItemStruct")
662        .node_with_explicit_kind("Enum", "ItemEnum")
663    )
664    .add_struct(StructBuilder::new("ImplItemMissing"))
665    .add_struct(StructBuilder::new("ItemImplAlias")
666        .node("attributes" ,"AttributeList")
667        .node("visibility", "Visibility")
668        .node("impl_kw", "TerminalImpl")
669        .key_node("name", "TerminalIdentifier")
670        .node("generic_params", "OptionWrappedGenericParamList")
671        .node("eq", "TerminalEq")
672        .node("impl_path", "ExprPath")
673        .node("semicolon", "TerminalSemicolon")
674    )
675    .add_struct(StructBuilder::new("ItemStruct")
676        .node("attributes" ,"AttributeList")
677        .node("visibility", "Visibility")
678        .node("struct_kw", "TerminalStruct")
679        .key_node("name", "TerminalIdentifier")
680        .node("generic_params", "OptionWrappedGenericParamList")
681        .node("lbrace", "TerminalLBrace")
682        .node("members", "MemberList")
683        .node("rbrace", "TerminalRBrace")
684    )
685    .add_struct(StructBuilder::new("ItemEnum")
686        .node("attributes" ,"AttributeList")
687        .node("visibility", "Visibility")
688        .node("enum_kw", "TerminalEnum")
689        .key_node("name", "TerminalIdentifier")
690        .node("generic_params", "OptionWrappedGenericParamList")
691        .node("lbrace", "TerminalLBrace")
692        .node("variants", "VariantList")
693        .node("rbrace", "TerminalRBrace")
694    )
695    .add_struct(StructBuilder::new("ItemTypeAlias")
696        .node("attributes" ,"AttributeList")
697        .node("visibility", "Visibility")
698        .node("type_kw", "TerminalType")
699        .key_node("name", "TerminalIdentifier")
700        .node("generic_params", "OptionWrappedGenericParamList")
701        .node("eq", "TerminalEq")
702        .node("ty", "Expr")
703        .node("semicolon", "TerminalSemicolon")
704    )
705    .add_struct(StructBuilder::new("ItemUse")
706        .node("attributes" ,"AttributeList")
707        .node("visibility", "Visibility")
708        .node("use_kw", "TerminalUse")
709        .node("dollar", "OptionTerminalDollar")
710        .key_node("use_path", "UsePath")
711        .node("semicolon", "TerminalSemicolon")
712    )
713    .add_enum(
714        EnumBuilder::new("UsePath")
715        .node("Leaf")
716        .node("Single")
717        .node("Multi")
718        .node("Star")
719    )
720    .add_struct(StructBuilder::new("UsePathLeaf")
721        .key_node("ident", "PathSegment")
722        .key_node("alias_clause", "OptionAliasClause")
723    )
724    .add_struct(StructBuilder::new("UsePathSingle")
725        .node("ident", "PathSegment")
726        .node("colon_colon", "TerminalColonColon")
727        .node("use_path", "UsePath")
728    )
729    .add_struct(StructBuilder::new("UsePathMulti")
730        .node("lbrace", "TerminalLBrace")
731        .node("use_paths", "UsePathList")
732        .node("rbrace", "TerminalRBrace")
733    )
734    .add_struct(StructBuilder::new("UsePathStar")
735        .node("star", "TerminalMul")
736    )
737    .add_separated_list("UsePathList", "UsePath", "TerminalComma")
738    .add_struct(StructBuilder::new("AliasClause")
739        .node("as_kw", "TerminalAs")
740        .key_node("alias", "TerminalIdentifier")
741    )
742    .add_option("AliasClause")
743    // --- Generics ---
744    .add_enum(
745        EnumBuilder::new("GenericArg")
746        .node("Unnamed")
747        .node("Named")
748    )
749    .add_struct(StructBuilder::new("GenericArgNamed")
750        .node("name", "TerminalIdentifier")
751        .node("colon", "TerminalColon")
752        .node("value", "Expr")
753    )
754    .add_struct(StructBuilder::new("GenericArgUnnamed")
755        .node("value", "Expr")
756    )
757    .add_struct(StructBuilder::new("GenericArgs")
758        .node("langle", "TerminalLT")
759        .node("generic_args", "GenericArgList")
760        .node("rangle", "TerminalGT")
761    )
762    .add_separated_list("GenericArgList", "GenericArg", "TerminalComma")
763    .add_struct(
764        StructBuilder::new("AssociatedItemConstraint")
765        .node("item","TerminalIdentifier")
766        .node("colon","TerminalColon")
767        .node("value","Expr")
768    )
769    .add_struct(StructBuilder::new("AssociatedItemConstraints")
770        .node("lbrack", "TerminalLBrack")
771        .node("associated_item_constraints", "AssociatedItemConstraintList")
772        .node("rbrack", "TerminalRBrack")
773    )
774    .add_separated_list("AssociatedItemConstraintList", "AssociatedItemConstraint", "TerminalComma")
775    .add_option("AssociatedItemConstraints")
776    .add_option("WrappedGenericParamList")
777    .add_struct(StructBuilder::new("WrappedGenericParamList")
778        .node("langle", "TerminalLT")
779        .node("generic_params", "GenericParamList")
780        .node("rangle", "TerminalGT")
781    )
782    .add_separated_list("GenericParamList", "GenericParam", "TerminalComma")
783    // TODO(spapini): Remove this indirection.
784    .add_enum(EnumBuilder::new("GenericParam")
785        .node("Type")
786        .node("Const")
787        .node("ImplNamed")
788        .node("ImplAnonymous")
789        .node("NegativeImpl")
790    )
791    .add_struct(StructBuilder::new("GenericParamType")
792        .key_node("name", "TerminalIdentifier")
793    )
794    .add_struct(StructBuilder::new("GenericParamConst")
795        .node("const_kw", "TerminalConst")
796        .key_node("name", "TerminalIdentifier")
797        .node("colon", "TerminalColon")
798        .node("ty", "Expr")
799    )
800    .add_struct(StructBuilder::new("GenericParamImplNamed")
801        .node("impl_kw", "TerminalImpl")
802        .key_node("name", "TerminalIdentifier")
803        .node("colon", "TerminalColon")
804        .node("trait_path", "ExprPath")
805        .node("type_constrains", "OptionAssociatedItemConstraints")
806    )
807    .add_struct(StructBuilder::new("GenericParamImplAnonymous")
808        .node("plus", "TerminalPlus")
809        .node("trait_path", "ExprPath")
810        .node("type_constrains", "OptionAssociatedItemConstraints")
811    )
812    .add_struct(StructBuilder::new("GenericParamNegativeImpl")
813        .node("minus", "TerminalMinus")
814        .node("trait_path", "ExprPath")
815    )
816    // --- Macros ---
817    // The structure of a token tree is:
818    // TokenTree: TokenNode | WrappedTokenTree
819    // Where WrappedTokenTree is:
820    // WrappedTokenTree: (TokenTree*) | {TokenTree*} | [TokenTree*]
821    // TokenTree* is represented as TokenList.
822    .add_list("TokenList", "TokenTree")
823    .add_struct(StructBuilder::new("TokenTreeLeaf")
824        .node("leaf", "TokenNode")
825    )
826    .add_struct(StructBuilder::new("TokenTreeNode")
827        .node("subtree", "WrappedTokenTree")
828    )
829    // TODO(Dean): Remove TokenTreeRepetition and TokenTreeParam (it's redundant).
830    .add_struct(StructBuilder::new("TokenTreeRepetition")
831        .node("dollar", "TerminalDollar")
832        .node("lparen", "TerminalLParen")
833        .node("elements", "TokenList")
834        .node("rparen", "TerminalRParen")
835        .node("separator", "OptionTerminalComma")
836        .node("operator", "MacroRepetitionOperator")
837    )
838    .add_struct(StructBuilder::new("TokenTreeParam")
839        .node("dollar", "TerminalDollar")
840        .node("name", "TerminalIdentifier")
841    )
842    .add_enum(EnumBuilder::new("TokenTree")
843        .missing("Missing")
844        .node_with_explicit_kind("Token", "TokenTreeLeaf")
845        .node_with_explicit_kind("Subtree", "TokenTreeNode")
846        .node_with_explicit_kind("Repetition", "TokenTreeRepetition")
847        .node_with_explicit_kind("Param", "TokenTreeParam")
848    )
849    .add_struct(StructBuilder::new("TokenTreeMissing"))
850    .add_enum(EnumBuilder::new("WrappedTokenTree")
851        .missing("Missing")
852        .node_with_explicit_kind("Parenthesized", "ParenthesizedTokenTree")
853        .node_with_explicit_kind("Braced", "BracedTokenTree")
854        .node_with_explicit_kind("Bracketed", "BracketedTokenTree")
855    )
856    .add_struct(StructBuilder::new("WrappedTokenTreeMissing"))
857    .add_struct(StructBuilder::new("ParenthesizedTokenTree")
858        .node("lparen", "TerminalLParen")
859        .node("tokens", "TokenList")
860        .node("rparen", "TerminalRParen")
861    )
862    .add_struct(StructBuilder::new("BracedTokenTree")
863        .node("lbrace", "TerminalLBrace")
864        .node("tokens", "TokenList")
865        .node("rbrace", "TerminalRBrace")
866    )
867    .add_struct(StructBuilder::new("BracketedTokenTree")
868        .node("lbrack", "TerminalLBrack")
869        .node("tokens", "TokenList")
870        .node("rbrack", "TerminalRBrack")
871    )
872    .add_struct(StructBuilder::new("ExprInlineMacro")
873        .node("path", "ExprPath")
874        .node("bang", "TerminalNot")
875        .node("arguments", "TokenTreeNode")
876    )
877    .add_struct(StructBuilder::new("ItemInlineMacro")
878    .node("attributes" ,"AttributeList")
879    .node("path", "ExprPath")
880    .node("bang", "TerminalNot")
881    .node("arguments", "TokenTreeNode")
882    .node("semicolon", "TerminalSemicolon"))
883    .add_struct(StructBuilder::new("ItemMacroDeclaration")
884        .node("attributes" ,"AttributeList")
885        .node("visibility", "Visibility")
886        .node("macro_kw", "TerminalMacro")
887        .key_node("name", "TerminalIdentifier")
888        .node("lbrace", "TerminalLBrace")
889        .node("rules", "MacroRulesList")
890        .node("rbrace", "TerminalRBrace")
891    )
892    .add_list("MacroRulesList", "MacroRule")
893    .add_struct(StructBuilder::new("MacroRule")
894        .node("lhs", "WrappedMacro")
895        .node("fat_arrow", "TerminalMatchArrow")
896        .node("rhs", "BracedMacro")
897        .node("semicolon", "TerminalSemicolon")
898    )
899    .add_struct(StructBuilder::new("ParamKind")
900        .node("colon", "TerminalColon")
901        .node("kind", "MacroParamKind")
902    )
903    .add_option("ParamKind")
904    .add_struct(StructBuilder::new("MacroParam")
905        .node("dollar", "TerminalDollar")
906        .node("name", "TerminalIdentifier")
907        .node("kind", "OptionParamKind")
908    )
909    .add_struct(StructBuilder::new("MacroRepetition")
910        .node("dollar", "TerminalDollar")
911        .node("lparen", "TerminalLParen")
912        .node("elements", "MacroElements")
913        .node("rparen", "TerminalRParen")
914        // TODO(Dean): Add support for more kinds of separators.
915        .node("separator", "OptionTerminalComma")
916        .node("operator", "MacroRepetitionOperator")
917    )
918    .add_option("TerminalComma")
919    .add_enum(EnumBuilder::new("MacroRepetitionOperator")
920        .node_with_explicit_kind("ZeroOrOne", "TerminalQuestionMark")
921        .node_with_explicit_kind("OneOrMore", "TerminalPlus")
922        .node_with_explicit_kind("ZeroOrMore", "TerminalMul")
923        .missing("Missing")
924    )
925    .add_struct(StructBuilder::new("MacroRepetitionOperatorMissing"))
926    // TODO(Gil): Add support for more kinds of macro rule parameters.
927    .add_struct(StructBuilder::new("ParamIdent")
928        .node("ident", "TerminalIdentifier")
929    )
930    .add_struct(StructBuilder::new("ParamExpr")
931        .node("expr", "TerminalIdentifier")
932    )
933    .add_enum(EnumBuilder::new("MacroParamKind")
934        .node_with_explicit_kind("Identifier", "ParamIdent")
935        .node_with_explicit_kind("Expr", "ParamExpr")
936        .missing("Missing")
937    )
938    .add_struct(StructBuilder::new("MacroParamKindMissing"))
939    .add_enum(EnumBuilder::new("MacroElement")
940        .node_with_explicit_kind("Token", "TokenTreeLeaf")
941        .node_with_explicit_kind("Param", "MacroParam")
942        .node_with_explicit_kind("Subtree", "MacroWrapper")
943        .node_with_explicit_kind("Repetition", "MacroRepetition")
944    )
945    .add_list("MacroElements", "MacroElement")
946    .add_struct(StructBuilder::new("MacroWrapper")
947        .node("subtree", "WrappedMacro")
948    )
949    .add_enum(EnumBuilder::new("WrappedMacro")
950        .node_with_explicit_kind("Parenthesized", "ParenthesizedMacro")
951        .node_with_explicit_kind("Braced", "BracedMacro")
952        .node_with_explicit_kind("Bracketed", "BracketedMacro")
953    )
954    .add_struct(StructBuilder::new("ParenthesizedMacro")
955        .node("lparen", "TerminalLParen")
956        .node("elements", "MacroElements")
957        .node("rparen", "TerminalRParen")
958    )
959    .add_struct(StructBuilder::new("BracedMacro")
960        .node("lbrace", "TerminalLBrace")
961        .node("elements", "MacroElements")
962        .node("rbrace", "TerminalRBrace")
963    )
964    .add_struct(StructBuilder::new("BracketedMacro")
965        .node("lbrack", "TerminalLBrack")
966        .node("elements", "MacroElements")
967        .node("rbrack", "TerminalRBrack")
968    )
969    .add_struct(StructBuilder::new("LegacyExprInlineMacro")
970        .node("path", "ExprPath")
971        .node("bang", "TerminalNot")
972        .node("arguments", "WrappedArgList")
973    )
974    .add_struct(StructBuilder::new("LegacyItemInlineMacro")
975        .node("attributes" ,"AttributeList")
976        .node("path", "ExprPath")
977        .node("bang", "TerminalNot")
978        .node("arguments", "WrappedArgList")
979        .node("semicolon", "TerminalSemicolon"))
980    // --- Skipped nodes ---
981    // A wrapper for the skipped node enum as the enum nodes (Trivium) can't have enum as a child directly.
982    .add_struct(StructBuilder::new("TriviumSkippedNode")
983        .node("node", "SkippedNode")
984    )
985    // An enum of all nodes that can be skipped while parsing, new nodes can be added here if needed to be skipped.
986    .add_enum(EnumBuilder::new("SkippedNode")
987        .node_with_explicit_kind("AttributeList", "AttributeList")
988        .node_with_explicit_kind("VisibilityPub", "VisibilityPub")
989        .node_with_explicit_kind("ExprPath", "ExprPath")
990    )
991    // --- Tokens + Terminals ---
992    .add_token_and_terminal("Identifier")
993    .add_token_and_terminal("LiteralNumber")
994    .add_token_and_terminal("ShortString")
995    .add_token_and_terminal("String")
996    .add_keyword_token_and_terminal("As")
997    .add_keyword_token_and_terminal("Const")
998    .add_keyword_token_and_terminal("Else")
999    .add_keyword_token_and_terminal("Enum")
1000    .add_keyword_token_and_terminal("Extern")
1001    .add_keyword_token_and_terminal("False")
1002    .add_keyword_token_and_terminal("Function")
1003    .add_keyword_token_and_terminal("If")
1004    .add_keyword_token_and_terminal("While")
1005    .add_keyword_token_and_terminal("For")
1006    .add_keyword_token_and_terminal("Loop")
1007    .add_keyword_token_and_terminal("Impl")
1008    .add_keyword_token_and_terminal("Implicits")
1009    .add_keyword_token_and_terminal("Let")
1010    .add_keyword_token_and_terminal("Macro")
1011    .add_keyword_token_and_terminal("Match")
1012    .add_keyword_token_and_terminal("Module")
1013    .add_keyword_token_and_terminal("Mut")
1014    .add_keyword_token_and_terminal("NoPanic")
1015    .add_keyword_token_and_terminal("Of")
1016    .add_keyword_token_and_terminal("Ref")
1017    .add_keyword_token_and_terminal("Continue")
1018    .add_keyword_token_and_terminal("Return")
1019    .add_keyword_token_and_terminal("Break")
1020    .add_keyword_token_and_terminal("Struct")
1021    .add_keyword_token_and_terminal("Trait")
1022    .add_keyword_token_and_terminal("True")
1023    .add_keyword_token_and_terminal("Type")
1024    .add_keyword_token_and_terminal("Use")
1025    .add_keyword_token_and_terminal("Pub")
1026    .add_token_and_terminal("And")
1027    .add_token_and_terminal("AndAnd")
1028    .add_token_and_terminal("Arrow")
1029    .add_token_and_terminal("At")
1030    .add_token_and_terminal("BadCharacters")
1031    .add_token_and_terminal("Colon")
1032    .add_token_and_terminal("ColonColon")
1033    .add_token_and_terminal("Comma")
1034    .add_token_and_terminal("Div")
1035    .add_token_and_terminal("DivEq")
1036    .add_token_and_terminal("Dollar")
1037    .add_token_and_terminal("Dot")
1038    .add_token_and_terminal("DotDot")
1039    .add_token_and_terminal("DotDotEq")
1040    .add_token_and_terminal("EndOfFile")
1041    .add_token_and_terminal("Eq")
1042    .add_token_and_terminal("EqEq")
1043    .add_token_and_terminal("GE")
1044    .add_token_and_terminal("GT")
1045    .add_token_and_terminal("Hash")
1046    .add_token_and_terminal("LBrace")
1047    .add_token_and_terminal("LBrack")
1048    .add_token_and_terminal("LE")
1049    .add_token_and_terminal("LParen")
1050    .add_token_and_terminal("LT")
1051    .add_token_and_terminal("MatchArrow")
1052    .add_token_and_terminal("Minus")
1053    .add_token_and_terminal("MinusEq")
1054    .add_token_and_terminal("Mod")
1055    .add_token_and_terminal("ModEq")
1056    .add_token_and_terminal("Mul")
1057    .add_token_and_terminal("MulEq")
1058    .add_token_and_terminal("Neq")
1059    .add_token_and_terminal("Not")
1060    .add_token_and_terminal("BitNot")
1061    .add_token_and_terminal("Or")
1062    .add_token_and_terminal("OrOr")
1063    .add_token_and_terminal("Plus")
1064    .add_token_and_terminal("PlusEq")
1065    .add_token_and_terminal("QuestionMark")
1066    .add_token_and_terminal("RBrace")
1067    .add_token_and_terminal("RBrack")
1068    .add_token_and_terminal("RParen")
1069    .add_token_and_terminal("Semicolon")
1070    .add_token_and_terminal("Underscore")
1071    .add_token_and_terminal("Xor")
1072    // --- Meta ---
1073    .add_struct(StructBuilder::new("SyntaxFile")
1074        .node("items", "ModuleItemList")
1075        .node("eof", "TerminalEndOfFile")
1076    )
1077    .add_token_and_terminal("Empty")
1078    .add_token("SingleLineComment")
1079    .add_token("SingleLineInnerComment")
1080    .add_token("SingleLineDocComment")
1081    .add_token("Whitespace")
1082    .add_token("Newline")
1083    .add_token("Missing")
1084    .add_token("Skipped")
1085    .add_all_tokens_enum("TokenNode")
1086    .get()
1087}