void StructMemberDecl( #line 753 "cs.ATG" ModifierList m, List<AttributeSection> attributes) { #line 755 "cs.ATG" string qualident = null; TypeReference type; Expression expr; List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); BlockStatement stmt = null; List<TemplateDefinition> templates = new List<TemplateDefinition>(); TypeReference explicitInterface = null; bool isExtensionMethod = false; if (la.kind == 60) { #line 765 "cs.ATG" m.Check(Modifiers.Constants); lexer.NextToken(); #line 766 "cs.ATG" Location startPos = t.Location; Type( #line 767 "cs.ATG" out type); Identifier(); #line 767 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location; f.TypeReference = type; SafeAdd(fd, fd.Fields, f); Expect(3); Expr( #line 774 "cs.ATG" out expr); #line 774 "cs.ATG" f.Initializer = expr; while (la.kind == 14) { lexer.NextToken(); Identifier(); #line 775 "cs.ATG" f = new VariableDeclaration(t.val); f.StartLocation = t.Location; f.TypeReference = type; SafeAdd(fd, fd.Fields, f); Expect(3); Expr( #line 780 "cs.ATG" out expr); #line 780 "cs.ATG" f.EndLocation = t.EndLocation; f.Initializer = expr; } Expect(11); #line 781 "cs.ATG" fd.EndLocation = t.EndLocation; AddChild(fd); } else if ( #line 785 "cs.ATG" NotVoidPointer()) { #line 785 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); Expect(123); #line 786 "cs.ATG" Location startPos = t.Location; if ( #line 787 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 788 "cs.ATG" out explicitInterface, false); #line 789 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(18)) { Identifier(); #line 792 "cs.ATG" qualident = t.val; } else SynErr(162); if (la.kind == 23) { TypeParameterList( #line 795 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); #line 798 "cs.ATG" isExtensionMethod = true; /* C# 3.0 */ } if (StartOf(11)) { FormalParameterList( #line 799 "cs.ATG" p); } Expect(21); #line 800 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, TypeReference = new TypeReference("System.Void", true), Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, Templates = templates, IsExtensionMethod = isExtensionMethod }; if (explicitInterface != null) SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); AddChild(methodDeclaration); BlockStart(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( #line 818 "cs.ATG" templates); } if (la.kind == 16) { Block( #line 820 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(163); #line 820 "cs.ATG" BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 69) { #line 824 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); lexer.NextToken(); #line 826 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration { Modifier = m.Modifier, Attributes = attributes, StartLocation = t.Location }; AddChild(eventDecl); BlockStart(eventDecl); EventAddRegion addBlock = null; EventRemoveRegion removeBlock = null; Type( #line 836 "cs.ATG" out type); #line 836 "cs.ATG" eventDecl.TypeReference = type; if ( #line 837 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 838 "cs.ATG" out explicitInterface, false); #line 839 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); #line 840 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (StartOf(18)) { Identifier(); #line 842 "cs.ATG" qualident = t.val; if (la.kind == 3) { lexer.NextToken(); Expr( #line 843 "cs.ATG" out expr); #line 843 "cs.ATG" eventDecl.Initializer = expr; } while (la.kind == 14) { lexer.NextToken(); #line 847 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; BlockEnd(); #line 849 "cs.ATG" eventDecl = new EventDeclaration { Modifier = eventDecl.Modifier, Attributes = eventDecl.Attributes, StartLocation = eventDecl.StartLocation, TypeReference = eventDecl.TypeReference.Clone() }; AddChild(eventDecl); BlockStart(eventDecl); Identifier(); #line 858 "cs.ATG" qualident = t.val; if (la.kind == 3) { lexer.NextToken(); Expr( #line 859 "cs.ATG" out expr); #line 859 "cs.ATG" eventDecl.Initializer = expr; } } } else SynErr(164); #line 862 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 16) { lexer.NextToken(); #line 863 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( #line 864 "cs.ATG" out addBlock, out removeBlock); Expect(17); #line 865 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } #line 868 "cs.ATG" BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( #line 874 "cs.ATG" IdentAndLPar()) { #line 874 "cs.ATG" m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); Identifier(); #line 875 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(11)) { #line 875 "cs.ATG" m.Check(Modifiers.Constructors); FormalParameterList( #line 876 "cs.ATG" p); } Expect(21); #line 878 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { #line 879 "cs.ATG" m.Check(Modifiers.Constructors); ConstructorInitializer( #line 880 "cs.ATG" out init); } #line 882 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 16) { Block( #line 887 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); #line 887 "cs.ATG" cd.Body = (BlockStatement)stmt; AddChild(cd); } else if (la.kind == 70 || la.kind == 80) { #line 890 "cs.ATG" m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; Location startPos = Location.Empty; if (la.kind == 80) { lexer.NextToken(); #line 895 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); #line 895 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(92); Type( #line 896 "cs.ATG" out type); #line 896 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( #line 897 "cs.ATG" out type); Identifier(); #line 897 "cs.ATG" string varName = t.val; Expect(21); #line 898 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( #line 899 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); #line 899 "cs.ATG" stmt = null; } else SynErr(166); #line 902 "cs.ATG" List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Name = (isImplicit ? "op_Implicit" : "op_Explicit"), Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, TypeReference = operatorType, ConversionType = isImplicit ? ConversionType.Implicit : ConversionType.Explicit, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; AddChild(operatorDeclaration); } else if (StartOf(21)) { TypeDecl( #line 920 "cs.ATG" m, attributes); } else if (StartOf(10)) { Type( #line 922 "cs.ATG" out type); #line 922 "cs.ATG" Location startPos = t.Location; if (la.kind == 92) { #line 924 "cs.ATG" OverloadableOperatorType op; m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( #line 928 "cs.ATG" out op); #line 928 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); #line 929 "cs.ATG" Location firstStart = la.Location, secondStart = Location.Empty, secondEnd = Location.Empty; Type( #line 929 "cs.ATG" out firstType); Identifier(); #line 929 "cs.ATG" string firstName = t.val; Location firstEnd = t.EndLocation; if (la.kind == 14) { lexer.NextToken(); #line 930 "cs.ATG" secondStart = la.Location; Type( #line 930 "cs.ATG" out secondType); Identifier(); #line 930 "cs.ATG" secondName = t.val; secondEnd = t.EndLocation; } else if (la.kind == 21) { } else SynErr(167); #line 938 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( #line 939 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(168); #line 941 "cs.ATG" if (op == OverloadableOperatorType.Add && secondType == null) op = OverloadableOperatorType.UnaryPlus; if (op == OverloadableOperatorType.Subtract && secondType == null) op = OverloadableOperatorType.UnaryMinus; OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, TypeReference = type, OverloadableOperator = op, Name = GetReflectionNameForOperator(op), Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName) { StartLocation = firstStart, EndLocation = firstEnd }); if (secondType != null) { SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName) { StartLocation = secondStart, EndLocation = secondEnd }); } AddChild(operatorDeclaration); } else if ( #line 963 "cs.ATG" IsVarDecl()) { #line 964 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( #line 968 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( #line 969 "cs.ATG" fd); Expect(18); Expr( #line 971 "cs.ATG" out expr); #line 971 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( #line 975 "cs.ATG" fd); Expect(18); Expr( #line 977 "cs.ATG" out expr); #line 977 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); } } else if (StartOf(18)) { VariableDeclarator( #line 982 "cs.ATG" fd); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( #line 983 "cs.ATG" fd); } } else SynErr(169); Expect(11); #line 985 "cs.ATG" fd.EndLocation = t.EndLocation; AddChild(fd); } else if (la.kind == 111) { #line 988 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( #line 989 "cs.ATG" p); Expect(19); #line 989 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); #line 990 "cs.ATG" PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; indexer.BodyStart = t.Location; indexer.TypeReference = type; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 998 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 999 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; AddChild(indexer); } else if ( #line 1004 "cs.ATG" IsIdentifierToken(la)) { if ( #line 1005 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 1006 "cs.ATG" out explicitInterface, false); #line 1007 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(18)) { Identifier(); #line 1010 "cs.ATG" qualident = t.val; } else SynErr(170); #line 1012 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { #line 1016 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( #line 1018 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); #line 1020 "cs.ATG" isExtensionMethod = true; } if (StartOf(11)) { FormalParameterList( #line 1021 "cs.ATG" p); } Expect(21); #line 1023 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes }; if (explicitInterface != null) methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; methodDeclaration.IsExtensionMethod = isExtensionMethod; methodDeclaration.Templates = templates; AddChild(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( #line 1038 "cs.ATG" templates); } if (la.kind == 16) { Block( #line 1039 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(171); #line 1039 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); #line 1042 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = qualIdentEndLocation; pDecl.BodyStart = t.Location; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 1051 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 1053 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; AddChild(pDecl); } } else if (la.kind == 15) { #line 1061 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(111); Expect(18); FormalParameterList( #line 1062 "cs.ATG" p); Expect(19); #line 1063 "cs.ATG" PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; indexer.TypeReference = type; if (explicitInterface != null) SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this")); PropertyGetRegion getRegion; PropertySetRegion setRegion; Expect(16); #line 1072 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( #line 1073 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 1074 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; AddChild(indexer); } else SynErr(172); } else SynErr(173); } else SynErr(174); }
void StructMemberDecl( #line 739 "cs.ATG" ModifierList m, List<AttributeSection> attributes) { #line 741 "cs.ATG" string qualident = null; TypeReference type; Expression expr; List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); Statement stmt = null; List<TemplateDefinition> templates = new List<TemplateDefinition>(); TypeReference explicitInterface = null; bool isExtensionMethod = false; if (la.kind == 60) { #line 751 "cs.ATG" m.Check(Modifiers.Constants); lexer.NextToken(); #line 752 "cs.ATG" Location startPos = t.Location; Type( #line 753 "cs.ATG" out type); Identifier(); #line 753 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); SafeAdd(fd, fd.Fields, f); Expect(3); Expr( #line 758 "cs.ATG" out expr); #line 758 "cs.ATG" f.Initializer = expr; while (la.kind == 14) { lexer.NextToken(); Identifier(); #line 759 "cs.ATG" f = new VariableDeclaration(t.val); SafeAdd(fd, fd.Fields, f); Expect(3); Expr( #line 762 "cs.ATG" out expr); #line 762 "cs.ATG" f.Initializer = expr; } Expect(11); #line 763 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( #line 767 "cs.ATG" NotVoidPointer()) { #line 767 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); Expect(123); #line 768 "cs.ATG" Location startPos = t.Location; if ( #line 769 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 770 "cs.ATG" out explicitInterface, false); #line 771 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(19)) { Identifier(); #line 774 "cs.ATG" qualident = t.val; } else SynErr(162); if (la.kind == 23) { TypeParameterList( #line 777 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); #line 780 "cs.ATG" isExtensionMethod = true; /* C# 3.0 */ } if (StartOf(11)) { FormalParameterList( #line 781 "cs.ATG" p); } Expect(21); #line 782 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, TypeReference = new TypeReference("System.Void", true), Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, Templates = templates, IsExtensionMethod = isExtensionMethod }; if (explicitInterface != null) SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( #line 800 "cs.ATG" templates); } if (la.kind == 16) { Block( #line 802 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(163); #line 802 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 69) { #line 806 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); lexer.NextToken(); #line 808 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration { Modifier = m.Modifier, Attributes = attributes, StartLocation = t.Location }; compilationUnit.AddChild(eventDecl); compilationUnit.BlockStart(eventDecl); EventAddRegion addBlock = null; EventRemoveRegion removeBlock = null; Type( #line 818 "cs.ATG" out type); #line 818 "cs.ATG" eventDecl.TypeReference = type; if ( #line 819 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 820 "cs.ATG" out explicitInterface, false); #line 821 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); #line 822 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (StartOf(19)) { Identifier(); #line 824 "cs.ATG" qualident = t.val; } else SynErr(164); #line 826 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 3) { lexer.NextToken(); Expr( #line 827 "cs.ATG" out expr); #line 827 "cs.ATG" eventDecl.Initializer = expr; } if (la.kind == 16) { lexer.NextToken(); #line 828 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( #line 829 "cs.ATG" out addBlock, out removeBlock); Expect(17); #line 830 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } #line 833 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( #line 839 "cs.ATG" IdentAndLPar()) { #line 839 "cs.ATG" m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); Identifier(); #line 840 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(11)) { #line 840 "cs.ATG" m.Check(Modifiers.Constructors); FormalParameterList( #line 841 "cs.ATG" p); } Expect(21); #line 843 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { #line 844 "cs.ATG" m.Check(Modifiers.Constructors); ConstructorInitializer( #line 845 "cs.ATG" out init); } #line 847 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 16) { Block( #line 852 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); #line 852 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 70 || la.kind == 80) { #line 855 "cs.ATG" m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; Location startPos = Location.Empty; if (la.kind == 80) { lexer.NextToken(); #line 860 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); #line 860 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(92); Type( #line 861 "cs.ATG" out type); #line 861 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( #line 862 "cs.ATG" out type); Identifier(); #line 862 "cs.ATG" string varName = t.val; Expect(21); #line 863 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( #line 864 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); #line 864 "cs.ATG" stmt = null; } else SynErr(166); #line 867 "cs.ATG" List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, TypeReference = operatorType, ConversionType = isImplicit ? ConversionType.Implicit : ConversionType.Explicit, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; compilationUnit.AddChild(operatorDeclaration); } else if (StartOf(22)) { TypeDecl( #line 884 "cs.ATG" m, attributes); } else if (StartOf(10)) { Type( #line 886 "cs.ATG" out type); #line 886 "cs.ATG" Location startPos = t.Location; if (la.kind == 92) { #line 888 "cs.ATG" OverloadableOperatorType op; m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( #line 892 "cs.ATG" out op); #line 892 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( #line 893 "cs.ATG" out firstType); Identifier(); #line 893 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( #line 894 "cs.ATG" out secondType); Identifier(); #line 894 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(167); #line 902 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( #line 903 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(168); #line 905 "cs.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, TypeReference = type, OverloadableOperator = op, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName)); } compilationUnit.AddChild(operatorDeclaration); } else if ( #line 922 "cs.ATG" IsVarDecl()) { #line 923 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( #line 927 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( #line 928 "cs.ATG" fd); Expect(18); Expr( #line 930 "cs.ATG" out expr); #line 930 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( #line 934 "cs.ATG" fd); Expect(18); Expr( #line 936 "cs.ATG" out expr); #line 936 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); } } else if (StartOf(19)) { VariableDeclarator( #line 941 "cs.ATG" fd); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( #line 942 "cs.ATG" fd); } } else SynErr(169); Expect(11); #line 944 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if (la.kind == 111) { #line 947 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( #line 948 "cs.ATG" p); Expect(19); #line 948 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); #line 949 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; indexer.BodyStart = t.Location; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 956 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 957 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( #line 962 "cs.ATG" IsIdentifierToken(la)) { if ( #line 963 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( #line 964 "cs.ATG" out explicitInterface, false); #line 965 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(19)) { Identifier(); #line 968 "cs.ATG" qualident = t.val; } else SynErr(170); #line 970 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { #line 974 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( #line 976 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); #line 978 "cs.ATG" isExtensionMethod = true; } if (StartOf(11)) { FormalParameterList( #line 979 "cs.ATG" p); } Expect(21); #line 981 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes }; if (explicitInterface != null) methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; methodDeclaration.IsExtensionMethod = isExtensionMethod; methodDeclaration.Templates = templates; compilationUnit.AddChild(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( #line 996 "cs.ATG" templates); } if (la.kind == 16) { Block( #line 997 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(171); #line 997 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); #line 1000 "cs.ATG" PropertyDeclaration ParameterDeclarationExpressionl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) ParameterDeclarationExpressionl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); ParameterDeclarationExpressionl.StartLocation = m.GetDeclarationLocation(startPos); ParameterDeclarationExpressionl.EndLocation = qualIdentEndLocation; ParameterDeclarationExpressionl.BodyStart = t.Location; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 1009 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 1011 "cs.ATG" ParameterDeclarationExpressionl.GetRegion = getRegion; ParameterDeclarationExpressionl.SetRegion = setRegion; ParameterDeclarationExpressionl.BodyEnd = t.EndLocation; compilationUnit.AddChild(ParameterDeclarationExpressionl); } } else if (la.kind == 15) { #line 1019 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(111); Expect(18); FormalParameterList( #line 1020 "cs.ATG" p); Expect(19); #line 1021 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; if (explicitInterface != null) SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this")); PropertyGetRegion getRegion; PropertySetRegion setRegion; Expect(16); #line 1029 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( #line 1030 "cs.ATG" out getRegion, out setRegion); Expect(17); #line 1031 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else SynErr(172); } else SynErr(173); } else SynErr(174); }