]> git.lizzy.rs Git - rust.git/blobdiff - crates/ra_syntax/src/grammar.ron
Add `ModuleItemsOwner` to `Block`
[rust.git] / crates / ra_syntax / src / grammar.ron
index 3e6c2d3f3ca5ce4dfcb9b8a963472baf7fb683a8..9ffa9095bc351e5dac3d217c69c48edc7e41087e 100644 (file)
@@ -1,7 +1,7 @@
 // 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"),
@@ -25,9 +25,6 @@ Grammar(
         ("^", "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"),
@@ -129,6 +126,7 @@ Grammar(
         "SOURCE_FILE",
 
         "STRUCT_DEF",
+        "UNION_DEF",
         "ENUM_DEF",
         "FN_DEF",
         "RET_TYPE",
@@ -161,6 +159,7 @@ Grammar(
         "BOX_PAT",
         "BIND_PAT",
         "PLACEHOLDER_PAT",
+        "DOT_DOT_PAT",
         "PATH_PAT",
         "RECORD_PAT",
         "RECORD_FIELD_PAT_LIST",
@@ -287,6 +286,16 @@ Grammar(
                 "DocCommentsOwner"
             ]
         ),
+        "UnionDef": (
+            traits: [
+                "VisibilityOwner",
+                "NameOwner",
+                "TypeParamsOwner",
+                "AttrsOwner",
+                "DocCommentsOwner"
+            ],
+            options: ["RecordFieldDefList"],
+        ),
         "RecordFieldDefList": (collections: [("fields", "RecordFieldDef")]),
         "RecordFieldDef": (
             traits: [
@@ -390,7 +399,7 @@ Grammar(
         ]),
 
         "NominalDef": (
-            enum: ["StructDef", "EnumDef"],
+            enum: ["StructDef", "EnumDef", "UnionDef"],
             traits: [
                 "NameOwner",
                 "TypeParamsOwner",
@@ -398,11 +407,13 @@ Grammar(
             ],
         ),
         "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": (
@@ -483,6 +494,7 @@ Grammar(
         "CastExpr": (options: ["Expr", "TypeRef"]),
         "RefExpr": (options: ["Expr"]),
         "PrefixExpr": (options: ["Expr"]),
+        "BoxExpr": (options: ["Expr"]),
         "RangeExpr": (),
         "BinExpr": (),
 
@@ -520,6 +532,7 @@ Grammar(
                 "BinExpr",
                 "Literal",
                 "MacroCall",
+                "BoxExpr",
             ],
         ),
 
@@ -530,6 +543,7 @@ Grammar(
             traits: ["NameOwner"]
         ),
         "PlaceholderPat": (),
+        "DotDotPat": (),
         "PathPat": ( options: [ "Path" ] ),
         "RecordPat": ( options: ["RecordFieldPatList", "Path"] ),
         "RecordFieldPatList": (
@@ -557,6 +571,7 @@ Grammar(
                 "BoxPat",
                 "BindPat",
                 "PlaceholderPat",
+                "DotDotPat",
                 "PathPat",
                 "RecordPat",
                 "TupleStructPat",
@@ -574,7 +589,8 @@ Grammar(
             traits: [ "NameOwner", "AttrsOwner","DocCommentsOwner" ],
             options: [ "TokenTree", "Path" ],
         ),
-        "Attr": ( options: [ ["value", "TokenTree"] ] ),
+        "AttrInput": ( enum: [ "Literal", "TokenTree" ] ),
+        "Attr": ( options: [ "Path", [ "input", "AttrInput" ] ] ),
         "TokenTree": (),
         "TypeParamList": (
             collections: [
@@ -582,7 +598,10 @@ Grammar(
                 ("lifetime_params", "LifetimeParam" ),
             ]
         ),
-        "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner", "DefaultTypeParamOwner"] ),
+        "TypeParam": (
+            options: [("default_type", "TypeRef")],
+            traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"],
+        ),
         "LifetimeParam": (
             traits: ["AttrsOwner"],
         ),
@@ -634,6 +653,7 @@ Grammar(
             ],
             traits: [
                 "AttrsOwner",
+                "ModuleItemOwner",
             ]
         ),
         "ParamList": (
@@ -645,14 +665,14 @@ Grammar(
         "SelfParam": (
             traits: [
                 "TypeAscriptionOwner",
-                               "AttrsOwner",
+                "AttrsOwner",
             ]
         ),
         "Param": (
             options: [ "Pat" ],
             traits: [
                 "TypeAscriptionOwner",
-                               "AttrsOwner",
+                "AttrsOwner",
             ]
         ),
         "UseItem": (
@@ -684,7 +704,7 @@ Grammar(
             ]
         ),
         "PathSegment": (
-            options: [ "NameRef", "TypeArgList" ]
+            options: [ "NameRef", "TypeArgList", "ParamList", "RetType", "PathType" ]
         ),
         "TypeArgList": (collections: [
             ("type_args", "TypeArg"),