// /* // See // https://github.com/rust-lang/rust/blob/master/src/grammar/lexer.l // https://github.com/rust-lang/rust/blob/master/src/grammar/parser-lalr.y // https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs // */ re_terminal!(Static,"static"); re_terminal!(Mut,"mut"); re_terminal!(Const,"const"); re_terminal!(Crate,"crate"); re_terminal!(Extern,"extern"); re_terminal!(As,"as"); re_terminal!(Struct,"struct"); re_terminal!(Enum,"enum"); re_terminal!(Union,"union"); re_terminal!(Mod,"mod"); re_terminal!(Unsafe,"unsafe"); re_terminal!(FN,"fn"); re_terminal!(Pub,"pub"); re_terminal!(LittleSelf,"self"); re_terminal!(Type,"type"); re_terminal!(For,"for"); re_terminal!(Trait,"trait"); re_terminal!(DEFAULT,"default"); re_terminal!(Impl,"impl"); re_terminal!(Where,"where"); re_terminal!(Super,"super"); re_terminal!(BOX,"box"); re_terminal!(Ref,"ref"); re_terminal!(Typeof,"typeof"); re_terminal!(StaticLifetime,"'static"); re_terminal!(Continue,"continue"); re_terminal!(Return,"return"); re_terminal!(Break,"break"); re_terminal!(Yield,"yield"); re_terminal!(Move,"move"); re_terminal!(Match,"match"); re_terminal!(If,"if"); re_terminal!(Else,"else"); re_terminal!(LiteralLet,"let"); re_terminal!(While,"while"); re_terminal!(Loop,"loop"); re_terminal!(In,"in"); re_terminal!(True,"true"); re_terminal!(False,"false"); re_terminal!(Catch,"catch"); re_terminal!(Use,"use"); terminal ShebangLine(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None //if parser.line_number>0 //{ // return None; //} //match parser.re("^#![^\n]*\n", source) //{ // None => None, // Some(size,string) => Some(size,()), //} } } terminal LitInteger(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None // 0x[0-9a-fA-F_]+ { BEGIN(suffix); return LIT_INTEGER; } // 0o[0-7_]+ { BEGIN(suffix); return LIT_INTEGER; } // 0b[01_]+ { BEGIN(suffix); return LIT_INTEGER; } // [0-9][0-9_]* { BEGIN(suffix); return LIT_INTEGER; } // [0-9][0-9_]*\.(\.|[a-zA-Z]) { yyless(yyleng - 2); BEGIN(suffix); return LIT_INTEGER; } } } terminal LiteralLifetime(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitByte(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitChar(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitFloat(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitStr(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitStrRaw(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitByteStr(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitByteStrRaw(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal NoSpace(()) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } re_terminal!(InnerDocComment,"\\\\![^\n]*\n"); re_terminal!(OuterDocComment,"\\\\\\[^\n]*\n"); re_terminal!(LiteralIdent(String),"[a-zA-Z\\x80-\\xff_][a-zA-Z0-9\\x80-\\xff_]*"); re_terminal!(Shebang,"#!"); re_terminal!(NumberSign,"#"); re_terminal!(FatArrow,"=>"); re_terminal!(EqualEqual,"=="); re_terminal!(NE,"!="); re_terminal!(Equal,"="); re_terminal!(LArrow,"\\<-"); re_terminal!(RArrow,"-\\>"); //These cause many problems. Perhaps "<<" -> (LT,NOSPACE,LT) //re_terminal!(SHL,"\\<\\<"); //re_terminal!(SHR,"\\>\\>"); //re_terminal!(SHREQ,"\\>\\>="); re_terminal!(LE,"\\<="); re_terminal!(GE,"\\>="); re_terminal!(MinusEqual,"-="); re_terminal!(AndEqual,"&="); re_terminal!(OrEqual,"\\|="); re_terminal!(PlusEqual,"\\+="); re_terminal!(StarEqual,"\\*="); re_terminal!(SlashEqual,"/="); re_terminal!(CaretEqual,"\\^="); re_terminal!(PercentEqual,"%="); re_terminal!(Underscore,"_"); re_terminal!(OrOr,"\\|\\|"); re_terminal!(Vertical,"\\|"); re_terminal!(Comma,","); re_terminal!(AndAnd,"&&"); re_terminal!(Ampersand,"&"); re_terminal!(DotDotDot,"\\.\\.\\."); re_terminal!(DotDot,"\\.\\."); re_terminal!(Dot,"\\."); re_terminal!(ModSep,"::"); re_terminal!(Colon,":"); re_terminal!(Caret,"\\^"); re_terminal!(Slash,"/"); re_terminal!(Percent,"%"); re_terminal!(Semicolon,";"); re_terminal!(Bang,"!"); re_terminal!(At,"@"); re_terminal!(Star,"\\*"); re_terminal!(QuestionMark,"\\?"); re_terminal!(LBracket,"\\["); re_terminal!(RBracket,"\\]"); re_terminal!(LPar,"\\("); re_terminal!(RPar,"\\)"); re_terminal!(LBrace,"\\{"); re_terminal!(RBrace,"\\}"); re_terminal!(LT,"\\<"); re_terminal!(GT,"\\>"); re_terminal!(Plus,"\\+"); re_terminal!(Minus,"-"); re_terminal!(_,"\\s+|\n|\\\\[^\n]*\n");//Otherwise skip spaces and normal comments //////////////////////////////////////////////////////////////////////// // Part 1: Items and attributes //////////////////////////////////////////////////////////////////////// nonterminal WholeCrate(()) { (MaybeShebang,InnerAttrs,MaybeModItems) => (), (MaybeShebang,MaybeModItems) => (), } nonterminal MaybeShebang(()) { (ShebangLine) => (), () => (), } nonterminal MaybeInnerAttrs(()) { (InnerAttrs) => (), () => (), } nonterminal InnerAttrs(()) { (InnerAttr) => (), (InnerAttrs,InnerAttr) => (), } nonterminal InnerAttr(()) { (Shebang,LBracket,MetaItem,RBracket) => (), (InnerDocComment) => (), } nonterminal MaybeOuterAttrs(()) { (OuterAttrs) => (), () => (), } nonterminal OuterAttrs(()) { (OuterAttr) => (), (OuterAttrs,OuterAttr) => (), } nonterminal OuterAttr(()) { (NumberSign,LBracket,MetaItem,RBracket) => (), (OuterDocComment) => (), } nonterminal MetaItem(()) { (Ident) => (), (Ident,Equal,Lit) => (), (Ident,LPar,MetaSeq,RPar) => (), (Ident,LPar,MetaSeq,Comma,RPar) => (), } nonterminal MetaSeq(()) { () => (), (MetaItem) => (), (MetaSeq,Comma,MetaItem) => (), } nonterminal MaybeModItems(()) { (ModItems) => (), () => (), } nonterminal ModItems(()) { (ModItem) => (), (ModItems,ModItem) => (), } nonterminal AttrsAndVis(()) { (MaybeOuterAttrs,Visibility) => (), } nonterminal ModItem(()) { (AttrsAndVis,Item) => (), } // items that can appear outside of a fn block nonterminal Item(()) { (StmtItem) => (), (ItemMacro) => (), } // items that can appear in "stmts" nonterminal StmtItem(()) { (ItemStatic) => (), (ItemConst) => (), (ItemType) => (), (BlockItem) => (), (ViewItem) => (), } nonterminal ItemStatic(()) { (Static,Ident,Colon,Ty,Equal,Expr,Semicolon) => (), (Static,Mut,Ident,Colon,Ty,Equal,Expr,Semicolon) => (), } nonterminal ItemConst(()) { (Const,Ident,Colon,Ty,Equal,Semicolon) => (), } nonterminal ItemMacro(()) { (PathExpr,Bang,MaybeIdent,ParensDelimitedTokenTrees,Semicolon) => (), (PathExpr,Bang,MaybeIdent,BracesDelimitedTokenTrees) => (), (PathExpr,Bang,MaybeIdent,BracketsDelimitedTokenTrees,Semicolon) => (), } nonterminal ViewItem(()) { (UseItem) => (), (ExternFnItem) => (), (Extern,Crate,Ident,Semicolon) => (), (Extern,Crate,Ident,As,Ident,Semicolon) => (), } nonterminal ExternFnItem(()) { (Extern,MaybeAbi,ItemFn) => (), } nonterminal UseItem { (Use,ViewPath,Semicolon) => (), } nonterminal ViewPath(()) { (PathNoTypesAllowed) => (), (PathNoTypesAllowed,ModSep,LBrace,RBrace) => (), (ModSep,LBrace,RBrace) => (), (PathNoTypesAllowed,ModSep,LBrace,IdentsOrSelf,RBrace) => (), (ModSep,LBrace,IdentsOrSelf,RBrace) => (), (PathNoTypesAllowed,ModSep,LBrace,IdentsOrSelf,Comma,RBrace) => (), (ModSep,LBrace,IdentsOrSelf,Comma,RBrace) => (), (PathNoTypesAllowed,ModSep,Star) => (), (ModSep,Star) => (), (Star) => (), (LBrace,RBrace) => (), (LBrace,IdentsOrSelf,RBrace) => (), (LBrace,IdentsOrSelf,Comma,RBrace) => (), (PathNoTypesAllowed,As,Ident) => (), } nonterminal BlockItem(()) { (ItemFn) => (), (ItemUnsafeFn) => (), (ItemMod) => (), (ItemForeignMod) => (), (ItemStruct) => (), (ItemEnum) => (), (ItemUnion) => (), (ItemTrait) => (), (ItemImpl) => (), } nonterminal MaybeTyAscription(()) { (Colon,TySum) => (), () => (), } nonterminal MaybeInitExpr(()) { (Equal,Expr) => (), () => (), } //structs nonterminal ItemStruct { (Struct,Ident,GenericParams,MaybeWhereClause,StructDeclArgs) => (), (Struct,Ident,GenericParams,StructTupleArgs,MaybeWhereClause,Semicolon) => (), (Struct,Ident,GenericParams,MaybeWhereClause,Semicolon) => (), } nonterminal StructDeclArgs { (LBrace,StructDeclFields,RBrace) => (), //(LBrace,StructDeclFields,RBrace,Comma) => (),//Wrong (LBrace,StructDeclFields,Comma,RBrace) => (), } nonterminal StructTupleArgs { (LPar,StructTupleFields,RPar) => (), (LPar,StructTupleFields,RPar,Comma) => (), } nonterminal StructDeclFields { (StructDeclField) => (), (StructDeclFields,Comma,StructDeclField) => (), () => (), } nonterminal StructDeclField { (AttrsAndVis,Ident,Colon,TySum) => (), } nonterminal StructTupleFields { (StructTupleField) => (), (StructTupleFields,Comma,StructTupleField) => (), () => (), } nonterminal StructTupleField { (AttrsAndVis,TySum) => (), } // enums nonterminal ItemEnum { (Enum,Ident,GenericParams,MaybeWhereClause,LBrace,EnumDefs,RBrace) => (), (Enum,Ident,GenericParams,MaybeWhereClause,LBrace,EnumDefs,Comma,RBrace) => (), } nonterminal EnumDefs { (EnumDef) => (), (EnumDefs,Comma,EnumDef) => (), () => (), } nonterminal EnumDef { (AttrsAndVis,Ident,EnumArgs) => (), } nonterminal EnumArgs { (LBrace,StructDeclFields,RBrace) => (), (LBrace,StructDeclFields,Comma,RBrace) => (), (LPar,MaybeTySums,RPar) => (), (Equal,Expr) => (), () => (), } // unions nonterminal ItemUnion { (Union,Ident,GenericParams,MaybeWhereClause,LBrace,StructDeclFields,RBrace) => (), (Union,Ident,GenericParams,MaybeWhereClause,LBrace,StructDeclFields,Comma,RBrace) => (), } nonterminal ItemMod { (Mod,Ident,Semicolon) => (), (Mod,Ident,LBrace,MaybeModItems,RBrace) => (), (Mod,Ident,LBrace,InnerAttrs,MaybeModItems,RBrace) => (), } nonterminal ItemForeignMod { (Extern,MaybeAbi,LBrace,MaybeForeignItems,RBrace) => (), (Extern,MaybeAbi,LBrace,InnerAttrs,MaybeForeignItems,RBrace) => (), } nonterminal MaybeAbi { (Str) => (), () => (), } nonterminal MaybeForeignItems { (ForeignItems) => (), () => (), } nonterminal ForeignItems { (ForeignItem) => (), (ForeignItems,ForeignItem) => (), } nonterminal ForeignItem { (AttrsAndVis,Static,ItemForeignStatic) => (), (AttrsAndVis,ItemForeignFn) => (), (AttrsAndVis,Unsafe,ItemForeignFn) => (), } nonterminal ItemForeignStatic { (MaybeMut,Ident,Colon,Ty,Semicolon) => (), } nonterminal ItemForeignFn { (FN,Ident,GenericParams,FnDeclAllowVariadic,MaybeWhereClause,Semicolon) => (), } nonterminal FnDeclAllowVariadic { (FnParamsAllowVariadic,RetTy) => (), } nonterminal FnParamsAllowVariadic { (LPar,RPar) => (), (LPar,Params,RPar) => (), (LPar,Params,Comma,RPar) => (), (LPar,Params,Comma,DotDotDot,RPar) => (), } nonterminal Visibility { (Pub) => (), () => (), } nonterminal IdentsOrSelf { (IdentOrSelf) => (), (IdentsOrSelf,As,Ident) => (), (IdentsOrSelf,Comma,IdentOrSelf) => (), } nonterminal IdentOrSelf { (Ident) => (), (LittleSelf) => (), } nonterminal ItemType { (Type,Ident,GenericParams,MaybeWhereClause,Equal,TySum,Semicolon) => (), } nonterminal ForSized { (For,QuestionMark,Ident) => (), (For,Ident,QuestionMark) => (), () => (), } nonterminal ItemTrait { (MaybeUnsafe,Trait,Ident,GenericParams,ForSized,MaybeTyParamBounds,MaybeWhereClause,LBrace,MaybeTraitItems,RBrace) => (), } nonterminal MaybeTraitItems { (TraitItems) => (), () => (), } nonterminal TraitItems { (TraitItem) => (), (TraitItems,TraitItem) => (), } nonterminal TraitItem { (TraitConst) => (), (TraitType) => (), (TraitMethod) => (), (MaybeOuterAttrs,ItemMacro) => (), } nonterminal TraitConst { (MaybeOuterAttrs,Const,Ident,MaybeTyAscription,MaybeConstDefault,Semicolon) => (), } nonterminal MaybeConstDefault { (Equal,Expr) => (), () => (), } nonterminal TraitType { (MaybeOuterAttrs,Type,TyParam,Semicolon) => (), } nonterminal MaybeUnsafe { (Unsafe) => (), () => (), } nonterminal MaybeDefaultMaybeUnsafe { (DEFAULT,Unsafe) => (), (Unsafe) => (), (Unsafe) => (), () => (), } nonterminal TraitMethod { (TypeMethod) => (), (Method) => (), } nonterminal TypeMethod { (MaybeOuterAttrs,MaybeUnsafe,FN,Ident,GenericParams,FnDeclWithSelfAllowAnonParams,MaybeWhereClause,Semicolon) => (), (MaybeOuterAttrs,Const,MaybeUnsafe,FN,Ident,GenericParams,FnDeclWithSelfAllowAnonParams,MaybeWhereClause,Semicolon) => (), (MaybeOuterAttrs,MaybeUnsafe,Extern,MaybeAbi,FN,Ident,GenericParams,FnDeclWithSelfAllowAnonParams,MaybeWhereClause,Semicolon) => (), } nonterminal Method { (MaybeOuterAttrs,MaybeUnsafe,FN,Ident,GenericParams,FnDeclWithSelfAllowAnonParams,MaybeWhereClause,InnerAttrsAndBlock) => (), (MaybeOuterAttrs,Const,MaybeUnsafe,FN,Ident,GenericParams,FnDeclWithSelfAllowAnonParams,MaybeWhereClause,InnerAttrsAndBlock) => (), (MaybeOuterAttrs,MaybeUnsafe,Extern,MaybeAbi,FN,Ident,GenericParams,FnDeclWithSelfAllowAnonParams,MaybeWhereClause,InnerAttrsAndBlock) => (), } nonterminal ImplMethod { (AttrsAndVis,MaybeDefault,MaybeUnsafe,FN,Ident,GenericParams,FnDeclWithSelf,MaybeWhereClause,InnerAttrsAndBlock) => (), (AttrsAndVis,MaybeDefault,Const,MaybeUnsafe,FN,Ident,GenericParams,FnDeclWithSelf,MaybeWhereClause,InnerAttrsAndBlock) => (), (AttrsAndVis,MaybeDefault,MaybeUnsafe,Extern,MaybeAbi,FN,Ident,GenericParams,FnDeclWithSelf,MaybeWhereClause,InnerAttrsAndBlock) => (), } // --- BISON NOTES --- // There are two forms of impl: // // impl (<...>)? TY { ... } // impl (<...>)? TRAIT for TY { ... } // // Unfortunately since TY can begin with '<' itself -- as part of a // TyQualifiedPath type -- there's an s/r conflict when we see '<' after IMPL: // should we reduce one of the early rules of TY (such as maybe_once) // or shall we continue shifting into the generic_params list for the // impl? // // The production parser disambiguates a different case here by // permitting / requiring the user to provide parens around types when // they are ambiguous with traits. We do the same here, regrettably, // by splitting ty into ty and ty_prim. nonterminal ItemImpl { (MaybeDefaultMaybeUnsafe,Impl,GenericParams,TyPrimSum,MaybeWhereClause,LBrace,MaybeInnerAttrs,MaybeImplItems,RBrace) => (), (MaybeDefaultMaybeUnsafe,Impl,GenericParams,LPar,Ty,RPar,MaybeWhereClause,LBrace,MaybeInnerAttrs,MaybeImplItems,RBrace) => (), (MaybeDefaultMaybeUnsafe,Impl,GenericParams,TraitRef,For,TySum,MaybeWhereClause,LBrace,MaybeInnerAttrs,MaybeImplItems,RBrace) => (), (MaybeDefaultMaybeUnsafe,Impl,GenericParams,Bang,TraitRef,For,TySum,MaybeWhereClause,LBrace,MaybeInnerAttrs,MaybeImplItems,RBrace) => (), (MaybeDefaultMaybeUnsafe,Impl,GenericParams,TraitRef,For,DotDot,LBrace,RBrace) => (), (MaybeDefaultMaybeUnsafe,Impl,GenericParams,Bang,TraitRef,For,DotDot,LBrace,RBrace) => (), } nonterminal MaybeImplItems { (ImplItems) => (), () => (), } nonterminal ImplItems { (ImplItem) => (), (ImplItem,ImplItems) => (), } nonterminal ImplItem { (ImplMethod) => (), (AttrsAndVis,ItemMacro) => (), (ImplConst) => (), (ImplType) => (), } nonterminal MaybeDefault { (DEFAULT) => (), () => (), } nonterminal ImplConst { (AttrsAndVis,MaybeDefault,ItemConst) => (), } nonterminal ImplType { (AttrsAndVis,MaybeDefault,Type,Ident,GenericParams,Equal,TySum,Semicolon) => (), } nonterminal ItemFn { (FN,Ident,GenericParams,FnDecl,MaybeWhereClause,InnerAttrsAndBlock) => (), (Const,FN,Ident,GenericParams,FnDecl,MaybeWhereClause,InnerAttrsAndBlock) => (), } nonterminal ItemUnsafeFn { (Unsafe,FN,Ident,GenericParams,FnDecl,MaybeWhereClause,InnerAttrsAndBlock) => (), (Const,Unsafe,FN,Ident,GenericParams,FnDecl,MaybeWhereClause,InnerAttrsAndBlock) => (), (Unsafe,Extern,MaybeAbi,FN,Ident,GenericParams,FnDecl,MaybeWhereClause,InnerAttrsAndBlock) => (), } nonterminal FnDecl { (FnParams,RetTy) => (), } nonterminal FnDeclWithSelf { (FnParamsWithSelf,RetTy) => (), } nonterminal FnDeclWithSelfAllowAnonParams { (FnAnonParamsWithSelf,RetTy) => (), } nonterminal FnParams { (LPar,MaybeParams,RPar) => (), } nonterminal FnAnonParams { (LPar,AnonParam,AnonParamsAllowVariadicTail,RPar) => (), (LPar,RPar) => (), } nonterminal FnParamsWithSelf { (LPar,MaybeMut,LittleSelf,MaybeTyAscription,MaybeCommaParams,RPar) => (), (LPar,Ampersand,MaybeMut,LittleSelf,MaybeTyAscription,MaybeCommaParams,RPar) => (), (LPar,Ampersand,Lifetime,MaybeMut,LittleSelf,MaybeTyAscription,MaybeCommaParams,RPar) => (), (LPar,MaybeParams,RPar) => (), } nonterminal FnAnonParamsWithSelf { (LPar,MaybeMut,LittleSelf,MaybeTyAscription,MaybeCommaAnonParams,RPar) => (), (LPar,Ampersand,MaybeMut,LittleSelf,MaybeTyAscription,MaybeCommaAnonParams,RPar) => (), (LPar,Ampersand,Lifetime,MaybeMut,LittleSelf,MaybeTyAscription,MaybeCommaAnonParams,RPar) => (), (LPar,MaybeAnonParams,RPar) => (), } nonterminal MaybeParams { (Params) => (), (Params,Comma) => (), () => (), } nonterminal Params { (Param) => (), (Params,Comma,Param) => (), } nonterminal Param { (Pat,Colon,TySum) => (), } nonterminal InferrableParams { (InferrableParam) => (), (InferrableParams,Comma,InferrableParam) => (), } nonterminal InferrableParam { (Pat,MaybeTyAscription) => (), } nonterminal MaybeCommaParams { (Comma) => (), (Comma,Params) => (), (Comma,Params,Comma) => (), () => (), } nonterminal MaybeCommaAnonParams { (Comma) => (), (Comma,AnonParams) => (), (Comma,AnonParams,Comma) => (), () => (), } nonterminal MaybeAnonParams { (AnonParams) => (), (AnonParams, Comma) => (), () => (), } nonterminal AnonParams { (AnonParam) => (), (AnonParams,Comma,AnonParam) => (), } // anon means it's allowed to be anonymous (type-only), but it can // still have a name nonterminal AnonParam { (NamedArg,Colon,Ty) => (), (Ty) => (), } nonterminal AnonParamsAllowVariadicTail { (Comma,DotDotDot) => (), (Comma,AnonParam,AnonParamsAllowVariadicTail) => (), () => (), } nonterminal NamedArg { (Ident) => (), (Underscore) => (), (Ampersand,Ident) => (), (Ampersand,Underscore) => (), (AndAnd,Ident) => (), (AndAnd,Underscore) => (), (Mut,Ident) => (), } nonterminal RetTy { (RArrow,Bang) => (), (RArrow,Ty) => (), () => (), //in bison with IDENT precedence } nonterminal GenericParams { (LT,GT,MaybeSpace) => (), (LT,Lifetimes,GT,MaybeSpace) => (), (LT,Lifetimes,Comma,GT,MaybeSpace) => (), //(LT,Lifetimes,SHR) => (), //(LT,Lifetimes,Comma,SHR) => (), //Tricky with bison: push_back('>'); (LT,Lifetimes,Comma,TyParams,GT,MaybeSpace) => (), (LT,Lifetimes,Comma,TyParams,Comma,GT,MaybeSpace) => (), //(LT,Lifetimes,Comma,TyParams,SHR) => (), //(LT,Lifetimes,Comma,TyParams,COMMA,SHR) => (), (LT,TyParams,GT) => (), (LT,TyParams,Comma,GT) => (), //(LT,TyParams,SHR) => (), //(LT,TyParams,Comma,SHR) => (), () => (), } nonterminal MaybeWhereClause { () => (), (WhereClause) => (), } nonterminal WhereClause { (Where,WherePredicates) => (), (Where,WherePredicates,Comma) => (), } nonterminal WherePredicates { (WherePredicate) => (), (WherePredicates,Comma,WherePredicate) => (), } nonterminal WherePredicate { (MaybeForLifetimes,Lifetime,Colon,Bounds) => (), (MaybeForLifetimes,Ty,Colon,TyParamBounds) => (), } nonterminal MaybeForLifetimes { (For,LT,Lifetimes,GT) => (), () => (), //bison precedence of FORTYPE } nonterminal TyParams { (TyParam) => (), (TyParams,Comma,TyParam) => (), } // A path with no type parameters; e.g. `foo::bar::Baz` // // These show up in 'use' view-items, because these are processed // without respect to types. nonterminal PathNoTypesAllowed { (Ident) => (), (ModSep,Ident) => (), (LittleSelf) => (), (ModSep,LittleSelf) => (), (Super) => (), (ModSep,Super) => (), (PathNoTypesAllowed,ModSep,Ident) => (), } // A path with a lifetime and type parameters, with no double colons // before the type parameters; e.g. `foo::bar<'a>::Baz` // // These show up in "trait references", the components of // type-parameter bounds lists, as well as in the prefix of the // path_generic_args_and_bounds rule, which is the full form of a // named typed expression. // // They do not have (nor need) an extra '::' before '<' because // unlike in expr context, there are no "less-than" type exprs to // be ambiguous with. nonterminal PathGenericArgsWithoutColons { (Ident) => (), (Ident,GenericArgs) => (), (Ident,LPar,MaybeTySums,RPar,RetTy) => (), (PathGenericArgsWithoutColons,ModSep,Ident) => (), (PathGenericArgsWithoutColons,ModSep,Ident,GenericArgs) => (), (PathGenericArgsWithoutColons,ModSep,Ident,LPar,MaybeTySums,RPar,RetTy) => (), } nonterminal GenericArgs { (LT,MaybeSpace,GenericValues,GT,MaybeSpace) => (), //(LT,GenericValues,SHR) => (), //push_back magic (LT,MaybeSpace,GenericValues,GE,MaybeSpace) => (), //(LT,GenericValues,SHREQ) => (), //(SHL,TyQualifiedPathAndGenericValues,GT) => (), //(SHL,TyQualifiedPathAndGenericValues,SHR) => (), //(SHL,TyQualifiedPathAndGenericValues,GE) => (), //(SHL,TyQualifiedPathAndGenericValues,SHREQ) => (), } nonterminal GenericValues { (MaybeTySumsAndOrBindings) => (), } nonterminal MaybeTySumsAndOrBindings { (TySums) => (), (TySums,Comma) => (), (TySums,Comma,Bindings) => (), (Bindings) => (), (Bindings,Comma) => (), () => (), } nonterminal MaybeBindings { (Comma,Bindings) => (), () => (), } //////////////////////////////////////////////////////////////////////// // Part 2: Patterns //////////////////////////////////////////////////////////////////////// nonterminal Pat { (Underscore) => (), (Ampersand,Pat) => (), (Ampersand,Mut,Pat) => (), (AndAnd,Mut,Pat) => (), (LPar,RPar) => (), (LPar,PatTup,RPar) => (), (LBracket,PatVec,RBracket) => (), (LitOrPath) => (), (LitOrPath,DotDotDot,LitOrPath) => (), (PathExpr,LBrace,PatStruct,RBrace) => (), (PathExpr,LPar,RPar) => (), (PathExpr,LPar,PatTup,RPar) => (), (PathExpr,Bang,MaybeIdent,DelimitedTokenTrees) => (), (BindingMode,Ident) => (), (Ident,At,Pat) => (), (BindingMode,Ident,At,Pat) => (), (BOX,Pat) => (), (LT,TySum,MaybeAsTraitRef,GT,ModSep,Ident) => (), //(SHL,TySum,MaybeAsTraitRef,GT,ModSep,Ident,MaybeAsTraitRef,GT,ModSep,Ident) => (), } nonterminal PatsOr { (Pat) => (), (PatsOr,Vertical,Pat) => (), } nonterminal BindingMode { (Ref) => (), (Ref,Mut) => (), (Mut) => (), } nonterminal LitOrPath { (PathExpr) => (), (Lit) => (), (Minus,Lit) => (), } nonterminal PatField { (Ident) => (), (BindingMode,Ident) => (), (BOX,Ident) => (), (BOX,BindingMode,Ident) => (), (Ident,Colon,Pat) => (), (BindingMode,Ident,Colon,Pat) => (), (LitInteger,Colon,Pat) => (), } nonterminal PatFields { (PatField) => (), (PatFields,Comma,PatField) => (), } nonterminal PatStruct { (PatFields) => (), (PatFields,Comma) => (), (PatFields,Comma,DotDot) => (), (DotDot) => (), () => (), } nonterminal PatTup { (PatTupElts) => (), (PatTupElts,Comma) => (), (PatTupElts,DotDot) => (), (PatTupElts,Comma,DotDot) => (), (PatTupElts,DotDot,Comma,PatTupElts) => (), (PatTupElts,DotDot,Comma,PatTupElts,Comma) => (), (PatTupElts,Comma,DotDot,Comma,PatTupElts) => (), (PatTupElts,Comma,DotDot,Comma,PatTupElts,Comma) => (), (DotDot,Comma,PatTupElts) => (), (DotDot,Comma,PatTupElts,Comma) => (), (DotDot) => (), } nonterminal PatTupElts { (Pat) => (), (PatTupElts,Comma,Pat) => (), } nonterminal PatVec { (PatVecElts) => (), (PatVecElts,Comma) => (), (PatVecElts,DotDot) => (), (PatVecElts,Comma,DotDot) => (), (PatVecElts,DotDot,Comma,PatVecElts) => (), (PatVecElts,DotDot,Comma,PatVecElts,Comma) => (), (PatVecElts,Comma,DotDot,Comma,PatVecElts) => (), (PatVecElts,Comma,DotDot,Comma,PatVecElts,Comma) => (), (DotDot,Comma,PatVecElts) => (), (DotDot,Comma,PatVecElts,Comma) => (), (DotDot) => (), () => (), } nonterminal PatVecElts { (Pat) => (), (PatVecElts,Comma,Pat) => (), } //////////////////////////////////////////////////////////////////////// // Part 3: Types //////////////////////////////////////////////////////////////////////// nonterminal Ty { (TyPrim) => (), (TyClosure) => (), (LT,TySum,MaybeAsTraitRef,GT,ModSep,Ident) => (), //(SHL,TySum,MaybeAsTraitRef,GT,ModSep,Ident,MaybeAsTraitRef,GT,ModSep,Ident) => (), (LPar,TySums,RPar) => (), (LPar,TySums,Comma,RPar) => (), (LPar,RPar) => (), } nonterminal TyPrim { (PathGenericArgsWithoutColons) => (), (ModSep,PathGenericArgsWithoutColons) => (), (LittleSelf,ModSep,PathGenericArgsWithoutColons) => (), (PathGenericArgsWithoutColons,Bang,MaybeIdent,DelimitedTokenTrees) => (), (ModSep,PathGenericArgsWithoutColons,Bang,MaybeIdent,DelimitedTokenTrees) => (), (BOX,Ty) => (), (Star,MaybeMutOrConst,Ty) => (), (Ampersand,Ty) => (), (Ampersand,Mut,Ty) => (), (AndAnd,Ty) => (), (AndAnd,Mut,Ty) => (), (Ampersand,Lifetime,MaybeMut,Ty) => (), (LBracket,Ty,RBracket) => (), (LBracket,Ty,Comma,DotDot,Expr,RBracket) => (), (LBracket,Ty,Semicolon,Expr,RBracket) => (), (Typeof,LPar,Expr,RPar) => (), (Underscore) => (), (TyBareFn) => (), (ForInType) => (), } nonterminal TyBareFn { (FN,TyFnDecl) => (), (Unsafe,FN,TyFnDecl) => (), (Extern,FN,TyFnDecl) => (), (Unsafe,Extern,FN,TyFnDecl) => (), } nonterminal TyFnDecl { (GenericParams,FnAnonParams,RetTy) => (), } nonterminal TyClosure { (Unsafe,Vertical,AnonParams,Vertical,MaybeBounds,RetTy) => (), (Vertical,AnonParams,Vertical,MaybeBounds,RetTy) => (), (Unsafe,OrOr,MaybeBounds,RetTy) => (), (OrOr,MaybeBounds,RetTy) => (), } nonterminal ForInType { (For,LT,MaybeLifetimes,GT,ForInTypeSuffix) => (), } nonterminal ForInTypeSuffix { (TyBareFn) => (), (TraitRef) => (), (TyClosure) => (), } nonterminal MaybeMut { (Mut) => (), () => (), } nonterminal MaybeMutOrConst { (Mut) => (), (Const) => (), () => (), } nonterminal TyQualifiedPathAndGenericValues { (TyQualifiedPath,MaybeBindings) => (), (TyQualifiedPath,Comma,TySums,MaybeBindings) => (), } nonterminal TyQualifiedPath { (TySums,As,TraitRef,GT,ModSep,Ident) => (), (TySums,As,TraitRef,GT,ModSep,Ident,Plus,TyParamBounds) => (), } nonterminal MaybeTySums { (TySums) => (), (TySums,Comma) => (), () => (), } nonterminal TySums { (TySum) => (), (TySums,Comma,TySum) => (), } nonterminal TySum { (TySumElt) => (), (TySum,Plus,TySumElt) => (), } nonterminal TySumElt { (Ty) => (), (Lifetime) => (), } nonterminal TyPrimSum { (TyPrimSumElt) => (), (TyPrimSum,Plus,TyPrimSumElt) => (), } nonterminal TyPrimSumElt { (TyPrim) => (), (Lifetime) => (), } nonterminal MaybeTyParamBounds { (Colon,TyParamBounds) => (), () => (), } nonterminal TyParamBounds { (Boundseq) => (), () => (), } nonterminal Boundseq { (Polybound) => (), (Boundseq,Plus,Polybound) => (), } nonterminal Polybound { (For,LT,MaybeLifetimes,GT,Bound) => (), (Bound) => (), (QuestionMark,For,LT,MaybeLifetimes,GT,Bound) => (), (QuestionMark,Bound) => (), } nonterminal Bindings { (Binding) => (), (Bindings,Comma,Binding) => (), } nonterminal Binding { (Ident,Equal,Ty) => (), } nonterminal TyParam { (Ident,MaybeTyParamBounds,MaybeTyDefault) => (), (Ident,QuestionMark,Ident,MaybeTyParamBounds,MaybeTyDefault) => (), } nonterminal MaybeBounds { (Colon,Bounds) => (), () => (), } nonterminal Bounds { (Bounds) => (), (Bounds,Plus,Bound) => (), } nonterminal Bound { (Lifetime) => (), (TraitRef) => (), } nonterminal MaybeLTBounds { (Colon,LTBounds) => (), () => (), } nonterminal LTBounds { (Lifetime) => (), (LTBounds,Plus,Lifetime) => (), } nonterminal MaybeTyDefault { (Equal,TySum) => (), () => (), } nonterminal MaybeLifetimes { (Lifetimes) => (), (Lifetimes,Comma) => (), () => (), } nonterminal Lifetimes { (LifetimeAndBounds) => (), (Lifetimes,Comma,LifetimeAndBounds) => (), } nonterminal LifetimeAndBounds { (LiteralLifetime,MaybeLTBounds) => (), (StaticLifetime) => (), } nonterminal Lifetime { (LiteralLifetime) => (), (StaticLifetime) => (), } nonterminal TraitRef { (PathGenericArgsWithoutColons) => (), (ModSep,PathGenericArgsWithoutColons) => (), } //////////////////////////////////////////////////////////////////////// // Part 4: Blocks, statements, and expressions //////////////////////////////////////////////////////////////////////// nonterminal InnerAttrsAndBlock { (LBrace,MaybeInnerAttrs,MaybeStmts,RBrace) => (), } nonterminal Block { (LBrace,MaybeStmts,RBrace) => (), } nonterminal MaybeStmts { (Stmts) => (), (Stmts,NonblockExpr) => (), (NonblockExpr) => (), () => (), } // --- BISON NOTES --- // There are two sub-grammars within a "stmts: exprs" derivation // depending on whether each stmt-expr is a block-expr form; this is to // handle the "semicolon rule" for stmt sequencing that permits // writing // // if foo { bar } 10 // // as a sequence of two stmts (one if-expr stmt, one lit-10-expr // stmt). Unfortunately by permitting juxtaposition of exprs in // sequence like that, the non-block expr grammar has to have a // second limited sub-grammar that excludes the prefix exprs that // are ambiguous with binops. That is to say: // // {10} - 1 // // should parse as (progn (progn 10) (- 1)) not (- (progn 10) 1), that // is to say, two statements rather than one, at least according to // the mainline rust parser. // // So we wind up with a 3-way split in exprs that occur in stmt lists: // block, nonblock-prefix, and nonblock-nonprefix. // // In non-stmts contexts, expr can relax this trichotomy. nonterminal Stmts { (Stmt) => (), (Stmts,Stmt) => (), } nonterminal Stmt { (MaybeOuterAttrs,Let) => (), (StmtItem) => (), (Pub,StmtItem) => (), (OuterAttrs,StmtItem) => (), (OuterAttrs,Pub,StmtItem) => (), (FullBlockExpr) => (), (MaybeOuterAttrs,Block) => (), (NonblockExpr,Semicolon) => (), (OuterAttrs,NonblockExpr,Semicolon) => (), (Semicolon) => (), } nonterminal MaybeExprs { (Exprs) => (), (Exprs,Comma) => (), () => (), } nonterminal MaybeExpr { (Expr) => (), () => (), } nonterminal Exprs { (Expr) => (), (Exprs,Comma,Expr) => (), } nonterminal PathExpr { (PathGenericArgsWithColons) => (), (ModSep,PathGenericArgsWithColons) => (), (LittleSelf,ModSep,PathGenericArgsWithColons) => (), } // A path with a lifetime and type parameters with double colons before // the type parameters; e.g. `foo::bar::<'a>::Baz::` // // These show up in expr context, in order to disambiguate from "less-than" // expressions. nonterminal PathGenericArgsWithColons { (Ident) => (), (Super) => (), (PathGenericArgsWithColons,ModSep,Ident) => (), (PathGenericArgsWithColons,ModSep,Super) => (), (PathGenericArgsWithColons,ModSep,GenericArgs) => (), } // the braces-delimited macro is a block_expr so it doesn't appear here nonterminal MacroExpr { (PathExpr,Bang,MaybeIdent,ParensDelimitedTokenTrees) => (), (PathExpr,Bang,MaybeIdent,BracketsDelimitedTokenTrees) => (), } nonterminal NonblockExpr { (Lit) => (), (PathExpr) => (), (LittleSelf) => (), (MacroExpr) => (), (PathExpr,LBrace,StructExprFields,RBrace) => (), (NonblockExpr,QuestionMark) => (), (NonblockExpr,Dot,PathGenericArgsWithColons) => (), (NonblockExpr,Dot,LitInteger) => (), (NonblockExpr,LBracket,MaybeExpr,RBracket) => (), (NonblockExpr,LPar,MaybeExprs,RPar) => (), (LBracket,VecExpr,RBracket) => (), (LPar,MaybeExprs,RPar) => (), (Continue) => (), (Continue,Lifetime) => (), (Return) => (), (Return,Expr) => (), (Break) => (), (Break,Lifetime) => (), (Yield) => (), (Yield,Expr) => (), (NonblockExpr,LArrow,Expr) => (), (NonblockExpr,Equal,Expr) => (), //(NonblockExpr,SHLEQ,Expr) => (), (NonblockExpr,LT,NoSpace,LT,Equal,Expr) => (), //(NonblockExpr,SHREQ,Expr) => (), (NonblockExpr,GT,NoSpace,GT,Equal,Expr) => (), (NonblockExpr,MinusEqual,Expr) => (), (NonblockExpr,AndEqual,Expr) => (), (NonblockExpr,OrEqual,Expr) => (), (NonblockExpr,PlusEqual,Expr) => (), (NonblockExpr,StarEqual,Expr) => (), (NonblockExpr,SlashEqual,Expr) => (), (NonblockExpr,CaretEqual,Expr) => (), (NonblockExpr,PercentEqual,Expr) => (), (NonblockExpr,OrOr,Expr) => (), (NonblockExpr,AndAnd,Expr) => (), (NonblockExpr,EqualEqual,Expr) => (), (NonblockExpr,NE,Expr) => (), (NonblockExpr,LT,Expr) => (), (NonblockExpr,GT,Expr) => (), (NonblockExpr,LE,Expr) => (), (NonblockExpr,GE,Expr) => (), (NonblockExpr,Vertical,Expr) => (), (NonblockExpr,Caret,Expr) => (), (NonblockExpr,Ampersand,Expr) => (), //(NonblockExpr,SHL,Expr) => (), (NonblockExpr,LT,NoSpace,LT,Expr) => (), //(NonblockExpr,SHR,Expr) => (), (NonblockExpr,GT,NoSpace,GT,Expr) => (), (NonblockExpr,Plus,Expr) => (), (NonblockExpr,Minus,Expr) => (), (NonblockExpr,Star,Expr) => (), (NonblockExpr,Slash,Expr) => (), (NonblockExpr,Percent,Expr) => (), (NonblockExpr,DotDot) => (), (NonblockExpr,DotDot,Expr) => (), (DotDot,Expr) => (), (DotDot) => (), (NonblockExpr,As,Ty) => (), (NonblockExpr,Colon,Ty) => (), (BOX,Expr) => (), (ExprQualifiedPath) => (), (NonblockPrefixExpr) => (), } nonterminal Expr { (Lit) => (), (PathExpr) => (), (LittleSelf) => (), (MacroExpr) => (), (PathExpr,LBrace,StructExprFields,RBrace) => (), (Expr,QuestionMark) => (), (Expr,Dot,PathGenericArgsWithColons) => (), (Expr,Dot,LitInteger) => (), (Expr,LBracket,MaybeExpr,RBracket) => (), (Expr,LPar,MaybeExprs,RPar) => (), (LPar,MaybeExprs,RPar) => (), (LBracket,VecExpr,RBracket) => (), (Continue) => (), (Continue,Ident) => (), (Return) => (), (Return,Expr) => (), (Break) => (), (Break,Ident) => (), (Yield) => (), (Yield,Expr) => (), (Expr,LArrow,Expr) => (), (Expr,Equal,Expr) => (), //(Expr,SHLEQ,Expr) => (), (Expr,LT,NoSpace,LT,Equal,Expr) => (), //(Expr,SHREQ,Expr) => (), (Expr,GT,NoSpace,GT,Equal,Expr) => (), (Expr,MinusEqual,Expr) => (), (Expr,AndEqual,Expr) => (), (Expr,OrEqual,Expr) => (), (Expr,PlusEqual,Expr) => (), (Expr,StarEqual,Expr) => (), (Expr,SlashEqual,Expr) => (), (Expr,CaretEqual,Expr) => (), (Expr,PercentEqual,Expr) => (), (Expr,OrOr,Expr) => (), (Expr,AndAnd,Expr) => (), (Expr,EqualEqual,Expr) => (), (Expr,NE,Expr) => (), (Expr,LT,Expr) => (), (Expr,GT,Expr) => (), (Expr,LE,Expr) => (), (Expr,GE,Expr) => (), (Expr,Vertical,Expr) => (), (Expr,Caret,Expr) => (), (Expr,Ampersand,Expr) => (), //(Expr,SHL,Expr) => (), (Expr,LT,NoSpace,LT,Expr) => (), //(Expr,SHR,Expr) => (), (Expr,GT,NoSpace,GT,Expr) => (), (Expr,Plus,Expr) => (), (Expr,Minus,Expr) => (), (Expr,Star,Expr) => (), (Expr,Slash,Expr) => (), (Expr,Percent,Expr) => (), (Expr,DotDot) => (), (Expr,DotDot,Expr) => (), (DotDot,Expr) => (), (DotDot) => (), (Expr,As,Ty) => (), (Expr,Colon,Ty) => (), (BOX,Expr) => (), (ExprQualifiedPath) => (), (BlockExpr) => (), (Block) => (), (NonblockPrefixExpr) => (), } nonterminal ExprNostruct { (Lit) => (), (PathExpr) => (), (LittleSelf) => (), (MacroExpr) => (), (ExprNostruct,QuestionMark) => (), (ExprNostruct,Dot,PathGenericArgsWithColons) => (), (ExprNostruct,Dot,LitInteger) => (), (ExprNostruct,LBracket,MaybeExpr,RBracket) => (), (ExprNostruct,LPar,MaybeExprs,RPar) => (), (LBracket,VecExpr,RBracket) => (), (LPar,MaybeExprs,RPar) => (), (Continue) => (), (Continue,Ident) => (), (Return) => (), (Return,Expr) => (), (Break) => (), (Break,Ident) => (), (Yield) => (), (Yield,Expr) => (), (ExprNostruct,LArrow,ExprNostruct) => (), (ExprNostruct,Equal,ExprNostruct) => (), //(ExprNostruct,SHLEQ,ExprNostruct) => (), (ExprNostruct,LT,NoSpace,LT,Equal,ExprNostruct) => (), //(ExprNostruct,SHREQ,ExprNostruct) => (), (ExprNostruct,GT,NoSpace,GT,Equal,ExprNostruct) => (), (ExprNostruct,MinusEqual,ExprNostruct) => (), (ExprNostruct,AndEqual,ExprNostruct) => (), (ExprNostruct,OrEqual,ExprNostruct) => (), (ExprNostruct,PlusEqual,ExprNostruct) => (), (ExprNostruct,StarEqual,ExprNostruct) => (), (ExprNostruct,SlashEqual,ExprNostruct) => (), (ExprNostruct,CaretEqual,ExprNostruct) => (), (ExprNostruct,PercentEqual,ExprNostruct) => (), (ExprNostruct,OrOr,ExprNostruct) => (), (ExprNostruct,AndAnd,ExprNostruct) => (), (ExprNostruct,EqualEqual,ExprNostruct) => (), (ExprNostruct,NE,ExprNostruct) => (), (ExprNostruct,LT,ExprNostruct) => (), (ExprNostruct,GT,ExprNostruct) => (), (ExprNostruct,LE,ExprNostruct) => (), (ExprNostruct,GE,ExprNostruct) => (), (ExprNostruct,Vertical,ExprNostruct) => (), (ExprNostruct,Caret,ExprNostruct) => (), (ExprNostruct,Ampersand,ExprNostruct) => (), //(ExprNostruct,SHL,ExprNostruct) => (), (ExprNostruct,LT,NoSpace,LT,ExprNostruct) => (), //(ExprNostruct,SHR,ExprNostruct) => (), (ExprNostruct,GT,NoSpace,GT,ExprNostruct) => (), (ExprNostruct,Plus,ExprNostruct) => (), (ExprNostruct,Minus,ExprNostruct) => (), (ExprNostruct,Star,ExprNostruct) => (), (ExprNostruct,Slash,ExprNostruct) => (), (ExprNostruct,Percent,ExprNostruct) => (), (ExprNostruct,DotDot) => (), (ExprNostruct,DotDot,ExprNostruct) => (), (DotDot,ExprNostruct) => (), (DotDot) => (), (ExprNostruct,As,Ty) => (), (ExprNostruct,Colon,Ty) => (), (BOX,ExprNostruct) => (), (ExprQualifiedPath) => (), (BlockExpr) => (), (Block) => (), (NonblockPrefixExprNostruct) => (), } nonterminal NonblockPrefixExprNostruct { (Minus,ExprNostruct) => (), (Bang,ExprNostruct) => (), (Star,ExprNostruct) => (), (Ampersand,MaybeMut,ExprNostruct) => (), (AndAnd,MaybeMut,ExprNostruct) => (), (LambdaExprNostruct) => (), (Move,LambdaExprNostruct) => (), } nonterminal NonblockPrefixExpr { (Minus,Expr) => (), (Bang,Expr) => (), (Star,Expr) => (), (Ampersand,MaybeMut,Expr) => (), (AndAnd,MaybeMut,Expr) => (), (LambdaExpr) => (), (Move,LambdaExpr) => (), } nonterminal ExprQualifiedPath { (LT,TySum,MaybeAsTraitRef,GT,ModSep,Ident,MaybeQPathParams) => (), //(SHL,TySum,MaybeAsTraitRef,GT,ModSep,Ident,MaybeAsTraitRef,GT,ModSep,Ident) => (), //(SHL,TySum,MaybeAsTraitRef,GT,ModSep,Ident,GenericArgs,MaybeAsTraitRef,GT,ModSep,Ident) => (), //(SHL,TySum,MaybeAsTraitRef,GT,ModSep,Ident,MaybeAsTraitRef,GT,ModSep,Ident,GenericArgs) => (), //(SHL,TySum,MaybeAsTraitRef,GT,ModSep,Ident,GenericArgs,MaybeAsTraitRef,GT,ModSep,Ident,GenericArgs) => (), } nonterminal MaybeQPathParams { (ModSep,GenericArgs) => (), () => (), } nonterminal MaybeAsTraitRef { (As,TraitRef) => (), () => (), } nonterminal LambdaExpr { (OrOr,RetTy,Expr) => (), (Vertical,Vertical,RetTy,Expr) => (), (Vertical,InferrableParams,Vertical,RetTy,Expr) => (), (Vertical,InferrableParams,OrOr,LambdaExprNoFirstBar) => (), } nonterminal LambdaExprNoFirstBar { (Vertical,RetTy,Expr) => (), (InferrableParams,Vertical,RetTy,Expr) => (), (InferrableParams,OrOr,LambdaExprNoFirstBar) => (), } nonterminal LambdaExprNostruct { (OrOr,ExprNostruct) => (), (Vertical,Vertical,RetTy,ExprNostruct) => (), (Vertical,InferrableParams,Vertical,ExprNostruct) => (), //No RetTy? (Vertical,InferrableParams,OrOr,LambdaExprNostructNoFirstBar) => (), } nonterminal LambdaExprNostructNoFirstBar { (Vertical,RetTy,ExprNostruct) => (), (InferrableParams,Vertical,RetTy,ExprNostruct) => (), (InferrableParams,OrOr,LambdaExprNostructNoFirstBar) => (), } nonterminal VecExpr { (MaybeExprs) => (), (Exprs,Semicolon,Expr) => (), } nonterminal StructExprFields { (FieldInits) => (), (FieldInits,Comma) => (), (MaybeFieldInits,DefaultFieldInit) => (), () => (), } nonterminal MaybeFieldInits { (FieldInits) => (), (FieldInits,Comma) => (), () => (), } nonterminal FieldInits { (FieldInit) => (), (FieldInits,Comma,FieldInit) => (), } nonterminal FieldInit { (Ident) => (), (Ident,Colon,Expr) => (), (LitInteger,Colon,Expr) => (), } nonterminal DefaultFieldInit { (DotDot,Expr) => (), } nonterminal BlockExpr { (ExprMatch) => (), (ExprIf) => (), (ExprIfLet) => (), (ExprWhile) => (), (ExprWhileLet) => (), (ExprLoop) => (), (ExprFor) => (), (Unsafe,Block) => (), (PathExpr,Bang,MaybeIdent,BracesDelimitedTokenTrees) => (), } nonterminal FullBlockExpr { (BlockExpr) => (), (BlockExprDot) => (), } nonterminal BlockExprDot { (BlockExpr,Dot,PathGenericArgsWithColons) => (), (BlockExprDot,Dot,PathGenericArgsWithColons) => (), (BlockExpr,Dot,PathGenericArgsWithColons,LBracket,MaybeExpr,RBracket) => (), (BlockExprDot,Dot,PathGenericArgsWithColons,LBracket,MaybeExpr,RBracket) => (), (BlockExpr,Dot,PathGenericArgsWithColons,LPar,MaybeExprs,RPar) => (), (BlockExprDot,Dot,PathGenericArgsWithColons,LPar,MaybeExprs,RPar) => (), (BlockExpr,Dot,LitInteger) => (), (BlockExprDot,Dot,LitInteger) => (), } nonterminal ExprMatch { (Match,ExprNostruct,LBrace,RBrace) => (), (Match,ExprNostruct,LBrace,MatchClauses,RBrace) => (), (Match,ExprNostruct,LBrace,MatchClauses,NonblockMatchClause,RBrace) => (), (Match,ExprNostruct,LBrace,NonblockMatchClause,RBrace) => (), } nonterminal MatchClauses { (MatchClause) => (), (MatchClauses,MatchClause) => (), } nonterminal MatchClause { (NonblockMatchClause,Comma) => (), (BlockMatchClause) => (), (BlockMatchClause,Comma) => (), } nonterminal NonblockMatchClause { (MaybeOuterAttrs,PatsOr,MaybeGuard,FatArrow,NonblockExpr) => (), (MaybeOuterAttrs,PatsOr,MaybeGuard,FatArrow,BlockExprDot) => (), } nonterminal BlockMatchClause { (MaybeOuterAttrs,PatsOr,MaybeGuard,FatArrow,Block) => (), (MaybeOuterAttrs,PatsOr,MaybeGuard,FatArrow,BlockExpr) => (), } nonterminal MaybeGuard { (If,ExprNostruct) => (), () => (), } nonterminal ExprIf { (If,ExprNostruct,Block) => (), (If,ExprNostruct,Block,Else,BlockOrIf) => (), } nonterminal ExprIfLet { (If,LiteralLet,Pat,Equal,ExprNostruct,Block) => (), (If,LiteralLet,Pat,Equal,ExprNostruct,Block,Else,BlockOrIf) => (), } nonterminal BlockOrIf { (Block) => (), (ExprIf) => (), (ExprIfLet) => (), } nonterminal ExprWhile { (MaybeLabel,While,ExprNostruct,Block) => (), } nonterminal ExprWhileLet { (MaybeLabel,While,LiteralLet,Pat,Equal,ExprNostruct,Block) => (), } nonterminal ExprLoop { (MaybeLabel,Loop,Block) => (), } nonterminal ExprFor { (MaybeLabel,For,Pat,In,ExprNostruct,Block) => (), } nonterminal MaybeLabel { (Lifetime,Colon) => (), () => (), } nonterminal Let { (LiteralLet,Pat,MaybeTyAscription,MaybeInitExpr,Semicolon) => (), } //////////////////////////////////////////////////////////////////////// // Part 5: Macros and misc. rules //////////////////////////////////////////////////////////////////////// nonterminal Lit { (LitByte) => (), (LitChar) => (), (LitInteger) => (), (LitFloat) => (), (True) => (), (False) => (), (Str) => (), } nonterminal Str { (LitStr) => (), (LitStrRaw) => (), (LitByteStr) => (), (LitByteStrRaw) => (), } nonterminal MaybeIdent { () => (), (Ident) => (), } nonterminal Ident { (LiteralIdent) => (), // Weak keywords that can be used as identifiers (Catch) => (), (DEFAULT) => (), (Union) => (), } nonterminal UnpairedToken { //(SHL) => (), //(SHR) => (), (LE) => (), (EqualEqual) => (), (NE) => (), (GE) => (), (AndAnd) => (), (OrOr) => (), (LArrow) => (), //(SHLEQ) => (), //(SHREQ) => (), (MinusEqual) => (), (AndEqual) => (), (OrEqual) => (), (PlusEqual) => (), (StarEqual) => (), (SlashEqual) => (), (CaretEqual) => (), (PercentEqual) => (), (DotDot) => (), (DotDotDot) => (), (ModSep) => (), (RArrow) => (), (FatArrow) => (), (LitByte) => (), (LitChar) => (), (LitInteger) => (), (LitFloat) => (), (LitStr) => (), (LitStrRaw) => (), (LitByteStr) => (), (LitByteStrRaw) => (), (LiteralIdent) => (), (Underscore) => (), (LiteralLifetime) => (), (LittleSelf) => (), (Static) => (), //(Abstract) => (), //(AlignOf) => (), (As) => (), //(Become) => (), (Break) => (), (Catch) => (), (Crate) => (), (DEFAULT) => (), //(Do) => (), (Else) => (), (Enum) => (), (Extern) => (), (False) => (), //(Final) => (), (FN) => (), (For) => (), (If) => (), (Impl) => (), (In) => (), (LiteralLet) => (), (Loop) => (), //(Macro) => (), (Match) => (), (Mod) => (), (Move) => (), (Mut) => (), //(OffsetOf) => (), //(Override) => (), //(Priv) => (), (Pub) => (), //(Pure) => (), (Ref) => (), (Return) => (), (Struct) => (), //(Sizeof) => (), (Super) => (), (True) => (), (Trait) => (), (Type) => (), (Union) => (), (Unsafe) => (), //(Unsized) => (), (Use) => (), //(Virtual) => (), (While) => (), (Yield) => (), (Continue) => (), //(Proc) => (), (BOX) => (), (Const) => (), (Where) => (), (Typeof) => (), (InnerDocComment) => (), (OuterDocComment) => (), (Shebang) => (), (StaticLifetime) => (), (Semicolon) => (), (Comma) => (), (Dot) => (), (At) => (), (NumberSign) => (), //(Tilde) => (), (Colon) => (), //(Dolar) => (), (Equal) => (), (QuestionMark) => (), (Bang) => (), (LT) => (), (GT) => (), (Minus) => (), (Ampersand) => (), (Vertical) => (), (Plus) => (), (Star) => (), (Slash) => (), (Caret) => (), (Percent) => (), } nonterminal TokenTrees { () => (), (TokenTrees,TokenTree) => (), } nonterminal TokenTree { (DelimitedTokenTrees) => (), (UnpairedToken) => (), } nonterminal DelimitedTokenTrees { (ParensDelimitedTokenTrees) => (), (BracesDelimitedTokenTrees) => (), (BracketsDelimitedTokenTrees) => (), } nonterminal ParensDelimitedTokenTrees { (LPar,TokenTrees,RPar) => (), } nonterminal BracesDelimitedTokenTrees { (LBrace,TokenTrees,RBrace) => (), } nonterminal BracketsDelimitedTokenTrees { (LBracket,TokenTrees,RBracket) => (), } nonterminal MaybeSpace { (NoSpace) => (), () => (), }