From 39e4a95f2dd516ac9d41477e56d9c47000ad0518 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 24 Jul 2005 19:26:47 +0000 Subject: [PATCH] Fixed C# parser (added support for generic methods inside interfaces). Changed CurrentLineBookmark to be invisible in BookmarkPad and not saved. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@245 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Parser/CSharp/Parser.cs | 1644 +++++++++-------- .../Project/Src/Parser/CSharp/cs.ATG | 32 +- .../TypeLevel/MethodDeclarationTests.cs | 40 + .../Base/Project/Src/Dom/ExpressionContext.cs | 82 +- .../NRefactoryResolver/NRefactoryResolver.cs | 2 +- .../Services/Debugger/CurrentLineBookmark.cs | 9 +- .../Src/TextEditor/Bookmarks/Bookmark.cs | 42 +- .../TextEditor/Bookmarks/BookmarkManager.cs | 2 +- .../TextEditor/Bookmarks/Pad/BookmarkPad.cs | 2 + .../MethodInsightDataProvider.cs | 4 +- 10 files changed, 1005 insertions(+), 854 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 988f37ddbe..3a3469e254 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -704,43 +704,43 @@ out expr); } void Expr( -#line 1856 "cs.ATG" +#line 1864 "cs.ATG" out Expression expr) { -#line 1857 "cs.ATG" +#line 1865 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; UnaryExpr( -#line 1859 "cs.ATG" +#line 1867 "cs.ATG" out expr); if (StartOf(5)) { ConditionalOrExpr( -#line 1862 "cs.ATG" +#line 1870 "cs.ATG" ref expr); if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1862 "cs.ATG" +#line 1870 "cs.ATG" out expr1); Expect(9); Expr( -#line 1862 "cs.ATG" +#line 1870 "cs.ATG" out expr2); -#line 1862 "cs.ATG" +#line 1870 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else if (StartOf(6)) { -#line 1864 "cs.ATG" +#line 1872 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1864 "cs.ATG" +#line 1872 "cs.ATG" out op); Expr( -#line 1864 "cs.ATG" +#line 1872 "cs.ATG" out val); -#line 1864 "cs.ATG" +#line 1872 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else SynErr(127); } @@ -816,76 +816,76 @@ out attribute); } void TypeModifier( -#line 988 "cs.ATG" +#line 990 "cs.ATG" Modifiers m) { switch (la.kind) { case 87: { lexer.NextToken(); -#line 990 "cs.ATG" +#line 992 "cs.ATG" m.Add(Modifier.New); break; } case 96: { lexer.NextToken(); -#line 991 "cs.ATG" +#line 993 "cs.ATG" m.Add(Modifier.Public); break; } case 95: { lexer.NextToken(); -#line 992 "cs.ATG" +#line 994 "cs.ATG" m.Add(Modifier.Protected); break; } case 82: { lexer.NextToken(); -#line 993 "cs.ATG" +#line 995 "cs.ATG" m.Add(Modifier.Internal); break; } case 94: { lexer.NextToken(); -#line 994 "cs.ATG" +#line 996 "cs.ATG" m.Add(Modifier.Private); break; } case 117: { lexer.NextToken(); -#line 995 "cs.ATG" +#line 997 "cs.ATG" m.Add(Modifier.Unsafe); break; } case 47: { lexer.NextToken(); -#line 996 "cs.ATG" +#line 998 "cs.ATG" m.Add(Modifier.Abstract); break; } case 101: { lexer.NextToken(); -#line 997 "cs.ATG" +#line 999 "cs.ATG" m.Add(Modifier.Sealed); break; } case 105: { lexer.NextToken(); -#line 998 "cs.ATG" +#line 1000 "cs.ATG" m.Add(Modifier.Static); break; } case 1: { lexer.NextToken(); -#line 999 "cs.ATG" +#line 1001 "cs.ATG" if (t.val == "partial") { m.Add(Modifier.Partial); } break; } @@ -1144,39 +1144,39 @@ templates); } void TypeParameterList( -#line 2239 "cs.ATG" +#line 2247 "cs.ATG" List templates) { -#line 2241 "cs.ATG" +#line 2249 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(22); while (la.kind == 17) { AttributeSection( -#line 2245 "cs.ATG" +#line 2253 "cs.ATG" out section); -#line 2245 "cs.ATG" +#line 2253 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2246 "cs.ATG" +#line 2254 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 13) { lexer.NextToken(); while (la.kind == 17) { AttributeSection( -#line 2247 "cs.ATG" +#line 2255 "cs.ATG" out section); -#line 2247 "cs.ATG" +#line 2255 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2248 "cs.ATG" +#line 2256 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(21); @@ -1209,25 +1209,25 @@ out typeRef); } void TypeParameterConstraintsClause( -#line 2252 "cs.ATG" +#line 2260 "cs.ATG" List templates) { -#line 2253 "cs.ATG" +#line 2261 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2255 "cs.ATG" +#line 2263 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2256 "cs.ATG" +#line 2264 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2258 "cs.ATG" +#line 2266 "cs.ATG" out type); -#line 2259 "cs.ATG" +#line 2267 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1240,10 +1240,10 @@ out type); while (la.kind == 13) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2268 "cs.ATG" +#line 2276 "cs.ATG" out type); -#line 2269 "cs.ATG" +#line 2277 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1379,72 +1379,72 @@ out typeRef); } void IntegralType( -#line 1010 "cs.ATG" +#line 1012 "cs.ATG" out string name) { -#line 1010 "cs.ATG" +#line 1012 "cs.ATG" name = ""; switch (la.kind) { case 100: { lexer.NextToken(); -#line 1012 "cs.ATG" +#line 1014 "cs.ATG" name = "sbyte"; break; } case 52: { lexer.NextToken(); -#line 1013 "cs.ATG" +#line 1015 "cs.ATG" name = "byte"; break; } case 102: { lexer.NextToken(); -#line 1014 "cs.ATG" +#line 1016 "cs.ATG" name = "short"; break; } case 118: { lexer.NextToken(); -#line 1015 "cs.ATG" +#line 1017 "cs.ATG" name = "ushort"; break; } case 80: { lexer.NextToken(); -#line 1016 "cs.ATG" +#line 1018 "cs.ATG" name = "int"; break; } case 114: { lexer.NextToken(); -#line 1017 "cs.ATG" +#line 1019 "cs.ATG" name = "uint"; break; } case 85: { lexer.NextToken(); -#line 1018 "cs.ATG" +#line 1020 "cs.ATG" name = "long"; break; } case 115: { lexer.NextToken(); -#line 1019 "cs.ATG" +#line 1021 "cs.ATG" name = "ulong"; break; } case 55: { lexer.NextToken(); -#line 1020 "cs.ATG" +#line 1022 "cs.ATG" name = "char"; break; } @@ -1539,34 +1539,36 @@ IsPointerOrDims()) { } #line 909 "cs.ATG" + if (type != null) { type.RankSpecifier = r.ToArray(); type.PointerNestingLevel = pointer; + } } void FormalParameterList( -#line 943 "cs.ATG" +#line 945 "cs.ATG" List parameter) { -#line 946 "cs.ATG" +#line 948 "cs.ATG" ParameterDeclarationExpression p; AttributeSection section; List attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 951 "cs.ATG" +#line 953 "cs.ATG" out section); -#line 951 "cs.ATG" +#line 953 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 953 "cs.ATG" +#line 955 "cs.ATG" out p); -#line 953 "cs.ATG" +#line 955 "cs.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1574,96 +1576,96 @@ out p); while (la.kind == 13) { lexer.NextToken(); -#line 958 "cs.ATG" +#line 960 "cs.ATG" attributes = new List(); if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 17) { AttributeSection( -#line 959 "cs.ATG" +#line 961 "cs.ATG" out section); -#line 959 "cs.ATG" +#line 961 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 961 "cs.ATG" +#line 963 "cs.ATG" out p); -#line 961 "cs.ATG" +#line 963 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else if (la.kind == 93) { ParameterArray( -#line 962 "cs.ATG" +#line 964 "cs.ATG" out p); -#line 962 "cs.ATG" +#line 964 "cs.ATG" paramsFound = true; p.Attributes = attributes; parameter.Add(p); } else SynErr(134); } } else if (la.kind == 93) { ParameterArray( -#line 965 "cs.ATG" +#line 967 "cs.ATG" out p); -#line 965 "cs.ATG" +#line 967 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else SynErr(135); } void ClassType( -#line 1002 "cs.ATG" +#line 1004 "cs.ATG" out TypeReference typeRef) { -#line 1003 "cs.ATG" +#line 1005 "cs.ATG" TypeReference r; typeRef = null; if (la.kind == 1) { TypeName( -#line 1005 "cs.ATG" +#line 1007 "cs.ATG" out r); -#line 1005 "cs.ATG" +#line 1007 "cs.ATG" typeRef = r; } else if (la.kind == 89) { lexer.NextToken(); -#line 1006 "cs.ATG" +#line 1008 "cs.ATG" typeRef = new TypeReference("object"); } else if (la.kind == 106) { lexer.NextToken(); -#line 1007 "cs.ATG" +#line 1009 "cs.ATG" typeRef = new TypeReference("string"); } else SynErr(136); } void TypeName( -#line 2204 "cs.ATG" +#line 2212 "cs.ATG" out TypeReference typeRef) { -#line 2205 "cs.ATG" +#line 2213 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 2210 "cs.ATG" +#line 2218 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 2211 "cs.ATG" +#line 2219 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2214 "cs.ATG" +#line 2222 "cs.ATG" out qualident); if (la.kind == 22) { TypeArgumentList( -#line 2215 "cs.ATG" +#line 2223 "cs.ATG" out typeArguments); } -#line 2217 "cs.ATG" +#line 2225 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1676,104 +1678,104 @@ out typeArguments); } void MemberModifier( -#line 1023 "cs.ATG" +#line 1025 "cs.ATG" Modifiers m) { switch (la.kind) { case 47: { lexer.NextToken(); -#line 1025 "cs.ATG" +#line 1027 "cs.ATG" m.Add(Modifier.Abstract); break; } case 69: { lexer.NextToken(); -#line 1026 "cs.ATG" +#line 1028 "cs.ATG" m.Add(Modifier.Extern); break; } case 82: { lexer.NextToken(); -#line 1027 "cs.ATG" +#line 1029 "cs.ATG" m.Add(Modifier.Internal); break; } case 87: { lexer.NextToken(); -#line 1028 "cs.ATG" +#line 1030 "cs.ATG" m.Add(Modifier.New); break; } case 92: { lexer.NextToken(); -#line 1029 "cs.ATG" +#line 1031 "cs.ATG" m.Add(Modifier.Override); break; } case 94: { lexer.NextToken(); -#line 1030 "cs.ATG" +#line 1032 "cs.ATG" m.Add(Modifier.Private); break; } case 95: { lexer.NextToken(); -#line 1031 "cs.ATG" +#line 1033 "cs.ATG" m.Add(Modifier.Protected); break; } case 96: { lexer.NextToken(); -#line 1032 "cs.ATG" +#line 1034 "cs.ATG" m.Add(Modifier.Public); break; } case 97: { lexer.NextToken(); -#line 1033 "cs.ATG" +#line 1035 "cs.ATG" m.Add(Modifier.Readonly); break; } case 101: { lexer.NextToken(); -#line 1034 "cs.ATG" +#line 1036 "cs.ATG" m.Add(Modifier.Sealed); break; } case 105: { lexer.NextToken(); -#line 1035 "cs.ATG" +#line 1037 "cs.ATG" m.Add(Modifier.Static); break; } case 117: { lexer.NextToken(); -#line 1036 "cs.ATG" +#line 1038 "cs.ATG" m.Add(Modifier.Unsafe); break; } case 120: { lexer.NextToken(); -#line 1037 "cs.ATG" +#line 1039 "cs.ATG" m.Add(Modifier.Virtual); break; } case 122: { lexer.NextToken(); -#line 1038 "cs.ATG" +#line 1040 "cs.ATG" m.Add(Modifier.Volatile); break; } @@ -1782,23 +1784,23 @@ Modifiers m) { } void ClassMemberDecl( -#line 1271 "cs.ATG" +#line 1273 "cs.ATG" Modifiers m, List attributes) { -#line 1272 "cs.ATG" +#line 1274 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 1274 "cs.ATG" +#line 1276 "cs.ATG" m, attributes); } else if (la.kind == 26) { -#line 1275 "cs.ATG" +#line 1277 "cs.ATG" m.Check(Modifier.Destructors); Point startPos = t.Location; lexer.NextToken(); Expect(1); -#line 1276 "cs.ATG" +#line 1278 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = startPos; @@ -1806,17 +1808,17 @@ m, attributes); Expect(19); Expect(20); -#line 1280 "cs.ATG" +#line 1282 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 15) { Block( -#line 1280 "cs.ATG" +#line 1282 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(138); -#line 1281 "cs.ATG" +#line 1283 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1824,10 +1826,10 @@ out stmt); } void StructMemberDecl( -#line 1041 "cs.ATG" +#line 1043 "cs.ATG" Modifiers m, List attributes) { -#line 1043 "cs.ATG" +#line 1045 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1838,18 +1840,18 @@ Modifiers m, List attributes) { if (la.kind == 58) { -#line 1052 "cs.ATG" +#line 1054 "cs.ATG" m.Check(Modifier.Constants); lexer.NextToken(); -#line 1053 "cs.ATG" +#line 1055 "cs.ATG" Point startPos = t.Location; Type( -#line 1054 "cs.ATG" +#line 1056 "cs.ATG" out type); Expect(1); -#line 1054 "cs.ATG" +#line 1056 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const); fd.StartLocation = startPos; VariableDeclaration f = new VariableDeclaration(t.val); @@ -1857,58 +1859,58 @@ out type); Expect(3); Expr( -#line 1059 "cs.ATG" +#line 1061 "cs.ATG" out expr); -#line 1059 "cs.ATG" +#line 1061 "cs.ATG" f.Initializer = expr; while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1060 "cs.ATG" +#line 1062 "cs.ATG" f = new VariableDeclaration(t.val); fd.Fields.Add(f); Expect(3); Expr( -#line 1063 "cs.ATG" +#line 1065 "cs.ATG" out expr); -#line 1063 "cs.ATG" +#line 1065 "cs.ATG" f.Initializer = expr; } Expect(11); -#line 1064 "cs.ATG" +#line 1066 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( -#line 1067 "cs.ATG" +#line 1069 "cs.ATG" NotVoidPointer()) { -#line 1067 "cs.ATG" +#line 1069 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); Expect(121); -#line 1068 "cs.ATG" +#line 1070 "cs.ATG" Point startPos = t.Location; Qualident( -#line 1069 "cs.ATG" +#line 1071 "cs.ATG" out qualident); if (la.kind == 22) { TypeParameterList( -#line 1071 "cs.ATG" +#line 1073 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1074 "cs.ATG" +#line 1076 "cs.ATG" p); } Expect(20); -#line 1074 "cs.ATG" +#line 1076 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, new TypeReference("void"), @@ -1921,31 +1923,31 @@ p); compilationUnit.BlockStart(methodDeclaration); while ( -#line 1087 "cs.ATG" +#line 1089 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1087 "cs.ATG" +#line 1089 "cs.ATG" templates); } if (la.kind == 15) { Block( -#line 1089 "cs.ATG" +#line 1091 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(140); -#line 1089 "cs.ATG" +#line 1091 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 67) { -#line 1093 "cs.ATG" +#line 1095 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); lexer.NextToken(); -#line 1094 "cs.ATG" +#line 1096 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); @@ -1954,103 +1956,103 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 1101 "cs.ATG" +#line 1103 "cs.ATG" out type); -#line 1101 "cs.ATG" +#line 1103 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 1103 "cs.ATG" +#line 1105 "cs.ATG" IsVarDecl()) { VariableDeclarator( -#line 1103 "cs.ATG" +#line 1105 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1104 "cs.ATG" +#line 1106 "cs.ATG" variableDeclarators); } Expect(11); -#line 1104 "cs.ATG" +#line 1106 "cs.ATG" eventDecl.VariableDeclarators = variableDeclarators; eventDecl.EndLocation = t.EndLocation; } else if (la.kind == 1) { Qualident( -#line 1105 "cs.ATG" +#line 1107 "cs.ATG" out qualident); -#line 1105 "cs.ATG" +#line 1107 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; Expect(15); -#line 1106 "cs.ATG" +#line 1108 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 1107 "cs.ATG" +#line 1109 "cs.ATG" out addBlock, out removeBlock); Expect(16); -#line 1108 "cs.ATG" +#line 1110 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } else SynErr(141); -#line 1109 "cs.ATG" +#line 1111 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 1116 "cs.ATG" +#line 1118 "cs.ATG" IdentAndLPar()) { -#line 1116 "cs.ATG" +#line 1118 "cs.ATG" m.Check(Modifier.Constructors | Modifier.StaticConstructors); Expect(1); -#line 1117 "cs.ATG" +#line 1119 "cs.ATG" string name = t.val; Point startPos = t.Location; Expect(19); if (StartOf(9)) { -#line 1117 "cs.ATG" +#line 1119 "cs.ATG" m.Check(Modifier.Constructors); FormalParameterList( -#line 1118 "cs.ATG" +#line 1120 "cs.ATG" p); } Expect(20); -#line 1120 "cs.ATG" +#line 1122 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 1121 "cs.ATG" +#line 1123 "cs.ATG" m.Check(Modifier.Constructors); ConstructorInitializer( -#line 1122 "cs.ATG" +#line 1124 "cs.ATG" out init); } -#line 1124 "cs.ATG" +#line 1126 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 15) { Block( -#line 1129 "cs.ATG" +#line 1131 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(142); -#line 1129 "cs.ATG" +#line 1131 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 68 || la.kind == 78) { -#line 1132 "cs.ATG" +#line 1134 "cs.ATG" m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -2060,37 +2062,37 @@ out stmt); } else { lexer.NextToken(); -#line 1136 "cs.ATG" +#line 1138 "cs.ATG" isImplicit = false; } Expect(90); Type( -#line 1137 "cs.ATG" +#line 1139 "cs.ATG" out type); -#line 1137 "cs.ATG" +#line 1139 "cs.ATG" TypeReference operatorType = type; Expect(19); Type( -#line 1138 "cs.ATG" +#line 1140 "cs.ATG" out type); Expect(1); -#line 1138 "cs.ATG" +#line 1140 "cs.ATG" string varName = t.val; Expect(20); if (la.kind == 15) { Block( -#line 1138 "cs.ATG" +#line 1140 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 1138 "cs.ATG" +#line 1140 "cs.ATG" stmt = null; } else SynErr(143); -#line 1141 "cs.ATG" +#line 1143 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -2104,58 +2106,58 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 1154 "cs.ATG" +#line 1156 "cs.ATG" m, attributes); } else if (StartOf(8)) { Type( -#line 1155 "cs.ATG" +#line 1157 "cs.ATG" out type); -#line 1155 "cs.ATG" +#line 1157 "cs.ATG" Point startPos = t.Location; if (la.kind == 90) { -#line 1157 "cs.ATG" +#line 1159 "cs.ATG" OverloadableOperatorType op; m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 1161 "cs.ATG" +#line 1163 "cs.ATG" out op); -#line 1161 "cs.ATG" +#line 1163 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(19); Type( -#line 1162 "cs.ATG" +#line 1164 "cs.ATG" out firstType); Expect(1); -#line 1162 "cs.ATG" +#line 1164 "cs.ATG" string firstName = t.val; if (la.kind == 13) { lexer.NextToken(); Type( -#line 1163 "cs.ATG" +#line 1165 "cs.ATG" out secondType); Expect(1); -#line 1163 "cs.ATG" +#line 1165 "cs.ATG" secondName = t.val; } else if (la.kind == 20) { } else SynErr(144); Expect(20); if (la.kind == 15) { Block( -#line 1171 "cs.ATG" +#line 1173 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(145); -#line 1173 "cs.ATG" +#line 1175 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -2170,43 +2172,43 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 1188 "cs.ATG" +#line 1190 "cs.ATG" IsVarDecl()) { -#line 1188 "cs.ATG" +#line 1190 "cs.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = startPos; VariableDeclarator( -#line 1192 "cs.ATG" +#line 1194 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1193 "cs.ATG" +#line 1195 "cs.ATG" variableDeclarators); } Expect(11); -#line 1194 "cs.ATG" +#line 1196 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 109) { -#line 1197 "cs.ATG" +#line 1199 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(17); FormalParameterList( -#line 1198 "cs.ATG" +#line 1200 "cs.ATG" p); Expect(18); -#line 1198 "cs.ATG" +#line 1200 "cs.ATG" Point endLocation = t.EndLocation; Expect(15); -#line 1199 "cs.ATG" +#line 1201 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2215,11 +2217,11 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 1206 "cs.ATG" +#line 1208 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1207 "cs.ATG" +#line 1209 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; @@ -2227,30 +2229,30 @@ out getRegion, out setRegion); } else if (la.kind == 1) { Qualident( -#line 1212 "cs.ATG" +#line 1214 "cs.ATG" out qualident); -#line 1212 "cs.ATG" +#line 1214 "cs.ATG" Point qualIdentEndLocation = t.EndLocation; if (la.kind == 15 || la.kind == 19 || la.kind == 22) { if (la.kind == 19 || la.kind == 22) { -#line 1215 "cs.ATG" +#line 1217 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); if (la.kind == 22) { TypeParameterList( -#line 1217 "cs.ATG" +#line 1219 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1218 "cs.ATG" +#line 1220 "cs.ATG" p); } Expect(20); -#line 1219 "cs.ATG" +#line 1221 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, type, @@ -2262,26 +2264,26 @@ p); compilationUnit.AddChild(methodDeclaration); while ( -#line 1229 "cs.ATG" +#line 1231 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1229 "cs.ATG" +#line 1231 "cs.ATG" templates); } if (la.kind == 15) { Block( -#line 1230 "cs.ATG" +#line 1232 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(146); -#line 1230 "cs.ATG" +#line 1232 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1233 "cs.ATG" +#line 1235 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); pDecl.StartLocation = startPos; pDecl.EndLocation = qualIdentEndLocation; @@ -2290,11 +2292,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1240 "cs.ATG" +#line 1242 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1242 "cs.ATG" +#line 1244 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2303,17 +2305,17 @@ out getRegion, out setRegion); } } else if (la.kind == 14) { -#line 1250 "cs.ATG" +#line 1252 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(109); Expect(17); FormalParameterList( -#line 1251 "cs.ATG" +#line 1253 "cs.ATG" p); Expect(18); -#line 1252 "cs.ATG" +#line 1254 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = t.EndLocation; @@ -2323,14 +2325,14 @@ p); Expect(15); -#line 1259 "cs.ATG" +#line 1261 "cs.ATG" Point bodyStart = t.Location; AccessorDecls( -#line 1260 "cs.ATG" +#line 1262 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1261 "cs.ATG" +#line 1263 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2344,7 +2346,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1288 "cs.ATG" +#line 1290 "cs.ATG" TypeReference type; AttributeSection section; @@ -2359,153 +2361,167 @@ out getRegion, out setRegion); while (la.kind == 17) { AttributeSection( -#line 1301 "cs.ATG" +#line 1303 "cs.ATG" out section); -#line 1301 "cs.ATG" +#line 1303 "cs.ATG" attributes.Add(section); } if (la.kind == 87) { lexer.NextToken(); -#line 1302 "cs.ATG" +#line 1304 "cs.ATG" mod = Modifier.New; startLocation = t.Location; } if ( -#line 1305 "cs.ATG" +#line 1307 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 1305 "cs.ATG" +#line 1307 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1305 "cs.ATG" +#line 1307 "cs.ATG" name = t.val; + if (la.kind == 22) { + TypeParameterList( +#line 1308 "cs.ATG" +templates); + } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1306 "cs.ATG" +#line 1309 "cs.ATG" parameters); } Expect(20); + while ( +#line 1310 "cs.ATG" +IdentIsWhere()) { + TypeParameterConstraintsClause( +#line 1310 "cs.ATG" +templates); + } Expect(11); -#line 1306 "cs.ATG" +#line 1312 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; + md.Templates = templates; compilationUnit.AddChild(md); } else if (StartOf(18)) { if (StartOf(8)) { Type( -#line 1312 "cs.ATG" +#line 1319 "cs.ATG" out type); -#line 1312 "cs.ATG" +#line 1319 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1314 "cs.ATG" +#line 1321 "cs.ATG" name = t.val; Point qualIdentEndLocation = t.EndLocation; if (la.kind == 19 || la.kind == 22) { if (la.kind == 22) { TypeParameterList( -#line 1318 "cs.ATG" +#line 1325 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1319 "cs.ATG" +#line 1326 "cs.ATG" parameters); } Expect(20); while ( -#line 1321 "cs.ATG" +#line 1328 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1321 "cs.ATG" +#line 1328 "cs.ATG" templates); } Expect(11); -#line 1322 "cs.ATG" +#line 1329 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); - md.StartLocation = startLocation; - md.EndLocation = t.EndLocation; - compilationUnit.AddChild(md); - + md.StartLocation = startLocation; + md.EndLocation = t.EndLocation; + md.Templates = templates; + compilationUnit.AddChild(md); + } else if (la.kind == 15) { -#line 1328 "cs.ATG" +#line 1336 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1329 "cs.ATG" +#line 1337 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1329 "cs.ATG" +#line 1337 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1329 "cs.ATG" +#line 1337 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(150); } else if (la.kind == 109) { lexer.NextToken(); Expect(17); FormalParameterList( -#line 1332 "cs.ATG" +#line 1340 "cs.ATG" parameters); Expect(18); -#line 1332 "cs.ATG" +#line 1340 "cs.ATG" Point bracketEndLocation = t.EndLocation; -#line 1332 "cs.ATG" +#line 1340 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); Expect(15); -#line 1333 "cs.ATG" +#line 1341 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1333 "cs.ATG" +#line 1341 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1333 "cs.ATG" +#line 1341 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(151); } else { lexer.NextToken(); -#line 1336 "cs.ATG" +#line 1344 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1336 "cs.ATG" +#line 1344 "cs.ATG" out type); Expect(1); -#line 1336 "cs.ATG" +#line 1344 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes); compilationUnit.AddChild(ed); Expect(11); -#line 1339 "cs.ATG" +#line 1347 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(152); } void EnumMemberDecl( -#line 1344 "cs.ATG" +#line 1352 "cs.ATG" out FieldDeclaration f) { -#line 1346 "cs.ATG" +#line 1354 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2513,15 +2529,15 @@ out FieldDeclaration f) { while (la.kind == 17) { AttributeSection( -#line 1352 "cs.ATG" +#line 1360 "cs.ATG" out section); -#line 1352 "cs.ATG" +#line 1360 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1353 "cs.ATG" +#line 1361 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2530,92 +2546,92 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1358 "cs.ATG" +#line 1366 "cs.ATG" out expr); -#line 1358 "cs.ATG" +#line 1366 "cs.ATG" varDecl.Initializer = expr; } } void SimpleType( -#line 932 "cs.ATG" +#line 934 "cs.ATG" out string name) { -#line 933 "cs.ATG" +#line 935 "cs.ATG" name = String.Empty; if (StartOf(19)) { IntegralType( -#line 935 "cs.ATG" +#line 937 "cs.ATG" out name); } else if (la.kind == 73) { lexer.NextToken(); -#line 936 "cs.ATG" +#line 938 "cs.ATG" name = "float"; } else if (la.kind == 64) { lexer.NextToken(); -#line 937 "cs.ATG" +#line 939 "cs.ATG" name = "double"; } else if (la.kind == 60) { lexer.NextToken(); -#line 938 "cs.ATG" +#line 940 "cs.ATG" name = "decimal"; } else if (la.kind == 50) { lexer.NextToken(); -#line 939 "cs.ATG" +#line 941 "cs.ATG" name = "bool"; } else SynErr(153); } void NonArrayType( -#line 914 "cs.ATG" +#line 916 "cs.ATG" out TypeReference type) { -#line 916 "cs.ATG" +#line 918 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 89 || la.kind == 106) { ClassType( -#line 921 "cs.ATG" +#line 923 "cs.ATG" out type); } else if (StartOf(14)) { SimpleType( -#line 922 "cs.ATG" +#line 924 "cs.ATG" out name); -#line 922 "cs.ATG" +#line 924 "cs.ATG" type = new TypeReference(name); } else if (la.kind == 121) { lexer.NextToken(); Expect(6); -#line 923 "cs.ATG" +#line 925 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(154); while ( -#line 926 "cs.ATG" +#line 928 "cs.ATG" IsPointer()) { Expect(6); -#line 927 "cs.ATG" +#line 929 "cs.ATG" ++pointer; } -#line 929 "cs.ATG" +#line 931 "cs.ATG" if (type != null) { type.PointerNestingLevel = pointer; } } void FixedParameter( -#line 969 "cs.ATG" +#line 971 "cs.ATG" out ParameterDeclarationExpression p) { -#line 971 "cs.ATG" +#line 973 "cs.ATG" TypeReference type; ParamModifier mod = ParamModifier.In; @@ -2623,46 +2639,46 @@ out ParameterDeclarationExpression p) { if (la.kind == 98) { lexer.NextToken(); -#line 976 "cs.ATG" +#line 978 "cs.ATG" mod = ParamModifier.Ref; } else { lexer.NextToken(); -#line 977 "cs.ATG" +#line 979 "cs.ATG" mod = ParamModifier.Out; } } Type( -#line 979 "cs.ATG" +#line 981 "cs.ATG" out type); Expect(1); -#line 979 "cs.ATG" +#line 981 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); } void ParameterArray( -#line 982 "cs.ATG" +#line 984 "cs.ATG" out ParameterDeclarationExpression p) { -#line 983 "cs.ATG" +#line 985 "cs.ATG" TypeReference type; Expect(93); Type( -#line 985 "cs.ATG" +#line 987 "cs.ATG" out type); Expect(1); -#line 985 "cs.ATG" +#line 987 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, ParamModifier.Params); } void Block( -#line 1462 "cs.ATG" +#line 1470 "cs.ATG" out Statement stmt) { Expect(15); -#line 1464 "cs.ATG" +#line 1472 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); @@ -2673,7 +2689,7 @@ out Statement stmt) { } Expect(16); -#line 1471 "cs.ATG" +#line 1479 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2681,34 +2697,34 @@ out Statement stmt) { } void VariableDeclarator( -#line 1455 "cs.ATG" +#line 1463 "cs.ATG" List fieldDeclaration) { -#line 1456 "cs.ATG" +#line 1464 "cs.ATG" Expression expr = null; Expect(1); -#line 1458 "cs.ATG" +#line 1466 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1459 "cs.ATG" +#line 1467 "cs.ATG" out expr); -#line 1459 "cs.ATG" +#line 1467 "cs.ATG" f.Initializer = expr; } -#line 1459 "cs.ATG" +#line 1467 "cs.ATG" fieldDeclaration.Add(f); } void EventAccessorDecls( -#line 1404 "cs.ATG" +#line 1412 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1405 "cs.ATG" +#line 1413 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2717,102 +2733,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 17) { AttributeSection( -#line 1412 "cs.ATG" +#line 1420 "cs.ATG" out section); -#line 1412 "cs.ATG" +#line 1420 "cs.ATG" attributes.Add(section); } if ( -#line 1414 "cs.ATG" +#line 1422 "cs.ATG" IdentIsAdd()) { -#line 1414 "cs.ATG" +#line 1422 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1415 "cs.ATG" +#line 1423 "cs.ATG" out stmt); -#line 1415 "cs.ATG" +#line 1423 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 17) { AttributeSection( -#line 1416 "cs.ATG" +#line 1424 "cs.ATG" out section); -#line 1416 "cs.ATG" +#line 1424 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1417 "cs.ATG" +#line 1425 "cs.ATG" out stmt); -#line 1417 "cs.ATG" +#line 1425 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1418 "cs.ATG" +#line 1426 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1419 "cs.ATG" +#line 1427 "cs.ATG" out stmt); -#line 1419 "cs.ATG" +#line 1427 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 1420 "cs.ATG" +#line 1428 "cs.ATG" out section); -#line 1420 "cs.ATG" +#line 1428 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1421 "cs.ATG" +#line 1429 "cs.ATG" out stmt); -#line 1421 "cs.ATG" +#line 1429 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1422 "cs.ATG" +#line 1430 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(155); } void ConstructorInitializer( -#line 1493 "cs.ATG" +#line 1501 "cs.ATG" out ConstructorInitializer ci) { -#line 1494 "cs.ATG" +#line 1502 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 49) { lexer.NextToken(); -#line 1498 "cs.ATG" +#line 1506 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 109) { lexer.NextToken(); -#line 1499 "cs.ATG" +#line 1507 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(156); Expect(19); if (StartOf(21)) { Argument( -#line 1502 "cs.ATG" +#line 1510 "cs.ATG" out expr); -#line 1502 "cs.ATG" +#line 1510 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1502 "cs.ATG" +#line 1510 "cs.ATG" out expr); -#line 1502 "cs.ATG" +#line 1510 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -2820,161 +2836,161 @@ out expr); } void OverloadableOperator( -#line 1514 "cs.ATG" +#line 1522 "cs.ATG" out OverloadableOperatorType op) { -#line 1515 "cs.ATG" +#line 1523 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1517 "cs.ATG" +#line 1525 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1518 "cs.ATG" +#line 1526 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 23: { lexer.NextToken(); -#line 1520 "cs.ATG" +#line 1528 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 26: { lexer.NextToken(); -#line 1521 "cs.ATG" +#line 1529 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 30: { lexer.NextToken(); -#line 1523 "cs.ATG" +#line 1531 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 31: { lexer.NextToken(); -#line 1524 "cs.ATG" +#line 1532 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 111: { lexer.NextToken(); -#line 1526 "cs.ATG" +#line 1534 "cs.ATG" op = OverloadableOperatorType.True; break; } case 70: { lexer.NextToken(); -#line 1527 "cs.ATG" +#line 1535 "cs.ATG" op = OverloadableOperatorType.False; break; } case 6: { lexer.NextToken(); -#line 1529 "cs.ATG" +#line 1537 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1530 "cs.ATG" +#line 1538 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1531 "cs.ATG" +#line 1539 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 27: { lexer.NextToken(); -#line 1533 "cs.ATG" +#line 1541 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 28: { lexer.NextToken(); -#line 1534 "cs.ATG" +#line 1542 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 29: { lexer.NextToken(); -#line 1535 "cs.ATG" +#line 1543 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 36: { lexer.NextToken(); -#line 1537 "cs.ATG" +#line 1545 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 32: { lexer.NextToken(); -#line 1538 "cs.ATG" +#line 1546 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 33: { lexer.NextToken(); -#line 1539 "cs.ATG" +#line 1547 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 22: { lexer.NextToken(); -#line 1540 "cs.ATG" +#line 1548 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 34: { lexer.NextToken(); -#line 1541 "cs.ATG" +#line 1549 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 35: { lexer.NextToken(); -#line 1542 "cs.ATG" +#line 1550 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 21: { lexer.NextToken(); -#line 1543 "cs.ATG" +#line 1551 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 21) { lexer.NextToken(); -#line 1543 "cs.ATG" +#line 1551 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2984,10 +3000,10 @@ out OverloadableOperatorType op) { } void AccessorDecls( -#line 1362 "cs.ATG" +#line 1370 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1364 "cs.ATG" +#line 1372 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2995,136 +3011,136 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 17) { AttributeSection( -#line 1370 "cs.ATG" +#line 1378 "cs.ATG" out section); -#line 1370 "cs.ATG" +#line 1378 "cs.ATG" attributes.Add(section); } if ( -#line 1372 "cs.ATG" +#line 1380 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1373 "cs.ATG" +#line 1381 "cs.ATG" out getBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1374 "cs.ATG" +#line 1382 "cs.ATG" attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 1375 "cs.ATG" +#line 1383 "cs.ATG" out section); -#line 1375 "cs.ATG" +#line 1383 "cs.ATG" attributes.Add(section); } SetAccessorDecl( -#line 1376 "cs.ATG" +#line 1384 "cs.ATG" out setBlock, attributes); } } else if ( -#line 1378 "cs.ATG" +#line 1386 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1379 "cs.ATG" +#line 1387 "cs.ATG" out setBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1380 "cs.ATG" +#line 1388 "cs.ATG" attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 1381 "cs.ATG" +#line 1389 "cs.ATG" out section); -#line 1381 "cs.ATG" +#line 1389 "cs.ATG" attributes.Add(section); } GetAccessorDecl( -#line 1382 "cs.ATG" +#line 1390 "cs.ATG" out getBlock, attributes); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1384 "cs.ATG" +#line 1392 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(158); } void InterfaceAccessors( -#line 1426 "cs.ATG" +#line 1434 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1428 "cs.ATG" +#line 1436 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; while (la.kind == 17) { AttributeSection( -#line 1433 "cs.ATG" +#line 1441 "cs.ATG" out section); -#line 1433 "cs.ATG" +#line 1441 "cs.ATG" attributes.Add(section); } if ( -#line 1435 "cs.ATG" +#line 1443 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1435 "cs.ATG" +#line 1443 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1436 "cs.ATG" +#line 1444 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1436 "cs.ATG" +#line 1444 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1437 "cs.ATG" +#line 1445 "cs.ATG" Error("set or get expected"); } else SynErr(159); Expect(11); -#line 1439 "cs.ATG" +#line 1447 "cs.ATG" attributes = new List(); if (la.kind == 1 || la.kind == 17) { while (la.kind == 17) { AttributeSection( -#line 1441 "cs.ATG" +#line 1449 "cs.ATG" out section); -#line 1441 "cs.ATG" +#line 1449 "cs.ATG" attributes.Add(section); } if ( -#line 1443 "cs.ATG" +#line 1451 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1443 "cs.ATG" +#line 1451 "cs.ATG" if (getBlock != null) Error("get already declared"); else getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1446 "cs.ATG" +#line 1454 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1446 "cs.ATG" +#line 1454 "cs.ATG" if (setBlock != null) Error("set already declared"); else setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1449 "cs.ATG" +#line 1457 "cs.ATG" Error("set or get expected"); } else SynErr(160); Expect(11); @@ -3132,183 +3148,183 @@ IdentIsSet()) { } void GetAccessorDecl( -#line 1388 "cs.ATG" +#line 1396 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1389 "cs.ATG" +#line 1397 "cs.ATG" Statement stmt = null; Expect(1); -#line 1392 "cs.ATG" +#line 1400 "cs.ATG" if (t.val != "get") Error("get expected"); if (la.kind == 15) { Block( -#line 1393 "cs.ATG" +#line 1401 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(161); -#line 1393 "cs.ATG" +#line 1401 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); } void SetAccessorDecl( -#line 1396 "cs.ATG" +#line 1404 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1397 "cs.ATG" +#line 1405 "cs.ATG" Statement stmt = null; Expect(1); -#line 1400 "cs.ATG" +#line 1408 "cs.ATG" if (t.val != "set") Error("set expected"); if (la.kind == 15) { Block( -#line 1401 "cs.ATG" +#line 1409 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(162); -#line 1401 "cs.ATG" +#line 1409 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); } void AddAccessorDecl( -#line 1477 "cs.ATG" +#line 1485 "cs.ATG" out Statement stmt) { -#line 1478 "cs.ATG" +#line 1486 "cs.ATG" stmt = null; Expect(1); -#line 1481 "cs.ATG" +#line 1489 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1482 "cs.ATG" +#line 1490 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1485 "cs.ATG" +#line 1493 "cs.ATG" out Statement stmt) { -#line 1486 "cs.ATG" +#line 1494 "cs.ATG" stmt = null; Expect(1); -#line 1489 "cs.ATG" +#line 1497 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1490 "cs.ATG" +#line 1498 "cs.ATG" out stmt); } void VariableInitializer( -#line 1506 "cs.ATG" +#line 1514 "cs.ATG" out Expression initializerExpression) { -#line 1507 "cs.ATG" +#line 1515 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(4)) { Expr( -#line 1509 "cs.ATG" +#line 1517 "cs.ATG" out initializerExpression); } else if (la.kind == 15) { ArrayInitializer( -#line 1510 "cs.ATG" +#line 1518 "cs.ATG" out initializerExpression); } else if (la.kind == 104) { lexer.NextToken(); Type( -#line 1511 "cs.ATG" +#line 1519 "cs.ATG" out type); Expect(17); Expr( -#line 1511 "cs.ATG" +#line 1519 "cs.ATG" out expr); Expect(18); -#line 1511 "cs.ATG" +#line 1519 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(163); } void Statement() { -#line 1615 "cs.ATG" +#line 1623 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; Point startPos = la.Location; if ( -#line 1623 "cs.ATG" +#line 1631 "cs.ATG" IsLabel()) { Expect(1); -#line 1623 "cs.ATG" +#line 1631 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 58) { lexer.NextToken(); Type( -#line 1626 "cs.ATG" +#line 1634 "cs.ATG" out type); -#line 1626 "cs.ATG" +#line 1634 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1627 "cs.ATG" +#line 1635 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1628 "cs.ATG" +#line 1636 "cs.ATG" out expr); -#line 1628 "cs.ATG" +#line 1636 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1629 "cs.ATG" +#line 1637 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1629 "cs.ATG" +#line 1637 "cs.ATG" out expr); -#line 1629 "cs.ATG" +#line 1637 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1630 "cs.ATG" +#line 1638 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1632 "cs.ATG" +#line 1640 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1632 "cs.ATG" +#line 1640 "cs.ATG" out stmt); Expect(11); -#line 1632 "cs.ATG" +#line 1640 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(22)) { EmbeddedStatement( -#line 1633 "cs.ATG" +#line 1641 "cs.ATG" out stmt); -#line 1633 "cs.ATG" +#line 1641 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(164); -#line 1639 "cs.ATG" +#line 1647 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3317,10 +3333,10 @@ out stmt); } void Argument( -#line 1546 "cs.ATG" +#line 1554 "cs.ATG" out Expression argumentexpr) { -#line 1548 "cs.ATG" +#line 1556 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3328,48 +3344,48 @@ out Expression argumentexpr) { if (la.kind == 98) { lexer.NextToken(); -#line 1553 "cs.ATG" +#line 1561 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1554 "cs.ATG" +#line 1562 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1556 "cs.ATG" +#line 1564 "cs.ATG" out expr); -#line 1556 "cs.ATG" +#line 1564 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1575 "cs.ATG" +#line 1583 "cs.ATG" out Expression outExpr) { -#line 1577 "cs.ATG" +#line 1585 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(15); if (StartOf(23)) { VariableInitializer( -#line 1582 "cs.ATG" +#line 1590 "cs.ATG" out expr); -#line 1582 "cs.ATG" +#line 1590 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1582 "cs.ATG" +#line 1590 "cs.ATG" NotFinalComma()) { Expect(13); VariableInitializer( -#line 1582 "cs.ATG" +#line 1590 "cs.ATG" out expr); -#line 1582 "cs.ATG" +#line 1590 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 13) { @@ -3378,84 +3394,84 @@ out expr); } Expect(16); -#line 1583 "cs.ATG" +#line 1591 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1559 "cs.ATG" +#line 1567 "cs.ATG" out AssignmentOperatorType op) { -#line 1560 "cs.ATG" +#line 1568 "cs.ATG" op = AssignmentOperatorType.None; switch (la.kind) { case 3: { lexer.NextToken(); -#line 1562 "cs.ATG" +#line 1570 "cs.ATG" op = AssignmentOperatorType.Assign; break; } case 37: { lexer.NextToken(); -#line 1563 "cs.ATG" +#line 1571 "cs.ATG" op = AssignmentOperatorType.Add; break; } case 38: { lexer.NextToken(); -#line 1564 "cs.ATG" +#line 1572 "cs.ATG" op = AssignmentOperatorType.Subtract; break; } case 39: { lexer.NextToken(); -#line 1565 "cs.ATG" +#line 1573 "cs.ATG" op = AssignmentOperatorType.Multiply; break; } case 40: { lexer.NextToken(); -#line 1566 "cs.ATG" +#line 1574 "cs.ATG" op = AssignmentOperatorType.Divide; break; } case 41: { lexer.NextToken(); -#line 1567 "cs.ATG" +#line 1575 "cs.ATG" op = AssignmentOperatorType.Modulus; break; } case 42: { lexer.NextToken(); -#line 1568 "cs.ATG" +#line 1576 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; break; } case 43: { lexer.NextToken(); -#line 1569 "cs.ATG" +#line 1577 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; break; } case 44: { lexer.NextToken(); -#line 1570 "cs.ATG" +#line 1578 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; break; } case 45: { lexer.NextToken(); -#line 1571 "cs.ATG" +#line 1579 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; break; } @@ -3463,7 +3479,7 @@ out AssignmentOperatorType op) { lexer.NextToken(); Expect(34); -#line 1572 "cs.ATG" +#line 1580 "cs.ATG" op = AssignmentOperatorType.ShiftRight; break; } @@ -3472,66 +3488,66 @@ out AssignmentOperatorType op) { } void LocalVariableDecl( -#line 1586 "cs.ATG" +#line 1594 "cs.ATG" out Statement stmt) { -#line 1588 "cs.ATG" +#line 1596 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1593 "cs.ATG" +#line 1601 "cs.ATG" out type); -#line 1593 "cs.ATG" +#line 1601 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1594 "cs.ATG" +#line 1602 "cs.ATG" out var); -#line 1594 "cs.ATG" +#line 1602 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 13) { lexer.NextToken(); LocalVariableDeclarator( -#line 1595 "cs.ATG" +#line 1603 "cs.ATG" out var); -#line 1595 "cs.ATG" +#line 1603 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1596 "cs.ATG" +#line 1604 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1599 "cs.ATG" +#line 1607 "cs.ATG" out VariableDeclaration var) { -#line 1600 "cs.ATG" +#line 1608 "cs.ATG" Expression expr = null; Expect(1); -#line 1603 "cs.ATG" +#line 1611 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1603 "cs.ATG" +#line 1611 "cs.ATG" out expr); -#line 1603 "cs.ATG" +#line 1611 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1646 "cs.ATG" +#line 1654 "cs.ATG" out Statement statement) { -#line 1648 "cs.ATG" +#line 1656 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3539,156 +3555,156 @@ out Statement statement) { if (la.kind == 15) { Block( -#line 1654 "cs.ATG" +#line 1662 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1656 "cs.ATG" +#line 1664 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1658 "cs.ATG" +#line 1666 "cs.ATG" UnCheckedAndLBrace()) { -#line 1658 "cs.ATG" +#line 1666 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 56) { lexer.NextToken(); } else if (la.kind == 116) { lexer.NextToken(); -#line 1659 "cs.ATG" +#line 1667 "cs.ATG" isChecked = false; } else SynErr(166); Block( -#line 1660 "cs.ATG" +#line 1668 "cs.ATG" out block); -#line 1660 "cs.ATG" +#line 1668 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 77) { lexer.NextToken(); -#line 1662 "cs.ATG" +#line 1670 "cs.ATG" Statement elseStatement = null; Expect(19); Expr( -#line 1663 "cs.ATG" +#line 1671 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1664 "cs.ATG" +#line 1672 "cs.ATG" out embeddedStatement); if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1665 "cs.ATG" +#line 1673 "cs.ATG" out elseStatement); } -#line 1666 "cs.ATG" +#line 1674 "cs.ATG" statement = elseStatement != null ? (Statement)new IfElseStatement(expr, embeddedStatement, elseStatement) : (Statement)new IfElseStatement(expr, embeddedStatement); } else if (la.kind == 108) { lexer.NextToken(); -#line 1667 "cs.ATG" +#line 1675 "cs.ATG" ArrayList switchSections = new ArrayList(); SwitchSection switchSection; Expect(19); Expr( -#line 1668 "cs.ATG" +#line 1676 "cs.ATG" out expr); Expect(20); Expect(15); while (la.kind == 53 || la.kind == 61) { SwitchSection( -#line 1669 "cs.ATG" +#line 1677 "cs.ATG" out switchSection); -#line 1669 "cs.ATG" +#line 1677 "cs.ATG" switchSections.Add(switchSection); } Expect(16); -#line 1670 "cs.ATG" +#line 1678 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 123) { lexer.NextToken(); Expect(19); Expr( -#line 1672 "cs.ATG" +#line 1680 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1674 "cs.ATG" +#line 1682 "cs.ATG" out embeddedStatement); -#line 1674 "cs.ATG" +#line 1682 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 63) { lexer.NextToken(); EmbeddedStatement( -#line 1675 "cs.ATG" +#line 1683 "cs.ATG" out embeddedStatement); Expect(123); Expect(19); Expr( -#line 1676 "cs.ATG" +#line 1684 "cs.ATG" out expr); Expect(20); Expect(11); -#line 1676 "cs.ATG" +#line 1684 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 74) { lexer.NextToken(); -#line 1677 "cs.ATG" +#line 1685 "cs.ATG" ArrayList initializer = null; ArrayList iterator = null; Expect(19); if (StartOf(4)) { ForInitializer( -#line 1678 "cs.ATG" +#line 1686 "cs.ATG" out initializer); } Expect(11); if (StartOf(4)) { Expr( -#line 1679 "cs.ATG" +#line 1687 "cs.ATG" out expr); } Expect(11); if (StartOf(4)) { ForIterator( -#line 1680 "cs.ATG" +#line 1688 "cs.ATG" out iterator); } Expect(20); EmbeddedStatement( -#line 1681 "cs.ATG" +#line 1689 "cs.ATG" out embeddedStatement); -#line 1681 "cs.ATG" +#line 1689 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 75) { lexer.NextToken(); Expect(19); Type( -#line 1682 "cs.ATG" +#line 1690 "cs.ATG" out type); Expect(1); -#line 1682 "cs.ATG" +#line 1690 "cs.ATG" string varName = t.val; Point start = t.Location; Expect(79); Expr( -#line 1683 "cs.ATG" +#line 1691 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1684 "cs.ATG" +#line 1692 "cs.ATG" out embeddedStatement); -#line 1684 "cs.ATG" +#line 1692 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -3696,34 +3712,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1688 "cs.ATG" +#line 1696 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 59) { lexer.NextToken(); Expect(11); -#line 1689 "cs.ATG" +#line 1697 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 76) { GotoStatement( -#line 1690 "cs.ATG" +#line 1698 "cs.ATG" out statement); } else if ( -#line 1691 "cs.ATG" +#line 1699 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 99) { lexer.NextToken(); Expr( -#line 1691 "cs.ATG" +#line 1699 "cs.ATG" out expr); -#line 1691 "cs.ATG" +#line 1699 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 51) { lexer.NextToken(); -#line 1692 "cs.ATG" +#line 1700 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(167); Expect(11); @@ -3731,513 +3747,513 @@ out expr); lexer.NextToken(); if (StartOf(4)) { Expr( -#line 1693 "cs.ATG" +#line 1701 "cs.ATG" out expr); } Expect(11); -#line 1693 "cs.ATG" +#line 1701 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 110) { lexer.NextToken(); if (StartOf(4)) { Expr( -#line 1694 "cs.ATG" +#line 1702 "cs.ATG" out expr); } Expect(11); -#line 1694 "cs.ATG" +#line 1702 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(4)) { StatementExpr( -#line 1696 "cs.ATG" +#line 1704 "cs.ATG" out statement); Expect(11); } else if (la.kind == 112) { TryStatement( -#line 1698 "cs.ATG" +#line 1706 "cs.ATG" out statement); } else if (la.kind == 84) { lexer.NextToken(); Expect(19); Expr( -#line 1700 "cs.ATG" +#line 1708 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1701 "cs.ATG" +#line 1709 "cs.ATG" out embeddedStatement); -#line 1701 "cs.ATG" +#line 1709 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 119) { -#line 1703 "cs.ATG" +#line 1711 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(19); ResourceAcquisition( -#line 1705 "cs.ATG" +#line 1713 "cs.ATG" out resourceAcquisitionStmt); Expect(20); EmbeddedStatement( -#line 1706 "cs.ATG" +#line 1714 "cs.ATG" out embeddedStatement); -#line 1706 "cs.ATG" +#line 1714 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 117) { lexer.NextToken(); Block( -#line 1708 "cs.ATG" +#line 1716 "cs.ATG" out embeddedStatement); -#line 1708 "cs.ATG" +#line 1716 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 72) { lexer.NextToken(); Expect(19); Type( -#line 1711 "cs.ATG" +#line 1719 "cs.ATG" out type); -#line 1711 "cs.ATG" +#line 1719 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); ArrayList pointerDeclarators = new ArrayList(1); Expect(1); -#line 1714 "cs.ATG" +#line 1722 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1715 "cs.ATG" +#line 1723 "cs.ATG" out expr); -#line 1715 "cs.ATG" +#line 1723 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1717 "cs.ATG" +#line 1725 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1718 "cs.ATG" +#line 1726 "cs.ATG" out expr); -#line 1718 "cs.ATG" +#line 1726 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(20); EmbeddedStatement( -#line 1720 "cs.ATG" +#line 1728 "cs.ATG" out embeddedStatement); -#line 1720 "cs.ATG" +#line 1728 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(168); } void SwitchSection( -#line 1742 "cs.ATG" +#line 1750 "cs.ATG" out SwitchSection stmt) { -#line 1744 "cs.ATG" +#line 1752 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1748 "cs.ATG" +#line 1756 "cs.ATG" out label); -#line 1748 "cs.ATG" +#line 1756 "cs.ATG" switchSection.SwitchLabels.Add(label); while (la.kind == 53 || la.kind == 61) { SwitchLabel( -#line 1750 "cs.ATG" +#line 1758 "cs.ATG" out label); -#line 1750 "cs.ATG" +#line 1758 "cs.ATG" switchSection.SwitchLabels.Add(label); } -#line 1752 "cs.ATG" +#line 1760 "cs.ATG" compilationUnit.BlockStart(switchSection); Statement(); while (StartOf(20)) { Statement(); } -#line 1755 "cs.ATG" +#line 1763 "cs.ATG" compilationUnit.BlockEnd(); stmt = switchSection; } void ForInitializer( -#line 1723 "cs.ATG" +#line 1731 "cs.ATG" out ArrayList initializer) { -#line 1725 "cs.ATG" +#line 1733 "cs.ATG" Statement stmt; initializer = new ArrayList(); if ( -#line 1729 "cs.ATG" +#line 1737 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1729 "cs.ATG" +#line 1737 "cs.ATG" out stmt); -#line 1729 "cs.ATG" +#line 1737 "cs.ATG" initializer.Add(stmt); } else if (StartOf(4)) { StatementExpr( -#line 1730 "cs.ATG" +#line 1738 "cs.ATG" out stmt); -#line 1730 "cs.ATG" +#line 1738 "cs.ATG" initializer.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1730 "cs.ATG" +#line 1738 "cs.ATG" out stmt); -#line 1730 "cs.ATG" +#line 1738 "cs.ATG" initializer.Add(stmt); } -#line 1730 "cs.ATG" +#line 1738 "cs.ATG" initializer.Add(stmt); } else SynErr(169); } void ForIterator( -#line 1733 "cs.ATG" +#line 1741 "cs.ATG" out ArrayList iterator) { -#line 1735 "cs.ATG" +#line 1743 "cs.ATG" Statement stmt; iterator = new ArrayList(); StatementExpr( -#line 1739 "cs.ATG" +#line 1747 "cs.ATG" out stmt); -#line 1739 "cs.ATG" +#line 1747 "cs.ATG" iterator.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1739 "cs.ATG" +#line 1747 "cs.ATG" out stmt); -#line 1739 "cs.ATG" +#line 1747 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1810 "cs.ATG" +#line 1818 "cs.ATG" out Statement stmt) { -#line 1811 "cs.ATG" +#line 1819 "cs.ATG" Expression expr; stmt = null; Expect(76); if (la.kind == 1) { lexer.NextToken(); -#line 1815 "cs.ATG" +#line 1823 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1816 "cs.ATG" +#line 1824 "cs.ATG" out expr); Expect(11); -#line 1816 "cs.ATG" +#line 1824 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1817 "cs.ATG" +#line 1825 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(170); } void StatementExpr( -#line 1837 "cs.ATG" +#line 1845 "cs.ATG" out Statement stmt) { -#line 1842 "cs.ATG" +#line 1850 "cs.ATG" bool mustBeAssignment = la.kind == Tokens.Plus || la.kind == Tokens.Minus || la.kind == Tokens.Not || la.kind == Tokens.BitwiseComplement || la.kind == Tokens.Times || la.kind == Tokens.BitwiseAnd || IsTypeCast(); Expression expr = null; UnaryExpr( -#line 1848 "cs.ATG" +#line 1856 "cs.ATG" out expr); if (StartOf(6)) { -#line 1851 "cs.ATG" +#line 1859 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1851 "cs.ATG" +#line 1859 "cs.ATG" out op); Expr( -#line 1851 "cs.ATG" +#line 1859 "cs.ATG" out val); -#line 1851 "cs.ATG" +#line 1859 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else if (la.kind == 11 || la.kind == 13 || la.kind == 20) { -#line 1852 "cs.ATG" +#line 1860 "cs.ATG" if (mustBeAssignment) Error("error in assignment."); } else SynErr(171); -#line 1853 "cs.ATG" +#line 1861 "cs.ATG" stmt = new StatementExpression(expr); } void TryStatement( -#line 1767 "cs.ATG" +#line 1775 "cs.ATG" out Statement tryStatement) { -#line 1769 "cs.ATG" +#line 1777 "cs.ATG" Statement blockStmt = null, finallyStmt = null; ArrayList catchClauses = null; Expect(112); Block( -#line 1773 "cs.ATG" +#line 1781 "cs.ATG" out blockStmt); if (la.kind == 54) { CatchClauses( -#line 1775 "cs.ATG" +#line 1783 "cs.ATG" out catchClauses); if (la.kind == 71) { lexer.NextToken(); Block( -#line 1775 "cs.ATG" +#line 1783 "cs.ATG" out finallyStmt); } } else if (la.kind == 71) { lexer.NextToken(); Block( -#line 1776 "cs.ATG" +#line 1784 "cs.ATG" out finallyStmt); } else SynErr(172); -#line 1779 "cs.ATG" +#line 1787 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 1821 "cs.ATG" +#line 1829 "cs.ATG" out Statement stmt) { -#line 1823 "cs.ATG" +#line 1831 "cs.ATG" stmt = null; Expression expr; if ( -#line 1828 "cs.ATG" +#line 1836 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1828 "cs.ATG" +#line 1836 "cs.ATG" out stmt); } else if (StartOf(4)) { Expr( -#line 1829 "cs.ATG" +#line 1837 "cs.ATG" out expr); -#line 1833 "cs.ATG" +#line 1841 "cs.ATG" stmt = new StatementExpression(expr); } else SynErr(173); } void SwitchLabel( -#line 1760 "cs.ATG" +#line 1768 "cs.ATG" out CaseLabel label) { -#line 1761 "cs.ATG" +#line 1769 "cs.ATG" Expression expr = null; label = null; if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1763 "cs.ATG" +#line 1771 "cs.ATG" out expr); Expect(9); -#line 1763 "cs.ATG" +#line 1771 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(9); -#line 1764 "cs.ATG" +#line 1772 "cs.ATG" label = new CaseLabel(); } else SynErr(174); } void CatchClauses( -#line 1784 "cs.ATG" +#line 1792 "cs.ATG" out ArrayList catchClauses) { -#line 1786 "cs.ATG" +#line 1794 "cs.ATG" catchClauses = new ArrayList(); Expect(54); -#line 1789 "cs.ATG" +#line 1797 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; if (la.kind == 15) { Block( -#line 1795 "cs.ATG" +#line 1803 "cs.ATG" out stmt); -#line 1795 "cs.ATG" +#line 1803 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 19) { lexer.NextToken(); ClassType( -#line 1797 "cs.ATG" +#line 1805 "cs.ATG" out typeRef); -#line 1797 "cs.ATG" +#line 1805 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1798 "cs.ATG" +#line 1806 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1799 "cs.ATG" +#line 1807 "cs.ATG" out stmt); -#line 1800 "cs.ATG" +#line 1808 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); while ( -#line 1801 "cs.ATG" +#line 1809 "cs.ATG" IsTypedCatch()) { Expect(54); Expect(19); ClassType( -#line 1801 "cs.ATG" +#line 1809 "cs.ATG" out typeRef); -#line 1801 "cs.ATG" +#line 1809 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1802 "cs.ATG" +#line 1810 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1803 "cs.ATG" +#line 1811 "cs.ATG" out stmt); -#line 1804 "cs.ATG" +#line 1812 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); } if (la.kind == 54) { lexer.NextToken(); Block( -#line 1806 "cs.ATG" +#line 1814 "cs.ATG" out stmt); -#line 1806 "cs.ATG" +#line 1814 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(175); } void UnaryExpr( -#line 1869 "cs.ATG" +#line 1877 "cs.ATG" out Expression uExpr) { -#line 1871 "cs.ATG" +#line 1879 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(24) || -#line 1895 "cs.ATG" +#line 1903 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1880 "cs.ATG" +#line 1888 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1881 "cs.ATG" +#line 1889 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 23) { lexer.NextToken(); -#line 1882 "cs.ATG" +#line 1890 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 26) { lexer.NextToken(); -#line 1883 "cs.ATG" +#line 1891 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1884 "cs.ATG" +#line 1892 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 30) { lexer.NextToken(); -#line 1885 "cs.ATG" +#line 1893 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1886 "cs.ATG" +#line 1894 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1887 "cs.ATG" +#line 1895 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(19); Type( -#line 1895 "cs.ATG" +#line 1903 "cs.ATG" out type); Expect(20); -#line 1895 "cs.ATG" +#line 1903 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 1899 "cs.ATG" +#line 1907 "cs.ATG" out expr); -#line 1899 "cs.ATG" +#line 1907 "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) { @@ -4255,33 +4271,33 @@ out expr); } void ConditionalOrExpr( -#line 2082 "cs.ATG" +#line 2090 "cs.ATG" ref Expression outExpr) { -#line 2083 "cs.ATG" +#line 2091 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2085 "cs.ATG" +#line 2093 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2085 "cs.ATG" +#line 2093 "cs.ATG" out expr); ConditionalAndExpr( -#line 2085 "cs.ATG" +#line 2093 "cs.ATG" ref expr); -#line 2085 "cs.ATG" +#line 2093 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1916 "cs.ATG" +#line 1924 "cs.ATG" out Expression pexpr) { -#line 1918 "cs.ATG" +#line 1926 "cs.ATG" TypeReference type = null; List typeList = null; bool isArrayCreation = false; @@ -4291,340 +4307,340 @@ out Expression pexpr) { if (la.kind == 111) { lexer.NextToken(); -#line 1926 "cs.ATG" +#line 1934 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 70) { lexer.NextToken(); -#line 1927 "cs.ATG" +#line 1935 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 88) { lexer.NextToken(); -#line 1928 "cs.ATG" +#line 1936 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1929 "cs.ATG" +#line 1937 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); } else if ( -#line 1930 "cs.ATG" +#line 1938 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { TypeName( -#line 1931 "cs.ATG" +#line 1939 "cs.ATG" out type); -#line 1931 "cs.ATG" +#line 1939 "cs.ATG" pexpr = new TypeReferenceExpression(type); } else if (la.kind == 1) { lexer.NextToken(); -#line 1933 "cs.ATG" +#line 1941 "cs.ATG" pexpr = new IdentifierExpression(t.val); } else if (la.kind == 19) { lexer.NextToken(); Expr( -#line 1935 "cs.ATG" +#line 1943 "cs.ATG" out expr); Expect(20); -#line 1935 "cs.ATG" +#line 1943 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(25)) { -#line 1937 "cs.ATG" +#line 1945 "cs.ATG" string val = null; switch (la.kind) { case 50: { lexer.NextToken(); -#line 1939 "cs.ATG" +#line 1947 "cs.ATG" val = "bool"; break; } case 52: { lexer.NextToken(); -#line 1940 "cs.ATG" +#line 1948 "cs.ATG" val = "byte"; break; } case 55: { lexer.NextToken(); -#line 1941 "cs.ATG" +#line 1949 "cs.ATG" val = "char"; break; } case 60: { lexer.NextToken(); -#line 1942 "cs.ATG" +#line 1950 "cs.ATG" val = "decimal"; break; } case 64: { lexer.NextToken(); -#line 1943 "cs.ATG" +#line 1951 "cs.ATG" val = "double"; break; } case 73: { lexer.NextToken(); -#line 1944 "cs.ATG" +#line 1952 "cs.ATG" val = "float"; break; } case 80: { lexer.NextToken(); -#line 1945 "cs.ATG" +#line 1953 "cs.ATG" val = "int"; break; } case 85: { lexer.NextToken(); -#line 1946 "cs.ATG" +#line 1954 "cs.ATG" val = "long"; break; } case 89: { lexer.NextToken(); -#line 1947 "cs.ATG" +#line 1955 "cs.ATG" val = "object"; break; } case 100: { lexer.NextToken(); -#line 1948 "cs.ATG" +#line 1956 "cs.ATG" val = "sbyte"; break; } case 102: { lexer.NextToken(); -#line 1949 "cs.ATG" +#line 1957 "cs.ATG" val = "short"; break; } case 106: { lexer.NextToken(); -#line 1950 "cs.ATG" +#line 1958 "cs.ATG" val = "string"; break; } case 114: { lexer.NextToken(); -#line 1951 "cs.ATG" +#line 1959 "cs.ATG" val = "uint"; break; } case 115: { lexer.NextToken(); -#line 1952 "cs.ATG" +#line 1960 "cs.ATG" val = "ulong"; break; } case 118: { lexer.NextToken(); -#line 1953 "cs.ATG" +#line 1961 "cs.ATG" val = "ushort"; break; } } -#line 1954 "cs.ATG" +#line 1962 "cs.ATG" t.val = ""; Expect(14); Expect(1); -#line 1954 "cs.ATG" +#line 1962 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); } else if (la.kind == 109) { lexer.NextToken(); -#line 1956 "cs.ATG" +#line 1964 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 49) { lexer.NextToken(); -#line 1958 "cs.ATG" +#line 1966 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1960 "cs.ATG" +#line 1968 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 17) { lexer.NextToken(); Expr( -#line 1961 "cs.ATG" +#line 1969 "cs.ATG" out expr); -#line 1961 "cs.ATG" +#line 1969 "cs.ATG" ArrayList indices = new ArrayList(); if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1962 "cs.ATG" +#line 1970 "cs.ATG" out expr); -#line 1962 "cs.ATG" +#line 1970 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 1963 "cs.ATG" +#line 1971 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(176); -#line 1964 "cs.ATG" +#line 1972 "cs.ATG" pexpr = retExpr; } else if (la.kind == 87) { lexer.NextToken(); NonArrayType( -#line 1965 "cs.ATG" +#line 1973 "cs.ATG" out type); -#line 1965 "cs.ATG" +#line 1973 "cs.ATG" ArrayList parameters = new ArrayList(); if (la.kind == 19) { lexer.NextToken(); -#line 1970 "cs.ATG" +#line 1978 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 1971 "cs.ATG" +#line 1979 "cs.ATG" out expr); -#line 1971 "cs.ATG" +#line 1979 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1972 "cs.ATG" +#line 1980 "cs.ATG" out expr); -#line 1972 "cs.ATG" +#line 1980 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(20); -#line 1974 "cs.ATG" +#line 1982 "cs.ATG" pexpr = oce; } else if (la.kind == 17) { -#line 1976 "cs.ATG" +#line 1984 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; lexer.NextToken(); -#line 1977 "cs.ATG" +#line 1985 "cs.ATG" int dims = 0; ArrayList rank = new ArrayList(); ArrayList parameterExpression = new ArrayList(); if (StartOf(4)) { Expr( -#line 1981 "cs.ATG" +#line 1989 "cs.ATG" out expr); -#line 1981 "cs.ATG" +#line 1989 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1983 "cs.ATG" +#line 1991 "cs.ATG" out expr); -#line 1983 "cs.ATG" +#line 1991 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } } Expect(18); -#line 1985 "cs.ATG" +#line 1993 "cs.ATG" parameters.Add(new ArrayCreationParameter(parameterExpression)); ace.Parameters = parameters; while ( -#line 1988 "cs.ATG" +#line 1996 "cs.ATG" IsDims()) { Expect(17); -#line 1988 "cs.ATG" +#line 1996 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 1989 "cs.ATG" +#line 1997 "cs.ATG" dims++; } -#line 1989 "cs.ATG" +#line 1997 "cs.ATG" rank.Add(dims); parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } -#line 1993 "cs.ATG" +#line 2001 "cs.ATG" if (rank.Count > 0) { ace.Rank = (int[])rank.ToArray(typeof (int)); } if (la.kind == 15) { ArrayInitializer( -#line 1997 "cs.ATG" +#line 2005 "cs.ATG" out expr); -#line 1997 "cs.ATG" +#line 2005 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else if (la.kind == 13 || la.kind == 18) { while (la.kind == 13) { lexer.NextToken(); -#line 1999 "cs.ATG" +#line 2007 "cs.ATG" dims++; } -#line 2000 "cs.ATG" +#line 2008 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); while ( -#line 2002 "cs.ATG" +#line 2010 "cs.ATG" IsDims()) { Expect(17); -#line 2002 "cs.ATG" +#line 2010 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 2002 "cs.ATG" +#line 2010 "cs.ATG" dims++; } -#line 2002 "cs.ATG" +#line 2010 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } ArrayInitializer( -#line 2002 "cs.ATG" +#line 2010 "cs.ATG" out expr); -#line 2002 "cs.ATG" +#line 2010 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters; } else SynErr(177); } else SynErr(178); @@ -4632,192 +4648,192 @@ out expr); lexer.NextToken(); Expect(19); if ( -#line 2008 "cs.ATG" +#line 2016 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 2008 "cs.ATG" +#line 2016 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(8)) { Type( -#line 2009 "cs.ATG" +#line 2017 "cs.ATG" out type); } else SynErr(179); Expect(20); -#line 2010 "cs.ATG" +#line 2018 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 103) { lexer.NextToken(); Expect(19); Type( -#line 2011 "cs.ATG" +#line 2019 "cs.ATG" out type); Expect(20); -#line 2011 "cs.ATG" +#line 2019 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 56) { lexer.NextToken(); Expect(19); Expr( -#line 2012 "cs.ATG" +#line 2020 "cs.ATG" out expr); Expect(20); -#line 2012 "cs.ATG" +#line 2020 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 116) { lexer.NextToken(); Expect(19); Expr( -#line 2013 "cs.ATG" +#line 2021 "cs.ATG" out expr); Expect(20); -#line 2013 "cs.ATG" +#line 2021 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 62) { lexer.NextToken(); AnonymousMethodExpr( -#line 2014 "cs.ATG" +#line 2022 "cs.ATG" out expr); -#line 2014 "cs.ATG" +#line 2022 "cs.ATG" pexpr = expr; } else SynErr(180); while (StartOf(26) || -#line 2035 "cs.ATG" -IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || #line 2043 "cs.ATG" +IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || +#line 2051 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 30 || la.kind == 31) { if (la.kind == 30) { lexer.NextToken(); -#line 2018 "cs.ATG" +#line 2026 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 31) { lexer.NextToken(); -#line 2019 "cs.ATG" +#line 2027 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(181); } else if (la.kind == 46) { lexer.NextToken(); Expect(1); -#line 2022 "cs.ATG" +#line 2030 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 2023 "cs.ATG" +#line 2031 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if ( -#line 2035 "cs.ATG" +#line 2043 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) { TypeArgumentList( -#line 2036 "cs.ATG" +#line 2044 "cs.ATG" out typeList); Expect(14); Expect(1); -#line 2037 "cs.ATG" +#line 2045 "cs.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeList), t.val); } else if (la.kind == 19) { lexer.NextToken(); -#line 2039 "cs.ATG" +#line 2047 "cs.ATG" ArrayList parameters = new ArrayList(); if (StartOf(21)) { Argument( -#line 2040 "cs.ATG" +#line 2048 "cs.ATG" out expr); -#line 2040 "cs.ATG" +#line 2048 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 13) { lexer.NextToken(); Argument( -#line 2041 "cs.ATG" +#line 2049 "cs.ATG" out expr); -#line 2041 "cs.ATG" +#line 2049 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(20); -#line 2042 "cs.ATG" +#line 2050 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else if ( -#line 2043 "cs.ATG" +#line 2051 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { TypeArgumentList( -#line 2043 "cs.ATG" +#line 2051 "cs.ATG" out typeList); Expect(19); -#line 2044 "cs.ATG" +#line 2052 "cs.ATG" ArrayList parameters = new ArrayList(); if (StartOf(21)) { Argument( -#line 2045 "cs.ATG" +#line 2053 "cs.ATG" out expr); -#line 2045 "cs.ATG" +#line 2053 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 13) { lexer.NextToken(); Argument( -#line 2046 "cs.ATG" +#line 2054 "cs.ATG" out expr); -#line 2046 "cs.ATG" +#line 2054 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(20); -#line 2047 "cs.ATG" +#line 2055 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 2049 "cs.ATG" +#line 2057 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); ArrayList indices = new ArrayList(); lexer.NextToken(); Expr( -#line 2052 "cs.ATG" +#line 2060 "cs.ATG" out expr); -#line 2052 "cs.ATG" +#line 2060 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 2053 "cs.ATG" +#line 2061 "cs.ATG" out expr); -#line 2053 "cs.ATG" +#line 2061 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 2054 "cs.ATG" +#line 2062 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void AnonymousMethodExpr( -#line 2058 "cs.ATG" +#line 2066 "cs.ATG" out Expression outExpr) { -#line 2060 "cs.ATG" +#line 2068 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; Statement stmt; @@ -4827,336 +4843,336 @@ out Expression outExpr) { Expect(19); if (StartOf(9)) { FormalParameterList( -#line 2068 "cs.ATG" +#line 2076 "cs.ATG" p); -#line 2068 "cs.ATG" +#line 2076 "cs.ATG" expr.Parameters = p; } Expect(20); -#line 2072 "cs.ATG" +#line 2080 "cs.ATG" if (compilationUnit != null) { Block( -#line 2073 "cs.ATG" +#line 2081 "cs.ATG" out stmt); -#line 2073 "cs.ATG" +#line 2081 "cs.ATG" expr.Body = (BlockStatement)stmt; -#line 2074 "cs.ATG" +#line 2082 "cs.ATG" } else { Expect(15); -#line 2076 "cs.ATG" +#line 2084 "cs.ATG" lexer.SkipCurrentBlock(); Expect(16); -#line 2078 "cs.ATG" +#line 2086 "cs.ATG" } -#line 2079 "cs.ATG" +#line 2087 "cs.ATG" expr.EndLocation = t.Location; } void TypeArgumentList( -#line 2228 "cs.ATG" +#line 2236 "cs.ATG" out List types) { -#line 2230 "cs.ATG" +#line 2238 "cs.ATG" types = new List(); TypeReference type = null; Expect(22); Type( -#line 2234 "cs.ATG" +#line 2242 "cs.ATG" out type); -#line 2234 "cs.ATG" +#line 2242 "cs.ATG" types.Add(type); while (la.kind == 13) { lexer.NextToken(); Type( -#line 2235 "cs.ATG" +#line 2243 "cs.ATG" out type); -#line 2235 "cs.ATG" +#line 2243 "cs.ATG" types.Add(type); } Expect(21); } void ConditionalAndExpr( -#line 2088 "cs.ATG" +#line 2096 "cs.ATG" ref Expression outExpr) { -#line 2089 "cs.ATG" +#line 2097 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2091 "cs.ATG" +#line 2099 "cs.ATG" ref outExpr); while (la.kind == 24) { lexer.NextToken(); UnaryExpr( -#line 2091 "cs.ATG" +#line 2099 "cs.ATG" out expr); InclusiveOrExpr( -#line 2091 "cs.ATG" +#line 2099 "cs.ATG" ref expr); -#line 2091 "cs.ATG" +#line 2099 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2094 "cs.ATG" +#line 2102 "cs.ATG" ref Expression outExpr) { -#line 2095 "cs.ATG" +#line 2103 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2097 "cs.ATG" +#line 2105 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2097 "cs.ATG" +#line 2105 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2097 "cs.ATG" +#line 2105 "cs.ATG" ref expr); -#line 2097 "cs.ATG" +#line 2105 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2100 "cs.ATG" +#line 2108 "cs.ATG" ref Expression outExpr) { -#line 2101 "cs.ATG" +#line 2109 "cs.ATG" Expression expr; AndExpr( -#line 2103 "cs.ATG" +#line 2111 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2103 "cs.ATG" +#line 2111 "cs.ATG" out expr); AndExpr( -#line 2103 "cs.ATG" +#line 2111 "cs.ATG" ref expr); -#line 2103 "cs.ATG" +#line 2111 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2106 "cs.ATG" +#line 2114 "cs.ATG" ref Expression outExpr) { -#line 2107 "cs.ATG" +#line 2115 "cs.ATG" Expression expr; EqualityExpr( -#line 2109 "cs.ATG" +#line 2117 "cs.ATG" ref outExpr); while (la.kind == 27) { lexer.NextToken(); UnaryExpr( -#line 2109 "cs.ATG" +#line 2117 "cs.ATG" out expr); EqualityExpr( -#line 2109 "cs.ATG" +#line 2117 "cs.ATG" ref expr); -#line 2109 "cs.ATG" +#line 2117 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2112 "cs.ATG" +#line 2120 "cs.ATG" ref Expression outExpr) { -#line 2114 "cs.ATG" +#line 2122 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2118 "cs.ATG" +#line 2126 "cs.ATG" ref outExpr); while (la.kind == 32 || la.kind == 33) { if (la.kind == 33) { lexer.NextToken(); -#line 2121 "cs.ATG" +#line 2129 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2122 "cs.ATG" +#line 2130 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2124 "cs.ATG" +#line 2132 "cs.ATG" out expr); RelationalExpr( -#line 2124 "cs.ATG" +#line 2132 "cs.ATG" ref expr); -#line 2124 "cs.ATG" +#line 2132 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2128 "cs.ATG" +#line 2136 "cs.ATG" ref Expression outExpr) { -#line 2130 "cs.ATG" +#line 2138 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2135 "cs.ATG" +#line 2143 "cs.ATG" ref outExpr); while (StartOf(27)) { if (StartOf(28)) { if (la.kind == 22) { lexer.NextToken(); -#line 2138 "cs.ATG" +#line 2146 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 21) { lexer.NextToken(); -#line 2139 "cs.ATG" +#line 2147 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 35) { lexer.NextToken(); -#line 2140 "cs.ATG" +#line 2148 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 34) { lexer.NextToken(); -#line 2141 "cs.ATG" +#line 2149 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(182); UnaryExpr( -#line 2143 "cs.ATG" +#line 2151 "cs.ATG" out expr); ShiftExpr( -#line 2143 "cs.ATG" +#line 2151 "cs.ATG" ref expr); -#line 2143 "cs.ATG" +#line 2151 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 83) { lexer.NextToken(); -#line 2146 "cs.ATG" +#line 2154 "cs.ATG" op = BinaryOperatorType.TypeCheck; } else if (la.kind == 48) { lexer.NextToken(); -#line 2147 "cs.ATG" +#line 2155 "cs.ATG" op = BinaryOperatorType.AsCast; } else SynErr(183); Type( -#line 2149 "cs.ATG" +#line 2157 "cs.ATG" out type); -#line 2149 "cs.ATG" +#line 2157 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, new TypeReferenceExpression(type)); } } } void ShiftExpr( -#line 2153 "cs.ATG" +#line 2161 "cs.ATG" ref Expression outExpr) { -#line 2155 "cs.ATG" +#line 2163 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2159 "cs.ATG" +#line 2167 "cs.ATG" ref outExpr); while (la.kind == 36 || -#line 2162 "cs.ATG" +#line 2170 "cs.ATG" IsShiftRight()) { if (la.kind == 36) { lexer.NextToken(); -#line 2161 "cs.ATG" +#line 2169 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(21); Expect(21); -#line 2163 "cs.ATG" +#line 2171 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2166 "cs.ATG" +#line 2174 "cs.ATG" out expr); AdditiveExpr( -#line 2166 "cs.ATG" +#line 2174 "cs.ATG" ref expr); -#line 2166 "cs.ATG" +#line 2174 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2170 "cs.ATG" +#line 2178 "cs.ATG" ref Expression outExpr) { -#line 2172 "cs.ATG" +#line 2180 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2176 "cs.ATG" +#line 2184 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2179 "cs.ATG" +#line 2187 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2180 "cs.ATG" +#line 2188 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2182 "cs.ATG" +#line 2190 "cs.ATG" out expr); MultiplicativeExpr( -#line 2182 "cs.ATG" +#line 2190 "cs.ATG" ref expr); -#line 2182 "cs.ATG" +#line 2190 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2186 "cs.ATG" +#line 2194 "cs.ATG" ref Expression outExpr) { -#line 2188 "cs.ATG" +#line 2196 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5164,57 +5180,57 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2194 "cs.ATG" +#line 2202 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2195 "cs.ATG" +#line 2203 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2196 "cs.ATG" +#line 2204 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2198 "cs.ATG" +#line 2206 "cs.ATG" out expr); -#line 2198 "cs.ATG" +#line 2206 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2280 "cs.ATG" +#line 2288 "cs.ATG" out TypeReference type) { -#line 2281 "cs.ATG" +#line 2289 "cs.ATG" TypeReference t; type = null; if (la.kind == 107) { lexer.NextToken(); -#line 2283 "cs.ATG" +#line 2291 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 57) { lexer.NextToken(); -#line 2284 "cs.ATG" +#line 2292 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 87) { lexer.NextToken(); Expect(19); Expect(20); -#line 2285 "cs.ATG" +#line 2293 "cs.ATG" type = new TypeReference("struct"); } else if (StartOf(8)) { Type( -#line 2286 "cs.ATG" +#line 2294 "cs.ATG" out t); -#line 2286 "cs.ATG" +#line 2294 "cs.ATG" type = t; } else SynErr(184); } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index cf72db73cf..0556bf8ee2 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -906,8 +906,10 @@ Type | "[" { "," (. ++i; .) } "]" (. r.Add(i); .) ) } - (. type.RankSpecifier = r.ToArray(); - type.PointerNestingLevel = pointer; + (. if (type != null) { + type.RankSpecifier = r.ToArray(); + type.PointerNestingLevel = pointer; + } .) . @@ -1303,11 +1305,16 @@ InterfaceMemberDecl ( /*--- interface void method (procedure) declaration: */ IF (NotVoidPointer()) "void" (. if (startLocation.X == -1) startLocation = t.Location; .) ident (. name = t.val; .) - "(" [ FormalParameterList ] ")" ";" (. MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); - md.StartLocation = startLocation; - md.EndLocation = t.EndLocation; - compilationUnit.AddChild(md); - .) + [ TypeParameterList ] + "(" [ FormalParameterList ] ")" + { IF (IdentIsWhere()) TypeParameterConstraintsClause } + ";" + (. MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); + md.StartLocation = startLocation; + md.EndLocation = t.EndLocation; + md.Templates = templates; + compilationUnit.AddChild(md); + .) | ( Type (. if (startLocation.X == -1) startLocation = t.Location; .) ( @@ -1319,11 +1326,12 @@ InterfaceMemberDecl "(" [ FormalParameterList ] ")" /* .NET 2.0 */ { IF (IdentIsWhere()) TypeParameterConstraintsClause } - ";" (. MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); - md.StartLocation = startLocation; - md.EndLocation = t.EndLocation; - compilationUnit.AddChild(md); - .) + ";" (. MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); + md.StartLocation = startLocation; + md.EndLocation = t.EndLocation; + md.Templates = templates; + compilationUnit.AddChild(md); + .) /*--- interface property declaration: */ | (. PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); .) "{" (. Point bodyStart = t.Location;.) InterfaceAccessors "}" (. pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; .) diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs index fd62b09e9b..dc3db4314d 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs @@ -111,6 +111,46 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.AreEqual(1, md.Templates[0].Bases.Count); Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type); } + + [Test] + public void CSharpGenericMethodInInterface() + { + const string program = @"interface MyInterface { + T MyMethod(T a) where T : ISomeInterface; +} +"; + TypeDeclaration td = (TypeDeclaration)ParseUtilCSharp.ParseGlobal(program, typeof(TypeDeclaration)); + MethodDeclaration md = (MethodDeclaration)td.Children[0]; + Assert.AreEqual("T", md.TypeReference.Type); + Assert.AreEqual(1, md.Parameters.Count); + Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); + Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); + + Assert.AreEqual(1, md.Templates.Count); + Assert.AreEqual("T", md.Templates[0].Name); + Assert.AreEqual(1, md.Templates[0].Bases.Count); + Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type); + } + + [Test] + public void CSharpGenericVoidMethodInInterface() + { + const string program = @"interface MyInterface { + void MyMethod(T a) where T : ISomeInterface; +} +"; + TypeDeclaration td = (TypeDeclaration)ParseUtilCSharp.ParseGlobal(program, typeof(TypeDeclaration)); + MethodDeclaration md = (MethodDeclaration)td.Children[0]; + Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual(1, md.Parameters.Count); + Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); + Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); + + Assert.AreEqual(1, md.Templates.Count); + Assert.AreEqual("T", md.Templates[0].Name); + Assert.AreEqual(1, md.Templates[0].Bases.Count); + Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type); + } #endregion #region VB.NET diff --git a/src/Main/Base/Project/Src/Dom/ExpressionContext.cs b/src/Main/Base/Project/Src/Dom/ExpressionContext.cs index df407e3846..1920717f4d 100644 --- a/src/Main/Base/Project/Src/Dom/ExpressionContext.cs +++ b/src/Main/Base/Project/Src/Dom/ExpressionContext.cs @@ -11,15 +11,52 @@ using ICSharpCode.Core; namespace ICSharpCode.SharpDevelop.Dom { /// - /// Class describing a contexts in which an expressions can be. + /// Class describing a context in which an expression can be. /// Serves as filter for code completion results, but the contexts exposed as static fields /// can also be used as a kind of enumeration for special behaviour in the resolver. /// public abstract class ExpressionContext { + #region Instance members public abstract bool ShowEntry(object o); - #region Default contexts (public fields) + protected bool readOnly = true; + object suggestedItem; + + /// + /// Gets if the expression is in the context of an object creation. + /// + public virtual bool IsObjectCreation { + get { + return false; + } + set { + if (value) + throw new NotSupportedException(); + } + } + + /// + /// Gets/Sets the default item that should be included in a code completion popup + /// in this context and selected as default value. + /// + /// + /// "List<TypeName> var = new *expr*();" has as suggested item the pseudo-class + /// "List<TypeName>". + /// + public object SuggestedItem { + get { + return suggestedItem; + } + set { + if (readOnly) + throw new NotSupportedException(); + suggestedItem = value; + } + } + #endregion + + #region Default contexts (public static fields) /// Default/unknown context public static ExpressionContext Default = new DefaultExpressionContext(); @@ -29,31 +66,32 @@ namespace ICSharpCode.SharpDevelop.Dom /// Context expects a type name /// typeof(*expr*), is *expr*, using(*expr* ...) - public static ExpressionContext Type = new TypeExpressionContext(null, false); + public static ExpressionContext Type = new TypeExpressionContext(null, false, true); /// Context expects a non-abstract type that has accessible constructors /// new *expr*(); /// When using this context, a resolver should treat the expression as object creation, /// even when the keyword "new" is not part of the expression. - public static ExpressionContext ObjectCreation = new TypeExpressionContext(null, true); + public static ExpressionContext ObjectCreation = new TypeExpressionContext(null, true, true); /// Context expects a non-abstract type deriving from System.Attribute. /// [*expr*()] /// When using this context, a resolver should try resolving typenames with an /// appended "Attribute" suffix and treat "invocations" of the attribute type as /// object creation. - public static ExpressionContext Attribute = new TypeExpressionContext(ProjectContentRegistry.Mscorlib.GetClass("System.Attribute"), true); + public static ExpressionContext Attribute = new TypeExpressionContext(ProjectContentRegistry.Mscorlib.GetClass("System.Attribute"), true, true); /// Context expects a type name which has special base type /// The class the expression must derive from. - /// Specifies whether classes must be constructable. + /// Specifies whether classes must be constructable. /// catch(*expr* ...), using(*expr* ...), throw new *** - public static ExpressionContext TypeDerivingFrom(IClass baseClass, bool mustBeConstructable) + public static ExpressionContext TypeDerivingFrom(IClass baseClass, bool isObjectCreation) { - return new TypeExpressionContext(baseClass, mustBeConstructable); + return new TypeExpressionContext(baseClass, isObjectCreation, false); } - /// Context expeacts an interface + /// Context expects an interface + /// Implements *expr* public static InterfaceExpressionContext Interface = new InterfaceExpressionContext(); #endregion @@ -92,12 +130,13 @@ namespace ICSharpCode.SharpDevelop.Dom class TypeExpressionContext : ExpressionContext { IClass baseClass; - bool mustBeConstructable; + bool isObjectCreation; - public TypeExpressionContext(IClass baseClass, bool mustBeConstructable) + public TypeExpressionContext(IClass baseClass, bool isObjectCreation, bool readOnly) { this.baseClass = baseClass; - this.mustBeConstructable = mustBeConstructable; + this.isObjectCreation = isObjectCreation; + this.readOnly = readOnly; } public override bool ShowEntry(object o) @@ -107,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Dom IClass c = o as IClass; if (c == null) return false; - if (mustBeConstructable) { + if (isObjectCreation) { if (c.IsAbstract || c.IsStatic) return false; if (c.ClassType == ClassType.Enum) return false; } @@ -116,13 +155,24 @@ namespace ICSharpCode.SharpDevelop.Dom return c.IsTypeInInheritanceTree(baseClass); } + public override bool IsObjectCreation { + get { + return isObjectCreation; + } + set { + if (readOnly && value != isObjectCreation) + throw new NotSupportedException(); + isObjectCreation = value; + } + } + public override string ToString() { if (baseClass != null) return "[" + GetType().Name + ": " + baseClass.FullyQualifiedName - + " mustBeConstructable=" + mustBeConstructable + "]"; + + " IsObjectCreation=" + IsObjectCreation + "]"; else - return "[" + GetType().Name + " mustBeConstructable=" + mustBeConstructable + "]"; + return "[" + GetType().Name + " IsObjectCreation=" + IsObjectCreation + "]"; } } #endregion @@ -184,8 +234,6 @@ namespace ICSharpCode.SharpDevelop.Dom #region InterfaceExpressionContext public class InterfaceExpressionContext : ExpressionContext { - IClass baseClass; - public InterfaceExpressionContext() { } diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs index aa750ee9d1..69ba59245d 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs @@ -118,7 +118,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } expression = expression.TrimStart(); - if (expressionResult.Context == ExpressionContext.ObjectCreation) { + if (expressionResult.Context.IsObjectCreation) { expression = "new " + expression; } diff --git a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs b/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs index 5780262924..2739df1fa7 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.Core public class CurrentLineBookmark: SDMarkerBookmark { static CurrentLineBookmark instance; - + static int startLine; static int startColumn; static int endLine; @@ -41,12 +41,12 @@ namespace ICSharpCode.Core public static void SetPosition(string fileName, IDocument document, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn) { Remove(); - + startLine = makerStartLine; startColumn = makerStartColumn; endLine = makerEndLine; endColumn = makerEndColumn; - + LineSegment line = document.GetLineSegment(startLine - 1); int offset = line.Offset + startColumn; instance = new CurrentLineBookmark(fileName, document, startLine - 1); @@ -72,7 +72,8 @@ namespace ICSharpCode.Core public CurrentLineBookmark(string fileName, IDocument document, int startLine) : base(fileName, document, startLine) { - + this.IsSaved = false; + this.IsVisibleInBookmarkPad = false; } public override void Draw(IconBarMargin margin, Graphics g, Point p) diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs index d394cc442c..cb451fb7b2 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs @@ -23,6 +23,11 @@ namespace ICSharpCode.SharpDevelop.Bookmarks [TypeConverter(typeof(BookmarkConverter))] public class SDBookmark : Bookmark { + public SDBookmark(string fileName, IDocument document, int lineNumber) : base(document, lineNumber) + { + this.fileName = fileName; + } + string fileName; public string FileName { @@ -34,9 +39,40 @@ namespace ICSharpCode.SharpDevelop.Bookmarks } } - public SDBookmark(string fileName, IDocument document, int lineNumber) : base(document, lineNumber) - { - this.fileName = fileName; + bool isSaved = true; + + /// + /// Gets/Sets if the bookmark should be saved to the project memento file. + /// + /// + /// Default is true, set this property to false if you are using the bookmark for + /// something special like like "CurrentLineBookmark" in the debugger. + /// + public bool IsSaved { + get { + return isSaved; + } + set { + isSaved = value; + } + } + + bool isVisibleInBookmarkPad = true; + + /// + /// Gets/Sets if the bookmark is shown in the bookmark pad. + /// + /// + /// Default is true, set this property to false if you are using the bookmark for + /// something special like like "CurrentLineBookmark" in the debugger. + /// + public bool IsVisibleInBookmarkPad { + get { + return isVisibleInBookmarkPad; + } + set { + isVisibleInBookmarkPad = value; + } } } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs index 056b6385b4..30295800b5 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs @@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks { List projectBookmarks = new List(); foreach (SDBookmark mark in bookmarks) { - if (mark.FileName != null && project.IsFileInProject(mark.FileName)) { + if (mark.IsSaved && mark.FileName != null && project.IsFileInProject(mark.FileName)) { projectBookmarks.Add(mark); } } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs index 35d4686850..bcac47ffb4 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs @@ -69,6 +69,8 @@ namespace ICSharpCode.SharpDevelop.Bookmarks void AddMark(SDBookmark mark) { + if (!mark.IsVisibleInBookmarkPad) + return; if (!fileNodes.ContainsKey(mark.FileName)) { BookmarkFolderNode folderNode = new BookmarkFolderNode(mark.FileName); fileNodes.Add(mark.FileName, folderNode); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs index feac41317d..1b97e36a79 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs @@ -119,9 +119,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor protected virtual void SetupDataProvider(string fileName, IDocument document, ExpressionResult expressionResult, int caretLineNumber, int caretColumn) { bool constructorInsight = false; - if (expressionResult.Context == ExpressionContext.ObjectCreation) { + if (expressionResult.Context.IsObjectCreation) { constructorInsight = true; - expressionResult.Context = ExpressionContext.Default; + expressionResult.Context = ExpressionContext.Type; } else if (expressionResult.Context == ExpressionContext.Attribute) { constructorInsight = true; }