// Stores definitions which must be used in multiple places
-// See `cargo gen-syntax` (defined in crates/tools/src/main.rs)
+// See `cargo xtask codegen` (defined in xtasks/src/main.rs)
Grammar(
- single_byte_tokens: [
+ punct: [
(";", "SEMI"),
(",", "COMMA"),
("(", "L_PAREN"),
("^", "CARET"),
("%", "PERCENT"),
("_", "UNDERSCORE"),
- ],
- // Tokens for which the longest match must be chosen (e.g. `..` is a DOTDOT, but `.` is a DOT)
- multi_byte_tokens: [
(".", "DOT"),
("..", "DOTDOT"),
("...", "DOTDOTDOT"),
"SOURCE_FILE",
"STRUCT_DEF",
+ "UNION_DEF",
"ENUM_DEF",
"FN_DEF",
"RET_TYPE",
"BOX_PAT",
"BIND_PAT",
"PLACEHOLDER_PAT",
+ "DOT_DOT_PAT",
"PATH_PAT",
"RECORD_PAT",
"RECORD_FIELD_PAT_LIST",
"DocCommentsOwner"
]
),
+ "UnionDef": (
+ traits: [
+ "VisibilityOwner",
+ "NameOwner",
+ "TypeParamsOwner",
+ "AttrsOwner",
+ "DocCommentsOwner"
+ ],
+ options: ["RecordFieldDefList"],
+ ),
"RecordFieldDefList": (collections: [("fields", "RecordFieldDef")]),
"RecordFieldDef": (
traits: [
]),
"NominalDef": (
- enum: ["StructDef", "EnumDef"],
+ enum: ["StructDef", "EnumDef", "UnionDef"],
traits: [
"NameOwner",
"TypeParamsOwner",
],
),
"ModuleItem": (
- enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeAliasDef", "ImplBlock",
- "UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ]
+ enum: ["StructDef", "UnionDef", "EnumDef", "FnDef", "TraitDef", "TypeAliasDef", "ImplBlock",
+ "UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ],
+ traits: ["AttrsOwner"],
),
"ImplItem": (
- enum: ["FnDef", "TypeAliasDef", "ConstDef"]
+ enum: ["FnDef", "TypeAliasDef", "ConstDef"],
+ traits: ["AttrsOwner"]
),
"TupleExpr": (
"CastExpr": (options: ["Expr", "TypeRef"]),
"RefExpr": (options: ["Expr"]),
"PrefixExpr": (options: ["Expr"]),
+ "BoxExpr": (options: ["Expr"]),
"RangeExpr": (),
"BinExpr": (),
"BinExpr",
"Literal",
"MacroCall",
+ "BoxExpr",
],
),
traits: ["NameOwner"]
),
"PlaceholderPat": (),
+ "DotDotPat": (),
"PathPat": ( options: [ "Path" ] ),
"RecordPat": ( options: ["RecordFieldPatList", "Path"] ),
"RecordFieldPatList": (
"BoxPat",
"BindPat",
"PlaceholderPat",
+ "DotDotPat",
"PathPat",
"RecordPat",
"TupleStructPat",
traits: [ "NameOwner", "AttrsOwner","DocCommentsOwner" ],
options: [ "TokenTree", "Path" ],
),
- "Attr": ( options: [ ["value", "TokenTree"] ] ),
+ "AttrInput": ( enum: [ "Literal", "TokenTree" ] ),
+ "Attr": ( options: [ "Path", [ "input", "AttrInput" ] ] ),
"TokenTree": (),
"TypeParamList": (
collections: [
("lifetime_params", "LifetimeParam" ),
]
),
- "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner", "DefaultTypeParamOwner"] ),
+ "TypeParam": (
+ options: [("default_type", "TypeRef")],
+ traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"],
+ ),
"LifetimeParam": (
traits: ["AttrsOwner"],
),
],
traits: [
"AttrsOwner",
+ "ModuleItemOwner",
]
),
"ParamList": (
"SelfParam": (
traits: [
"TypeAscriptionOwner",
- "AttrsOwner",
+ "AttrsOwner",
]
),
"Param": (
options: [ "Pat" ],
traits: [
"TypeAscriptionOwner",
- "AttrsOwner",
+ "AttrsOwner",
]
),
"UseItem": (
]
),
"PathSegment": (
- options: [ "NameRef", "TypeArgList", "ParamList", "RetType" ]
+ options: [ "NameRef", "TypeArgList", "ParamList", "RetType", "PathType" ]
),
"TypeArgList": (collections: [
("type_args", "TypeArg"),