From 4bbddfd8b62479505ef553ea5f40e029b45f377d Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 25 Feb 2012 16:52:21 +0100 Subject: [PATCH] Fixed C# parser bug that occurs when the first parameter of an extension method is decorated with an attribute. Closes icsharpcode/SharpDevelop#19. --- .../NRefactory/Project/Src/Ast/Enums.cs | 3 +- .../Project/Src/Parser/CSharp/Parser.cs | 2007 ++++++++--------- .../Project/Src/Parser/CSharp/cs.ATG | 8 +- .../TypeLevel/MethodDeclarationTests.cs | 13 + .../Src/Interfaces/ParameterModifiers.cs | 3 +- 5 files changed, 1020 insertions(+), 1014 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs b/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs index 29fc3fc8cc..9da994c47a 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/Enums.cs @@ -115,7 +115,8 @@ namespace ICSharpCode.NRefactory.Ast Out = 2, Ref = 4, Params = 8, - Optional = 16 + Optional = 16, + This = 32 } public enum VarianceModifier diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index db20ad098c..cb7abcca4a 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -509,68 +509,68 @@ out expr); } void Expr( -#line 1808 "cs.ATG" +#line 1806 "cs.ATG" out Expression expr) { -#line 1809 "cs.ATG" +#line 1807 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; -#line 1811 "cs.ATG" +#line 1809 "cs.ATG" Location startLocation = la.Location; UnaryExpr( -#line 1812 "cs.ATG" +#line 1810 "cs.ATG" out expr); if (StartOf(7)) { AssignmentOperator( -#line 1815 "cs.ATG" +#line 1813 "cs.ATG" out op); Expr( -#line 1815 "cs.ATG" +#line 1813 "cs.ATG" out expr1); -#line 1815 "cs.ATG" +#line 1813 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1816 "cs.ATG" +#line 1814 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1817 "cs.ATG" +#line 1815 "cs.ATG" out op); Expr( -#line 1817 "cs.ATG" +#line 1815 "cs.ATG" out expr1); -#line 1817 "cs.ATG" +#line 1815 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(8)) { ConditionalOrExpr( -#line 1819 "cs.ATG" +#line 1817 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1820 "cs.ATG" +#line 1818 "cs.ATG" out expr1); -#line 1820 "cs.ATG" +#line 1818 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1821 "cs.ATG" +#line 1819 "cs.ATG" out expr1); Expect(9); Expr( -#line 1821 "cs.ATG" +#line 1819 "cs.ATG" out expr2); -#line 1821 "cs.ATG" +#line 1819 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(152); -#line 1824 "cs.ATG" +#line 1822 "cs.ATG" if (expr != null) { if (expr.StartLocation.IsEmpty) expr.StartLocation = startLocation; @@ -648,76 +648,76 @@ out attribute); } void TypeModifier( -#line 695 "cs.ATG" +#line 696 "cs.ATG" ModifierList m) { switch (la.kind) { case 89: { lexer.NextToken(); -#line 697 "cs.ATG" +#line 698 "cs.ATG" m.Add(Modifiers.New, t.Location); break; } case 98: { lexer.NextToken(); -#line 698 "cs.ATG" +#line 699 "cs.ATG" m.Add(Modifiers.Public, t.Location); break; } case 97: { lexer.NextToken(); -#line 699 "cs.ATG" +#line 700 "cs.ATG" m.Add(Modifiers.Protected, t.Location); break; } case 84: { lexer.NextToken(); -#line 700 "cs.ATG" +#line 701 "cs.ATG" m.Add(Modifiers.Internal, t.Location); break; } case 96: { lexer.NextToken(); -#line 701 "cs.ATG" +#line 702 "cs.ATG" m.Add(Modifiers.Private, t.Location); break; } case 119: { lexer.NextToken(); -#line 702 "cs.ATG" +#line 703 "cs.ATG" m.Add(Modifiers.Unsafe, t.Location); break; } case 49: { lexer.NextToken(); -#line 703 "cs.ATG" +#line 704 "cs.ATG" m.Add(Modifiers.Abstract, t.Location); break; } case 103: { lexer.NextToken(); -#line 704 "cs.ATG" +#line 705 "cs.ATG" m.Add(Modifiers.Sealed, t.Location); break; } case 107: { lexer.NextToken(); -#line 705 "cs.ATG" +#line 706 "cs.ATG" m.Add(Modifiers.Static, t.Location); break; } case 126: { lexer.NextToken(); -#line 706 "cs.ATG" +#line 707 "cs.ATG" m.Add(Modifiers.Partial, t.Location); break; } @@ -974,26 +974,26 @@ templates); } void TypeParameterList( -#line 2397 "cs.ATG" +#line 2395 "cs.ATG" List templates) { -#line 2399 "cs.ATG" +#line 2397 "cs.ATG" TemplateDefinition template; Expect(23); VariantTypeParameter( -#line 2403 "cs.ATG" +#line 2401 "cs.ATG" out template); -#line 2403 "cs.ATG" +#line 2401 "cs.ATG" templates.Add(template); while (la.kind == 14) { lexer.NextToken(); VariantTypeParameter( -#line 2405 "cs.ATG" +#line 2403 "cs.ATG" out template); -#line 2405 "cs.ATG" +#line 2403 "cs.ATG" templates.Add(template); } Expect(22); @@ -1026,22 +1026,22 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2425 "cs.ATG" +#line 2423 "cs.ATG" List templates) { -#line 2426 "cs.ATG" +#line 2424 "cs.ATG" string name = ""; TypeReference type; Expect(127); Identifier(); -#line 2429 "cs.ATG" +#line 2427 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2431 "cs.ATG" +#line 2429 "cs.ATG" out type); -#line 2432 "cs.ATG" +#line 2430 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1054,10 +1054,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2441 "cs.ATG" +#line 2439 "cs.ATG" out type); -#line 2442 "cs.ATG" +#line 2440 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1189,72 +1189,72 @@ out typeRef, false); } void IntegralType( -#line 717 "cs.ATG" +#line 718 "cs.ATG" out string name) { -#line 717 "cs.ATG" +#line 718 "cs.ATG" name = ""; switch (la.kind) { case 102: { lexer.NextToken(); -#line 719 "cs.ATG" +#line 720 "cs.ATG" name = "System.SByte"; break; } case 54: { lexer.NextToken(); -#line 720 "cs.ATG" +#line 721 "cs.ATG" name = "System.Byte"; break; } case 104: { lexer.NextToken(); -#line 721 "cs.ATG" +#line 722 "cs.ATG" name = "System.Int16"; break; } case 120: { lexer.NextToken(); -#line 722 "cs.ATG" +#line 723 "cs.ATG" name = "System.UInt16"; break; } case 82: { lexer.NextToken(); -#line 723 "cs.ATG" +#line 724 "cs.ATG" name = "System.Int32"; break; } case 116: { lexer.NextToken(); -#line 724 "cs.ATG" +#line 725 "cs.ATG" name = "System.UInt32"; break; } case 87: { lexer.NextToken(); -#line 725 "cs.ATG" +#line 726 "cs.ATG" name = "System.Int64"; break; } case 117: { lexer.NextToken(); -#line 726 "cs.ATG" +#line 727 "cs.ATG" name = "System.UInt64"; break; } case 57: { lexer.NextToken(); -#line 727 "cs.ATG" +#line 728 "cs.ATG" name = "System.Char"; break; } @@ -1348,60 +1348,60 @@ out p); } void ClassType( -#line 709 "cs.ATG" +#line 710 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 710 "cs.ATG" +#line 711 "cs.ATG" TypeReference r; typeRef = null; if (StartOf(18)) { TypeName( -#line 712 "cs.ATG" +#line 713 "cs.ATG" out r, canBeUnbound); -#line 712 "cs.ATG" +#line 713 "cs.ATG" typeRef = r; } else if (la.kind == 91) { lexer.NextToken(); -#line 713 "cs.ATG" +#line 714 "cs.ATG" typeRef = new TypeReference("System.Object", true); typeRef.StartLocation = t.Location; typeRef.EndLocation = t.EndLocation; } else if (la.kind == 108) { lexer.NextToken(); -#line 714 "cs.ATG" +#line 715 "cs.ATG" typeRef = new TypeReference("System.String", true); typeRef.StartLocation = t.Location; typeRef.EndLocation = t.EndLocation; } else SynErr(159); } void TypeName( -#line 2338 "cs.ATG" +#line 2336 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2339 "cs.ATG" +#line 2337 "cs.ATG" List typeArguments = null; string alias = null; string qualident; Location startLocation = la.Location; if ( -#line 2345 "cs.ATG" +#line 2343 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 2346 "cs.ATG" +#line 2344 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2349 "cs.ATG" +#line 2347 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2350 "cs.ATG" +#line 2348 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2352 "cs.ATG" +#line 2350 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1412,150 +1412,150 @@ out typeArguments, canBeUnbound); } while ( -#line 2361 "cs.ATG" +#line 2359 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2362 "cs.ATG" +#line 2360 "cs.ATG" typeArguments = null; Qualident( -#line 2363 "cs.ATG" +#line 2361 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2364 "cs.ATG" +#line 2362 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2365 "cs.ATG" +#line 2363 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } -#line 2367 "cs.ATG" +#line 2365 "cs.ATG" typeRef.StartLocation = startLocation; typeRef.EndLocation = t.EndLocation; } void MemberModifiers( -#line 730 "cs.ATG" +#line 731 "cs.ATG" ModifierList m) { while (StartOf(19)) { switch (la.kind) { case 49: { lexer.NextToken(); -#line 733 "cs.ATG" +#line 734 "cs.ATG" m.Add(Modifiers.Abstract, t.Location); break; } case 71: { lexer.NextToken(); -#line 734 "cs.ATG" +#line 735 "cs.ATG" m.Add(Modifiers.Extern, t.Location); break; } case 84: { lexer.NextToken(); -#line 735 "cs.ATG" +#line 736 "cs.ATG" m.Add(Modifiers.Internal, t.Location); break; } case 89: { lexer.NextToken(); -#line 736 "cs.ATG" +#line 737 "cs.ATG" m.Add(Modifiers.New, t.Location); break; } case 94: { lexer.NextToken(); -#line 737 "cs.ATG" +#line 738 "cs.ATG" m.Add(Modifiers.Override, t.Location); break; } case 96: { lexer.NextToken(); -#line 738 "cs.ATG" +#line 739 "cs.ATG" m.Add(Modifiers.Private, t.Location); break; } case 97: { lexer.NextToken(); -#line 739 "cs.ATG" +#line 740 "cs.ATG" m.Add(Modifiers.Protected, t.Location); break; } case 98: { lexer.NextToken(); -#line 740 "cs.ATG" +#line 741 "cs.ATG" m.Add(Modifiers.Public, t.Location); break; } case 99: { lexer.NextToken(); -#line 741 "cs.ATG" +#line 742 "cs.ATG" m.Add(Modifiers.ReadOnly, t.Location); break; } case 103: { lexer.NextToken(); -#line 742 "cs.ATG" +#line 743 "cs.ATG" m.Add(Modifiers.Sealed, t.Location); break; } case 107: { lexer.NextToken(); -#line 743 "cs.ATG" +#line 744 "cs.ATG" m.Add(Modifiers.Static, t.Location); break; } case 74: { lexer.NextToken(); -#line 744 "cs.ATG" +#line 745 "cs.ATG" m.Add(Modifiers.Fixed, t.Location); break; } case 119: { lexer.NextToken(); -#line 745 "cs.ATG" +#line 746 "cs.ATG" m.Add(Modifiers.Unsafe, t.Location); break; } case 122: { lexer.NextToken(); -#line 746 "cs.ATG" +#line 747 "cs.ATG" m.Add(Modifiers.Virtual, t.Location); break; } case 124: { lexer.NextToken(); -#line 747 "cs.ATG" +#line 748 "cs.ATG" m.Add(Modifiers.Volatile, t.Location); break; } case 126: { lexer.NextToken(); -#line 748 "cs.ATG" +#line 749 "cs.ATG" m.Add(Modifiers.Partial, t.Location); break; } case 145: { lexer.NextToken(); -#line 749 "cs.ATG" +#line 750 "cs.ATG" m.Add(Modifiers.Async, t.Location); break; } @@ -1564,23 +1564,23 @@ ModifierList m) { } void ClassMemberDecl( -#line 1084 "cs.ATG" +#line 1082 "cs.ATG" ModifierList m, List attributes) { -#line 1085 "cs.ATG" +#line 1083 "cs.ATG" BlockStatement stmt = null; if (StartOf(20)) { StructMemberDecl( -#line 1087 "cs.ATG" +#line 1085 "cs.ATG" m, attributes); } else if (la.kind == 27) { -#line 1088 "cs.ATG" +#line 1086 "cs.ATG" m.Check(Modifiers.Destructors); Location startPos = la.Location; lexer.NextToken(); Identifier(); -#line 1089 "cs.ATG" +#line 1087 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1588,17 +1588,17 @@ m, attributes); Expect(20); Expect(21); -#line 1093 "cs.ATG" +#line 1091 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 1093 "cs.ATG" +#line 1091 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(160); -#line 1094 "cs.ATG" +#line 1092 "cs.ATG" d.Body = stmt; AddChild(d); @@ -1606,10 +1606,10 @@ out stmt); } void StructMemberDecl( -#line 753 "cs.ATG" +#line 754 "cs.ATG" ModifierList m, List attributes) { -#line 755 "cs.ATG" +#line 756 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1617,7 +1617,6 @@ ModifierList m, List attributes) { BlockStatement stmt = null; List templates = new List(); TypeReference explicitInterface = null; - bool isExtensionMethod = false; if (la.kind == 60) { @@ -1702,20 +1701,14 @@ out explicitInterface, false); 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" +#line 798 "cs.ATG" p); } Expect(21); -#line 800 "cs.ATG" +#line 799 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, @@ -1725,7 +1718,7 @@ p); StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, Templates = templates, - IsExtensionMethod = isExtensionMethod + IsExtensionMethod = p.Count > 0 && p[0].ParamModifier == ParameterModifiers.This }; if (explicitInterface != null) SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); @@ -1734,28 +1727,28 @@ p); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 818 "cs.ATG" +#line 817 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 820 "cs.ATG" +#line 819 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(163); -#line 820 "cs.ATG" +#line 819 "cs.ATG" BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 69) { -#line 824 "cs.ATG" +#line 823 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); lexer.NextToken(); -#line 826 "cs.ATG" +#line 825 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration { Modifier = m.Modifier, Attributes = attributes, @@ -1767,44 +1760,44 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 836 "cs.ATG" +#line 835 "cs.ATG" out type); -#line 836 "cs.ATG" +#line 835 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 837 "cs.ATG" +#line 836 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 838 "cs.ATG" +#line 837 "cs.ATG" out explicitInterface, false); -#line 839 "cs.ATG" +#line 838 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); -#line 840 "cs.ATG" +#line 839 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (StartOf(18)) { Identifier(); -#line 842 "cs.ATG" +#line 841 "cs.ATG" qualident = t.val; if (la.kind == 3) { lexer.NextToken(); Expr( -#line 843 "cs.ATG" +#line 842 "cs.ATG" out expr); -#line 843 "cs.ATG" +#line 842 "cs.ATG" eventDecl.Initializer = expr; } while (la.kind == 14) { lexer.NextToken(); -#line 847 "cs.ATG" +#line 846 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; BlockEnd(); -#line 849 "cs.ATG" +#line 848 "cs.ATG" eventDecl = new EventDeclaration { Modifier = eventDecl.Modifier, Attributes = eventDecl.Attributes, @@ -1816,94 +1809,94 @@ out expr); Identifier(); -#line 858 "cs.ATG" +#line 857 "cs.ATG" qualident = t.val; if (la.kind == 3) { lexer.NextToken(); Expr( -#line 859 "cs.ATG" +#line 858 "cs.ATG" out expr); -#line 859 "cs.ATG" +#line 858 "cs.ATG" eventDecl.Initializer = expr; } } } else SynErr(164); -#line 862 "cs.ATG" +#line 861 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 16) { lexer.NextToken(); -#line 863 "cs.ATG" +#line 862 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 864 "cs.ATG" +#line 863 "cs.ATG" out addBlock, out removeBlock); Expect(17); -#line 865 "cs.ATG" +#line 864 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } -#line 868 "cs.ATG" +#line 867 "cs.ATG" BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 874 "cs.ATG" +#line 873 "cs.ATG" IdentAndLPar()) { -#line 874 "cs.ATG" +#line 873 "cs.ATG" m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); Identifier(); -#line 875 "cs.ATG" +#line 874 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(11)) { -#line 875 "cs.ATG" +#line 874 "cs.ATG" m.Check(Modifiers.Constructors); FormalParameterList( -#line 876 "cs.ATG" +#line 875 "cs.ATG" p); } Expect(21); -#line 878 "cs.ATG" +#line 877 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 879 "cs.ATG" +#line 878 "cs.ATG" m.Check(Modifiers.Constructors); ConstructorInitializer( -#line 880 "cs.ATG" +#line 879 "cs.ATG" out init); } -#line 882 "cs.ATG" +#line 881 "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" +#line 886 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); -#line 887 "cs.ATG" +#line 886 "cs.ATG" cd.Body = (BlockStatement)stmt; AddChild(cd); } else if (la.kind == 70 || la.kind == 80) { -#line 890 "cs.ATG" +#line 889 "cs.ATG" m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -1912,45 +1905,45 @@ out stmt); if (la.kind == 80) { lexer.NextToken(); -#line 895 "cs.ATG" +#line 894 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); -#line 895 "cs.ATG" +#line 894 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(92); Type( -#line 896 "cs.ATG" +#line 895 "cs.ATG" out type); -#line 896 "cs.ATG" +#line 895 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( -#line 897 "cs.ATG" +#line 896 "cs.ATG" out type); Identifier(); -#line 897 "cs.ATG" +#line 896 "cs.ATG" string varName = t.val; Expect(21); -#line 898 "cs.ATG" +#line 897 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( -#line 899 "cs.ATG" +#line 898 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 899 "cs.ATG" +#line 898 "cs.ATG" stmt = null; } else SynErr(166); -#line 902 "cs.ATG" +#line 901 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration { @@ -1968,67 +1961,67 @@ out stmt); } else if (StartOf(21)) { TypeDecl( -#line 920 "cs.ATG" +#line 919 "cs.ATG" m, attributes); } else if (StartOf(10)) { Type( -#line 922 "cs.ATG" +#line 921 "cs.ATG" out type); -#line 922 "cs.ATG" +#line 921 "cs.ATG" Location startPos = t.Location; if (la.kind == 92) { -#line 924 "cs.ATG" +#line 923 "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" +#line 927 "cs.ATG" out op); -#line 928 "cs.ATG" +#line 927 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); -#line 929 "cs.ATG" +#line 928 "cs.ATG" Location firstStart = la.Location, secondStart = Location.Empty, secondEnd = Location.Empty; Type( -#line 929 "cs.ATG" +#line 928 "cs.ATG" out firstType); Identifier(); -#line 929 "cs.ATG" +#line 928 "cs.ATG" string firstName = t.val; Location firstEnd = t.EndLocation; if (la.kind == 14) { lexer.NextToken(); -#line 930 "cs.ATG" +#line 929 "cs.ATG" secondStart = la.Location; Type( -#line 930 "cs.ATG" +#line 929 "cs.ATG" out secondType); Identifier(); -#line 930 "cs.ATG" +#line 929 "cs.ATG" secondName = t.val; secondEnd = t.EndLocation; } else if (la.kind == 21) { } else SynErr(167); -#line 938 "cs.ATG" +#line 937 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( -#line 939 "cs.ATG" +#line 938 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(168); -#line 941 "cs.ATG" +#line 940 "cs.ATG" if (op == OverloadableOperatorType.Add && secondType == null) op = OverloadableOperatorType.UnaryPlus; if (op == OverloadableOperatorType.Subtract && secondType == null) @@ -2050,75 +2043,75 @@ out stmt); AddChild(operatorDeclaration); } else if ( -#line 963 "cs.ATG" +#line 962 "cs.ATG" IsVarDecl()) { -#line 964 "cs.ATG" +#line 963 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( -#line 968 "cs.ATG" +#line 967 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( -#line 969 "cs.ATG" +#line 968 "cs.ATG" fd); Expect(18); Expr( -#line 971 "cs.ATG" +#line 970 "cs.ATG" out expr); -#line 971 "cs.ATG" +#line 970 "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" +#line 974 "cs.ATG" fd); Expect(18); Expr( -#line 977 "cs.ATG" +#line 976 "cs.ATG" out expr); -#line 977 "cs.ATG" +#line 976 "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" +#line 981 "cs.ATG" fd); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 983 "cs.ATG" +#line 982 "cs.ATG" fd); } } else SynErr(169); Expect(11); -#line 985 "cs.ATG" +#line 984 "cs.ATG" fd.EndLocation = t.EndLocation; AddChild(fd); } else if (la.kind == 111) { -#line 988 "cs.ATG" +#line 987 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( -#line 989 "cs.ATG" +#line 988 "cs.ATG" p); Expect(19); -#line 989 "cs.ATG" +#line 988 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); -#line 990 "cs.ATG" +#line 989 "cs.ATG" PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2128,64 +2121,58 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 998 "cs.ATG" +#line 997 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 999 "cs.ATG" +#line 998 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; AddChild(indexer); } else if ( -#line 1004 "cs.ATG" +#line 1003 "cs.ATG" IsIdentifierToken(la)) { if ( -#line 1005 "cs.ATG" +#line 1004 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 1006 "cs.ATG" +#line 1005 "cs.ATG" out explicitInterface, false); -#line 1007 "cs.ATG" +#line 1006 "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" +#line 1009 "cs.ATG" qualident = t.val; } else SynErr(170); -#line 1012 "cs.ATG" +#line 1011 "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" +#line 1015 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( -#line 1018 "cs.ATG" +#line 1017 "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" +#line 1019 "cs.ATG" p); } Expect(21); -#line 1023 "cs.ATG" +#line 1021 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, @@ -2197,29 +2184,29 @@ p); methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; - methodDeclaration.IsExtensionMethod = isExtensionMethod; + methodDeclaration.IsExtensionMethod = p.Count > 0 && p[0].ParamModifier == ParameterModifiers.This; methodDeclaration.Templates = templates; AddChild(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1038 "cs.ATG" +#line 1036 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 1039 "cs.ATG" +#line 1037 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(171); -#line 1039 "cs.ATG" +#line 1037 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1042 "cs.ATG" +#line 1040 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); @@ -2230,11 +2217,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1051 "cs.ATG" +#line 1049 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1053 "cs.ATG" +#line 1051 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2243,17 +2230,17 @@ out getRegion, out setRegion); } } else if (la.kind == 15) { -#line 1061 "cs.ATG" +#line 1059 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(111); Expect(18); FormalParameterList( -#line 1062 "cs.ATG" +#line 1060 "cs.ATG" p); Expect(19); -#line 1063 "cs.ATG" +#line 1061 "cs.ATG" PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; @@ -2265,14 +2252,14 @@ p); Expect(16); -#line 1072 "cs.ATG" +#line 1070 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( -#line 1073 "cs.ATG" +#line 1071 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1074 "cs.ATG" +#line 1072 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2286,7 +2273,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1101 "cs.ATG" +#line 1099 "cs.ATG" TypeReference type; AttributeSection section; @@ -2301,49 +2288,49 @@ out getRegion, out setRegion); while (la.kind == 18) { AttributeSection( -#line 1114 "cs.ATG" +#line 1112 "cs.ATG" out section); -#line 1114 "cs.ATG" +#line 1112 "cs.ATG" attributes.Add(section); } if (la.kind == 89) { lexer.NextToken(); -#line 1115 "cs.ATG" +#line 1113 "cs.ATG" mod = Modifiers.New; startLocation = t.Location; } if ( -#line 1118 "cs.ATG" +#line 1116 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1118 "cs.ATG" +#line 1116 "cs.ATG" if (startLocation.IsEmpty) startLocation = t.Location; Identifier(); -#line 1119 "cs.ATG" +#line 1117 "cs.ATG" name = t.val; if (la.kind == 23) { TypeParameterList( -#line 1120 "cs.ATG" +#line 1118 "cs.ATG" templates); } Expect(20); if (StartOf(11)) { FormalParameterList( -#line 1121 "cs.ATG" +#line 1119 "cs.ATG" parameters); } Expect(21); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1122 "cs.ATG" +#line 1120 "cs.ATG" templates); } Expect(11); -#line 1124 "cs.ATG" +#line 1122 "cs.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true), Parameters = parameters, Attributes = attributes, Templates = templates, @@ -2354,37 +2341,37 @@ templates); } else if (StartOf(22)) { if (StartOf(10)) { Type( -#line 1132 "cs.ATG" +#line 1130 "cs.ATG" out type); -#line 1132 "cs.ATG" +#line 1130 "cs.ATG" if (startLocation.IsEmpty) startLocation = t.Location; if (StartOf(18)) { Identifier(); -#line 1134 "cs.ATG" +#line 1132 "cs.ATG" name = t.val; Location qualIdentEndLocation = t.EndLocation; if (la.kind == 20 || la.kind == 23) { if (la.kind == 23) { TypeParameterList( -#line 1138 "cs.ATG" +#line 1136 "cs.ATG" templates); } Expect(20); if (StartOf(11)) { FormalParameterList( -#line 1139 "cs.ATG" +#line 1137 "cs.ATG" parameters); } Expect(21); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1141 "cs.ATG" +#line 1139 "cs.ATG" templates); } Expect(11); -#line 1142 "cs.ATG" +#line 1140 "cs.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod, TypeReference = type, Parameters = parameters, Attributes = attributes, Templates = templates, @@ -2394,59 +2381,59 @@ templates); } else if (la.kind == 16) { -#line 1151 "cs.ATG" +#line 1149 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); AddChild(pd); lexer.NextToken(); -#line 1154 "cs.ATG" +#line 1152 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1155 "cs.ATG" +#line 1153 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1156 "cs.ATG" +#line 1154 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(175); } else if (la.kind == 111) { lexer.NextToken(); Expect(18); FormalParameterList( -#line 1159 "cs.ATG" +#line 1157 "cs.ATG" parameters); Expect(19); -#line 1160 "cs.ATG" +#line 1158 "cs.ATG" Location bracketEndLocation = t.EndLocation; -#line 1161 "cs.ATG" +#line 1159 "cs.ATG" PropertyDeclaration id = new PropertyDeclaration(mod | Modifiers.Default, attributes, "Item", parameters); id.TypeReference = type; AddChild(id); Expect(16); -#line 1164 "cs.ATG" +#line 1162 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1165 "cs.ATG" +#line 1163 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1167 "cs.ATG" +#line 1165 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(176); } else { lexer.NextToken(); -#line 1170 "cs.ATG" +#line 1168 "cs.ATG" if (startLocation.IsEmpty) startLocation = t.Location; Type( -#line 1171 "cs.ATG" +#line 1169 "cs.ATG" out type); Identifier(); -#line 1172 "cs.ATG" +#line 1170 "cs.ATG" EventDeclaration ed = new EventDeclaration { TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes }; @@ -2454,17 +2441,17 @@ out type); Expect(11); -#line 1178 "cs.ATG" +#line 1176 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(177); } void EnumMemberDecl( -#line 1183 "cs.ATG" +#line 1181 "cs.ATG" out FieldDeclaration f) { -#line 1185 "cs.ATG" +#line 1183 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2472,15 +2459,15 @@ out FieldDeclaration f) { while (la.kind == 18) { AttributeSection( -#line 1191 "cs.ATG" +#line 1189 "cs.ATG" out section); -#line 1191 "cs.ATG" +#line 1189 "cs.ATG" attributes.Add(section); } Identifier(); -#line 1192 "cs.ATG" +#line 1190 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2490,10 +2477,10 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1198 "cs.ATG" +#line 1196 "cs.ATG" out expr); -#line 1198 "cs.ATG" +#line 1196 "cs.ATG" varDecl.Initializer = expr; } } @@ -2606,14 +2593,14 @@ out name); } void NullableQuestionMark( -#line 2371 "cs.ATG" +#line 2369 "cs.ATG" ref TypeReference typeRef) { -#line 2372 "cs.ATG" +#line 2370 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2376 "cs.ATG" +#line 2374 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -2629,7 +2616,7 @@ out ParameterDeclarationExpression p) { Location start = la.Location; Expression expr; - if (la.kind == 93 || la.kind == 95 || la.kind == 100) { + if (StartOf(24)) { if (la.kind == 100) { lexer.NextToken(); @@ -2640,88 +2627,93 @@ out ParameterDeclarationExpression p) { #line 676 "cs.ATG" mod = ParameterModifiers.Out; - } else { + } else if (la.kind == 95) { lexer.NextToken(); #line 677 "cs.ATG" mod = ParameterModifiers.Params; + } else { + lexer.NextToken(); + +#line 678 "cs.ATG" + mod = ParameterModifiers.This; } } Type( -#line 679 "cs.ATG" +#line 680 "cs.ATG" out type); Identifier(); -#line 680 "cs.ATG" +#line 681 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 681 "cs.ATG" +#line 682 "cs.ATG" out expr); -#line 681 "cs.ATG" +#line 682 "cs.ATG" p.DefaultValue = expr; p.ParamModifier |= ParameterModifiers.Optional; } -#line 682 "cs.ATG" +#line 683 "cs.ATG" p.StartLocation = start; p.EndLocation = t.EndLocation; } void AccessorModifiers( -#line 685 "cs.ATG" +#line 686 "cs.ATG" out ModifierList m) { -#line 686 "cs.ATG" +#line 687 "cs.ATG" m = new ModifierList(); if (la.kind == 96) { lexer.NextToken(); -#line 688 "cs.ATG" +#line 689 "cs.ATG" m.Add(Modifiers.Private, t.Location); } else if (la.kind == 97) { lexer.NextToken(); -#line 689 "cs.ATG" +#line 690 "cs.ATG" m.Add(Modifiers.Protected, t.Location); if (la.kind == 84) { lexer.NextToken(); -#line 690 "cs.ATG" +#line 691 "cs.ATG" m.Add(Modifiers.Internal, t.Location); } } else if (la.kind == 84) { lexer.NextToken(); -#line 691 "cs.ATG" +#line 692 "cs.ATG" m.Add(Modifiers.Internal, t.Location); if (la.kind == 97) { lexer.NextToken(); -#line 692 "cs.ATG" +#line 693 "cs.ATG" m.Add(Modifiers.Protected, t.Location); } } else SynErr(181); } void Block( -#line 1318 "cs.ATG" +#line 1316 "cs.ATG" out BlockStatement stmt) { Expect(16); -#line 1320 "cs.ATG" +#line 1318 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.Location; BlockStart(blockStmt); if (!ParseMethodBodies) lexer.SkipCurrentBlock(0); - while (StartOf(24)) { + while (StartOf(25)) { Statement(); } while (!(la.kind == 0 || la.kind == 17)) {SynErr(182); lexer.NextToken(); } Expect(17); -#line 1328 "cs.ATG" +#line 1326 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; BlockEnd(); @@ -2729,10 +2721,10 @@ out BlockStatement stmt) { } void EventAccessorDecls( -#line 1255 "cs.ATG" +#line 1253 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1256 "cs.ATG" +#line 1254 "cs.ATG" AttributeSection section; List attributes = new List(); BlockStatement stmt; @@ -2741,93 +2733,93 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 18) { AttributeSection( -#line 1263 "cs.ATG" +#line 1261 "cs.ATG" out section); -#line 1263 "cs.ATG" +#line 1261 "cs.ATG" attributes.Add(section); } if (la.kind == 130) { -#line 1265 "cs.ATG" +#line 1263 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1266 "cs.ATG" +#line 1264 "cs.ATG" out stmt); -#line 1266 "cs.ATG" +#line 1264 "cs.ATG" attributes = new List(); addBlock.Block = stmt; while (la.kind == 18) { AttributeSection( -#line 1267 "cs.ATG" +#line 1265 "cs.ATG" out section); -#line 1267 "cs.ATG" +#line 1265 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1268 "cs.ATG" +#line 1266 "cs.ATG" out stmt); -#line 1268 "cs.ATG" +#line 1266 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = stmt; } else if (la.kind == 131) { RemoveAccessorDecl( -#line 1270 "cs.ATG" +#line 1268 "cs.ATG" out stmt); -#line 1270 "cs.ATG" +#line 1268 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = stmt; attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1271 "cs.ATG" +#line 1269 "cs.ATG" out section); -#line 1271 "cs.ATG" +#line 1269 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1272 "cs.ATG" +#line 1270 "cs.ATG" out stmt); -#line 1272 "cs.ATG" +#line 1270 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = stmt; } else SynErr(183); } void ConstructorInitializer( -#line 1348 "cs.ATG" +#line 1346 "cs.ATG" out ConstructorInitializer ci) { -#line 1349 "cs.ATG" +#line 1347 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 51) { lexer.NextToken(); -#line 1353 "cs.ATG" +#line 1351 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 111) { lexer.NextToken(); -#line 1354 "cs.ATG" +#line 1352 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(184); Expect(20); - if (StartOf(25)) { + if (StartOf(26)) { Argument( -#line 1357 "cs.ATG" +#line 1355 "cs.ATG" out expr); -#line 1357 "cs.ATG" +#line 1355 "cs.ATG" SafeAdd(ci, ci.Arguments, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1358 "cs.ATG" +#line 1356 "cs.ATG" out expr); -#line 1358 "cs.ATG" +#line 1356 "cs.ATG" SafeAdd(ci, ci.Arguments, expr); } } @@ -2835,161 +2827,161 @@ out expr); } void OverloadableOperator( -#line 1371 "cs.ATG" +#line 1369 "cs.ATG" out OverloadableOperatorType op) { -#line 1372 "cs.ATG" +#line 1370 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1374 "cs.ATG" +#line 1372 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1375 "cs.ATG" +#line 1373 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 24: { lexer.NextToken(); -#line 1377 "cs.ATG" +#line 1375 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 27: { lexer.NextToken(); -#line 1378 "cs.ATG" +#line 1376 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 31: { lexer.NextToken(); -#line 1380 "cs.ATG" +#line 1378 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 32: { lexer.NextToken(); -#line 1381 "cs.ATG" +#line 1379 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 113: { lexer.NextToken(); -#line 1383 "cs.ATG" +#line 1381 "cs.ATG" op = OverloadableOperatorType.IsTrue; break; } case 72: { lexer.NextToken(); -#line 1384 "cs.ATG" +#line 1382 "cs.ATG" op = OverloadableOperatorType.IsFalse; break; } case 6: { lexer.NextToken(); -#line 1386 "cs.ATG" +#line 1384 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1387 "cs.ATG" +#line 1385 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1388 "cs.ATG" +#line 1386 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 28: { lexer.NextToken(); -#line 1390 "cs.ATG" +#line 1388 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 29: { lexer.NextToken(); -#line 1391 "cs.ATG" +#line 1389 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 30: { lexer.NextToken(); -#line 1392 "cs.ATG" +#line 1390 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 37: { lexer.NextToken(); -#line 1394 "cs.ATG" +#line 1392 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1395 "cs.ATG" +#line 1393 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 34: { lexer.NextToken(); -#line 1396 "cs.ATG" +#line 1394 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 23: { lexer.NextToken(); -#line 1397 "cs.ATG" +#line 1395 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 35: { lexer.NextToken(); -#line 1398 "cs.ATG" +#line 1396 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 36: { lexer.NextToken(); -#line 1399 "cs.ATG" +#line 1397 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 22: { lexer.NextToken(); -#line 1400 "cs.ATG" +#line 1398 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 22) { lexer.NextToken(); -#line 1400 "cs.ATG" +#line 1398 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2999,34 +2991,34 @@ out OverloadableOperatorType op) { } void VariableDeclarator( -#line 1310 "cs.ATG" +#line 1308 "cs.ATG" FieldDeclaration parentFieldDeclaration) { -#line 1311 "cs.ATG" +#line 1309 "cs.ATG" Expression expr = null; Identifier(); -#line 1313 "cs.ATG" +#line 1311 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); f.StartLocation = t.Location; if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1314 "cs.ATG" +#line 1312 "cs.ATG" out expr); -#line 1314 "cs.ATG" +#line 1312 "cs.ATG" f.Initializer = expr; } -#line 1315 "cs.ATG" +#line 1313 "cs.ATG" f.EndLocation = t.EndLocation; SafeAdd(parentFieldDeclaration, parentFieldDeclaration.Fields, f); } void AccessorDecls( -#line 1202 "cs.ATG" +#line 1200 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1204 "cs.ATG" +#line 1202 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -3035,92 +3027,92 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1211 "cs.ATG" +#line 1209 "cs.ATG" out section); -#line 1211 "cs.ATG" +#line 1209 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1212 "cs.ATG" +#line 1210 "cs.ATG" out modifiers); } if (la.kind == 128) { GetAccessorDecl( -#line 1214 "cs.ATG" +#line 1212 "cs.ATG" out getBlock, attributes); -#line 1215 "cs.ATG" +#line 1213 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } - if (StartOf(26)) { + if (StartOf(27)) { -#line 1216 "cs.ATG" +#line 1214 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1217 "cs.ATG" +#line 1215 "cs.ATG" out section); -#line 1217 "cs.ATG" +#line 1215 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1218 "cs.ATG" +#line 1216 "cs.ATG" out modifiers); } SetAccessorDecl( -#line 1219 "cs.ATG" +#line 1217 "cs.ATG" out setBlock, attributes); -#line 1220 "cs.ATG" +#line 1218 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } } } else if (la.kind == 129) { SetAccessorDecl( -#line 1223 "cs.ATG" +#line 1221 "cs.ATG" out setBlock, attributes); -#line 1224 "cs.ATG" +#line 1222 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } - if (StartOf(27)) { + if (StartOf(28)) { -#line 1225 "cs.ATG" +#line 1223 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1226 "cs.ATG" +#line 1224 "cs.ATG" out section); -#line 1226 "cs.ATG" +#line 1224 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1227 "cs.ATG" +#line 1225 "cs.ATG" out modifiers); } GetAccessorDecl( -#line 1228 "cs.ATG" +#line 1226 "cs.ATG" out getBlock, attributes); -#line 1229 "cs.ATG" +#line 1227 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } } } else if (StartOf(18)) { Identifier(); -#line 1231 "cs.ATG" +#line 1229 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(186); } void InterfaceAccessors( -#line 1276 "cs.ATG" +#line 1274 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1278 "cs.ATG" +#line 1276 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; @@ -3128,218 +3120,218 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1284 "cs.ATG" +#line 1282 "cs.ATG" out section); -#line 1284 "cs.ATG" +#line 1282 "cs.ATG" attributes.Add(section); } -#line 1285 "cs.ATG" +#line 1283 "cs.ATG" Location startLocation = la.Location; if (la.kind == 128) { lexer.NextToken(); -#line 1287 "cs.ATG" +#line 1285 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if (la.kind == 129) { lexer.NextToken(); -#line 1288 "cs.ATG" +#line 1286 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else SynErr(187); Expect(11); -#line 1291 "cs.ATG" +#line 1289 "cs.ATG" if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } attributes = new List(); if (la.kind == 18 || la.kind == 128 || la.kind == 129) { while (la.kind == 18) { AttributeSection( -#line 1295 "cs.ATG" +#line 1293 "cs.ATG" out section); -#line 1295 "cs.ATG" +#line 1293 "cs.ATG" attributes.Add(section); } -#line 1296 "cs.ATG" +#line 1294 "cs.ATG" startLocation = la.Location; if (la.kind == 128) { lexer.NextToken(); -#line 1298 "cs.ATG" +#line 1296 "cs.ATG" if (getBlock != null) Error("get already declared"); else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } } else if (la.kind == 129) { lexer.NextToken(); -#line 1301 "cs.ATG" +#line 1299 "cs.ATG" if (setBlock != null) Error("set already declared"); else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } } else SynErr(188); Expect(11); -#line 1306 "cs.ATG" +#line 1304 "cs.ATG" if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } } } void GetAccessorDecl( -#line 1235 "cs.ATG" +#line 1233 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1236 "cs.ATG" +#line 1234 "cs.ATG" BlockStatement stmt = null; Expect(128); -#line 1239 "cs.ATG" +#line 1237 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1240 "cs.ATG" +#line 1238 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(189); -#line 1241 "cs.ATG" +#line 1239 "cs.ATG" getBlock = new PropertyGetRegion(stmt, attributes); -#line 1242 "cs.ATG" +#line 1240 "cs.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } void SetAccessorDecl( -#line 1245 "cs.ATG" +#line 1243 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1246 "cs.ATG" +#line 1244 "cs.ATG" BlockStatement stmt = null; Expect(129); -#line 1249 "cs.ATG" +#line 1247 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1250 "cs.ATG" +#line 1248 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(190); -#line 1251 "cs.ATG" +#line 1249 "cs.ATG" setBlock = new PropertySetRegion(stmt, attributes); -#line 1252 "cs.ATG" +#line 1250 "cs.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } void AddAccessorDecl( -#line 1334 "cs.ATG" +#line 1332 "cs.ATG" out BlockStatement stmt) { -#line 1335 "cs.ATG" +#line 1333 "cs.ATG" stmt = null; Expect(130); Block( -#line 1338 "cs.ATG" +#line 1336 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1341 "cs.ATG" +#line 1339 "cs.ATG" out BlockStatement stmt) { -#line 1342 "cs.ATG" +#line 1340 "cs.ATG" stmt = null; Expect(131); Block( -#line 1345 "cs.ATG" +#line 1343 "cs.ATG" out stmt); } void VariableInitializer( -#line 1363 "cs.ATG" +#line 1361 "cs.ATG" out Expression initializerExpression) { -#line 1364 "cs.ATG" +#line 1362 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(6)) { Expr( -#line 1366 "cs.ATG" +#line 1364 "cs.ATG" out initializerExpression); } else if (la.kind == 16) { CollectionInitializer( -#line 1367 "cs.ATG" +#line 1365 "cs.ATG" out initializerExpression); } else if (la.kind == 106) { lexer.NextToken(); Type( -#line 1368 "cs.ATG" +#line 1366 "cs.ATG" out type); Expect(18); Expr( -#line 1368 "cs.ATG" +#line 1366 "cs.ATG" out expr); Expect(19); -#line 1368 "cs.ATG" +#line 1366 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(191); } void Statement() { -#line 1525 "cs.ATG" +#line 1523 "cs.ATG" Statement stmt = null; Location startPos = la.Location; - while (!(StartOf(28))) {SynErr(192); lexer.NextToken(); } + while (!(StartOf(29))) {SynErr(192); lexer.NextToken(); } if ( -#line 1532 "cs.ATG" +#line 1530 "cs.ATG" IsLabel()) { Identifier(); -#line 1532 "cs.ATG" +#line 1530 "cs.ATG" AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 60) { lexer.NextToken(); LocalVariableDecl( -#line 1536 "cs.ATG" +#line 1534 "cs.ATG" out stmt); -#line 1537 "cs.ATG" +#line 1535 "cs.ATG" if (stmt != null) { ((LocalVariableDeclaration)stmt).Modifier |= Modifiers.Const; } Expect(11); -#line 1538 "cs.ATG" +#line 1536 "cs.ATG" AddChild(stmt); } else if ( -#line 1540 "cs.ATG" +#line 1538 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1540 "cs.ATG" +#line 1538 "cs.ATG" out stmt); Expect(11); -#line 1540 "cs.ATG" +#line 1538 "cs.ATG" AddChild(stmt); - } else if (StartOf(29)) { + } else if (StartOf(30)) { EmbeddedStatement( -#line 1542 "cs.ATG" +#line 1540 "cs.ATG" out stmt); -#line 1542 "cs.ATG" +#line 1540 "cs.ATG" AddChild(stmt); } else SynErr(193); -#line 1548 "cs.ATG" +#line 1546 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3348,63 +3340,63 @@ out stmt); } void Argument( -#line 1403 "cs.ATG" +#line 1401 "cs.ATG" out Expression argumentexpr) { -#line 1404 "cs.ATG" +#line 1402 "cs.ATG" argumentexpr = null; if ( -#line 1406 "cs.ATG" +#line 1404 "cs.ATG" IdentAndColon()) { -#line 1407 "cs.ATG" +#line 1405 "cs.ATG" Token ident; Expression expr; Identifier(); -#line 1408 "cs.ATG" +#line 1406 "cs.ATG" ident = t; Expect(9); ArgumentValue( -#line 1410 "cs.ATG" +#line 1408 "cs.ATG" out expr); -#line 1411 "cs.ATG" +#line 1409 "cs.ATG" argumentexpr = new NamedArgumentExpression(ident.val, expr) { StartLocation = ident.Location, EndLocation = t.EndLocation }; - } else if (StartOf(25)) { + } else if (StartOf(26)) { ArgumentValue( -#line 1413 "cs.ATG" +#line 1411 "cs.ATG" out argumentexpr); } else SynErr(194); } void CollectionInitializer( -#line 1447 "cs.ATG" +#line 1445 "cs.ATG" out Expression outExpr) { -#line 1449 "cs.ATG" +#line 1447 "cs.ATG" Expression expr = null; CollectionInitializerExpression initializer = new CollectionInitializerExpression(); Expect(16); -#line 1453 "cs.ATG" +#line 1451 "cs.ATG" initializer.StartLocation = t.Location; - if (StartOf(30)) { + if (StartOf(31)) { VariableInitializer( -#line 1454 "cs.ATG" +#line 1452 "cs.ATG" out expr); -#line 1455 "cs.ATG" +#line 1453 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); while ( -#line 1456 "cs.ATG" +#line 1454 "cs.ATG" NotFinalComma()) { Expect(14); VariableInitializer( -#line 1457 "cs.ATG" +#line 1455 "cs.ATG" out expr); -#line 1458 "cs.ATG" +#line 1456 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); } if (la.kind == 14) { @@ -3413,15 +3405,15 @@ out expr); } Expect(17); -#line 1462 "cs.ATG" +#line 1460 "cs.ATG" initializer.EndLocation = t.Location; outExpr = initializer; } void ArgumentValue( -#line 1416 "cs.ATG" +#line 1414 "cs.ATG" out Expression argumentexpr) { -#line 1418 "cs.ATG" +#line 1416 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3429,118 +3421,118 @@ out Expression argumentexpr) { if (la.kind == 100) { lexer.NextToken(); -#line 1423 "cs.ATG" +#line 1421 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1424 "cs.ATG" +#line 1422 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1426 "cs.ATG" +#line 1424 "cs.ATG" out expr); -#line 1427 "cs.ATG" +#line 1425 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void AssignmentOperator( -#line 1430 "cs.ATG" +#line 1428 "cs.ATG" out AssignmentOperatorType op) { -#line 1431 "cs.ATG" +#line 1429 "cs.ATG" op = AssignmentOperatorType.None; if (la.kind == 3) { lexer.NextToken(); -#line 1433 "cs.ATG" +#line 1431 "cs.ATG" op = AssignmentOperatorType.Assign; } else if (la.kind == 38) { lexer.NextToken(); -#line 1434 "cs.ATG" +#line 1432 "cs.ATG" op = AssignmentOperatorType.Add; } else if (la.kind == 39) { lexer.NextToken(); -#line 1435 "cs.ATG" +#line 1433 "cs.ATG" op = AssignmentOperatorType.Subtract; } else if (la.kind == 40) { lexer.NextToken(); -#line 1436 "cs.ATG" +#line 1434 "cs.ATG" op = AssignmentOperatorType.Multiply; } else if (la.kind == 41) { lexer.NextToken(); -#line 1437 "cs.ATG" +#line 1435 "cs.ATG" op = AssignmentOperatorType.Divide; } else if (la.kind == 42) { lexer.NextToken(); -#line 1438 "cs.ATG" +#line 1436 "cs.ATG" op = AssignmentOperatorType.Modulus; } else if (la.kind == 43) { lexer.NextToken(); -#line 1439 "cs.ATG" +#line 1437 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; } else if (la.kind == 44) { lexer.NextToken(); -#line 1440 "cs.ATG" +#line 1438 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; } else if (la.kind == 45) { lexer.NextToken(); -#line 1441 "cs.ATG" +#line 1439 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; } else if (la.kind == 46) { lexer.NextToken(); -#line 1442 "cs.ATG" +#line 1440 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; } else if ( -#line 1443 "cs.ATG" +#line 1441 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { Expect(22); Expect(35); -#line 1444 "cs.ATG" +#line 1442 "cs.ATG" op = AssignmentOperatorType.ShiftRight; } else SynErr(195); } void CollectionOrObjectInitializer( -#line 1465 "cs.ATG" +#line 1463 "cs.ATG" out Expression outExpr) { -#line 1467 "cs.ATG" +#line 1465 "cs.ATG" Expression expr = null; CollectionInitializerExpression initializer = new CollectionInitializerExpression(); Expect(16); -#line 1471 "cs.ATG" +#line 1469 "cs.ATG" initializer.StartLocation = t.Location; - if (StartOf(30)) { + if (StartOf(31)) { ObjectPropertyInitializerOrVariableInitializer( -#line 1472 "cs.ATG" +#line 1470 "cs.ATG" out expr); -#line 1473 "cs.ATG" +#line 1471 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); while ( -#line 1474 "cs.ATG" +#line 1472 "cs.ATG" NotFinalComma()) { Expect(14); ObjectPropertyInitializerOrVariableInitializer( -#line 1475 "cs.ATG" +#line 1473 "cs.ATG" out expr); -#line 1476 "cs.ATG" +#line 1474 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); } if (la.kind == 14) { @@ -3549,22 +3541,22 @@ out expr); } Expect(17); -#line 1480 "cs.ATG" +#line 1478 "cs.ATG" initializer.EndLocation = t.Location; outExpr = initializer; } void ObjectPropertyInitializerOrVariableInitializer( -#line 1483 "cs.ATG" +#line 1481 "cs.ATG" out Expression expr) { -#line 1484 "cs.ATG" +#line 1482 "cs.ATG" expr = null; if ( -#line 1486 "cs.ATG" +#line 1484 "cs.ATG" IdentAndAsgn()) { Identifier(); -#line 1488 "cs.ATG" +#line 1486 "cs.ATG" MemberInitializerExpression mie = new MemberInitializerExpression(t.val, null); mie.StartLocation = t.Location; mie.IsKey = true; @@ -3572,88 +3564,88 @@ IdentAndAsgn()) { Expect(3); if (la.kind == 16) { CollectionOrObjectInitializer( -#line 1493 "cs.ATG" +#line 1491 "cs.ATG" out r); - } else if (StartOf(30)) { + } else if (StartOf(31)) { VariableInitializer( -#line 1494 "cs.ATG" +#line 1492 "cs.ATG" out r); } else SynErr(196); -#line 1495 "cs.ATG" +#line 1493 "cs.ATG" mie.Expression = r; mie.EndLocation = t.EndLocation; expr = mie; - } else if (StartOf(30)) { + } else if (StartOf(31)) { VariableInitializer( -#line 1497 "cs.ATG" +#line 1495 "cs.ATG" out expr); } else SynErr(197); } void LocalVariableDecl( -#line 1501 "cs.ATG" +#line 1499 "cs.ATG" out Statement stmt) { -#line 1503 "cs.ATG" +#line 1501 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Location startPos = la.Location; Type( -#line 1509 "cs.ATG" +#line 1507 "cs.ATG" out type); -#line 1509 "cs.ATG" +#line 1507 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = startPos; LocalVariableDeclarator( -#line 1510 "cs.ATG" +#line 1508 "cs.ATG" out var); -#line 1510 "cs.ATG" +#line 1508 "cs.ATG" SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); while (la.kind == 14) { lexer.NextToken(); LocalVariableDeclarator( -#line 1511 "cs.ATG" +#line 1509 "cs.ATG" out var); -#line 1511 "cs.ATG" +#line 1509 "cs.ATG" SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); } -#line 1512 "cs.ATG" +#line 1510 "cs.ATG" stmt = localVariableDeclaration; stmt.EndLocation = t.EndLocation; } void LocalVariableDeclarator( -#line 1515 "cs.ATG" +#line 1513 "cs.ATG" out VariableDeclaration var) { -#line 1516 "cs.ATG" +#line 1514 "cs.ATG" Expression expr = null; Identifier(); -#line 1518 "cs.ATG" +#line 1516 "cs.ATG" var = new VariableDeclaration(t.val); var.StartLocation = t.Location; if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1519 "cs.ATG" +#line 1517 "cs.ATG" out expr); -#line 1519 "cs.ATG" +#line 1517 "cs.ATG" var.Initializer = expr; } -#line 1520 "cs.ATG" +#line 1518 "cs.ATG" var.EndLocation = t.EndLocation; } void EmbeddedStatement( -#line 1555 "cs.ATG" +#line 1553 "cs.ATG" out Statement statement) { -#line 1557 "cs.ATG" +#line 1555 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3661,173 +3653,173 @@ out Statement statement) { statement = null; -#line 1564 "cs.ATG" +#line 1562 "cs.ATG" Location startLocation = la.Location; if (la.kind == 16) { Block( -#line 1566 "cs.ATG" +#line 1564 "cs.ATG" out block); -#line 1566 "cs.ATG" +#line 1564 "cs.ATG" statement = block; } else if (la.kind == 11) { lexer.NextToken(); -#line 1569 "cs.ATG" +#line 1567 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1572 "cs.ATG" +#line 1570 "cs.ATG" UnCheckedAndLBrace()) { -#line 1572 "cs.ATG" +#line 1570 "cs.ATG" bool isChecked = true; if (la.kind == 58) { lexer.NextToken(); } else if (la.kind == 118) { lexer.NextToken(); -#line 1573 "cs.ATG" +#line 1571 "cs.ATG" isChecked = false; } else SynErr(198); Block( -#line 1574 "cs.ATG" +#line 1572 "cs.ATG" out block); -#line 1574 "cs.ATG" +#line 1572 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 79) { IfStatement( -#line 1577 "cs.ATG" +#line 1575 "cs.ATG" out statement); } else if (la.kind == 110) { lexer.NextToken(); -#line 1579 "cs.ATG" +#line 1577 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1580 "cs.ATG" +#line 1578 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1581 "cs.ATG" +#line 1579 "cs.ATG" switchSections); Expect(17); -#line 1583 "cs.ATG" +#line 1581 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 125) { lexer.NextToken(); Expect(20); Expr( -#line 1586 "cs.ATG" +#line 1584 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1587 "cs.ATG" +#line 1585 "cs.ATG" out embeddedStatement); -#line 1588 "cs.ATG" +#line 1586 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1590 "cs.ATG" +#line 1588 "cs.ATG" out embeddedStatement); Expect(125); Expect(20); Expr( -#line 1591 "cs.ATG" +#line 1589 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1592 "cs.ATG" +#line 1590 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 76) { lexer.NextToken(); -#line 1594 "cs.ATG" +#line 1592 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(6)) { ForInitializer( -#line 1595 "cs.ATG" +#line 1593 "cs.ATG" out initializer); } Expect(11); if (StartOf(6)) { Expr( -#line 1596 "cs.ATG" +#line 1594 "cs.ATG" out expr); } Expect(11); if (StartOf(6)) { ForIterator( -#line 1597 "cs.ATG" +#line 1595 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1598 "cs.ATG" +#line 1596 "cs.ATG" out embeddedStatement); -#line 1599 "cs.ATG" +#line 1597 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 77) { lexer.NextToken(); Expect(20); Type( -#line 1601 "cs.ATG" +#line 1599 "cs.ATG" out type); Identifier(); -#line 1601 "cs.ATG" +#line 1599 "cs.ATG" string varName = t.val; Expect(81); Expr( -#line 1602 "cs.ATG" +#line 1600 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1603 "cs.ATG" +#line 1601 "cs.ATG" out embeddedStatement); -#line 1604 "cs.ATG" +#line 1602 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); } else if (la.kind == 53) { lexer.NextToken(); Expect(11); -#line 1607 "cs.ATG" +#line 1605 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1608 "cs.ATG" +#line 1606 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 78) { GotoStatement( -#line 1609 "cs.ATG" +#line 1607 "cs.ATG" out statement); } else if ( -#line 1611 "cs.ATG" +#line 1609 "cs.ATG" IsYieldStatement()) { Expect(132); if (la.kind == 101) { lexer.NextToken(); Expr( -#line 1612 "cs.ATG" +#line 1610 "cs.ATG" out expr); -#line 1612 "cs.ATG" +#line 1610 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 53) { lexer.NextToken(); -#line 1613 "cs.ATG" +#line 1611 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(199); Expect(11); @@ -3835,90 +3827,90 @@ out expr); lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1616 "cs.ATG" +#line 1614 "cs.ATG" out expr); } Expect(11); -#line 1616 "cs.ATG" +#line 1614 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 112) { lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1617 "cs.ATG" +#line 1615 "cs.ATG" out expr); } Expect(11); -#line 1617 "cs.ATG" +#line 1615 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(6)) { StatementExpr( -#line 1620 "cs.ATG" +#line 1618 "cs.ATG" out statement); while (!(la.kind == 0 || la.kind == 11)) {SynErr(200); lexer.NextToken(); } Expect(11); } else if (la.kind == 114) { TryStatement( -#line 1623 "cs.ATG" +#line 1621 "cs.ATG" out statement); } else if (la.kind == 86) { lexer.NextToken(); Expect(20); Expr( -#line 1626 "cs.ATG" +#line 1624 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1627 "cs.ATG" +#line 1625 "cs.ATG" out embeddedStatement); -#line 1627 "cs.ATG" +#line 1625 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 121) { -#line 1630 "cs.ATG" +#line 1628 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1632 "cs.ATG" +#line 1630 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1633 "cs.ATG" +#line 1631 "cs.ATG" out embeddedStatement); -#line 1633 "cs.ATG" +#line 1631 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 119) { lexer.NextToken(); Block( -#line 1636 "cs.ATG" +#line 1634 "cs.ATG" out block); -#line 1636 "cs.ATG" +#line 1634 "cs.ATG" statement = new UnsafeStatement(block); } else if (la.kind == 74) { -#line 1638 "cs.ATG" +#line 1636 "cs.ATG" Statement pointerDeclarationStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1640 "cs.ATG" +#line 1638 "cs.ATG" out pointerDeclarationStmt); Expect(21); EmbeddedStatement( -#line 1641 "cs.ATG" +#line 1639 "cs.ATG" out embeddedStatement); -#line 1641 "cs.ATG" +#line 1639 "cs.ATG" statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); } else SynErr(201); -#line 1643 "cs.ATG" +#line 1641 "cs.ATG" if (statement != null) { statement.StartLocation = startLocation; statement.EndLocation = t.EndLocation; @@ -3927,10 +3919,10 @@ out embeddedStatement); } void IfStatement( -#line 1650 "cs.ATG" +#line 1648 "cs.ATG" out Statement statement) { -#line 1652 "cs.ATG" +#line 1650 "cs.ATG" Expression expr = null; Statement embeddedStatement = null; statement = null; @@ -3938,26 +3930,26 @@ out Statement statement) { Expect(79); Expect(20); Expr( -#line 1658 "cs.ATG" +#line 1656 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1659 "cs.ATG" +#line 1657 "cs.ATG" out embeddedStatement); -#line 1660 "cs.ATG" +#line 1658 "cs.ATG" Statement elseStatement = null; if (la.kind == 67) { lexer.NextToken(); EmbeddedStatement( -#line 1661 "cs.ATG" +#line 1659 "cs.ATG" out elseStatement); } -#line 1662 "cs.ATG" +#line 1660 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1663 "cs.ATG" +#line 1661 "cs.ATG" if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { /* else if-section (otherwise we would have a BlockStatment) */ (statement as IfElseStatement).ElseIfSections.Add( @@ -3970,29 +3962,29 @@ out elseStatement); } void SwitchSections( -#line 1693 "cs.ATG" +#line 1691 "cs.ATG" List switchSections) { -#line 1695 "cs.ATG" +#line 1693 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1699 "cs.ATG" +#line 1697 "cs.ATG" out label); -#line 1699 "cs.ATG" +#line 1697 "cs.ATG" SafeAdd(switchSection, switchSection.SwitchLabels, label); -#line 1700 "cs.ATG" +#line 1698 "cs.ATG" BlockStart(switchSection); - while (StartOf(31)) { + while (StartOf(32)) { if (la.kind == 55 || la.kind == 63) { SwitchLabel( -#line 1702 "cs.ATG" +#line 1700 "cs.ATG" out label); -#line 1703 "cs.ATG" +#line 1701 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -4008,145 +4000,145 @@ out label); } } -#line 1715 "cs.ATG" +#line 1713 "cs.ATG" BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1674 "cs.ATG" +#line 1672 "cs.ATG" out List initializer) { -#line 1676 "cs.ATG" +#line 1674 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1680 "cs.ATG" +#line 1678 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1680 "cs.ATG" +#line 1678 "cs.ATG" out stmt); -#line 1680 "cs.ATG" +#line 1678 "cs.ATG" initializer.Add(stmt); } else if (StartOf(6)) { StatementExpr( -#line 1681 "cs.ATG" +#line 1679 "cs.ATG" out stmt); -#line 1681 "cs.ATG" +#line 1679 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1681 "cs.ATG" +#line 1679 "cs.ATG" out stmt); -#line 1681 "cs.ATG" +#line 1679 "cs.ATG" initializer.Add(stmt); } } else SynErr(202); } void ForIterator( -#line 1684 "cs.ATG" +#line 1682 "cs.ATG" out List iterator) { -#line 1686 "cs.ATG" +#line 1684 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1690 "cs.ATG" +#line 1688 "cs.ATG" out stmt); -#line 1690 "cs.ATG" +#line 1688 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1690 "cs.ATG" +#line 1688 "cs.ATG" out stmt); -#line 1690 "cs.ATG" +#line 1688 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1772 "cs.ATG" +#line 1770 "cs.ATG" out Statement stmt) { -#line 1773 "cs.ATG" +#line 1771 "cs.ATG" Expression expr; stmt = null; Expect(78); if (StartOf(18)) { Identifier(); -#line 1777 "cs.ATG" +#line 1775 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1778 "cs.ATG" +#line 1776 "cs.ATG" out expr); Expect(11); -#line 1778 "cs.ATG" +#line 1776 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(11); -#line 1779 "cs.ATG" +#line 1777 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(203); } void StatementExpr( -#line 1799 "cs.ATG" +#line 1797 "cs.ATG" out Statement stmt) { -#line 1800 "cs.ATG" +#line 1798 "cs.ATG" Expression expr; Expr( -#line 1802 "cs.ATG" +#line 1800 "cs.ATG" out expr); -#line 1805 "cs.ATG" +#line 1803 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1725 "cs.ATG" +#line 1723 "cs.ATG" out Statement tryStatement) { -#line 1727 "cs.ATG" +#line 1725 "cs.ATG" BlockStatement blockStmt = null, finallyStmt = null; CatchClause catchClause = null; List catchClauses = new List(); Expect(114); Block( -#line 1732 "cs.ATG" +#line 1730 "cs.ATG" out blockStmt); while (la.kind == 56) { CatchClause( -#line 1734 "cs.ATG" +#line 1732 "cs.ATG" out catchClause); -#line 1735 "cs.ATG" +#line 1733 "cs.ATG" if (catchClause != null) catchClauses.Add(catchClause); } if (la.kind == 73) { lexer.NextToken(); Block( -#line 1737 "cs.ATG" +#line 1735 "cs.ATG" out finallyStmt); } -#line 1739 "cs.ATG" +#line 1737 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); if (catchClauses != null) { foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; @@ -4155,59 +4147,59 @@ out finallyStmt); } void ResourceAcquisition( -#line 1783 "cs.ATG" +#line 1781 "cs.ATG" out Statement stmt) { -#line 1785 "cs.ATG" +#line 1783 "cs.ATG" stmt = null; Expression expr; if ( -#line 1790 "cs.ATG" +#line 1788 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1790 "cs.ATG" +#line 1788 "cs.ATG" out stmt); } else if (StartOf(6)) { Expr( -#line 1791 "cs.ATG" +#line 1789 "cs.ATG" out expr); -#line 1795 "cs.ATG" +#line 1793 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(204); } void SwitchLabel( -#line 1718 "cs.ATG" +#line 1716 "cs.ATG" out CaseLabel label) { -#line 1719 "cs.ATG" +#line 1717 "cs.ATG" Expression expr = null; label = null; if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1721 "cs.ATG" +#line 1719 "cs.ATG" out expr); Expect(9); -#line 1721 "cs.ATG" +#line 1719 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(9); -#line 1722 "cs.ATG" +#line 1720 "cs.ATG" label = new CaseLabel(); } else SynErr(205); } void CatchClause( -#line 1746 "cs.ATG" +#line 1744 "cs.ATG" out CatchClause catchClause) { Expect(56); -#line 1748 "cs.ATG" +#line 1746 "cs.ATG" string identifier; BlockStatement stmt; TypeReference typeRef; @@ -4216,35 +4208,35 @@ out CatchClause catchClause) { if (la.kind == 16) { Block( -#line 1756 "cs.ATG" +#line 1754 "cs.ATG" out stmt); -#line 1756 "cs.ATG" +#line 1754 "cs.ATG" catchClause = new CatchClause(stmt); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1759 "cs.ATG" +#line 1757 "cs.ATG" out typeRef, false); -#line 1759 "cs.ATG" +#line 1757 "cs.ATG" identifier = null; if (StartOf(18)) { Identifier(); -#line 1760 "cs.ATG" +#line 1758 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1761 "cs.ATG" +#line 1759 "cs.ATG" out stmt); -#line 1762 "cs.ATG" +#line 1760 "cs.ATG" catchClause = new CatchClause(typeRef, identifier, stmt); } else SynErr(206); -#line 1765 "cs.ATG" +#line 1763 "cs.ATG" if (catchClause != null) { catchClause.StartLocation = startPos; catchClause.EndLocation = t.Location; @@ -4253,80 +4245,80 @@ out stmt); } void UnaryExpr( -#line 1834 "cs.ATG" +#line 1832 "cs.ATG" out Expression uExpr) { -#line 1836 "cs.ATG" +#line 1834 "cs.ATG" TypeReference type = null; Expression expr = null; ArrayList expressions = new ArrayList(); uExpr = null; - while (StartOf(32) || -#line 1859 "cs.ATG" + while (StartOf(33) || +#line 1857 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1845 "cs.ATG" +#line 1843 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus) { StartLocation = t.Location }); } else if (la.kind == 5) { lexer.NextToken(); -#line 1846 "cs.ATG" +#line 1844 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus) { StartLocation = t.Location }); } else if (la.kind == 24) { lexer.NextToken(); -#line 1847 "cs.ATG" +#line 1845 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not) { StartLocation = t.Location }); } else if (la.kind == 27) { lexer.NextToken(); -#line 1848 "cs.ATG" +#line 1846 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot) { StartLocation = t.Location }); } else if (la.kind == 6) { lexer.NextToken(); -#line 1849 "cs.ATG" +#line 1847 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference) { StartLocation = t.Location }); } else if (la.kind == 31) { lexer.NextToken(); -#line 1850 "cs.ATG" +#line 1848 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment) { StartLocation = t.Location }); } else if (la.kind == 32) { lexer.NextToken(); -#line 1851 "cs.ATG" +#line 1849 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement) { StartLocation = t.Location }); } else if (la.kind == 28) { lexer.NextToken(); -#line 1852 "cs.ATG" +#line 1850 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf) { StartLocation = t.Location }); } else if (la.kind == 146) { lexer.NextToken(); -#line 1853 "cs.ATG" +#line 1851 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Await) { StartLocation = t.Location }); } else { Expect(20); Type( -#line 1859 "cs.ATG" +#line 1857 "cs.ATG" out type); Expect(21); -#line 1859 "cs.ATG" +#line 1857 "cs.ATG" expressions.Add(new CastExpression(type) { StartLocation = t.Location }); } } if ( -#line 1864 "cs.ATG" +#line 1862 "cs.ATG" LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) { Expect(2); -#line 1867 "cs.ATG" +#line 1865 "cs.ATG" expressions.RemoveAt(expressions.Count - 1); if (t.literalValue is uint) { expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString()); @@ -4336,13 +4328,13 @@ LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffi throw new Exception("t.literalValue must be uint or ulong"); } - } else if (StartOf(33)) { + } else if (StartOf(34)) { PrimaryExpr( -#line 1876 "cs.ATG" +#line 1874 "cs.ATG" out expr); } else SynErr(207); -#line 1878 "cs.ATG" +#line 1876 "cs.ATG" for (int i = 0; i < expressions.Count; ++i) { Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr; if (expressions[i] is CastExpression) { @@ -4360,363 +4352,363 @@ out expr); } void ConditionalOrExpr( -#line 2204 "cs.ATG" +#line 2202 "cs.ATG" ref Expression outExpr) { -#line 2205 "cs.ATG" +#line 2203 "cs.ATG" Expression expr; Location startLocation = la.Location; ConditionalAndExpr( -#line 2207 "cs.ATG" +#line 2205 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2207 "cs.ATG" +#line 2205 "cs.ATG" out expr); ConditionalAndExpr( -#line 2207 "cs.ATG" +#line 2205 "cs.ATG" ref expr); -#line 2207 "cs.ATG" +#line 2205 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void PrimaryExpr( -#line 1895 "cs.ATG" +#line 1893 "cs.ATG" out Expression pexpr) { -#line 1897 "cs.ATG" +#line 1895 "cs.ATG" TypeReference type = null; Expression expr; pexpr = null; -#line 1902 "cs.ATG" +#line 1900 "cs.ATG" Location startLocation = la.Location; if (la.kind == 113) { lexer.NextToken(); -#line 1904 "cs.ATG" +#line 1902 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); -#line 1905 "cs.ATG" +#line 1903 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); -#line 1906 "cs.ATG" +#line 1904 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1907 "cs.ATG" +#line 1905 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; } else if ( -#line 1908 "cs.ATG" +#line 1906 "cs.ATG" StartOfQueryExpression()) { QueryExpression( -#line 1909 "cs.ATG" +#line 1907 "cs.ATG" out pexpr); } else if ( -#line 1910 "cs.ATG" +#line 1908 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 1911 "cs.ATG" +#line 1909 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1912 "cs.ATG" +#line 1910 "cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); -#line 1913 "cs.ATG" +#line 1911 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( -#line 1915 "cs.ATG" +#line 1913 "cs.ATG" out expr); -#line 1915 "cs.ATG" +#line 1913 "cs.ATG" pexpr = expr; } else if ( -#line 1916 "cs.ATG" +#line 1914 "cs.ATG" la.kind == Tokens.Async && Peek(1).kind == Tokens.Delegate) { Expect(145); Expect(64); AnonymousMethodExpr( -#line 1917 "cs.ATG" +#line 1915 "cs.ATG" out expr); -#line 1917 "cs.ATG" +#line 1915 "cs.ATG" pexpr = expr; -#line 1918 "cs.ATG" +#line 1916 "cs.ATG" ((AnonymousMethodExpression)expr).IsAsync = true; } else if ( -#line 1920 "cs.ATG" +#line 1918 "cs.ATG" la.kind == Tokens.Async && Peek(1).kind == Tokens.OpenParenthesis) { Expect(145); LambdaExpression( -#line 1922 "cs.ATG" +#line 1920 "cs.ATG" out pexpr); -#line 1923 "cs.ATG" +#line 1921 "cs.ATG" ((LambdaExpression)pexpr).IsAsync = true; } else if ( -#line 1925 "cs.ATG" +#line 1923 "cs.ATG" la.kind == Tokens.Async && IsIdentifierToken(Peek(1))) { Expect(145); Identifier(); -#line 1927 "cs.ATG" +#line 1925 "cs.ATG" pexpr = new IdentifierExpression(t.val); ShortedLambdaExpression( -#line 1928 "cs.ATG" +#line 1926 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); -#line 1929 "cs.ATG" +#line 1927 "cs.ATG" ((LambdaExpression)pexpr).IsAsync = true; } else if (StartOf(18)) { Identifier(); -#line 1933 "cs.ATG" +#line 1931 "cs.ATG" pexpr = new IdentifierExpression(t.val); if (la.kind == 48 || -#line 1936 "cs.ATG" +#line 1934 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { if (la.kind == 48) { ShortedLambdaExpression( -#line 1935 "cs.ATG" +#line 1933 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); } else { -#line 1937 "cs.ATG" +#line 1935 "cs.ATG" List typeList; TypeArgumentList( -#line 1938 "cs.ATG" +#line 1936 "cs.ATG" out typeList, false); -#line 1939 "cs.ATG" +#line 1937 "cs.ATG" ((IdentifierExpression)pexpr).TypeArguments = typeList; } } } else if ( -#line 1942 "cs.ATG" +#line 1940 "cs.ATG" IsLambdaExpression()) { LambdaExpression( -#line 1943 "cs.ATG" +#line 1941 "cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1946 "cs.ATG" +#line 1944 "cs.ATG" out expr); Expect(21); -#line 1946 "cs.ATG" +#line 1944 "cs.ATG" pexpr = new ParenthesizedExpression(expr); - } else if (StartOf(34)) { + } else if (StartOf(35)) { -#line 1949 "cs.ATG" +#line 1947 "cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); -#line 1950 "cs.ATG" +#line 1948 "cs.ATG" val = "System.Boolean"; break; } case 54: { lexer.NextToken(); -#line 1951 "cs.ATG" +#line 1949 "cs.ATG" val = "System.Byte"; break; } case 57: { lexer.NextToken(); -#line 1952 "cs.ATG" +#line 1950 "cs.ATG" val = "System.Char"; break; } case 62: { lexer.NextToken(); -#line 1953 "cs.ATG" +#line 1951 "cs.ATG" val = "System.Decimal"; break; } case 66: { lexer.NextToken(); -#line 1954 "cs.ATG" +#line 1952 "cs.ATG" val = "System.Double"; break; } case 75: { lexer.NextToken(); -#line 1955 "cs.ATG" +#line 1953 "cs.ATG" val = "System.Single"; break; } case 82: { lexer.NextToken(); -#line 1956 "cs.ATG" +#line 1954 "cs.ATG" val = "System.Int32"; break; } case 87: { lexer.NextToken(); -#line 1957 "cs.ATG" +#line 1955 "cs.ATG" val = "System.Int64"; break; } case 91: { lexer.NextToken(); -#line 1958 "cs.ATG" +#line 1956 "cs.ATG" val = "System.Object"; break; } case 102: { lexer.NextToken(); -#line 1959 "cs.ATG" +#line 1957 "cs.ATG" val = "System.SByte"; break; } case 104: { lexer.NextToken(); -#line 1960 "cs.ATG" +#line 1958 "cs.ATG" val = "System.Int16"; break; } case 108: { lexer.NextToken(); -#line 1961 "cs.ATG" +#line 1959 "cs.ATG" val = "System.String"; break; } case 116: { lexer.NextToken(); -#line 1962 "cs.ATG" +#line 1960 "cs.ATG" val = "System.UInt32"; break; } case 117: { lexer.NextToken(); -#line 1963 "cs.ATG" +#line 1961 "cs.ATG" val = "System.UInt64"; break; } case 120: { lexer.NextToken(); -#line 1964 "cs.ATG" +#line 1962 "cs.ATG" val = "System.UInt16"; break; } case 123: { lexer.NextToken(); -#line 1965 "cs.ATG" +#line 1963 "cs.ATG" val = "System.Void"; break; } } -#line 1967 "cs.ATG" +#line 1965 "cs.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; } else if (la.kind == 111) { lexer.NextToken(); -#line 1970 "cs.ATG" +#line 1968 "cs.ATG" pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 51) { lexer.NextToken(); -#line 1972 "cs.ATG" +#line 1970 "cs.ATG" pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 89) { NewExpression( -#line 1975 "cs.ATG" +#line 1973 "cs.ATG" out pexpr); } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( -#line 1979 "cs.ATG" +#line 1977 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1979 "cs.ATG" +#line 1977 "cs.ATG" type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( -#line 1980 "cs.ATG" +#line 1978 "cs.ATG" out type, true, true); } else SynErr(208); Expect(21); -#line 1982 "cs.ATG" +#line 1980 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( -#line 1984 "cs.ATG" +#line 1982 "cs.ATG" out type); Expect(21); -#line 1984 "cs.ATG" +#line 1982 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( -#line 1985 "cs.ATG" +#line 1983 "cs.ATG" out type); Expect(21); -#line 1985 "cs.ATG" +#line 1983 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( -#line 1986 "cs.ATG" +#line 1984 "cs.ATG" out expr); Expect(21); -#line 1986 "cs.ATG" +#line 1984 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( -#line 1987 "cs.ATG" +#line 1985 "cs.ATG" out expr); Expect(21); -#line 1987 "cs.ATG" +#line 1985 "cs.ATG" pexpr = new UncheckedExpression(expr); } else SynErr(209); -#line 1989 "cs.ATG" +#line 1987 "cs.ATG" if (pexpr != null) { if (pexpr.StartLocation.IsEmpty) pexpr.StartLocation = startLocation; @@ -4724,59 +4716,59 @@ out expr); pexpr.EndLocation = t.EndLocation; } - while (StartOf(35)) { + while (StartOf(36)) { -#line 1997 "cs.ATG" +#line 1995 "cs.ATG" startLocation = la.Location; switch (la.kind) { case 31: { lexer.NextToken(); -#line 1999 "cs.ATG" +#line 1997 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); break; } case 32: { lexer.NextToken(); -#line 2001 "cs.ATG" +#line 1999 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); break; } case 47: { PointerMemberAccess( -#line 2003 "cs.ATG" +#line 2001 "cs.ATG" out pexpr, pexpr); break; } case 15: { MemberAccess( -#line 2004 "cs.ATG" +#line 2002 "cs.ATG" out pexpr, pexpr); break; } case 20: { lexer.NextToken(); -#line 2008 "cs.ATG" +#line 2006 "cs.ATG" List parameters = new List(); -#line 2009 "cs.ATG" +#line 2007 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); - if (StartOf(25)) { + if (StartOf(26)) { Argument( -#line 2010 "cs.ATG" +#line 2008 "cs.ATG" out expr); -#line 2010 "cs.ATG" +#line 2008 "cs.ATG" SafeAdd(pexpr, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2011 "cs.ATG" +#line 2009 "cs.ATG" out expr); -#line 2011 "cs.ATG" +#line 2009 "cs.ATG" SafeAdd(pexpr, parameters, expr); } } @@ -4785,24 +4777,24 @@ out expr); } case 18: { -#line 2017 "cs.ATG" +#line 2015 "cs.ATG" List indices = new List(); pexpr = new IndexerExpression(pexpr, indices); lexer.NextToken(); Expr( -#line 2020 "cs.ATG" +#line 2018 "cs.ATG" out expr); -#line 2020 "cs.ATG" +#line 2018 "cs.ATG" SafeAdd(pexpr, indices, expr); while (la.kind == 14) { lexer.NextToken(); Expr( -#line 2021 "cs.ATG" +#line 2019 "cs.ATG" out expr); -#line 2021 "cs.ATG" +#line 2019 "cs.ATG" SafeAdd(pexpr, indices, expr); } Expect(19); @@ -4810,7 +4802,7 @@ out expr); } } -#line 2024 "cs.ATG" +#line 2022 "cs.ATG" if (pexpr != null) { if (pexpr.StartLocation.IsEmpty) pexpr.StartLocation = startLocation; @@ -4822,34 +4814,34 @@ out expr); } void QueryExpression( -#line 2462 "cs.ATG" +#line 2460 "cs.ATG" out Expression outExpr) { -#line 2463 "cs.ATG" +#line 2461 "cs.ATG" QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; QueryExpressionFromClause fromClause; QueryExpressionFromClause( -#line 2467 "cs.ATG" +#line 2465 "cs.ATG" out fromClause); -#line 2467 "cs.ATG" +#line 2465 "cs.ATG" q.FromClause = fromClause; QueryExpressionBody( -#line 2468 "cs.ATG" +#line 2466 "cs.ATG" ref q); -#line 2469 "cs.ATG" +#line 2467 "cs.ATG" q.EndLocation = t.EndLocation; outExpr = q; /* set outExpr to q again if QueryExpressionBody changed it (can happen with 'into' clauses) */ } void AnonymousMethodExpr( -#line 2185 "cs.ATG" +#line 2183 "cs.ATG" out Expression outExpr) { -#line 2187 "cs.ATG" +#line 2185 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; BlockStatement stmt; @@ -4860,117 +4852,117 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(11)) { FormalParameterList( -#line 2196 "cs.ATG" +#line 2194 "cs.ATG" p); -#line 2196 "cs.ATG" +#line 2194 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 2198 "cs.ATG" +#line 2196 "cs.ATG" expr.HasParameterList = true; } Block( -#line 2200 "cs.ATG" +#line 2198 "cs.ATG" out stmt); -#line 2200 "cs.ATG" +#line 2198 "cs.ATG" expr.Body = stmt; -#line 2201 "cs.ATG" +#line 2199 "cs.ATG" expr.EndLocation = t.Location; } void LambdaExpression( -#line 2118 "cs.ATG" +#line 2116 "cs.ATG" out Expression outExpr) { -#line 2120 "cs.ATG" +#line 2118 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; ParameterDeclarationExpression p; outExpr = lambda; Expect(20); - if (StartOf(36)) { + if (StartOf(37)) { LambdaExpressionParameter( -#line 2128 "cs.ATG" +#line 2126 "cs.ATG" out p); -#line 2128 "cs.ATG" +#line 2126 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); while (la.kind == 14) { lexer.NextToken(); LambdaExpressionParameter( -#line 2130 "cs.ATG" +#line 2128 "cs.ATG" out p); -#line 2130 "cs.ATG" +#line 2128 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); } } Expect(21); Expect(48); LambdaExpressionBody( -#line 2135 "cs.ATG" +#line 2133 "cs.ATG" lambda); } void ShortedLambdaExpression( -#line 2138 "cs.ATG" +#line 2136 "cs.ATG" IdentifierExpression ident, out Expression pexpr) { -#line 2139 "cs.ATG" +#line 2137 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); -#line 2144 "cs.ATG" +#line 2142 "cs.ATG" lambda.StartLocation = ident.StartLocation; SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); lambda.Parameters[0].StartLocation = ident.StartLocation; lambda.Parameters[0].EndLocation = ident.EndLocation; LambdaExpressionBody( -#line 2149 "cs.ATG" +#line 2147 "cs.ATG" lambda); } void TypeArgumentList( -#line 2381 "cs.ATG" +#line 2379 "cs.ATG" out List types, bool canBeUnbound) { -#line 2383 "cs.ATG" +#line 2381 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2388 "cs.ATG" +#line 2386 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2389 "cs.ATG" +#line 2387 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2390 "cs.ATG" +#line 2388 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(10)) { Type( -#line 2391 "cs.ATG" +#line 2389 "cs.ATG" out type); -#line 2391 "cs.ATG" +#line 2389 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2392 "cs.ATG" +#line 2390 "cs.ATG" out type); -#line 2392 "cs.ATG" +#line 2390 "cs.ATG" if (type != null) { types.Add(type); } } } else SynErr(210); @@ -4978,10 +4970,10 @@ out type); } void NewExpression( -#line 2065 "cs.ATG" +#line 2063 "cs.ATG" out Expression pexpr) { -#line 2066 "cs.ATG" +#line 2064 "cs.ATG" pexpr = null; List parameters = new List(); TypeReference type = null; @@ -4990,65 +4982,65 @@ out Expression pexpr) { Expect(89); if (StartOf(10)) { NonArrayType( -#line 2073 "cs.ATG" +#line 2071 "cs.ATG" out type); } if (la.kind == 16 || la.kind == 20) { if (la.kind == 20) { -#line 2079 "cs.ATG" +#line 2077 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); lexer.NextToken(); -#line 2080 "cs.ATG" +#line 2078 "cs.ATG" if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); - if (StartOf(25)) { + if (StartOf(26)) { Argument( -#line 2081 "cs.ATG" +#line 2079 "cs.ATG" out expr); -#line 2081 "cs.ATG" +#line 2079 "cs.ATG" SafeAdd(oce, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2082 "cs.ATG" +#line 2080 "cs.ATG" out expr); -#line 2082 "cs.ATG" +#line 2080 "cs.ATG" SafeAdd(oce, parameters, expr); } } Expect(21); -#line 2084 "cs.ATG" +#line 2082 "cs.ATG" pexpr = oce; if (la.kind == 16) { CollectionOrObjectInitializer( -#line 2085 "cs.ATG" +#line 2083 "cs.ATG" out expr); -#line 2085 "cs.ATG" +#line 2083 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; } } else { -#line 2086 "cs.ATG" +#line 2084 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); CollectionOrObjectInitializer( -#line 2087 "cs.ATG" +#line 2085 "cs.ATG" out expr); -#line 2087 "cs.ATG" +#line 2085 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; -#line 2088 "cs.ATG" +#line 2086 "cs.ATG" pexpr = oce; } } else if (la.kind == 18) { lexer.NextToken(); -#line 2093 "cs.ATG" +#line 2091 "cs.ATG" ArrayCreateExpression ace = new ArrayCreateExpression(type); /* we must not change RankSpecifier on the null type reference*/ if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); } @@ -5059,80 +5051,80 @@ out expr); while (la.kind == 14) { lexer.NextToken(); -#line 2100 "cs.ATG" +#line 2098 "cs.ATG" dims += 1; } Expect(19); -#line 2101 "cs.ATG" +#line 2099 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2102 "cs.ATG" +#line 2100 "cs.ATG" ++dims; } Expect(19); -#line 2102 "cs.ATG" +#line 2100 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2103 "cs.ATG" +#line 2101 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); CollectionInitializer( -#line 2104 "cs.ATG" +#line 2102 "cs.ATG" out expr); -#line 2104 "cs.ATG" +#line 2102 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } else if (StartOf(6)) { Expr( -#line 2105 "cs.ATG" +#line 2103 "cs.ATG" out expr); -#line 2105 "cs.ATG" +#line 2103 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2106 "cs.ATG" +#line 2104 "cs.ATG" dims += 1; Expr( -#line 2107 "cs.ATG" +#line 2105 "cs.ATG" out expr); -#line 2107 "cs.ATG" +#line 2105 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2109 "cs.ATG" +#line 2107 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2110 "cs.ATG" +#line 2108 "cs.ATG" ++dims; } Expect(19); -#line 2110 "cs.ATG" +#line 2108 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2111 "cs.ATG" +#line 2109 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { CollectionInitializer( -#line 2112 "cs.ATG" +#line 2110 "cs.ATG" out expr); -#line 2112 "cs.ATG" +#line 2110 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } } else SynErr(211); @@ -5140,36 +5132,36 @@ out expr); } void PointerMemberAccess( -#line 2053 "cs.ATG" +#line 2051 "cs.ATG" out Expression expr, Expression target) { -#line 2054 "cs.ATG" +#line 2052 "cs.ATG" List typeList; Expect(47); Identifier(); -#line 2058 "cs.ATG" +#line 2056 "cs.ATG" expr = new PointerReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 2059 "cs.ATG" +#line 2057 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2060 "cs.ATG" +#line 2058 "cs.ATG" out typeList, false); -#line 2061 "cs.ATG" +#line 2059 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void MemberAccess( -#line 2034 "cs.ATG" +#line 2032 "cs.ATG" out Expression expr, Expression target) { -#line 2035 "cs.ATG" +#line 2033 "cs.ATG" List typeList; -#line 2037 "cs.ATG" +#line 2035 "cs.ATG" if (ShouldConvertTargetExpressionToTypeReference(target)) { TypeReference type = GetTypeReferenceFromExpression(target); if (type != null) { @@ -5179,62 +5171,62 @@ out Expression expr, Expression target) { Expect(15); -#line 2044 "cs.ATG" +#line 2042 "cs.ATG" Location startLocation = t.Location; Identifier(); -#line 2046 "cs.ATG" +#line 2044 "cs.ATG" expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; if ( -#line 2047 "cs.ATG" +#line 2045 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2048 "cs.ATG" +#line 2046 "cs.ATG" out typeList, false); -#line 2049 "cs.ATG" +#line 2047 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void LambdaExpressionParameter( -#line 2152 "cs.ATG" +#line 2150 "cs.ATG" out ParameterDeclarationExpression p) { -#line 2153 "cs.ATG" +#line 2151 "cs.ATG" Location start = la.Location; p = null; TypeReference type; ParameterModifiers mod = ParameterModifiers.In; if ( -#line 2158 "cs.ATG" +#line 2156 "cs.ATG" Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { Identifier(); -#line 2160 "cs.ATG" +#line 2158 "cs.ATG" p = new ParameterDeclarationExpression(null, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; - } else if (StartOf(36)) { + } else if (StartOf(37)) { if (la.kind == 93 || la.kind == 100) { if (la.kind == 100) { lexer.NextToken(); -#line 2163 "cs.ATG" +#line 2161 "cs.ATG" mod = ParameterModifiers.Ref; } else { lexer.NextToken(); -#line 2164 "cs.ATG" +#line 2162 "cs.ATG" mod = ParameterModifiers.Out; } } Type( -#line 2166 "cs.ATG" +#line 2164 "cs.ATG" out type); Identifier(); -#line 2168 "cs.ATG" +#line 2166 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5242,237 +5234,237 @@ out type); } void LambdaExpressionBody( -#line 2174 "cs.ATG" +#line 2172 "cs.ATG" LambdaExpression lambda) { -#line 2175 "cs.ATG" +#line 2173 "cs.ATG" Expression expr; BlockStatement stmt; if (la.kind == 16) { Block( -#line 2178 "cs.ATG" +#line 2176 "cs.ATG" out stmt); -#line 2178 "cs.ATG" +#line 2176 "cs.ATG" lambda.StatementBody = stmt; } else if (StartOf(6)) { Expr( -#line 2179 "cs.ATG" +#line 2177 "cs.ATG" out expr); -#line 2179 "cs.ATG" +#line 2177 "cs.ATG" lambda.ExpressionBody = expr; } else SynErr(214); -#line 2181 "cs.ATG" +#line 2179 "cs.ATG" lambda.EndLocation = t.EndLocation; -#line 2182 "cs.ATG" +#line 2180 "cs.ATG" lambda.ExtendedEndLocation = la.Location; } void ConditionalAndExpr( -#line 2210 "cs.ATG" +#line 2208 "cs.ATG" ref Expression outExpr) { -#line 2211 "cs.ATG" +#line 2209 "cs.ATG" Expression expr; Location startLocation = la.Location; InclusiveOrExpr( -#line 2213 "cs.ATG" +#line 2211 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2213 "cs.ATG" +#line 2211 "cs.ATG" out expr); InclusiveOrExpr( -#line 2213 "cs.ATG" +#line 2211 "cs.ATG" ref expr); -#line 2213 "cs.ATG" +#line 2211 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void InclusiveOrExpr( -#line 2216 "cs.ATG" +#line 2214 "cs.ATG" ref Expression outExpr) { -#line 2217 "cs.ATG" +#line 2215 "cs.ATG" Expression expr; Location startLocation = la.Location; ExclusiveOrExpr( -#line 2219 "cs.ATG" +#line 2217 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2219 "cs.ATG" +#line 2217 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2219 "cs.ATG" +#line 2217 "cs.ATG" ref expr); -#line 2219 "cs.ATG" +#line 2217 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void ExclusiveOrExpr( -#line 2222 "cs.ATG" +#line 2220 "cs.ATG" ref Expression outExpr) { -#line 2223 "cs.ATG" +#line 2221 "cs.ATG" Expression expr; Location startLocation = la.Location; AndExpr( -#line 2225 "cs.ATG" +#line 2223 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2225 "cs.ATG" +#line 2223 "cs.ATG" out expr); AndExpr( -#line 2225 "cs.ATG" +#line 2223 "cs.ATG" ref expr); -#line 2225 "cs.ATG" +#line 2223 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void AndExpr( -#line 2228 "cs.ATG" +#line 2226 "cs.ATG" ref Expression outExpr) { -#line 2229 "cs.ATG" +#line 2227 "cs.ATG" Expression expr; Location startLocation = la.Location; EqualityExpr( -#line 2231 "cs.ATG" +#line 2229 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2231 "cs.ATG" +#line 2229 "cs.ATG" out expr); EqualityExpr( -#line 2231 "cs.ATG" +#line 2229 "cs.ATG" ref expr); -#line 2231 "cs.ATG" +#line 2229 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void EqualityExpr( -#line 2234 "cs.ATG" +#line 2232 "cs.ATG" ref Expression outExpr) { -#line 2236 "cs.ATG" +#line 2234 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; Location startLocation = la.Location; RelationalExpr( -#line 2241 "cs.ATG" +#line 2239 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2244 "cs.ATG" +#line 2242 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2245 "cs.ATG" +#line 2243 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2247 "cs.ATG" +#line 2245 "cs.ATG" out expr); RelationalExpr( -#line 2247 "cs.ATG" +#line 2245 "cs.ATG" ref expr); -#line 2247 "cs.ATG" +#line 2245 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void RelationalExpr( -#line 2251 "cs.ATG" +#line 2249 "cs.ATG" ref Expression outExpr) { -#line 2253 "cs.ATG" +#line 2251 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; Location startLocation = la.Location; ShiftExpr( -#line 2259 "cs.ATG" +#line 2257 "cs.ATG" ref outExpr); - while (StartOf(37)) { - if (StartOf(38)) { + while (StartOf(38)) { + if (StartOf(39)) { if (la.kind == 23) { lexer.NextToken(); -#line 2261 "cs.ATG" +#line 2259 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2262 "cs.ATG" +#line 2260 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2263 "cs.ATG" +#line 2261 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2264 "cs.ATG" +#line 2262 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(215); UnaryExpr( -#line 2266 "cs.ATG" +#line 2264 "cs.ATG" out expr); ShiftExpr( -#line 2267 "cs.ATG" +#line 2265 "cs.ATG" ref expr); -#line 2268 "cs.ATG" +#line 2266 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } else { if (la.kind == 85) { lexer.NextToken(); TypeWithRestriction( -#line 2271 "cs.ATG" +#line 2269 "cs.ATG" out type, false, false); if ( -#line 2272 "cs.ATG" +#line 2270 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2273 "cs.ATG" +#line 2271 "cs.ATG" ref type); } -#line 2274 "cs.ATG" +#line 2272 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type) { StartLocation = startLocation, EndLocation = t.EndLocation }; } else if (la.kind == 50) { lexer.NextToken(); TypeWithRestriction( -#line 2276 "cs.ATG" +#line 2274 "cs.ATG" out type, false, false); if ( -#line 2277 "cs.ATG" +#line 2275 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2278 "cs.ATG" +#line 2276 "cs.ATG" ref type); } -#line 2279 "cs.ATG" +#line 2277 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast) { StartLocation = startLocation, EndLocation = t.EndLocation }; } else SynErr(216); } @@ -5480,85 +5472,85 @@ ref type); } void ShiftExpr( -#line 2284 "cs.ATG" +#line 2282 "cs.ATG" ref Expression outExpr) { -#line 2286 "cs.ATG" +#line 2284 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; Location startLocation = la.Location; AdditiveExpr( -#line 2291 "cs.ATG" +#line 2289 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2294 "cs.ATG" +#line 2292 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2293 "cs.ATG" +#line 2291 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2295 "cs.ATG" +#line 2293 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2298 "cs.ATG" +#line 2296 "cs.ATG" out expr); AdditiveExpr( -#line 2298 "cs.ATG" +#line 2296 "cs.ATG" ref expr); -#line 2298 "cs.ATG" +#line 2296 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void AdditiveExpr( -#line 2302 "cs.ATG" +#line 2300 "cs.ATG" ref Expression outExpr) { -#line 2304 "cs.ATG" +#line 2302 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; Location startLocation = la.Location; MultiplicativeExpr( -#line 2309 "cs.ATG" +#line 2307 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2312 "cs.ATG" +#line 2310 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2313 "cs.ATG" +#line 2311 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2315 "cs.ATG" +#line 2313 "cs.ATG" out expr); MultiplicativeExpr( -#line 2315 "cs.ATG" +#line 2313 "cs.ATG" ref expr); -#line 2315 "cs.ATG" +#line 2313 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void MultiplicativeExpr( -#line 2319 "cs.ATG" +#line 2317 "cs.ATG" ref Expression outExpr) { -#line 2321 "cs.ATG" +#line 2319 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; Location startLocation = la.Location; @@ -5567,378 +5559,378 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2328 "cs.ATG" +#line 2326 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2329 "cs.ATG" +#line 2327 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2330 "cs.ATG" +#line 2328 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2332 "cs.ATG" +#line 2330 "cs.ATG" out expr); -#line 2332 "cs.ATG" +#line 2330 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; } } void VariantTypeParameter( -#line 2410 "cs.ATG" +#line 2408 "cs.ATG" out TemplateDefinition typeParameter) { -#line 2412 "cs.ATG" +#line 2410 "cs.ATG" typeParameter = new TemplateDefinition(); AttributeSection section; while (la.kind == 18) { AttributeSection( -#line 2416 "cs.ATG" +#line 2414 "cs.ATG" out section); -#line 2416 "cs.ATG" +#line 2414 "cs.ATG" typeParameter.Attributes.Add(section); } if (la.kind == 81 || la.kind == 93) { if (la.kind == 81) { lexer.NextToken(); -#line 2418 "cs.ATG" +#line 2416 "cs.ATG" typeParameter.VarianceModifier = VarianceModifier.Contravariant; } else { lexer.NextToken(); -#line 2419 "cs.ATG" +#line 2417 "cs.ATG" typeParameter.VarianceModifier = VarianceModifier.Covariant; } } Identifier(); -#line 2421 "cs.ATG" +#line 2419 "cs.ATG" typeParameter.Name = t.val; typeParameter.StartLocation = t.Location; -#line 2422 "cs.ATG" +#line 2420 "cs.ATG" typeParameter.EndLocation = t.EndLocation; } void TypeParameterConstraintsClauseBase( -#line 2453 "cs.ATG" +#line 2451 "cs.ATG" out TypeReference type) { -#line 2454 "cs.ATG" +#line 2452 "cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); -#line 2456 "cs.ATG" +#line 2454 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); -#line 2457 "cs.ATG" +#line 2455 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); -#line 2458 "cs.ATG" +#line 2456 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( -#line 2459 "cs.ATG" +#line 2457 "cs.ATG" out t); -#line 2459 "cs.ATG" +#line 2457 "cs.ATG" type = t; } else SynErr(217); } void QueryExpressionFromClause( -#line 2474 "cs.ATG" +#line 2472 "cs.ATG" out QueryExpressionFromClause fc) { -#line 2475 "cs.ATG" +#line 2473 "cs.ATG" fc = new QueryExpressionFromClause(); fc.StartLocation = la.Location; CollectionRangeVariable variable; Expect(137); QueryExpressionFromOrJoinClause( -#line 2481 "cs.ATG" +#line 2479 "cs.ATG" out variable); -#line 2482 "cs.ATG" +#line 2480 "cs.ATG" fc.EndLocation = t.EndLocation; fc.Sources.Add(variable); } void QueryExpressionBody( -#line 2518 "cs.ATG" +#line 2516 "cs.ATG" ref QueryExpression q) { -#line 2519 "cs.ATG" +#line 2517 "cs.ATG" QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; QueryExpressionOrderClause orderClause; QueryExpressionSelectClause selectClause; QueryExpressionGroupClause groupClause; - while (StartOf(39)) { + while (StartOf(40)) { if (la.kind == 137) { QueryExpressionFromClause( -#line 2525 "cs.ATG" +#line 2523 "cs.ATG" out fromClause); -#line 2525 "cs.ATG" +#line 2523 "cs.ATG" SafeAdd(q, q.MiddleClauses, fromClause); } else if (la.kind == 127) { QueryExpressionWhereClause( -#line 2526 "cs.ATG" +#line 2524 "cs.ATG" out whereClause); -#line 2526 "cs.ATG" +#line 2524 "cs.ATG" SafeAdd(q, q.MiddleClauses, whereClause); } else if (la.kind == 141) { QueryExpressionLetClause( -#line 2527 "cs.ATG" +#line 2525 "cs.ATG" out letClause); -#line 2527 "cs.ATG" +#line 2525 "cs.ATG" SafeAdd(q, q.MiddleClauses, letClause); } else if (la.kind == 142) { QueryExpressionJoinClause( -#line 2528 "cs.ATG" +#line 2526 "cs.ATG" out joinClause); -#line 2528 "cs.ATG" +#line 2526 "cs.ATG" SafeAdd(q, q.MiddleClauses, joinClause); } else { QueryExpressionOrderByClause( -#line 2529 "cs.ATG" +#line 2527 "cs.ATG" out orderClause); -#line 2529 "cs.ATG" +#line 2527 "cs.ATG" SafeAdd(q, q.MiddleClauses, orderClause); } } if (la.kind == 133) { QueryExpressionSelectClause( -#line 2531 "cs.ATG" +#line 2529 "cs.ATG" out selectClause); -#line 2531 "cs.ATG" +#line 2529 "cs.ATG" q.SelectOrGroupClause = selectClause; } else if (la.kind == 134) { QueryExpressionGroupClause( -#line 2532 "cs.ATG" +#line 2530 "cs.ATG" out groupClause); -#line 2532 "cs.ATG" +#line 2530 "cs.ATG" q.SelectOrGroupClause = groupClause; } else SynErr(218); if (la.kind == 136) { QueryExpressionIntoClause( -#line 2534 "cs.ATG" +#line 2532 "cs.ATG" ref q); } } void QueryExpressionFromOrJoinClause( -#line 2508 "cs.ATG" +#line 2506 "cs.ATG" out CollectionRangeVariable variable) { -#line 2509 "cs.ATG" +#line 2507 "cs.ATG" TypeReference type; Expression expr; variable = new CollectionRangeVariable(); -#line 2511 "cs.ATG" +#line 2509 "cs.ATG" variable.Type = null; if ( -#line 2512 "cs.ATG" +#line 2510 "cs.ATG" IsLocalVarDecl()) { Type( -#line 2512 "cs.ATG" +#line 2510 "cs.ATG" out type); -#line 2512 "cs.ATG" +#line 2510 "cs.ATG" variable.Type = type; } Identifier(); -#line 2513 "cs.ATG" +#line 2511 "cs.ATG" variable.Identifier = t.val; Expect(81); Expr( -#line 2515 "cs.ATG" +#line 2513 "cs.ATG" out expr); -#line 2515 "cs.ATG" +#line 2513 "cs.ATG" variable.Expression = expr; } void QueryExpressionJoinClause( -#line 2487 "cs.ATG" +#line 2485 "cs.ATG" out QueryExpressionJoinClause jc) { -#line 2488 "cs.ATG" +#line 2486 "cs.ATG" jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; Expression expr; CollectionRangeVariable variable; Expect(142); QueryExpressionFromOrJoinClause( -#line 2494 "cs.ATG" +#line 2492 "cs.ATG" out variable); Expect(143); Expr( -#line 2496 "cs.ATG" +#line 2494 "cs.ATG" out expr); -#line 2496 "cs.ATG" +#line 2494 "cs.ATG" jc.OnExpression = expr; Expect(144); Expr( -#line 2498 "cs.ATG" +#line 2496 "cs.ATG" out expr); -#line 2498 "cs.ATG" +#line 2496 "cs.ATG" jc.EqualsExpression = expr; if (la.kind == 136) { lexer.NextToken(); Identifier(); -#line 2500 "cs.ATG" +#line 2498 "cs.ATG" jc.IntoIdentifier = t.val; } -#line 2503 "cs.ATG" +#line 2501 "cs.ATG" jc.EndLocation = t.EndLocation; jc.Source = variable; } void QueryExpressionWhereClause( -#line 2537 "cs.ATG" +#line 2535 "cs.ATG" out QueryExpressionWhereClause wc) { -#line 2538 "cs.ATG" +#line 2536 "cs.ATG" Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; Expect(127); Expr( -#line 2541 "cs.ATG" +#line 2539 "cs.ATG" out expr); -#line 2541 "cs.ATG" +#line 2539 "cs.ATG" wc.Condition = expr; -#line 2542 "cs.ATG" +#line 2540 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionLetClause( -#line 2545 "cs.ATG" +#line 2543 "cs.ATG" out QueryExpressionLetClause wc) { -#line 2546 "cs.ATG" +#line 2544 "cs.ATG" Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; Expect(141); Identifier(); -#line 2549 "cs.ATG" +#line 2547 "cs.ATG" wc.Identifier = t.val; Expect(3); Expr( -#line 2551 "cs.ATG" +#line 2549 "cs.ATG" out expr); -#line 2551 "cs.ATG" +#line 2549 "cs.ATG" wc.Expression = expr; -#line 2552 "cs.ATG" +#line 2550 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionOrderByClause( -#line 2555 "cs.ATG" +#line 2553 "cs.ATG" out QueryExpressionOrderClause oc) { -#line 2556 "cs.ATG" +#line 2554 "cs.ATG" QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; Expect(140); QueryExpressionOrdering( -#line 2559 "cs.ATG" +#line 2557 "cs.ATG" out ordering); -#line 2559 "cs.ATG" +#line 2557 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); while (la.kind == 14) { lexer.NextToken(); QueryExpressionOrdering( -#line 2561 "cs.ATG" +#line 2559 "cs.ATG" out ordering); -#line 2561 "cs.ATG" +#line 2559 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); } -#line 2563 "cs.ATG" +#line 2561 "cs.ATG" oc.EndLocation = t.EndLocation; } void QueryExpressionSelectClause( -#line 2576 "cs.ATG" +#line 2574 "cs.ATG" out QueryExpressionSelectClause sc) { -#line 2577 "cs.ATG" +#line 2575 "cs.ATG" Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; Expect(133); Expr( -#line 2580 "cs.ATG" +#line 2578 "cs.ATG" out expr); -#line 2580 "cs.ATG" +#line 2578 "cs.ATG" sc.Projection = expr; -#line 2581 "cs.ATG" +#line 2579 "cs.ATG" sc.EndLocation = t.EndLocation; } void QueryExpressionGroupClause( -#line 2584 "cs.ATG" +#line 2582 "cs.ATG" out QueryExpressionGroupClause gc) { -#line 2585 "cs.ATG" +#line 2583 "cs.ATG" Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; Expect(134); Expr( -#line 2588 "cs.ATG" +#line 2586 "cs.ATG" out expr); -#line 2588 "cs.ATG" +#line 2586 "cs.ATG" gc.Projection = expr; Expect(135); Expr( -#line 2590 "cs.ATG" +#line 2588 "cs.ATG" out expr); -#line 2590 "cs.ATG" +#line 2588 "cs.ATG" gc.GroupBy = expr; -#line 2591 "cs.ATG" +#line 2589 "cs.ATG" gc.EndLocation = t.EndLocation; } void QueryExpressionIntoClause( -#line 2594 "cs.ATG" +#line 2592 "cs.ATG" ref QueryExpression q) { -#line 2595 "cs.ATG" +#line 2593 "cs.ATG" QueryExpression firstQuery = q; QueryExpression continuedQuery = new QueryExpression(); continuedQuery.StartLocation = q.StartLocation; @@ -5955,43 +5947,43 @@ ref QueryExpression q) { Expect(136); Identifier(); -#line 2610 "cs.ATG" +#line 2608 "cs.ATG" fromVariable.Identifier = t.val; -#line 2611 "cs.ATG" +#line 2609 "cs.ATG" continuedQuery.FromClause.EndLocation = t.EndLocation; QueryExpressionBody( -#line 2612 "cs.ATG" +#line 2610 "cs.ATG" ref q); } void QueryExpressionOrdering( -#line 2566 "cs.ATG" +#line 2564 "cs.ATG" out QueryExpressionOrdering ordering) { -#line 2567 "cs.ATG" +#line 2565 "cs.ATG" Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; Expr( -#line 2569 "cs.ATG" +#line 2567 "cs.ATG" out expr); -#line 2569 "cs.ATG" +#line 2567 "cs.ATG" ordering.Criteria = expr; if (la.kind == 138 || la.kind == 139) { if (la.kind == 138) { lexer.NextToken(); -#line 2570 "cs.ATG" +#line 2568 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2571 "cs.ATG" +#line 2569 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2573 "cs.ATG" +#line 2571 "cs.ATG" ordering.EndLocation = t.EndLocation; } @@ -6249,7 +6241,7 @@ out expr); {x,T,x,T, T,T,T,T, T,T,x,T, T,T,T,T, T,T,T,T, T,T,T,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,T,T,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,T,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, - {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,T,x,T, x,x,x,x, T,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, + {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,T,x,T, x,x,x,x, T,x,T,x, T,x,x,x, T,x,x,T, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,x,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, {T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,x,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,T,x,T, T,x,T,x, T,x,T,x, T,T,T,T, x,x,T,T, x,x,x,x, T,x,T,T, T,x,x,T, x,T,x,T, x,x,T,x, T,T,T,T, x,x,T,T, T,x,x,T, T,T,x,x, x,x,x,x, T,T,x,T, T,x,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, @@ -6262,6 +6254,7 @@ out expr); {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,T,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x}, + {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x}, {x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,x, x,T,T,x, T,T,T,T, T,T,T,x, x,x,x,x, T,x,T,T, T,T,T,T, x,x,T,x, x,x,T,T, x,T,T,T, x,x,x,x, x,x,x,x, x,T,T,x, T,T,x,x, T,x,T,T, T,T,T,T, T,T,T,T, T,T,x,T, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, {x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,T,T,x, x,x,T,T, T,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,T,T, x,T,x,x, x,x,x,x, T,x,T,x, T,T,x,x, T,x,x,T, x,T,x,T, T,T,T,x, T,x,x,T, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x}, diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index ee6c75a6a6..50faab0567 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -675,6 +675,7 @@ FixedParameter "ref" (. mod = ParameterModifiers.Ref; .) | "out" (. mod = ParameterModifiers.Out; .) | "params" (. mod = ParameterModifiers.Params; .) + | "this" (. mod = ParameterModifiers.This; .) ] Type Identifier (. p = new ParameterDeclarationExpression(type, t.val, mod); .) @@ -759,7 +760,6 @@ StructMemberDecl attributes> BlockStatement stmt = null; List templates = new List(); TypeReference explicitInterface = null; - bool isExtensionMethod = false; .) = /*--- constant declaration: */ (. m.Check(Modifiers.Constants); .) @@ -795,7 +795,6 @@ StructMemberDecl attributes> [ TypeParameterList ] "(" - [ "this" (. isExtensionMethod = true; /* C# 3.0 */ .) ] [ FormalParameterList

] ")" (. MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, @@ -806,7 +805,7 @@ StructMemberDecl attributes> StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, Templates = templates, - IsExtensionMethod = isExtensionMethod + IsExtensionMethod = p.Count > 0 && p[0].ParamModifier == ParameterModifiers.This }; if (explicitInterface != null) SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); @@ -1017,7 +1016,6 @@ StructMemberDecl attributes> /* .NET 2.0 */ [ TypeParameterList ] "(" - [ "this" (. isExtensionMethod = true; .) ] [ FormalParameterList

] ")" (. MethodDeclaration methodDeclaration = new MethodDeclaration { @@ -1031,7 +1029,7 @@ StructMemberDecl attributes> methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; - methodDeclaration.IsExtensionMethod = isExtensionMethod; + methodDeclaration.IsExtensionMethod = p.Count > 0 && p[0].ParamModifier == ParameterModifiers.This; methodDeclaration.Templates = templates; AddChild(methodDeclaration); .) diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs index 5cff963748..b7738a6307 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs @@ -293,6 +293,19 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual("System.String", md.Parameters[0].TypeReference.Type); } + [Test] + public void CSharpExtensionMethodWithAttributeTest() + { + MethodDeclaration md = ParseUtilCSharp.ParseTypeMember( + "public static int ToInt32([Attr] this string s) { return int.Parse(s); }" + ); + Assert.AreEqual("ToInt32", md.Name); + Assert.IsTrue(md.IsExtensionMethod); + Assert.AreEqual("s", md.Parameters[0].ParameterName); + Assert.AreEqual("System.String", md.Parameters[0].TypeReference.Type); + Assert.AreEqual(1, md.Parameters[0].Attributes.Count); + } + [Test] public void CSharpVoidExtensionMethodTest() { diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/ParameterModifiers.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/ParameterModifiers.cs index a28bf5a401..fbab8d2e03 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/ParameterModifiers.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Interfaces/ParameterModifiers.cs @@ -15,6 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom Out = 2, Ref = 4, Params = 8, - Optional = 16 + Optional = 16, + This = 32 } }