// Used to create bootsrapper2.rs using bootstrapper.rs // /* // 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"); re_terminal!(Terminal,"terminal"); re_terminal!(Nonterminal,"nonterminal"); 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(usize) { 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(char) { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitFloat { fn _match(parser: &mut Parser, source:&str) -> Option<(usize,())> { None } } terminal LitStr(String) { 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(V)//Vec>) { (MaybeShebang,InnerAttrs,MaybeModItems(items)) => items.clone(), (MaybeShebang,MaybeModItems(items)) => items.clone(), } nonterminal MaybeShebang { (ShebangLine) => (), () => (), } nonterminal MaybeInnerAttrs { (InnerAttrs) => (), () => (), } nonterminal InnerAttrs { (InnerAttr) => (), (InnerAttrs,InnerAttr) => (), } nonterminal InnerAttr { (Shebang,LBracket,MetaItem,RBracket) => (), (InnerDocComment) => (), } nonterminal MaybeOuterAttrs(VA) { (OuterAttrs(attrs)) => attrs.clone(), () => vec[], } nonterminal OuterAttrs(VA) { (OuterAttr(kind)) => vec[kind.clone()], (OuterAttrs(attrs),OuterAttr(attr)) => { new=(attrs.clone()); new.push(attr.clone()); new }, } nonterminal OuterAttr(AttrKind) { (NumberSign,LBracket,MetaItem(attr),RBracket) => attr.clone(), (OuterDocComment(string)) => AttrKind_Documentation(string.clone()), } nonterminal MetaItem(AttrKind) { (Ident(string)) => AttrKind_Flag(string.clone()), (Ident(string),Equal,Lit(lit)) => AttrKind_Value(string.clone(),lit.clone()), (Ident(string),LPar,MetaSeq(seq),RPar) => AttrKind_Sequence(string.clone(),seq.clone()), (Ident(string),LPar,MetaSeq(seq),Comma,RPar) => AttrKind_Sequence(string.clone(),seq.clone()), } nonterminal MetaSeq(VA) { () => vec[], (MetaItem(attr)) => vec[attr.clone()], (MetaSeq(seq),Comma,MetaItem(attr)) => { new=(seq.clone()); new.push(attr.clone()); new }, } nonterminal MaybeModItems(V) { (ModItems(items)) => items.clone(), () => vec[], } nonterminal ModItems(V) { (ModItem) => vec[Rc_new(Token_ModItem(outer.clone(),item.clone()))], (ModItems(items),ModItem(outer,item)) => { new=(items.clone()); new.push(Rc_new(Token_ModItem(outer.clone(),item.clone()))); new }, } nonterminal AttrsAndVis(VA) { (MaybeOuterAttrs(attrs),Visibility) => attrs.clone(), } nonterminal ModItem(VA,R) { (AttrsAndVis(attrs),Item(item)) => (attrs.clone(),item.clone()), } // items that can appear outside of a fn block nonterminal Item(R) { (StmtItem(item)) => item.clone(), (ItemMacro(path,id,tree)) => Rc_new(Token_ItemMacro(path.clone(),id.clone(),tree.clone())), } // items that can appear in "stmts" nonterminal StmtItem(R) { (ItemStatic) => (), (ItemConst) => (), (ItemType) => (), (BlockItem(item)) => item.clone(), (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(R,OR,R) { (PathExpr(s),Bang,MaybeIdent,ParensDelimitedTokenTrees(trees),Semicolon) => (Rc_new(Token_PathExpr(s.clone())),None,Rc_new(Token_ParensDelimitedTokenTrees(trees.clone()))), (PathExpr(s),Bang,MaybeIdent,BracesDelimitedTokenTrees(trees)) => (Rc_new(Token_PathExpr(s.clone())),None,Rc_new(Token_BracesDelimitedTokenTrees(trees.clone()))), (PathExpr(s),Bang,MaybeIdent,BracketsDelimitedTokenTrees(trees),Semicolon) => (Rc_new(Token_PathExpr(s.clone())),None,Rc_new(Token_BracketsDelimitedTokenTrees(trees.clone()))), } 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(R) { (ItemFn) => Rc_new(state.values[0].clone()), (ItemUnsafeFn) => (), (ItemMod) => (), (ItemForeignMod) => (), (ItemStruct) => (), (ItemEnum) => (), (ItemUnion) => (), (ItemTrait) => (), (ItemImpl) => (), (ItemTerminal) => Rc_new(state.values[0].clone()),//NEW (ItemNonterminal) => Rc_new(state.values[0].clone()),//NEW } 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) => (), } 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,RBrace,Comma) => (), } 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(String) { (Ident(string)) => string.clone(), (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(PatKind) { (Underscore) => PatKind_Underscore, (Ampersand,Pat(kind)) => PatKind_Ref(Rc_new(kind.clone())), (Ampersand,Mut,Pat) => PatKind_RefMut(Rc_new(kind.clone())), (AndAnd,Mut,Pat) => PatKind_Ref(Rc_new(PatKind_RefMut(Rc_new(kind.clone())))), (LPar,RPar) => PatKind_Void, (LPar,PatTup,RPar) => PatKind_Tuple(Rc_new(state.values[1].clone())), (LBracket,PatVec,RBracket) => (), (LitOrPath) => PatKind_Path(Rc_new(state.values[0].clone())), (LitOrPath,DotDotDot,LitOrPath) => (), (PathExpr,LBrace,PatStruct,RBrace) => (), (PathExpr,LPar,RPar) => PatKind_EnumEmpty(Rc_new(state.values[0].clone())), (PathExpr,LPar,PatTup,RPar) => PatKind_Enum(Rc_new(state.values[0].clone()),Rc_new(state.values[2].clone())), (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(R) { (Pat) => Rc_new(state.values[0].clone()), (PatsOr,Vertical,Pat) => (), } nonterminal BindingMode { (Ref) => (), (Ref,Mut) => (), (Mut) => (), } nonterminal LitOrPath(String) { (PathExpr(string)) => string.clone(), (Lit) => String_from("[Lit]"), (Minus,Lit) => String_from("[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(V) { (PatTupElts(elements)) => elements.clone(), (PatTupElts(elements),Comma) => elements.clone(), (PatTupElts(elements),DotDot) => (), (PatTupElts(elements),Comma,DotDot) => (), (PatTupElts(elements),DotDot,Comma,PatTupElts) => (), (PatTupElts(elements),DotDot,Comma,PatTupElts,Comma) => (), (PatTupElts(elements),Comma,DotDot,Comma,PatTupElts) => (), (PatTupElts(elements),Comma,DotDot,Comma,PatTupElts,Comma) => (), (DotDot,Comma,PatTupElts) => (), (DotDot,Comma,PatTupElts,Comma) => (), (DotDot) => (), } nonterminal PatTupElts(V) { (Pat) => vec[Rc_new(state.values[0].clone())], (PatTupElts(elements),Comma,Pat) => { new=(elements.clone()); new.push(Rc_new(state.values[2].clone())); new }, } 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(TyKind) { (TyPrim(kind)) => kind.clone(), (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) => TyKind_Void, } nonterminal TyPrim(TyKind) { (PathGenericArgsWithoutColons(string)) => TyKind_Path(string.clone()), (ModSep,PathGenericArgsWithoutColons) => (), (LittleSelf,ModSep,PathGenericArgsWithoutColons) => (), (PathGenericArgsWithoutColons,Bang,MaybeIdent,DelimitedTokenTrees) => (), (ModSep,PathGenericArgsWithoutColons,Bang,MaybeIdent,DelimitedTokenTrees) => (), (BOX,Ty) => (), (Star,MaybeMutOrConst,Ty) => (), (Ampersand,Ty(kind)) => TyKind_Ref(Rc_new(kind.clone())), (Ampersand,Mut,Ty(kind)) => TyKind_RefMut(Rc_new(kind.clone())), (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) => TyKind_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(bool) { (Mut) => true, () => false, } 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(V) { (TySums(types)) => types.clone(), (TySums(types),Comma) => types.clone(), () => vec[], } nonterminal TySums(V) { (TySum) => vec[Rc_new(state.values[0].clone())], (TySums(types),Comma,TySum) => { new=(types.clone()); new.push(Rc_new(state.values[2].clone())); new }, } nonterminal TySum(TyKind) { (TySumElt(kind)) => kind.clone(), (TySum,Plus,TySumElt) => (), } nonterminal TySumElt(TyKind) { (Ty(kind)) => kind.clone(), (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(VS,OE) { (LBrace,MaybeStmts,RBrace) => (), } nonterminal MaybeStmts(VS,OE) { (Stmts(list)) => (list.clone(),None), (Stmts(list),NonblockExpr(expr)) => (list.clone(),Some(expr.clone())), (NonblockExpr(expr)) => (vec[],Some(expr.clone())), () => (vec[],None), } // --- 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(VS) { (Stmt(stmt)) => vec[stmt.clone()], (Stmts(stmts),Stmt(stmt)) => { new=(stmts.clone()); new.push(stmt.clone()); new }, } nonterminal Stmt(StmtKind) { (MaybeOuterAttrs,Let) => StmtKind_Empty,//FIXME (StmtItem(item)) => StmtKind_Item(vec[],item.clone()), (Pub,StmtItem(item)) => StmtKind_Item(vec[],item.clone()), (OuterAttrs(attrs),StmtItem(item)) => StmtKind_Item(attrs.clone(),item.clone()), (OuterAttrs(attrs),Pub,StmtItem(item)) => StmtKind_Item(attrs.clone(),item.clone()), (FullBlockExpr(block)) => StmtKind_Block(vec[],block.clone()), (MaybeOuterAttrs(attrs),Block) => StmtKind_Block(attrs.clone(),Rc_new(state.values[1].clone())), (NonblockExpr(expr),Semicolon) => StmtKind_Expr(vec[],expr.clone()), (OuterAttrs(attrs),NonblockExpr(expr),Semicolon) => StmtKind_Expr(attrs.clone(),expr.clone()), (Semicolon) => StmtKind_Empty, } nonterminal MaybeExprs(VE) { (Exprs(list)) => list.clone(), (Exprs(list),Comma) => list.clone(), () => vec[], } nonterminal MaybeExpr(OE) { (Expr(expr)) => Some(expr.clone()), () => None, } nonterminal Exprs(VE) { (Expr(expr)) => vec[expr.clone()], (Exprs(list),Comma,Expr(expr)) => { new=(list.clone()); new.push(expr.clone()); new }, } nonterminal PathExpr(String) { (PathGenericArgsWithColons(s)) => s.clone(), (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(String) { (Ident(s)) => s.clone(), (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(ExprKind) { (Lit) => ExprKind_Single(Rc_new(state.values[0].clone())), (PathExpr) => ExprKind_Single(Rc_new(state.values[0].clone())), (LittleSelf) => ExprKind_Single(Rc_new(state.values[0].clone())), (MacroExpr) => ExprKind_Single(Rc_new(state.values[0].clone())), (PathExpr,LBrace,StructExprFields,RBrace) => (), (NonblockExpr,QuestionMark) => (), #[priority(member)] (NonblockExpr(kind),Dot,PathGenericArgsWithColons(string)) => ExprKind_Member(Rc_new(kind.clone()),string.clone()), (NonblockExpr,Dot,LitInteger) => (), (NonblockExpr(kind),LBracket,MaybeExpr(option),RBracket) => match option { None => ExprKind_Index(Rc_new(kind.clone()),None), Some(qindex) => ExprKind_Index(Rc_new(kind.clone()),Some(Rc_new(qindex.clone()))), }, (NonblockExpr(kind),LPar,MaybeExprs(arguments),RPar) => ExprKind_Call(Rc_new(kind.clone()),arguments.clone()), (LBracket,VecExpr,RBracket) => (), (LPar,MaybeExprs(arguments),RPar) => ExprKind_Parentheses(arguments.clone()), (Continue) => (), (Continue,Lifetime) => (), (Return) => (), (Return,Expr) => (), (Break) => (), (Break,Lifetime) => (), (Yield) => (), (Yield,Expr) => (), (NonblockExpr,LArrow,Expr) => (), #[priority(assignation)] (NonblockExpr(left),Equal,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), //(NonblockExpr,SHLEQ,Expr) => (), (NonblockExpr(left),LT,NoSpace,LT,Equal,Expr(right)) => (), //(NonblockExpr,SHREQ,Expr) => (), (NonblockExpr(left),GT,NoSpace,GT,Equal,Expr(right)) => (), (NonblockExpr(left),MinusEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),AndEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),OrEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),PlusEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),StarEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),SlashEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),CaretEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),PercentEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),OrOr,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),AndAnd,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),EqualEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),NE,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),LT,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),GT,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),LE,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),GE,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),Vertical,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),Caret,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),Ampersand,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), //(NonblockExpr,SHL,Expr) => (), (NonblockExpr(left),LT,NoSpace,LT,Expr(right)) => (), //(NonblockExpr,SHR,Expr) => (), (NonblockExpr(left),GT,NoSpace,GT,Expr(right)) => (), (NonblockExpr(left),Plus,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),Minus,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),Star,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),Slash,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr(left),Percent,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (NonblockExpr,DotDot) => (), (NonblockExpr,DotDot,Expr) => (), (DotDot,Expr) => (), (DotDot) => (), (NonblockExpr,As,Ty) => (), (NonblockExpr,Colon,Ty) => (), (BOX,Expr) => (), (ExprQualifiedPath) => (), (NonblockPrefixExpr(expt)) => expr.clone(), } nonterminal Expr(ExprKind) { (Lit) => ExprKind_Single(Rc_new(state.values[0].clone())), (PathExpr) => ExprKind_Single(Rc_new(state.values[0].clone())), (LittleSelf) => ExprKind_Single(Rc_new(state.values[0].clone())), (MacroExpr) => ExprKind_Single(Rc_new(state.values[0].clone())), (PathExpr,LBrace,StructExprFields,RBrace) => (), (Expr,QuestionMark) => (), #[priority(member)] (Expr(kind),Dot,PathGenericArgsWithColons(string)) => ExprKind_Member(Rc_new(kind.clone()),string.clone()), (Expr,Dot,LitInteger) => (), (Expr(kind),LBracket,MaybeExpr(option),RBracket) => match option { None => ExprKind_Index(Rc_new(kind.clone()),None), Some(qindex) => ExprKind_Index(Rc_new(kind.clone()),Some(Rc_new(qindex.clone()))), }, (Expr(kind),LPar,MaybeExprs(arguments),RPar) => ExprKind_Call(Rc_new(kind.clone()),arguments.clone()), (LPar,MaybeExprs(arguments),RPar) => ExprKind_Parentheses(arguments.clone()), (LBracket,VecExpr,RBracket) => (), (Continue) => (), (Continue,Ident) => (), (Return) => (), (Return,Expr) => (), (Break) => (), (Break,Ident) => (), (Yield) => (), (Yield,Expr) => (), (Expr,LArrow,Expr) => (), #[priority(assignation)] (Expr(left),Equal,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), //(Expr,SHLEQ,Expr) => (), (Expr(left),LT,NoSpace,LT,Equal,Expr(right)) => (), //(Expr,SHREQ,Expr) => (), (Expr(left),GT,NoSpace,GT,Equal,Expr(right)) => (), (Expr(left),MinusEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),AndEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),OrEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),PlusEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),StarEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),SlashEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),CaretEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),PercentEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),OrOr,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),AndAnd,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),EqualEqual,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),NE,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),LT,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),GT,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),LE,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),GE,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Vertical,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Caret,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Ampersand,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), //(Expr,SHL,Expr) => (), (Expr(left),LT,NoSpace,LT,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), //(Expr,SHR,Expr) => (), (Expr(left),GT,NoSpace,GT,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Plus,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Minus,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Star,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Slash,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr(left),Percent,Expr(right)) => ExprKind_Infix(Rc_new(left.clone()),Rc_new(state.values[1].clone()),Rc_new(right.clone())), (Expr,DotDot) => (), (Expr,DotDot,Expr) => (), (DotDot,Expr) => (), (DotDot) => (), (Expr,As,Ty) => (), (Expr,Colon,Ty) => (), (BOX,Expr) => (), (ExprQualifiedPath) => (), (BlockExpr(block)) => ExprKind_Single(block.clone()), (Block) => ExprKind_Single(Rc_new(state.values[0].clone())), (NonblockPrefixExpr(expr)) => expr.clone(), } nonterminal ExprNostruct { (Lit) => (), (PathExpr) => (), (LittleSelf) => (), (MacroExpr) => (), (ExprNostruct,QuestionMark) => (), #[priority(member)] (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) => (), #[priority(assignation)] (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(ExprKind) { (Minus,Expr(expr)) => ExprKind_Prefix(Rc_new(state.values[0].clone()),Rc_new(expr.clone())), (Bang,Expr(expr)) => ExprKind_Prefix(Rc_new(state.values[0].clone()),Rc_new(expr.clone())), (Star,Expr(expr)) => ExprKind_Prefix(Rc_new(state.values[0].clone()),Rc_new(expr.clone())), (Ampersand,MaybeMut(ismut),Expr(expr)) => if ismut {ExprKind_RefMut(Rc_new(expr.clone()))} else {ExprKind_Ref(Rc_new(expr.clone()))}, (AndAnd,MaybeMut,Expr(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(R) { (ExprMatch) => Rc_new(state.values[0].clone()), (ExprIf) => Rc_new(state.values[0].clone()), (ExprIfLet) => Rc_new(state.values[0].clone()), (ExprWhile) => Rc_new(state.values[0].clone()), (ExprWhileLet) => Rc_new(state.values[0].clone()), (ExprLoop) => Rc_new(state.values[0].clone()), (ExprFor) => Rc_new(state.values[0].clone()), (Unsafe,Block) => (), (PathExpr,Bang,MaybeIdent,BracesDelimitedTokenTrees) => (), } nonterminal FullBlockExpr(R) { (BlockExpr(block)) => block.clone(), (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(V) { (MatchClause) => vec[Rc_new(state.values[0].clone())], (MatchClauses(clauses),MatchClause) => { new=(clauses.clone()); new.push(Rc_new(state.values[1].clone())); new }, } nonterminal MatchClause(VA,R,R) { (NonblockMatchClause(attributes, pattern, expression),Comma) => (attributes.clone(),pattern.clone(),expression.clone()), (BlockMatchClause(attributes, pattern, expression)) => (attributes.clone(),pattern.clone(),expression.clone()), (BlockMatchClause(attributes, pattern, expression),Comma) => (attributes.clone(),pattern.clone(),expression.clone()), } nonterminal NonblockMatchClause(VA,R,R) { (MaybeOuterAttrs(attributes),PatsOr,MaybeGuard,FatArrow,NonblockExpr) => (attributes.clone(),Rc_new(state.values[1].clone()),Rc_new(state.values[4].clone())), (MaybeOuterAttrs,PatsOr,MaybeGuard,FatArrow,BlockExprDot) => (), } nonterminal BlockMatchClause(VA,R,R) { (MaybeOuterAttrs(attributes),PatsOr,MaybeGuard,FatArrow,Block) => (attributes.clone(),Rc_new(state.values[1].clone()),Rc_new(state.values[4].clone())), (MaybeOuterAttrs(attributes),PatsOr,MaybeGuard,FatArrow,BlockExpr) => (attributes.clone(),Rc_new(state.values[1].clone()),Rc_new(state.values[4].clone())), } 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(R) { (LitByte) => Rc_new(state.values[0].clone()), (LitChar) => Rc_new(state.values[0].clone()), (LitInteger) => Rc_new(state.values[0].clone()), (LitFloat) => Rc_new(state.values[0].clone()), (True) => Rc_new(state.values[0].clone()), (False) => Rc_new(state.values[0].clone()), (Str) => Rc_new(state.values[0].clone()), } nonterminal Str { (LitStr) => (), (LitStrRaw) => (), (LitByteStr) => (), (LitByteStrRaw) => (), } nonterminal MaybeIdent { () => (), (Ident) => (), } nonterminal Ident(String) { (LiteralIdent(s)) => s.clone(), // Weak keywords that can be used as identifiers (Catch) => (), (DEFAULT) => (), (Union) => (), } nonterminal UnpairedToken(R) { //(SHL) => (), //(SHR) => (), (LE) => Rc_new(state.values[0].clone()), (EqualEqual) => Rc_new(state.values[0].clone()), (NE) => Rc_new(state.values[0].clone()), (GE) => Rc_new(state.values[0].clone()), (AndAnd) => Rc_new(state.values[0].clone()), (OrOr) => Rc_new(state.values[0].clone()), (LArrow) => Rc_new(state.values[0].clone()), //(SHLEQ) => (), //(SHREQ) => (), (MinusEqual) => Rc_new(state.values[0].clone()), (AndEqual) => Rc_new(state.values[0].clone()), (OrEqual) => Rc_new(state.values[0].clone()), (PlusEqual) => Rc_new(state.values[0].clone()), (StarEqual) => Rc_new(state.values[0].clone()), (SlashEqual) => Rc_new(state.values[0].clone()), (CaretEqual) => Rc_new(state.values[0].clone()), (PercentEqual) => Rc_new(state.values[0].clone()), (DotDot) => Rc_new(state.values[0].clone()), (DotDotDot) => Rc_new(state.values[0].clone()), (ModSep) => Rc_new(state.values[0].clone()), (RArrow) => Rc_new(state.values[0].clone()), (FatArrow) => Rc_new(state.values[0].clone()), (LitByte) => Rc_new(state.values[0].clone()), (LitChar) => Rc_new(state.values[0].clone()), (LitInteger) => Rc_new(state.values[0].clone()), (LitFloat) => Rc_new(state.values[0].clone()), (LitStr) => Rc_new(state.values[0].clone()), (LitStrRaw) => Rc_new(state.values[0].clone()), (LitByteStr) => Rc_new(state.values[0].clone()), (LitByteStrRaw) => Rc_new(state.values[0].clone()), (LiteralIdent) => Rc_new(state.values[0].clone()), (Underscore) => Rc_new(state.values[0].clone()), (LiteralLifetime) => Rc_new(state.values[0].clone()), (LittleSelf) => Rc_new(state.values[0].clone()), (Static) => Rc_new(state.values[0].clone()), //(Abstract) => (), //(AlignOf) => (), (As) => Rc_new(state.values[0].clone()), //(Become) => (), (Break) => Rc_new(state.values[0].clone()), (Catch) => Rc_new(state.values[0].clone()), (Crate) => Rc_new(state.values[0].clone()), (DEFAULT) => Rc_new(state.values[0].clone()), //(Do) => (), (Else) => Rc_new(state.values[0].clone()), (Enum) => Rc_new(state.values[0].clone()), (Extern) => Rc_new(state.values[0].clone()), (False) => Rc_new(state.values[0].clone()), //(Final) => (), (FN) => Rc_new(state.values[0].clone()), (For) => Rc_new(state.values[0].clone()), (If) => Rc_new(state.values[0].clone()), (Impl) => Rc_new(state.values[0].clone()), (In) => Rc_new(state.values[0].clone()), (LiteralLet) => Rc_new(state.values[0].clone()), (Loop) => Rc_new(state.values[0].clone()), //(Macro) => (), (Match) => Rc_new(state.values[0].clone()), (Mod) => Rc_new(state.values[0].clone()), (Move) => Rc_new(state.values[0].clone()), (Mut) => Rc_new(state.values[0].clone()), //(OffsetOf) => (), //(Override) => (), //(Priv) => (), (Pub) => Rc_new(state.values[0].clone()), //(Pure) => (), (Ref) => Rc_new(state.values[0].clone()), (Return) => Rc_new(state.values[0].clone()), (Struct) => Rc_new(state.values[0].clone()), //(Sizeof) => (), (Super) => Rc_new(state.values[0].clone()), (True) => Rc_new(state.values[0].clone()), (Trait) => Rc_new(state.values[0].clone()), (Type) => Rc_new(state.values[0].clone()), (Union) => Rc_new(state.values[0].clone()), (Unsafe) => Rc_new(state.values[0].clone()), //(Unsized) => (), (Use) => Rc_new(state.values[0].clone()), //(Virtual) => (), (While) => Rc_new(state.values[0].clone()), (Yield) => Rc_new(state.values[0].clone()), (Continue) => Rc_new(state.values[0].clone()), //(Proc) => (), (BOX) => Rc_new(state.values[0].clone()), (Const) => Rc_new(state.values[0].clone()), (Where) => Rc_new(state.values[0].clone()), (Typeof) => Rc_new(state.values[0].clone()), (InnerDocComment) => Rc_new(state.values[0].clone()), (OuterDocComment) => Rc_new(state.values[0].clone()), (Shebang) => Rc_new(state.values[0].clone()), (StaticLifetime) => Rc_new(state.values[0].clone()), (Semicolon) => Rc_new(state.values[0].clone()), (Comma) => Rc_new(state.values[0].clone()), (Dot) => Rc_new(state.values[0].clone()), (At) => Rc_new(state.values[0].clone()), (NumberSign) => Rc_new(state.values[0].clone()), //(Tilde) => (), (Colon) => Rc_new(state.values[0].clone()), //(Dolar) => (), (Equal) => Rc_new(state.values[0].clone()), (QuestionMark) => Rc_new(state.values[0].clone()), (Bang) => Rc_new(state.values[0].clone()), (LT) => Rc_new(state.values[0].clone()), (GT) => Rc_new(state.values[0].clone()), (Minus) => Rc_new(state.values[0].clone()), (Ampersand) => Rc_new(state.values[0].clone()), (Vertical) => Rc_new(state.values[0].clone()), (Plus) => Rc_new(state.values[0].clone()), (Star) => Rc_new(state.values[0].clone()), (Slash) => Rc_new(state.values[0].clone()), (Caret) => Rc_new(state.values[0].clone()), (Percent) => Rc_new(state.values[0].clone()), } nonterminal TokenTrees(V) { () => vec[], (TokenTrees(trees),TokenTree(token)) => { new=(trees.clone()); new.push(token.clone()); Token_TokenTrees(new) }, } nonterminal TokenTree(R) { (DelimitedTokenTrees(trees)) => Rc_new(Token_DelimitedTokenTrees(trees.clone())), (UnpairedToken(token)) => token.clone(), } nonterminal DelimitedTokenTrees(V) { (ParensDelimitedTokenTrees(trees)) => trees.clone(), (BracesDelimitedTokenTrees(trees)) => trees.clone(), (BracketsDelimitedTokenTrees(trees)) => trees.clone(), } nonterminal ParensDelimitedTokenTrees(V) { (LPar,TokenTrees(trees),RPar) => trees.clone(), } nonterminal BracesDelimitedTokenTrees { (LBrace,TokenTrees,RBrace) => (), } nonterminal BracketsDelimitedTokenTrees { (LBracket,TokenTrees,RBracket) => (), } nonterminal MaybeSpace { (NoSpace) => (), () => (), } //New nonterminal ItemTerminal(String,OR,V) { //(Struct,Ident,GenericParams,MaybeWhereClause,StructDeclArgs) => (), //(Struct,Ident,GenericParams,StructTupleArgs,MaybeWhereClause,Semicolon) => (), //(MaybeDefaultMaybeUnsafe,Impl,GenericParams,TyPrimSum,MaybeWhereClause,LBrace,MaybeInnerAttrs,MaybeImplItems,RBrace) => (), (Terminal,Ident(id),LBrace,MaybeTerminalItems(items),RBrace) => (id.clone(),None,items.clone()), (Terminal,Ident(id),LPar,MaybeTySums,RPar,LBrace,MaybeTerminalItems(items),RBrace) => (id.clone(),Some(Rc_new(state.values[3].clone())),items.clone()), } //New nonterminal MaybeTerminalItems(V) { (TerminalItems(items)) => items.clone(), () => vec[], } //New nonterminal TerminalItems(V) { (TerminalItem(item)) => vec[item.clone()], (TerminalItem(item),TerminalItems(items)) => { new=(vec[item.clone()]); //new.extend(items.iter().map(|x|x.clone())); //FIXME new }, } //New nonterminal TerminalItem(R) { (ItemFn) => Rc_new(state.values[0].clone()), //(AttrsAndVis,ItemMacro) => (), //(ImplConst) => (), //(ImplType) => (), } //New nonterminal ItemNonterminal(String,OR,V) { (Nonterminal,Ident(id),LBrace,MatchClauses(clauses),RBrace) => (id.clone(),None,clauses.clone()), (Nonterminal,Ident(id),LPar,MaybeTySums,RPar,LBrace,MatchClauses(clauses),RBrace) => (id.clone(),Some(Rc_new(state.values[3].clone())),clauses.clone()), } ordering!(member,assignation);