// 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",
"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": (
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": (