From 2921e6f48bec154fede0fb22a360c5a09e585a6a Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 22 Dec 2008 19:18:25 +0000 Subject: [PATCH] NRefactory: ensure Parent property is correctly set for all nodes git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3717 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../NRefactoryASTGenerator/AST/Node.cs | 2 +- .../NRefactory/NRefactoryASTGenerator/Main.cs | 8 +- .../NRefactory/Project/NRefactory.csproj | 2 +- .../Ast/General/LocalVariableDeclaration.cs | 1 + .../NRefactory/Project/Src/Ast/Generated.cs | 23 + .../Project/Src/Ast/TypeReference.cs | 6 +- .../Project/Src/Lexer/VBNet/Lexer.cs | 2 +- .../NRefactory/Project/Src/Location.cs | 2 + .../Project/Src/Parser/CSharp/CSharpParser.cs | 32 +- .../Project/Src/Parser/CSharp/Parser.cs | 1766 +++++++------ .../Project/Src/Parser/CSharp/cs.ATG | 68 +- .../Project/Src/Parser/CSharp/trace.txt | 0 .../Project/Src/Parser/Frames/Parser.frame | 2 +- .../Project/Src/Parser/ModifierList.cs | 4 +- .../Project/Src/Parser/VBNet/Parser.cs | 2285 ++++++++--------- .../Project/Src/Parser/VBNet/VBNET.ATG | 49 +- .../Project/Src/Parser/VBNet/VBNetParser.cs | 26 +- .../CSharp/CSharpOutputVisitor.cs | 2 +- .../PrettyPrinter/VBNet/VBNetOutputVisitor.cs | 2 +- .../Project/Src/Visitors/SetParentVisitor.cs | 37 + .../Test/Parser/CheckParentVisitor.cs | 10 +- .../GlobalScope/TypeDeclarationTests.cs | 22 +- .../Parser/Statements/BlockStatementTests.cs | 8 +- .../Parser/Statements/IfElseStatementTests.cs | 8 +- .../TypeLevel/MethodDeclarationTests.cs | 18 +- 25 files changed, 2163 insertions(+), 2222 deletions(-) delete mode 100644 src/Libraries/NRefactory/Project/Src/Parser/CSharp/trace.txt create mode 100644 src/Libraries/NRefactory/Project/Src/Visitors/SetParentVisitor.cs diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs index 3cb8926538..aee75ed507 100644 --- a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs @@ -43,7 +43,7 @@ namespace NRefactoryASTGenerator.Ast } [CustomImplementation] - class TypeReference : AbstractNode + class TypeReference : AbstractNode, INullable { List genericTypes; } diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs index d57354b1fa..4aa23f4731 100644 --- a/src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs @@ -377,8 +377,12 @@ namespace NRefactoryASTGenerator else ex = GetDefaultValue("value", field); p.Setter.Assign(Easy.Var(field.Name), ex); - if (typeof(INode).IsAssignableFrom(field.FieldType) && typeof(INullable).IsAssignableFrom(field.FieldType)) { - p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\tif (!" +field.Name+".IsNull) "+field.Name+".Parent = this;")); + if (typeof(INode).IsAssignableFrom(field.FieldType)) { + if (typeof(INullable).IsAssignableFrom(field.FieldType)) { + p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\tif (!" +field.Name+".IsNull) "+field.Name+".Parent = this;")); + } else { + p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\t"+field.Name+".Parent = this;")); + } } } foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { diff --git a/src/Libraries/NRefactory/Project/NRefactory.csproj b/src/Libraries/NRefactory/Project/NRefactory.csproj index 040eca0f77..62567cbb5c 100644 --- a/src/Libraries/NRefactory/Project/NRefactory.csproj +++ b/src/Libraries/NRefactory/Project/NRefactory.csproj @@ -109,6 +109,7 @@ + @@ -138,7 +139,6 @@ - diff --git a/src/Libraries/NRefactory/Project/Src/Ast/General/LocalVariableDeclaration.cs b/src/Libraries/NRefactory/Project/Src/Ast/General/LocalVariableDeclaration.cs index 935a8866c8..f337273fa9 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/General/LocalVariableDeclaration.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/General/LocalVariableDeclaration.cs @@ -22,6 +22,7 @@ namespace ICSharpCode.NRefactory.Ast } set { typeReference = TypeReference.CheckNull(value); + if (!typeReference.IsNull) typeReference.Parent = this; } } diff --git a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs index 28b952700f..45dc7cbc6b 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs @@ -144,6 +144,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { createType = value ?? TypeReference.Null; + if (!createType.IsNull) createType.Parent = this; } } @@ -555,6 +556,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { castTo = value ?? TypeReference.Null; + if (!castTo.IsNull) castTo.Parent = this; } } @@ -613,6 +615,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -1052,6 +1055,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -1086,6 +1090,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -1127,6 +1132,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { returnType = value ?? TypeReference.Null; + if (!returnType.IsNull) returnType.Parent = this; } } @@ -1752,6 +1758,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { type = value ?? TypeReference.Null; + if (!type.IsNull) type.Parent = this; } } @@ -1840,6 +1847,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -1938,6 +1946,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -2057,6 +2066,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -2380,6 +2390,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -2531,6 +2542,7 @@ namespace ICSharpCode.NRefactory.Ast { } set { interfaceType = value ?? TypeReference.Null; + if (!interfaceType.IsNull) interfaceType.Parent = this; } } @@ -2730,6 +2742,7 @@ public Location ExtendedEndLocation { get; set; } } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -2949,6 +2962,7 @@ public Location ExtendedEndLocation { get; set; } } set { createType = value ?? TypeReference.Null; + if (!createType.IsNull) createType.Parent = this; } } @@ -3138,6 +3152,7 @@ public Location ExtendedEndLocation { get; set; } } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -3787,6 +3802,7 @@ public Location ExtendedEndLocation { get; set; } } set { type = value ?? TypeReference.Null; + if (!type.IsNull) type.Parent = this; } } @@ -4558,6 +4574,7 @@ public Location ExtendedEndLocation { get; set; } } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -4586,6 +4603,7 @@ public Location ExtendedEndLocation { get; set; } } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -4914,6 +4932,7 @@ public Location ExtendedEndLocation { get; set; } } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -4952,6 +4971,7 @@ public Location ExtendedEndLocation { get; set; } } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -4979,6 +4999,7 @@ public Location ExtendedEndLocation { get; set; } } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } @@ -5143,6 +5164,7 @@ public Location ExtendedEndLocation { get; set; } } set { alias = value ?? TypeReference.Null; + if (!alias.IsNull) alias.Parent = this; } } @@ -5264,6 +5286,7 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L } set { typeReference = value ?? TypeReference.Null; + if (!typeReference.IsNull) typeReference.Parent = this; } } diff --git a/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs b/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs index f304146241..2039b992f8 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs @@ -374,6 +374,10 @@ namespace ICSharpCode.NRefactory.Ast return true; } } + public override TypeReference Clone() + { + return this; + } public override object AcceptVisitor(IAstVisitor visitor, object data) { return null; @@ -402,7 +406,7 @@ namespace ICSharpCode.NRefactory.Ast public override TypeReference Clone() { - InnerClassTypeReference c = new InnerClassTypeReference(baseType.Clone(), Type, GenericTypes); + InnerClassTypeReference c = new InnerClassTypeReference(baseType.Clone(), Type, new List()); CopyFields(this, c); return c; } diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs index 84b412b251..5d13b5a3fa 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs @@ -507,7 +507,7 @@ namespace ICSharpCode.NRefactory.Parser.VB Location start = new Location(Col - 1, Line); string directive = ReadIdent('#'); string argument = ReadToEndOfLine(); - this.specialTracker.AddPreprocessingDirective(new PreprocessingDirective(directive, argument.Trim(), start, new Location(start.X + directive.Length + argument.Length, start.Y))); + this.specialTracker.AddPreprocessingDirective(new PreprocessingDirective(directive, argument.Trim(), start, new Location(start.Column + directive.Length + argument.Length, start.Line))); } string ReadDate() diff --git a/src/Libraries/NRefactory/Project/Src/Location.cs b/src/Libraries/NRefactory/Project/Src/Location.cs index 4c4a5dc529..eb1a5b051e 100644 --- a/src/Libraries/NRefactory/Project/Src/Location.cs +++ b/src/Libraries/NRefactory/Project/Src/Location.cs @@ -25,11 +25,13 @@ namespace ICSharpCode.NRefactory int x, y; + [Obsolete("Use Column instead")] public int X { get { return x; } set { x = value; } } + [Obsolete("Use Line instead")] public int Y { get { return y; } set { y = value; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs index 4281ac9828..5265841589 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs @@ -5,11 +5,11 @@ // $Revision$ // +using ICSharpCode.NRefactory.Visitors; using System; using System.Collections.Generic; -using System.Text; using System.Diagnostics; - +using System.Text; using ICSharpCode.NRefactory.Ast; namespace ICSharpCode.NRefactory.Parser.CSharp @@ -50,6 +50,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp errDist = 0; } + public override void Parse() + { + ParseRoot(); + compilationUnit.AcceptVisitor(new SetParentVisitor(), null); + } + public override Expression ParseExpression() { lexer.NextToken(); @@ -61,6 +67,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp if (expr != null) { expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; + expr.AcceptVisitor(new SetParentVisitor(), null); } Expect(Tokens.EOF); return expr; @@ -87,6 +94,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp compilationUnit.BlockEnd(); blockStmt.EndLocation = t.EndLocation; Expect(Tokens.EOF); + blockStmt.AcceptVisitor(new SetParentVisitor(), null); return blockStmt; } @@ -100,6 +108,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp ClassBody(); compilationUnit.BlockEnd(); Expect(Tokens.EOF); + newType.AcceptVisitor(new SetParentVisitor(), null); return newType.Children; } @@ -590,24 +599,5 @@ namespace ICSharpCode.NRefactory.Parser.CSharp item.Parent = parent; } } - - static void SetParent(List list, INode parent) where T : class, INode, INullable - { - if (list != null) { - foreach (T x in list) { - if (!x.IsNull) - x.Parent = parent; - } - } - } - - static void SetParentNonNullable(List list, INode parent) where T : class, INode - { - if (list != null) { - foreach (T x in list) { - x.Parent = parent; - } - } - } } } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 30e0af9052..4d8f1a8d8c 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -453,68 +453,68 @@ out expr); } void Expr( -#line 1738 "cs.ATG" +#line 1736 "cs.ATG" out Expression expr) { -#line 1739 "cs.ATG" +#line 1737 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; -#line 1741 "cs.ATG" +#line 1739 "cs.ATG" Location startLocation = la.Location; UnaryExpr( -#line 1742 "cs.ATG" +#line 1740 "cs.ATG" out expr); if (StartOf(7)) { AssignmentOperator( -#line 1745 "cs.ATG" +#line 1743 "cs.ATG" out op); Expr( -#line 1745 "cs.ATG" +#line 1743 "cs.ATG" out expr1); -#line 1745 "cs.ATG" +#line 1743 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1746 "cs.ATG" +#line 1744 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1747 "cs.ATG" +#line 1745 "cs.ATG" out op); Expr( -#line 1747 "cs.ATG" +#line 1745 "cs.ATG" out expr1); -#line 1747 "cs.ATG" +#line 1745 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(8)) { ConditionalOrExpr( -#line 1749 "cs.ATG" +#line 1747 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1750 "cs.ATG" +#line 1748 "cs.ATG" out expr1); -#line 1750 "cs.ATG" +#line 1748 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1751 "cs.ATG" +#line 1749 "cs.ATG" out expr1); Expect(9); Expr( -#line 1751 "cs.ATG" +#line 1749 "cs.ATG" out expr2); -#line 1751 "cs.ATG" +#line 1749 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(150); -#line 1754 "cs.ATG" +#line 1752 "cs.ATG" if (expr != null) { expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; @@ -707,9 +707,6 @@ ModifierList m, List attributes) { #line 367 "cs.ATG" templates); } - -#line 367 "cs.ATG" - SetParentNonNullable(templates, newType); if (la.kind == 9) { ClassBase( #line 369 "cs.ATG" @@ -761,9 +758,6 @@ templates); #line 392 "cs.ATG" templates); } - -#line 392 "cs.ATG" - SetParentNonNullable(templates, newType); if (la.kind == 9) { StructInterfaces( #line 394 "cs.ATG" @@ -809,9 +803,6 @@ templates); #line 416 "cs.ATG" templates); } - -#line 416 "cs.ATG" - SetParentNonNullable(templates, newType); if (la.kind == 9) { InterfaceBase( #line 418 "cs.ATG" @@ -904,9 +895,6 @@ out type); #line 454 "cs.ATG" templates); } - -#line 454 "cs.ATG" - SetParentNonNullable(templates, delegateDeclr); Expect(20); if (StartOf(11)) { FormalParameterList( @@ -933,39 +921,39 @@ templates); } void TypeParameterList( -#line 2307 "cs.ATG" +#line 2305 "cs.ATG" List templates) { -#line 2309 "cs.ATG" +#line 2307 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2313 "cs.ATG" +#line 2311 "cs.ATG" out section); -#line 2313 "cs.ATG" +#line 2311 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2314 "cs.ATG" +#line 2312 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2315 "cs.ATG" +#line 2313 "cs.ATG" out section); -#line 2315 "cs.ATG" +#line 2313 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2316 "cs.ATG" +#line 2314 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -998,22 +986,22 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2320 "cs.ATG" +#line 2318 "cs.ATG" List templates) { -#line 2321 "cs.ATG" +#line 2319 "cs.ATG" string name = ""; TypeReference type; Expect(127); Identifier(); -#line 2324 "cs.ATG" +#line 2322 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2326 "cs.ATG" +#line 2324 "cs.ATG" out type); -#line 2327 "cs.ATG" +#line 2325 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1026,10 +1014,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2336 "cs.ATG" +#line 2334 "cs.ATG" out type); -#line 2337 "cs.ATG" +#line 2335 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1365,33 +1353,33 @@ out r, canBeUnbound); } void TypeName( -#line 2250 "cs.ATG" +#line 2248 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2251 "cs.ATG" +#line 2249 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 2256 "cs.ATG" +#line 2254 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 2257 "cs.ATG" +#line 2255 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2260 "cs.ATG" +#line 2258 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2261 "cs.ATG" +#line 2259 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2263 "cs.ATG" +#line 2261 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1402,22 +1390,22 @@ out typeArguments, canBeUnbound); } while ( -#line 2272 "cs.ATG" +#line 2270 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2273 "cs.ATG" +#line 2271 "cs.ATG" typeArguments = null; Qualident( -#line 2274 "cs.ATG" +#line 2272 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2275 "cs.ATG" +#line 2273 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2276 "cs.ATG" +#line 2274 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } } @@ -1544,23 +1532,23 @@ ModifierList m) { } void ClassMemberDecl( -#line 1035 "cs.ATG" +#line 1029 "cs.ATG" ModifierList m, List attributes) { -#line 1036 "cs.ATG" +#line 1030 "cs.ATG" Statement stmt = null; if (StartOf(21)) { StructMemberDecl( -#line 1038 "cs.ATG" +#line 1032 "cs.ATG" m, attributes); } else if (la.kind == 27) { -#line 1039 "cs.ATG" +#line 1033 "cs.ATG" m.Check(Modifiers.Destructors); Location startPos = t.Location; lexer.NextToken(); Identifier(); -#line 1040 "cs.ATG" +#line 1034 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1568,17 +1556,17 @@ m, attributes); Expect(20); Expect(21); -#line 1044 "cs.ATG" +#line 1038 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 1044 "cs.ATG" +#line 1038 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(160); -#line 1045 "cs.ATG" +#line 1039 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1703,36 +1691,35 @@ p); Templates = templates, IsExtensionMethod = isExtensionMethod }; - SetParentNonNullable(templates, methodDeclaration); if (explicitInterface != null) - methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); + SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 789 "cs.ATG" +#line 788 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 791 "cs.ATG" +#line 790 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(163); -#line 791 "cs.ATG" +#line 790 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 69) { -#line 795 "cs.ATG" +#line 794 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); lexer.NextToken(); -#line 797 "cs.ATG" +#line 796 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration { Modifier = m.Modifier, Attributes = attributes, @@ -1744,113 +1731,113 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 807 "cs.ATG" +#line 806 "cs.ATG" out type); -#line 807 "cs.ATG" +#line 806 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 808 "cs.ATG" +#line 807 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 809 "cs.ATG" +#line 808 "cs.ATG" out explicitInterface, false); -#line 810 "cs.ATG" +#line 809 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); -#line 811 "cs.ATG" +#line 810 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (StartOf(19)) { Identifier(); -#line 813 "cs.ATG" +#line 812 "cs.ATG" qualident = t.val; } else SynErr(164); -#line 815 "cs.ATG" +#line 814 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 3) { lexer.NextToken(); Expr( -#line 816 "cs.ATG" +#line 815 "cs.ATG" out expr); -#line 816 "cs.ATG" +#line 815 "cs.ATG" eventDecl.Initializer = expr; } if (la.kind == 16) { lexer.NextToken(); -#line 817 "cs.ATG" +#line 816 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 818 "cs.ATG" +#line 817 "cs.ATG" out addBlock, out removeBlock); Expect(17); -#line 819 "cs.ATG" +#line 818 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } -#line 822 "cs.ATG" +#line 821 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 828 "cs.ATG" +#line 827 "cs.ATG" IdentAndLPar()) { -#line 828 "cs.ATG" +#line 827 "cs.ATG" m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); Identifier(); -#line 829 "cs.ATG" +#line 828 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(11)) { -#line 829 "cs.ATG" +#line 828 "cs.ATG" m.Check(Modifiers.Constructors); FormalParameterList( -#line 830 "cs.ATG" +#line 829 "cs.ATG" p); } Expect(21); -#line 832 "cs.ATG" +#line 831 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 833 "cs.ATG" +#line 832 "cs.ATG" m.Check(Modifiers.Constructors); ConstructorInitializer( -#line 834 "cs.ATG" +#line 833 "cs.ATG" out init); } -#line 836 "cs.ATG" - ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); +#line 835 "cs.ATG" + ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 841 "cs.ATG" +#line 840 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); -#line 841 "cs.ATG" +#line 840 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 70 || la.kind == 80) { -#line 844 "cs.ATG" +#line 843 "cs.ATG" m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -1859,45 +1846,45 @@ out stmt); if (la.kind == 80) { lexer.NextToken(); -#line 849 "cs.ATG" +#line 848 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); -#line 849 "cs.ATG" +#line 848 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(92); Type( -#line 850 "cs.ATG" +#line 849 "cs.ATG" out type); -#line 850 "cs.ATG" +#line 849 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( -#line 851 "cs.ATG" +#line 850 "cs.ATG" out type); Identifier(); -#line 851 "cs.ATG" +#line 850 "cs.ATG" string varName = t.val; Expect(21); -#line 852 "cs.ATG" +#line 851 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( -#line 853 "cs.ATG" +#line 852 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 853 "cs.ATG" +#line 852 "cs.ATG" stmt = null; } else SynErr(166); -#line 856 "cs.ATG" +#line 855 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration { @@ -1910,154 +1897,150 @@ out stmt); StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; - SetParent(parameters, operatorDeclaration); compilationUnit.AddChild(operatorDeclaration); } else if (StartOf(22)) { TypeDecl( -#line 874 "cs.ATG" +#line 872 "cs.ATG" m, attributes); } else if (StartOf(10)) { Type( -#line 876 "cs.ATG" +#line 874 "cs.ATG" out type); -#line 876 "cs.ATG" +#line 874 "cs.ATG" Location startPos = t.Location; if (la.kind == 92) { -#line 878 "cs.ATG" +#line 876 "cs.ATG" OverloadableOperatorType op; m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 882 "cs.ATG" +#line 880 "cs.ATG" out op); -#line 882 "cs.ATG" +#line 880 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( -#line 883 "cs.ATG" +#line 881 "cs.ATG" out firstType); Identifier(); -#line 883 "cs.ATG" +#line 881 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( -#line 884 "cs.ATG" +#line 882 "cs.ATG" out secondType); Identifier(); -#line 884 "cs.ATG" +#line 882 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(167); -#line 892 "cs.ATG" +#line 890 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( -#line 893 "cs.ATG" +#line 891 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(168); -#line 895 "cs.ATG" - List parameters = new List(); - parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); - if (secondType != null) { - parameters.Add(new ParameterDeclarationExpression(secondType, secondName)); - } +#line 893 "cs.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration { - Modifier = m.Modifier, - Attributes = attributes, - Parameters = parameters, - TypeReference = type, - OverloadableOperator = op, - Body = (BlockStatement)stmt, - StartLocation = m.GetDeclarationLocation(startPos), - EndLocation = endPos + Modifier = m.Modifier, + Attributes = attributes, + TypeReference = type, + OverloadableOperator = op, + Body = (BlockStatement)stmt, + StartLocation = m.GetDeclarationLocation(startPos), + EndLocation = endPos }; - SetParent(parameters, operatorDeclaration); + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName)); + if (secondType != null) { + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName)); + } compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 915 "cs.ATG" +#line 910 "cs.ATG" IsVarDecl()) { -#line 916 "cs.ATG" +#line 911 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( -#line 920 "cs.ATG" +#line 915 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( -#line 921 "cs.ATG" +#line 916 "cs.ATG" fd); Expect(18); Expr( -#line 923 "cs.ATG" +#line 918 "cs.ATG" out expr); -#line 923 "cs.ATG" +#line 918 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 927 "cs.ATG" +#line 922 "cs.ATG" fd); Expect(18); Expr( -#line 929 "cs.ATG" +#line 924 "cs.ATG" out expr); -#line 929 "cs.ATG" +#line 924 "cs.ATG" if (fd.Fields.Count > 0) fd.Fields[fd.Fields.Count-1].FixedArrayInitialization = expr; Expect(19); } } else if (StartOf(19)) { VariableDeclarator( -#line 934 "cs.ATG" +#line 929 "cs.ATG" fd); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 935 "cs.ATG" +#line 930 "cs.ATG" fd); } } else SynErr(169); Expect(11); -#line 937 "cs.ATG" +#line 932 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if (la.kind == 111) { -#line 940 "cs.ATG" +#line 935 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( -#line 941 "cs.ATG" +#line 936 "cs.ATG" p); Expect(19); -#line 941 "cs.ATG" +#line 936 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); -#line 942 "cs.ATG" +#line 937 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2066,64 +2049,64 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 949 "cs.ATG" +#line 944 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 950 "cs.ATG" +#line 945 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( -#line 955 "cs.ATG" +#line 950 "cs.ATG" IsIdentifierToken(la)) { if ( -#line 956 "cs.ATG" +#line 951 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 957 "cs.ATG" +#line 952 "cs.ATG" out explicitInterface, false); -#line 958 "cs.ATG" +#line 953 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (StartOf(19)) { Identifier(); -#line 961 "cs.ATG" +#line 956 "cs.ATG" qualident = t.val; } else SynErr(170); -#line 963 "cs.ATG" +#line 958 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { -#line 967 "cs.ATG" +#line 962 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( -#line 969 "cs.ATG" +#line 964 "cs.ATG" templates); } Expect(20); if (la.kind == 111) { lexer.NextToken(); -#line 971 "cs.ATG" +#line 966 "cs.ATG" isExtensionMethod = true; } if (StartOf(11)) { FormalParameterList( -#line 972 "cs.ATG" +#line 967 "cs.ATG" p); } Expect(21); -#line 974 "cs.ATG" +#line 969 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, @@ -2137,28 +2120,27 @@ p); methodDeclaration.EndLocation = t.EndLocation; methodDeclaration.IsExtensionMethod = isExtensionMethod; methodDeclaration.Templates = templates; - SetParentNonNullable(templates, methodDeclaration); compilationUnit.AddChild(methodDeclaration); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 990 "cs.ATG" +#line 984 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 991 "cs.ATG" +#line 985 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(171); -#line 991 "cs.ATG" +#line 985 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 994 "cs.ATG" +#line 988 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); @@ -2169,11 +2151,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1003 "cs.ATG" +#line 997 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1005 "cs.ATG" +#line 999 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2182,35 +2164,35 @@ out getRegion, out setRegion); } } else if (la.kind == 15) { -#line 1013 "cs.ATG" +#line 1007 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(111); Expect(18); FormalParameterList( -#line 1014 "cs.ATG" +#line 1008 "cs.ATG" p); Expect(19); -#line 1015 "cs.ATG" +#line 1009 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; if (explicitInterface != null) - indexer.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, "this")); + SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this")); PropertyGetRegion getRegion; PropertySetRegion setRegion; Expect(16); -#line 1023 "cs.ATG" +#line 1017 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( -#line 1024 "cs.ATG" +#line 1018 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1025 "cs.ATG" +#line 1019 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2224,7 +2206,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1052 "cs.ATG" +#line 1046 "cs.ATG" TypeReference type; AttributeSection section; @@ -2239,151 +2221,151 @@ out getRegion, out setRegion); while (la.kind == 18) { AttributeSection( -#line 1065 "cs.ATG" +#line 1059 "cs.ATG" out section); -#line 1065 "cs.ATG" +#line 1059 "cs.ATG" attributes.Add(section); } if (la.kind == 89) { lexer.NextToken(); -#line 1066 "cs.ATG" +#line 1060 "cs.ATG" mod = Modifiers.New; startLocation = t.Location; } if ( -#line 1069 "cs.ATG" +#line 1063 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1069 "cs.ATG" - if (startLocation.X == -1) startLocation = t.Location; +#line 1063 "cs.ATG" + if (startLocation.IsEmpty) startLocation = t.Location; Identifier(); -#line 1070 "cs.ATG" +#line 1064 "cs.ATG" name = t.val; if (la.kind == 23) { TypeParameterList( -#line 1071 "cs.ATG" +#line 1065 "cs.ATG" templates); } Expect(20); if (StartOf(11)) { FormalParameterList( -#line 1072 "cs.ATG" +#line 1066 "cs.ATG" parameters); } Expect(21); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1073 "cs.ATG" +#line 1067 "cs.ATG" templates); } Expect(11); -#line 1075 "cs.ATG" +#line 1069 "cs.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true), Parameters = parameters, Attributes = attributes, Templates = templates, StartLocation = startLocation, EndLocation = t.EndLocation }; - SetParentNonNullable(templates, md); compilationUnit.AddChild(md); } else if (StartOf(23)) { if (StartOf(10)) { Type( -#line 1084 "cs.ATG" +#line 1077 "cs.ATG" out type); -#line 1084 "cs.ATG" - if (startLocation.X == -1) startLocation = t.Location; +#line 1077 "cs.ATG" + if (startLocation.IsEmpty) startLocation = t.Location; if (StartOf(19)) { Identifier(); -#line 1086 "cs.ATG" +#line 1079 "cs.ATG" name = t.val; Location qualIdentEndLocation = t.EndLocation; if (la.kind == 20 || la.kind == 23) { if (la.kind == 23) { TypeParameterList( -#line 1090 "cs.ATG" +#line 1083 "cs.ATG" templates); } Expect(20); if (StartOf(11)) { FormalParameterList( -#line 1091 "cs.ATG" +#line 1084 "cs.ATG" parameters); } Expect(21); while (la.kind == 127) { TypeParameterConstraintsClause( -#line 1093 "cs.ATG" +#line 1086 "cs.ATG" templates); } Expect(11); -#line 1094 "cs.ATG" +#line 1087 "cs.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod, TypeReference = type, Parameters = parameters, Attributes = attributes, Templates = templates, StartLocation = startLocation, EndLocation = t.EndLocation }; - SetParentNonNullable(templates, md); compilationUnit.AddChild(md); } else if (la.kind == 16) { -#line 1103 "cs.ATG" - PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); +#line 1096 "cs.ATG" + PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); + compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1104 "cs.ATG" +#line 1099 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1104 "cs.ATG" +#line 1100 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1104 "cs.ATG" +#line 1101 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(175); } else if (la.kind == 111) { lexer.NextToken(); Expect(18); FormalParameterList( -#line 1107 "cs.ATG" +#line 1104 "cs.ATG" parameters); Expect(19); -#line 1107 "cs.ATG" +#line 1105 "cs.ATG" Location bracketEndLocation = t.EndLocation; -#line 1107 "cs.ATG" - IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); +#line 1106 "cs.ATG" + IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); + compilationUnit.AddChild(id); Expect(16); #line 1108 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1108 "cs.ATG" +#line 1109 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1108 "cs.ATG" +#line 1111 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(176); } else { lexer.NextToken(); -#line 1111 "cs.ATG" - if (startLocation.X == -1) startLocation = t.Location; +#line 1114 "cs.ATG" + if (startLocation.IsEmpty) startLocation = t.Location; Type( -#line 1112 "cs.ATG" +#line 1115 "cs.ATG" out type); Identifier(); -#line 1113 "cs.ATG" +#line 1116 "cs.ATG" EventDeclaration ed = new EventDeclaration { TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes }; @@ -2391,17 +2373,17 @@ out type); Expect(11); -#line 1118 "cs.ATG" +#line 1122 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(177); } void EnumMemberDecl( -#line 1123 "cs.ATG" +#line 1127 "cs.ATG" out FieldDeclaration f) { -#line 1125 "cs.ATG" +#line 1129 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2409,15 +2391,15 @@ out FieldDeclaration f) { while (la.kind == 18) { AttributeSection( -#line 1131 "cs.ATG" +#line 1135 "cs.ATG" out section); -#line 1131 "cs.ATG" +#line 1135 "cs.ATG" attributes.Add(section); } Identifier(); -#line 1132 "cs.ATG" +#line 1136 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2426,10 +2408,10 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1137 "cs.ATG" +#line 1141 "cs.ATG" out expr); -#line 1137 "cs.ATG" +#line 1141 "cs.ATG" varDecl.Initializer = expr; } } @@ -2539,14 +2521,14 @@ out name); } void NullableQuestionMark( -#line 2281 "cs.ATG" +#line 2279 "cs.ATG" ref TypeReference typeRef) { -#line 2282 "cs.ATG" +#line 2280 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2286 "cs.ATG" +#line 2284 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -2636,11 +2618,11 @@ out ModifierList m) { } void Block( -#line 1257 "cs.ATG" +#line 1261 "cs.ATG" out Statement stmt) { Expect(16); -#line 1259 "cs.ATG" +#line 1263 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.Location; compilationUnit.BlockStart(blockStmt); @@ -2652,7 +2634,7 @@ out Statement stmt) { while (!(la.kind == 0 || la.kind == 17)) {SynErr(182); lexer.NextToken(); } Expect(17); -#line 1267 "cs.ATG" +#line 1271 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2660,10 +2642,10 @@ out Statement stmt) { } void EventAccessorDecls( -#line 1194 "cs.ATG" +#line 1198 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1195 "cs.ATG" +#line 1199 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2672,93 +2654,93 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 18) { AttributeSection( -#line 1202 "cs.ATG" +#line 1206 "cs.ATG" out section); -#line 1202 "cs.ATG" +#line 1206 "cs.ATG" attributes.Add(section); } if (la.kind == 130) { -#line 1204 "cs.ATG" +#line 1208 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1205 "cs.ATG" +#line 1209 "cs.ATG" out stmt); -#line 1205 "cs.ATG" +#line 1209 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 18) { AttributeSection( -#line 1206 "cs.ATG" +#line 1210 "cs.ATG" out section); -#line 1206 "cs.ATG" +#line 1210 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1207 "cs.ATG" +#line 1211 "cs.ATG" out stmt); -#line 1207 "cs.ATG" +#line 1211 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if (la.kind == 131) { RemoveAccessorDecl( -#line 1209 "cs.ATG" +#line 1213 "cs.ATG" out stmt); -#line 1209 "cs.ATG" +#line 1213 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1210 "cs.ATG" +#line 1214 "cs.ATG" out section); -#line 1210 "cs.ATG" +#line 1214 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1211 "cs.ATG" +#line 1215 "cs.ATG" out stmt); -#line 1211 "cs.ATG" +#line 1215 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else SynErr(183); } void ConstructorInitializer( -#line 1287 "cs.ATG" +#line 1291 "cs.ATG" out ConstructorInitializer ci) { -#line 1288 "cs.ATG" +#line 1292 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 51) { lexer.NextToken(); -#line 1292 "cs.ATG" +#line 1296 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 111) { lexer.NextToken(); -#line 1293 "cs.ATG" +#line 1297 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(184); Expect(20); if (StartOf(26)) { Argument( -#line 1296 "cs.ATG" +#line 1300 "cs.ATG" out expr); -#line 1296 "cs.ATG" +#line 1300 "cs.ATG" SafeAdd(ci, ci.Arguments, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1297 "cs.ATG" +#line 1301 "cs.ATG" out expr); -#line 1297 "cs.ATG" +#line 1301 "cs.ATG" SafeAdd(ci, ci.Arguments, expr); } } @@ -2766,161 +2748,161 @@ out expr); } void OverloadableOperator( -#line 1310 "cs.ATG" +#line 1314 "cs.ATG" out OverloadableOperatorType op) { -#line 1311 "cs.ATG" +#line 1315 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1313 "cs.ATG" +#line 1317 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1314 "cs.ATG" +#line 1318 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 24: { lexer.NextToken(); -#line 1316 "cs.ATG" +#line 1320 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 27: { lexer.NextToken(); -#line 1317 "cs.ATG" +#line 1321 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 31: { lexer.NextToken(); -#line 1319 "cs.ATG" +#line 1323 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 32: { lexer.NextToken(); -#line 1320 "cs.ATG" +#line 1324 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 113: { lexer.NextToken(); -#line 1322 "cs.ATG" +#line 1326 "cs.ATG" op = OverloadableOperatorType.IsTrue; break; } case 72: { lexer.NextToken(); -#line 1323 "cs.ATG" +#line 1327 "cs.ATG" op = OverloadableOperatorType.IsFalse; break; } case 6: { lexer.NextToken(); -#line 1325 "cs.ATG" +#line 1329 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1326 "cs.ATG" +#line 1330 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1327 "cs.ATG" +#line 1331 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 28: { lexer.NextToken(); -#line 1329 "cs.ATG" +#line 1333 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 29: { lexer.NextToken(); -#line 1330 "cs.ATG" +#line 1334 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 30: { lexer.NextToken(); -#line 1331 "cs.ATG" +#line 1335 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 37: { lexer.NextToken(); -#line 1333 "cs.ATG" +#line 1337 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1334 "cs.ATG" +#line 1338 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 34: { lexer.NextToken(); -#line 1335 "cs.ATG" +#line 1339 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 23: { lexer.NextToken(); -#line 1336 "cs.ATG" +#line 1340 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 35: { lexer.NextToken(); -#line 1337 "cs.ATG" +#line 1341 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 36: { lexer.NextToken(); -#line 1338 "cs.ATG" +#line 1342 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 22: { lexer.NextToken(); -#line 1339 "cs.ATG" +#line 1343 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 22) { lexer.NextToken(); -#line 1339 "cs.ATG" +#line 1343 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2930,34 +2912,34 @@ out OverloadableOperatorType op) { } void VariableDeclarator( -#line 1249 "cs.ATG" +#line 1253 "cs.ATG" FieldDeclaration parentFieldDeclaration) { -#line 1250 "cs.ATG" +#line 1254 "cs.ATG" Expression expr = null; Identifier(); -#line 1252 "cs.ATG" +#line 1256 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1253 "cs.ATG" +#line 1257 "cs.ATG" out expr); -#line 1253 "cs.ATG" +#line 1257 "cs.ATG" f.Initializer = expr; } -#line 1254 "cs.ATG" +#line 1258 "cs.ATG" SafeAdd(parentFieldDeclaration, parentFieldDeclaration.Fields, f); } void AccessorDecls( -#line 1141 "cs.ATG" +#line 1145 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1143 "cs.ATG" +#line 1147 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2966,92 +2948,92 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1150 "cs.ATG" +#line 1154 "cs.ATG" out section); -#line 1150 "cs.ATG" +#line 1154 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1151 "cs.ATG" +#line 1155 "cs.ATG" out modifiers); } if (la.kind == 128) { GetAccessorDecl( -#line 1153 "cs.ATG" +#line 1157 "cs.ATG" out getBlock, attributes); -#line 1154 "cs.ATG" +#line 1158 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } if (StartOf(27)) { -#line 1155 "cs.ATG" +#line 1159 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1156 "cs.ATG" +#line 1160 "cs.ATG" out section); -#line 1156 "cs.ATG" +#line 1160 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1157 "cs.ATG" +#line 1161 "cs.ATG" out modifiers); } SetAccessorDecl( -#line 1158 "cs.ATG" +#line 1162 "cs.ATG" out setBlock, attributes); -#line 1159 "cs.ATG" +#line 1163 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } } } else if (la.kind == 129) { SetAccessorDecl( -#line 1162 "cs.ATG" +#line 1166 "cs.ATG" out setBlock, attributes); -#line 1163 "cs.ATG" +#line 1167 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } if (StartOf(28)) { -#line 1164 "cs.ATG" +#line 1168 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1165 "cs.ATG" +#line 1169 "cs.ATG" out section); -#line 1165 "cs.ATG" +#line 1169 "cs.ATG" attributes.Add(section); } if (la.kind == 84 || la.kind == 96 || la.kind == 97) { AccessorModifiers( -#line 1166 "cs.ATG" +#line 1170 "cs.ATG" out modifiers); } GetAccessorDecl( -#line 1167 "cs.ATG" +#line 1171 "cs.ATG" out getBlock, attributes); -#line 1168 "cs.ATG" +#line 1172 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } } } else if (StartOf(19)) { Identifier(); -#line 1170 "cs.ATG" +#line 1174 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(186); } void InterfaceAccessors( -#line 1215 "cs.ATG" +#line 1219 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1217 "cs.ATG" +#line 1221 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; @@ -3059,173 +3041,173 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1223 "cs.ATG" +#line 1227 "cs.ATG" out section); -#line 1223 "cs.ATG" +#line 1227 "cs.ATG" attributes.Add(section); } -#line 1224 "cs.ATG" +#line 1228 "cs.ATG" Location startLocation = la.Location; if (la.kind == 128) { lexer.NextToken(); -#line 1226 "cs.ATG" +#line 1230 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if (la.kind == 129) { lexer.NextToken(); -#line 1227 "cs.ATG" +#line 1231 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else SynErr(187); Expect(11); -#line 1230 "cs.ATG" +#line 1234 "cs.ATG" if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } attributes = new List(); if (la.kind == 18 || la.kind == 128 || la.kind == 129) { while (la.kind == 18) { AttributeSection( -#line 1234 "cs.ATG" +#line 1238 "cs.ATG" out section); -#line 1234 "cs.ATG" +#line 1238 "cs.ATG" attributes.Add(section); } -#line 1235 "cs.ATG" +#line 1239 "cs.ATG" startLocation = la.Location; if (la.kind == 128) { lexer.NextToken(); -#line 1237 "cs.ATG" +#line 1241 "cs.ATG" if (getBlock != null) Error("get already declared"); else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } } else if (la.kind == 129) { lexer.NextToken(); -#line 1240 "cs.ATG" +#line 1244 "cs.ATG" if (setBlock != null) Error("set already declared"); else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } } else SynErr(188); Expect(11); -#line 1245 "cs.ATG" +#line 1249 "cs.ATG" if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } } } void GetAccessorDecl( -#line 1174 "cs.ATG" +#line 1178 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1175 "cs.ATG" +#line 1179 "cs.ATG" Statement stmt = null; Expect(128); -#line 1178 "cs.ATG" +#line 1182 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1179 "cs.ATG" +#line 1183 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(189); -#line 1180 "cs.ATG" +#line 1184 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); -#line 1181 "cs.ATG" +#line 1185 "cs.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } void SetAccessorDecl( -#line 1184 "cs.ATG" +#line 1188 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1185 "cs.ATG" +#line 1189 "cs.ATG" Statement stmt = null; Expect(129); -#line 1188 "cs.ATG" +#line 1192 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1189 "cs.ATG" +#line 1193 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(190); -#line 1190 "cs.ATG" +#line 1194 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); -#line 1191 "cs.ATG" +#line 1195 "cs.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } void AddAccessorDecl( -#line 1273 "cs.ATG" +#line 1277 "cs.ATG" out Statement stmt) { -#line 1274 "cs.ATG" +#line 1278 "cs.ATG" stmt = null; Expect(130); Block( -#line 1277 "cs.ATG" +#line 1281 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1280 "cs.ATG" +#line 1284 "cs.ATG" out Statement stmt) { -#line 1281 "cs.ATG" +#line 1285 "cs.ATG" stmt = null; Expect(131); Block( -#line 1284 "cs.ATG" +#line 1288 "cs.ATG" out stmt); } void VariableInitializer( -#line 1302 "cs.ATG" +#line 1306 "cs.ATG" out Expression initializerExpression) { -#line 1303 "cs.ATG" +#line 1307 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(6)) { Expr( -#line 1305 "cs.ATG" +#line 1309 "cs.ATG" out initializerExpression); } else if (la.kind == 16) { CollectionInitializer( -#line 1306 "cs.ATG" +#line 1310 "cs.ATG" out initializerExpression); } else if (la.kind == 106) { lexer.NextToken(); Type( -#line 1307 "cs.ATG" +#line 1311 "cs.ATG" out type); Expect(18); Expr( -#line 1307 "cs.ATG" +#line 1311 "cs.ATG" out expr); Expect(19); -#line 1307 "cs.ATG" +#line 1311 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(191); } void Statement() { -#line 1448 "cs.ATG" +#line 1452 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; @@ -3233,71 +3215,71 @@ out expr); while (!(StartOf(29))) {SynErr(192); lexer.NextToken(); } if ( -#line 1457 "cs.ATG" +#line 1461 "cs.ATG" IsLabel()) { Identifier(); -#line 1457 "cs.ATG" +#line 1461 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 60) { lexer.NextToken(); Type( -#line 1460 "cs.ATG" +#line 1464 "cs.ATG" out type); -#line 1460 "cs.ATG" +#line 1464 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; Identifier(); -#line 1461 "cs.ATG" +#line 1465 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1462 "cs.ATG" +#line 1466 "cs.ATG" out expr); -#line 1462 "cs.ATG" +#line 1466 "cs.ATG" SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr)); while (la.kind == 14) { lexer.NextToken(); Identifier(); -#line 1463 "cs.ATG" +#line 1467 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1463 "cs.ATG" +#line 1467 "cs.ATG" out expr); -#line 1463 "cs.ATG" +#line 1467 "cs.ATG" SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr)); } Expect(11); -#line 1464 "cs.ATG" +#line 1468 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1467 "cs.ATG" +#line 1471 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1467 "cs.ATG" +#line 1471 "cs.ATG" out stmt); Expect(11); -#line 1467 "cs.ATG" +#line 1471 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(30)) { EmbeddedStatement( -#line 1469 "cs.ATG" +#line 1473 "cs.ATG" out stmt); -#line 1469 "cs.ATG" +#line 1473 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(193); -#line 1475 "cs.ATG" +#line 1479 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3306,10 +3288,10 @@ out stmt); } void Argument( -#line 1342 "cs.ATG" +#line 1346 "cs.ATG" out Expression argumentexpr) { -#line 1344 "cs.ATG" +#line 1348 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3317,51 +3299,51 @@ out Expression argumentexpr) { if (la.kind == 100) { lexer.NextToken(); -#line 1349 "cs.ATG" +#line 1353 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1350 "cs.ATG" +#line 1354 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1352 "cs.ATG" +#line 1356 "cs.ATG" out expr); -#line 1353 "cs.ATG" +#line 1357 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void CollectionInitializer( -#line 1373 "cs.ATG" +#line 1377 "cs.ATG" out Expression outExpr) { -#line 1375 "cs.ATG" +#line 1379 "cs.ATG" Expression expr = null; CollectionInitializerExpression initializer = new CollectionInitializerExpression(); Expect(16); -#line 1379 "cs.ATG" +#line 1383 "cs.ATG" initializer.StartLocation = t.Location; if (StartOf(31)) { VariableInitializer( -#line 1380 "cs.ATG" +#line 1384 "cs.ATG" out expr); -#line 1381 "cs.ATG" +#line 1385 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); while ( -#line 1382 "cs.ATG" +#line 1386 "cs.ATG" NotFinalComma()) { Expect(14); VariableInitializer( -#line 1383 "cs.ATG" +#line 1387 "cs.ATG" out expr); -#line 1384 "cs.ATG" +#line 1388 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); } if (la.kind == 14) { @@ -3370,105 +3352,105 @@ out expr); } Expect(17); -#line 1388 "cs.ATG" +#line 1392 "cs.ATG" initializer.EndLocation = t.Location; outExpr = initializer; } void AssignmentOperator( -#line 1356 "cs.ATG" +#line 1360 "cs.ATG" out AssignmentOperatorType op) { -#line 1357 "cs.ATG" +#line 1361 "cs.ATG" op = AssignmentOperatorType.None; if (la.kind == 3) { lexer.NextToken(); -#line 1359 "cs.ATG" +#line 1363 "cs.ATG" op = AssignmentOperatorType.Assign; } else if (la.kind == 38) { lexer.NextToken(); -#line 1360 "cs.ATG" +#line 1364 "cs.ATG" op = AssignmentOperatorType.Add; } else if (la.kind == 39) { lexer.NextToken(); -#line 1361 "cs.ATG" +#line 1365 "cs.ATG" op = AssignmentOperatorType.Subtract; } else if (la.kind == 40) { lexer.NextToken(); -#line 1362 "cs.ATG" +#line 1366 "cs.ATG" op = AssignmentOperatorType.Multiply; } else if (la.kind == 41) { lexer.NextToken(); -#line 1363 "cs.ATG" +#line 1367 "cs.ATG" op = AssignmentOperatorType.Divide; } else if (la.kind == 42) { lexer.NextToken(); -#line 1364 "cs.ATG" +#line 1368 "cs.ATG" op = AssignmentOperatorType.Modulus; } else if (la.kind == 43) { lexer.NextToken(); -#line 1365 "cs.ATG" +#line 1369 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; } else if (la.kind == 44) { lexer.NextToken(); -#line 1366 "cs.ATG" +#line 1370 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; } else if (la.kind == 45) { lexer.NextToken(); -#line 1367 "cs.ATG" +#line 1371 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; } else if (la.kind == 46) { lexer.NextToken(); -#line 1368 "cs.ATG" +#line 1372 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; } else if ( -#line 1369 "cs.ATG" +#line 1373 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { Expect(22); Expect(35); -#line 1370 "cs.ATG" +#line 1374 "cs.ATG" op = AssignmentOperatorType.ShiftRight; } else SynErr(194); } void CollectionOrObjectInitializer( -#line 1391 "cs.ATG" +#line 1395 "cs.ATG" out Expression outExpr) { -#line 1393 "cs.ATG" +#line 1397 "cs.ATG" Expression expr = null; CollectionInitializerExpression initializer = new CollectionInitializerExpression(); Expect(16); -#line 1397 "cs.ATG" +#line 1401 "cs.ATG" initializer.StartLocation = t.Location; if (StartOf(31)) { ObjectPropertyInitializerOrVariableInitializer( -#line 1398 "cs.ATG" +#line 1402 "cs.ATG" out expr); -#line 1399 "cs.ATG" +#line 1403 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); while ( -#line 1400 "cs.ATG" +#line 1404 "cs.ATG" NotFinalComma()) { Expect(14); ObjectPropertyInitializerOrVariableInitializer( -#line 1401 "cs.ATG" +#line 1405 "cs.ATG" out expr); -#line 1402 "cs.ATG" +#line 1406 "cs.ATG" SafeAdd(initializer, initializer.CreateExpressions, expr); } if (la.kind == 14) { @@ -3477,229 +3459,223 @@ out expr); } Expect(17); -#line 1406 "cs.ATG" +#line 1410 "cs.ATG" initializer.EndLocation = t.Location; outExpr = initializer; } void ObjectPropertyInitializerOrVariableInitializer( -#line 1409 "cs.ATG" +#line 1413 "cs.ATG" out Expression expr) { -#line 1410 "cs.ATG" +#line 1414 "cs.ATG" expr = null; if ( -#line 1412 "cs.ATG" +#line 1416 "cs.ATG" IdentAndAsgn()) { Identifier(); -#line 1414 "cs.ATG" +#line 1418 "cs.ATG" NamedArgumentExpression nae = new NamedArgumentExpression(t.val, null); nae.StartLocation = t.Location; Expression r = null; Expect(3); if (la.kind == 16) { CollectionOrObjectInitializer( -#line 1418 "cs.ATG" +#line 1422 "cs.ATG" out r); } else if (StartOf(31)) { VariableInitializer( -#line 1419 "cs.ATG" +#line 1423 "cs.ATG" out r); } else SynErr(195); -#line 1420 "cs.ATG" +#line 1424 "cs.ATG" nae.Expression = r; nae.EndLocation = t.EndLocation; expr = nae; } else if (StartOf(31)) { VariableInitializer( -#line 1422 "cs.ATG" +#line 1426 "cs.ATG" out expr); } else SynErr(196); } void LocalVariableDecl( -#line 1426 "cs.ATG" +#line 1430 "cs.ATG" out Statement stmt) { -#line 1428 "cs.ATG" +#line 1432 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1433 "cs.ATG" +#line 1437 "cs.ATG" out type); -#line 1433 "cs.ATG" +#line 1437 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1434 "cs.ATG" +#line 1438 "cs.ATG" out var); -#line 1434 "cs.ATG" +#line 1438 "cs.ATG" SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); while (la.kind == 14) { lexer.NextToken(); LocalVariableDeclarator( -#line 1435 "cs.ATG" +#line 1439 "cs.ATG" out var); -#line 1435 "cs.ATG" +#line 1439 "cs.ATG" SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); } -#line 1436 "cs.ATG" +#line 1440 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1439 "cs.ATG" +#line 1443 "cs.ATG" out VariableDeclaration var) { -#line 1440 "cs.ATG" +#line 1444 "cs.ATG" Expression expr = null; Identifier(); -#line 1442 "cs.ATG" +#line 1446 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1443 "cs.ATG" +#line 1447 "cs.ATG" out expr); -#line 1443 "cs.ATG" +#line 1447 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1482 "cs.ATG" +#line 1486 "cs.ATG" out Statement statement) { -#line 1484 "cs.ATG" +#line 1488 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; statement = null; -#line 1490 "cs.ATG" +#line 1494 "cs.ATG" Location startLocation = la.Location; if (la.kind == 16) { Block( -#line 1492 "cs.ATG" +#line 1496 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1495 "cs.ATG" +#line 1499 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1498 "cs.ATG" +#line 1502 "cs.ATG" UnCheckedAndLBrace()) { -#line 1498 "cs.ATG" +#line 1502 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 58) { lexer.NextToken(); } else if (la.kind == 118) { lexer.NextToken(); -#line 1499 "cs.ATG" +#line 1503 "cs.ATG" isChecked = false; } else SynErr(197); Block( -#line 1500 "cs.ATG" +#line 1504 "cs.ATG" out block); -#line 1500 "cs.ATG" +#line 1504 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 79) { IfStatement( -#line 1503 "cs.ATG" +#line 1507 "cs.ATG" out statement); } else if (la.kind == 110) { lexer.NextToken(); -#line 1505 "cs.ATG" +#line 1509 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1506 "cs.ATG" +#line 1510 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1507 "cs.ATG" +#line 1511 "cs.ATG" switchSections); Expect(17); -#line 1509 "cs.ATG" +#line 1513 "cs.ATG" statement = new SwitchStatement(expr, switchSections); - -#line 1510 "cs.ATG" - SetParent(switchSections, statement); } else if (la.kind == 125) { lexer.NextToken(); Expect(20); Expr( -#line 1513 "cs.ATG" +#line 1516 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1514 "cs.ATG" +#line 1517 "cs.ATG" out embeddedStatement); -#line 1515 "cs.ATG" +#line 1518 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1517 "cs.ATG" +#line 1520 "cs.ATG" out embeddedStatement); Expect(125); Expect(20); Expr( -#line 1518 "cs.ATG" +#line 1521 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1519 "cs.ATG" +#line 1522 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 76) { lexer.NextToken(); -#line 1521 "cs.ATG" +#line 1524 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(6)) { ForInitializer( -#line 1522 "cs.ATG" +#line 1525 "cs.ATG" out initializer); } Expect(11); if (StartOf(6)) { Expr( -#line 1523 "cs.ATG" +#line 1526 "cs.ATG" out expr); } Expect(11); if (StartOf(6)) { ForIterator( -#line 1524 "cs.ATG" +#line 1527 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1525 "cs.ATG" +#line 1528 "cs.ATG" out embeddedStatement); -#line 1526 "cs.ATG" +#line 1529 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); - SetParent(initializer, statement); - SetParent(iterator, statement); - } else if (la.kind == 77) { lexer.NextToken(); Expect(20); @@ -3890,36 +3866,34 @@ out elseStatement); (elseStatement as IfElseStatement).TrueStatement[0])); (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; - SetParent((statement as IfElseStatement).FalseStatement, statement); - SetParent((statement as IfElseStatement).ElseIfSections, statement); } } void SwitchSections( -#line 1625 "cs.ATG" +#line 1623 "cs.ATG" List switchSections) { -#line 1627 "cs.ATG" +#line 1625 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1631 "cs.ATG" +#line 1629 "cs.ATG" out label); -#line 1631 "cs.ATG" +#line 1629 "cs.ATG" SafeAdd(switchSection, switchSection.SwitchLabels, label); -#line 1632 "cs.ATG" +#line 1630 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(32)) { if (la.kind == 55 || la.kind == 63) { SwitchLabel( -#line 1634 "cs.ATG" +#line 1632 "cs.ATG" out label); -#line 1635 "cs.ATG" +#line 1633 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -3935,146 +3909,146 @@ out label); } } -#line 1647 "cs.ATG" +#line 1645 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1606 "cs.ATG" +#line 1604 "cs.ATG" out List initializer) { -#line 1608 "cs.ATG" +#line 1606 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1612 "cs.ATG" +#line 1610 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1612 "cs.ATG" +#line 1610 "cs.ATG" out stmt); -#line 1612 "cs.ATG" +#line 1610 "cs.ATG" initializer.Add(stmt); } else if (StartOf(6)) { StatementExpr( -#line 1613 "cs.ATG" +#line 1611 "cs.ATG" out stmt); -#line 1613 "cs.ATG" +#line 1611 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1613 "cs.ATG" +#line 1611 "cs.ATG" out stmt); -#line 1613 "cs.ATG" +#line 1611 "cs.ATG" initializer.Add(stmt); } } else SynErr(201); } void ForIterator( -#line 1616 "cs.ATG" +#line 1614 "cs.ATG" out List iterator) { -#line 1618 "cs.ATG" +#line 1616 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1622 "cs.ATG" +#line 1620 "cs.ATG" out stmt); -#line 1622 "cs.ATG" +#line 1620 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1622 "cs.ATG" +#line 1620 "cs.ATG" out stmt); -#line 1622 "cs.ATG" +#line 1620 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1702 "cs.ATG" +#line 1700 "cs.ATG" out Statement stmt) { -#line 1703 "cs.ATG" +#line 1701 "cs.ATG" Expression expr; stmt = null; Expect(78); if (StartOf(19)) { Identifier(); -#line 1707 "cs.ATG" +#line 1705 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1708 "cs.ATG" +#line 1706 "cs.ATG" out expr); Expect(11); -#line 1708 "cs.ATG" +#line 1706 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(11); -#line 1709 "cs.ATG" +#line 1707 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(202); } void StatementExpr( -#line 1729 "cs.ATG" +#line 1727 "cs.ATG" out Statement stmt) { -#line 1730 "cs.ATG" +#line 1728 "cs.ATG" Expression expr; Expr( -#line 1732 "cs.ATG" +#line 1730 "cs.ATG" out expr); -#line 1735 "cs.ATG" +#line 1733 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1657 "cs.ATG" +#line 1655 "cs.ATG" out Statement tryStatement) { -#line 1659 "cs.ATG" +#line 1657 "cs.ATG" Statement blockStmt = null, finallyStmt = null; List catchClauses = null; Expect(114); Block( -#line 1663 "cs.ATG" +#line 1661 "cs.ATG" out blockStmt); if (la.kind == 56) { CatchClauses( -#line 1665 "cs.ATG" +#line 1663 "cs.ATG" out catchClauses); if (la.kind == 73) { lexer.NextToken(); Block( -#line 1665 "cs.ATG" +#line 1663 "cs.ATG" out finallyStmt); } } else if (la.kind == 73) { lexer.NextToken(); Block( -#line 1666 "cs.ATG" +#line 1664 "cs.ATG" out finallyStmt); } else SynErr(203); -#line 1669 "cs.ATG" +#line 1667 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); if (catchClauses != null) { foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; @@ -4083,202 +4057,202 @@ out finallyStmt); } void ResourceAcquisition( -#line 1713 "cs.ATG" +#line 1711 "cs.ATG" out Statement stmt) { -#line 1715 "cs.ATG" +#line 1713 "cs.ATG" stmt = null; Expression expr; if ( -#line 1720 "cs.ATG" +#line 1718 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1720 "cs.ATG" +#line 1718 "cs.ATG" out stmt); } else if (StartOf(6)) { Expr( -#line 1721 "cs.ATG" +#line 1719 "cs.ATG" out expr); -#line 1725 "cs.ATG" +#line 1723 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(204); } void SwitchLabel( -#line 1650 "cs.ATG" +#line 1648 "cs.ATG" out CaseLabel label) { -#line 1651 "cs.ATG" +#line 1649 "cs.ATG" Expression expr = null; label = null; if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1653 "cs.ATG" +#line 1651 "cs.ATG" out expr); Expect(9); -#line 1653 "cs.ATG" +#line 1651 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(9); -#line 1654 "cs.ATG" +#line 1652 "cs.ATG" label = new CaseLabel(); } else SynErr(205); } void CatchClauses( -#line 1676 "cs.ATG" +#line 1674 "cs.ATG" out List catchClauses) { -#line 1678 "cs.ATG" +#line 1676 "cs.ATG" catchClauses = new List(); Expect(56); -#line 1681 "cs.ATG" +#line 1679 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; if (la.kind == 16) { Block( -#line 1687 "cs.ATG" +#line 1685 "cs.ATG" out stmt); -#line 1687 "cs.ATG" +#line 1685 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1689 "cs.ATG" +#line 1687 "cs.ATG" out typeRef, false); -#line 1689 "cs.ATG" +#line 1687 "cs.ATG" identifier = null; if (StartOf(19)) { Identifier(); -#line 1690 "cs.ATG" +#line 1688 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1691 "cs.ATG" +#line 1689 "cs.ATG" out stmt); -#line 1692 "cs.ATG" +#line 1690 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); while ( -#line 1693 "cs.ATG" +#line 1691 "cs.ATG" IsTypedCatch()) { Expect(56); Expect(20); ClassType( -#line 1693 "cs.ATG" +#line 1691 "cs.ATG" out typeRef, false); -#line 1693 "cs.ATG" +#line 1691 "cs.ATG" identifier = null; if (StartOf(19)) { Identifier(); -#line 1694 "cs.ATG" +#line 1692 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1695 "cs.ATG" +#line 1693 "cs.ATG" out stmt); -#line 1696 "cs.ATG" +#line 1694 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); } if (la.kind == 56) { lexer.NextToken(); Block( -#line 1698 "cs.ATG" +#line 1696 "cs.ATG" out stmt); -#line 1698 "cs.ATG" +#line 1696 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(206); } void UnaryExpr( -#line 1762 "cs.ATG" +#line 1760 "cs.ATG" out Expression uExpr) { -#line 1764 "cs.ATG" +#line 1762 "cs.ATG" TypeReference type = null; Expression expr = null; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(33) || -#line 1786 "cs.ATG" +#line 1784 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1773 "cs.ATG" +#line 1771 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1774 "cs.ATG" +#line 1772 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 1775 "cs.ATG" +#line 1773 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1776 "cs.ATG" +#line 1774 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1777 "cs.ATG" +#line 1775 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1778 "cs.ATG" +#line 1776 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 1779 "cs.ATG" +#line 1777 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 1780 "cs.ATG" +#line 1778 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf)); } else { Expect(20); Type( -#line 1786 "cs.ATG" +#line 1784 "cs.ATG" out type); Expect(21); -#line 1786 "cs.ATG" +#line 1784 "cs.ATG" expressions.Add(new CastExpression(type)); } } if ( -#line 1791 "cs.ATG" +#line 1789 "cs.ATG" LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) { Expect(2); -#line 1794 "cs.ATG" +#line 1792 "cs.ATG" expressions.RemoveAt(expressions.Count - 1); if (t.literalValue is uint) { expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString()); @@ -4290,11 +4264,11 @@ LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffi } else if (StartOf(34)) { PrimaryExpr( -#line 1803 "cs.ATG" +#line 1801 "cs.ATG" out expr); } else SynErr(207); -#line 1805 "cs.ATG" +#line 1803 "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) { @@ -4312,325 +4286,325 @@ out expr); } void ConditionalOrExpr( -#line 2121 "cs.ATG" +#line 2119 "cs.ATG" ref Expression outExpr) { -#line 2122 "cs.ATG" +#line 2120 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2124 "cs.ATG" +#line 2122 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2124 "cs.ATG" +#line 2122 "cs.ATG" out expr); ConditionalAndExpr( -#line 2124 "cs.ATG" +#line 2122 "cs.ATG" ref expr); -#line 2124 "cs.ATG" +#line 2122 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1822 "cs.ATG" +#line 1820 "cs.ATG" out Expression pexpr) { -#line 1824 "cs.ATG" +#line 1822 "cs.ATG" TypeReference type = null; Expression expr; pexpr = null; -#line 1829 "cs.ATG" +#line 1827 "cs.ATG" Location startLocation = la.Location; if (la.kind == 113) { lexer.NextToken(); -#line 1831 "cs.ATG" +#line 1829 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); -#line 1832 "cs.ATG" +#line 1830 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); -#line 1833 "cs.ATG" +#line 1831 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1834 "cs.ATG" +#line 1832 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; } else if ( -#line 1835 "cs.ATG" +#line 1833 "cs.ATG" StartOfQueryExpression()) { QueryExpression( -#line 1836 "cs.ATG" +#line 1834 "cs.ATG" out pexpr); } else if ( -#line 1837 "cs.ATG" +#line 1835 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 1838 "cs.ATG" +#line 1836 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1839 "cs.ATG" +#line 1837 "cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); -#line 1840 "cs.ATG" +#line 1838 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); } else if (StartOf(19)) { Identifier(); -#line 1844 "cs.ATG" +#line 1842 "cs.ATG" pexpr = new IdentifierExpression(t.val); if (la.kind == 48 || -#line 1847 "cs.ATG" +#line 1845 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { if (la.kind == 48) { ShortedLambdaExpression( -#line 1846 "cs.ATG" +#line 1844 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); } else { -#line 1848 "cs.ATG" +#line 1846 "cs.ATG" List typeList; TypeArgumentList( -#line 1849 "cs.ATG" +#line 1847 "cs.ATG" out typeList, false); -#line 1850 "cs.ATG" +#line 1848 "cs.ATG" ((IdentifierExpression)pexpr).TypeArguments = typeList; } } } else if ( -#line 1852 "cs.ATG" +#line 1850 "cs.ATG" IsLambdaExpression()) { LambdaExpression( -#line 1853 "cs.ATG" +#line 1851 "cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1856 "cs.ATG" +#line 1854 "cs.ATG" out expr); Expect(21); -#line 1856 "cs.ATG" +#line 1854 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(35)) { -#line 1859 "cs.ATG" +#line 1857 "cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); -#line 1860 "cs.ATG" +#line 1858 "cs.ATG" val = "System.Boolean"; break; } case 54: { lexer.NextToken(); -#line 1861 "cs.ATG" +#line 1859 "cs.ATG" val = "System.Byte"; break; } case 57: { lexer.NextToken(); -#line 1862 "cs.ATG" +#line 1860 "cs.ATG" val = "System.Char"; break; } case 62: { lexer.NextToken(); -#line 1863 "cs.ATG" +#line 1861 "cs.ATG" val = "System.Decimal"; break; } case 66: { lexer.NextToken(); -#line 1864 "cs.ATG" +#line 1862 "cs.ATG" val = "System.Double"; break; } case 75: { lexer.NextToken(); -#line 1865 "cs.ATG" +#line 1863 "cs.ATG" val = "System.Single"; break; } case 82: { lexer.NextToken(); -#line 1866 "cs.ATG" +#line 1864 "cs.ATG" val = "System.Int32"; break; } case 87: { lexer.NextToken(); -#line 1867 "cs.ATG" +#line 1865 "cs.ATG" val = "System.Int64"; break; } case 91: { lexer.NextToken(); -#line 1868 "cs.ATG" +#line 1866 "cs.ATG" val = "System.Object"; break; } case 102: { lexer.NextToken(); -#line 1869 "cs.ATG" +#line 1867 "cs.ATG" val = "System.SByte"; break; } case 104: { lexer.NextToken(); -#line 1870 "cs.ATG" +#line 1868 "cs.ATG" val = "System.Int16"; break; } case 108: { lexer.NextToken(); -#line 1871 "cs.ATG" +#line 1869 "cs.ATG" val = "System.String"; break; } case 116: { lexer.NextToken(); -#line 1872 "cs.ATG" +#line 1870 "cs.ATG" val = "System.UInt32"; break; } case 117: { lexer.NextToken(); -#line 1873 "cs.ATG" +#line 1871 "cs.ATG" val = "System.UInt64"; break; } case 120: { lexer.NextToken(); -#line 1874 "cs.ATG" +#line 1872 "cs.ATG" val = "System.UInt16"; break; } case 123: { lexer.NextToken(); -#line 1875 "cs.ATG" +#line 1873 "cs.ATG" val = "System.Void"; break; } } -#line 1877 "cs.ATG" +#line 1875 "cs.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; } else if (la.kind == 111) { lexer.NextToken(); -#line 1880 "cs.ATG" +#line 1878 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 51) { lexer.NextToken(); -#line 1882 "cs.ATG" +#line 1880 "cs.ATG" pexpr = new BaseReferenceExpression(); } else if (la.kind == 89) { NewExpression( -#line 1885 "cs.ATG" +#line 1883 "cs.ATG" out pexpr); } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( -#line 1889 "cs.ATG" +#line 1887 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1889 "cs.ATG" +#line 1887 "cs.ATG" type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( -#line 1890 "cs.ATG" +#line 1888 "cs.ATG" out type, true, true); } else SynErr(208); Expect(21); -#line 1892 "cs.ATG" +#line 1890 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( -#line 1894 "cs.ATG" +#line 1892 "cs.ATG" out type); Expect(21); -#line 1894 "cs.ATG" +#line 1892 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( -#line 1895 "cs.ATG" +#line 1893 "cs.ATG" out type); Expect(21); -#line 1895 "cs.ATG" +#line 1893 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( -#line 1896 "cs.ATG" +#line 1894 "cs.ATG" out expr); Expect(21); -#line 1896 "cs.ATG" +#line 1894 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( -#line 1897 "cs.ATG" +#line 1895 "cs.ATG" out expr); Expect(21); -#line 1897 "cs.ATG" +#line 1895 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( -#line 1898 "cs.ATG" +#line 1896 "cs.ATG" out expr); -#line 1898 "cs.ATG" +#line 1896 "cs.ATG" pexpr = expr; } else SynErr(209); -#line 1900 "cs.ATG" +#line 1898 "cs.ATG" if (pexpr != null) { pexpr.StartLocation = startLocation; pexpr.EndLocation = t.EndLocation; @@ -4639,78 +4613,78 @@ out expr); while (StartOf(36)) { if (la.kind == 31 || la.kind == 32) { -#line 1906 "cs.ATG" +#line 1904 "cs.ATG" startLocation = la.Location; if (la.kind == 31) { lexer.NextToken(); -#line 1908 "cs.ATG" +#line 1906 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 1909 "cs.ATG" +#line 1907 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(210); } else if (la.kind == 47) { PointerMemberAccess( -#line 1912 "cs.ATG" +#line 1910 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 15) { MemberAccess( -#line 1913 "cs.ATG" +#line 1911 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 20) { lexer.NextToken(); -#line 1917 "cs.ATG" +#line 1915 "cs.ATG" List parameters = new List(); -#line 1918 "cs.ATG" +#line 1916 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); if (StartOf(26)) { Argument( -#line 1919 "cs.ATG" +#line 1917 "cs.ATG" out expr); -#line 1919 "cs.ATG" +#line 1917 "cs.ATG" SafeAdd(pexpr, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1920 "cs.ATG" +#line 1918 "cs.ATG" out expr); -#line 1920 "cs.ATG" +#line 1918 "cs.ATG" SafeAdd(pexpr, parameters, expr); } } Expect(21); } else { -#line 1926 "cs.ATG" +#line 1924 "cs.ATG" List indices = new List(); pexpr = new IndexerExpression(pexpr, indices); lexer.NextToken(); Expr( -#line 1929 "cs.ATG" +#line 1927 "cs.ATG" out expr); -#line 1929 "cs.ATG" +#line 1927 "cs.ATG" SafeAdd(pexpr, indices, expr); while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1930 "cs.ATG" +#line 1928 "cs.ATG" out expr); -#line 1930 "cs.ATG" +#line 1928 "cs.ATG" SafeAdd(pexpr, indices, expr); } Expect(19); -#line 1933 "cs.ATG" +#line 1931 "cs.ATG" if (pexpr != null) { pexpr.StartLocation = startLocation; pexpr.EndLocation = t.EndLocation; @@ -4721,83 +4695,83 @@ out expr); } void QueryExpression( -#line 2357 "cs.ATG" +#line 2355 "cs.ATG" out Expression outExpr) { -#line 2358 "cs.ATG" +#line 2356 "cs.ATG" QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; QueryExpressionFromClause fromClause; QueryExpressionFromClause( -#line 2362 "cs.ATG" +#line 2360 "cs.ATG" out fromClause); -#line 2362 "cs.ATG" +#line 2360 "cs.ATG" q.FromClause = fromClause; QueryExpressionBody( -#line 2363 "cs.ATG" +#line 2361 "cs.ATG" ref q); -#line 2364 "cs.ATG" +#line 2362 "cs.ATG" q.EndLocation = t.EndLocation; outExpr = q; /* set outExpr to q again if QueryExpressionBody changed it (can happen with 'into' clauses) */ } void ShortedLambdaExpression( -#line 2045 "cs.ATG" +#line 2043 "cs.ATG" IdentifierExpression ident, out Expression pexpr) { -#line 2046 "cs.ATG" +#line 2044 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); -#line 2051 "cs.ATG" +#line 2049 "cs.ATG" lambda.StartLocation = ident.StartLocation; - lambda.Parameters.Add(new ParameterDeclarationExpression(null, ident.Identifier)); + SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); lambda.Parameters[0].StartLocation = ident.StartLocation; lambda.Parameters[0].EndLocation = ident.EndLocation; LambdaExpressionBody( -#line 2056 "cs.ATG" +#line 2054 "cs.ATG" lambda); } void TypeArgumentList( -#line 2291 "cs.ATG" +#line 2289 "cs.ATG" out List types, bool canBeUnbound) { -#line 2293 "cs.ATG" +#line 2291 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2298 "cs.ATG" +#line 2296 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2299 "cs.ATG" +#line 2297 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2300 "cs.ATG" +#line 2298 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(10)) { Type( -#line 2301 "cs.ATG" +#line 2299 "cs.ATG" out type); -#line 2301 "cs.ATG" +#line 2299 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2302 "cs.ATG" +#line 2300 "cs.ATG" out type); -#line 2302 "cs.ATG" +#line 2300 "cs.ATG" if (type != null) { types.Add(type); } } } else SynErr(211); @@ -4805,10 +4779,10 @@ out type); } void LambdaExpression( -#line 2025 "cs.ATG" +#line 2023 "cs.ATG" out Expression outExpr) { -#line 2027 "cs.ATG" +#line 2025 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; ParameterDeclarationExpression p; @@ -4817,33 +4791,33 @@ out Expression outExpr) { Expect(20); if (StartOf(10)) { LambdaExpressionParameter( -#line 2035 "cs.ATG" +#line 2033 "cs.ATG" out p); -#line 2035 "cs.ATG" +#line 2033 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); while (la.kind == 14) { lexer.NextToken(); LambdaExpressionParameter( -#line 2037 "cs.ATG" +#line 2035 "cs.ATG" out p); -#line 2037 "cs.ATG" +#line 2035 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); } } Expect(21); Expect(48); LambdaExpressionBody( -#line 2042 "cs.ATG" +#line 2040 "cs.ATG" lambda); } void NewExpression( -#line 1972 "cs.ATG" +#line 1970 "cs.ATG" out Expression pexpr) { -#line 1973 "cs.ATG" +#line 1971 "cs.ATG" pexpr = null; List parameters = new List(); TypeReference type = null; @@ -4852,65 +4826,65 @@ out Expression pexpr) { Expect(89); if (StartOf(10)) { NonArrayType( -#line 1980 "cs.ATG" +#line 1978 "cs.ATG" out type); } if (la.kind == 16 || la.kind == 20) { if (la.kind == 20) { -#line 1986 "cs.ATG" +#line 1984 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); lexer.NextToken(); -#line 1987 "cs.ATG" +#line 1985 "cs.ATG" if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); if (StartOf(26)) { Argument( -#line 1988 "cs.ATG" +#line 1986 "cs.ATG" out expr); -#line 1988 "cs.ATG" +#line 1986 "cs.ATG" SafeAdd(oce, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1989 "cs.ATG" +#line 1987 "cs.ATG" out expr); -#line 1989 "cs.ATG" +#line 1987 "cs.ATG" SafeAdd(oce, parameters, expr); } } Expect(21); -#line 1991 "cs.ATG" +#line 1989 "cs.ATG" pexpr = oce; if (la.kind == 16) { CollectionOrObjectInitializer( -#line 1992 "cs.ATG" +#line 1990 "cs.ATG" out expr); -#line 1992 "cs.ATG" +#line 1990 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; } } else { -#line 1993 "cs.ATG" +#line 1991 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); CollectionOrObjectInitializer( -#line 1994 "cs.ATG" +#line 1992 "cs.ATG" out expr); -#line 1994 "cs.ATG" +#line 1992 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; -#line 1995 "cs.ATG" +#line 1993 "cs.ATG" pexpr = oce; } } else if (la.kind == 18) { lexer.NextToken(); -#line 2000 "cs.ATG" +#line 1998 "cs.ATG" ArrayCreateExpression ace = new ArrayCreateExpression(type); /* we must not change RankSpecifier on the null type reference*/ if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); } @@ -4921,80 +4895,80 @@ out expr); while (la.kind == 14) { lexer.NextToken(); -#line 2007 "cs.ATG" +#line 2005 "cs.ATG" dims += 1; } Expect(19); -#line 2008 "cs.ATG" +#line 2006 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2009 "cs.ATG" +#line 2007 "cs.ATG" ++dims; } Expect(19); -#line 2009 "cs.ATG" +#line 2007 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2010 "cs.ATG" +#line 2008 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); CollectionInitializer( -#line 2011 "cs.ATG" +#line 2009 "cs.ATG" out expr); -#line 2011 "cs.ATG" +#line 2009 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } else if (StartOf(6)) { Expr( -#line 2012 "cs.ATG" +#line 2010 "cs.ATG" out expr); -#line 2012 "cs.ATG" +#line 2010 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2013 "cs.ATG" +#line 2011 "cs.ATG" dims += 1; Expr( -#line 2014 "cs.ATG" +#line 2012 "cs.ATG" out expr); -#line 2014 "cs.ATG" +#line 2012 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2016 "cs.ATG" +#line 2014 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2017 "cs.ATG" +#line 2015 "cs.ATG" ++dims; } Expect(19); -#line 2017 "cs.ATG" +#line 2015 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2018 "cs.ATG" +#line 2016 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { CollectionInitializer( -#line 2019 "cs.ATG" +#line 2017 "cs.ATG" out expr); -#line 2019 "cs.ATG" +#line 2017 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } } else SynErr(212); @@ -5002,10 +4976,10 @@ out expr); } void AnonymousMethodExpr( -#line 2088 "cs.ATG" +#line 2086 "cs.ATG" out Expression outExpr) { -#line 2090 "cs.ATG" +#line 2088 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; BlockStatement stmt; @@ -5016,59 +4990,59 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(11)) { FormalParameterList( -#line 2099 "cs.ATG" +#line 2097 "cs.ATG" p); -#line 2099 "cs.ATG" +#line 2097 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 2101 "cs.ATG" +#line 2099 "cs.ATG" expr.HasParameterList = true; } BlockInsideExpression( -#line 2103 "cs.ATG" +#line 2101 "cs.ATG" out stmt); -#line 2103 "cs.ATG" +#line 2101 "cs.ATG" expr.Body = stmt; -#line 2104 "cs.ATG" +#line 2102 "cs.ATG" expr.EndLocation = t.Location; } void PointerMemberAccess( -#line 1960 "cs.ATG" +#line 1958 "cs.ATG" out Expression expr, Expression target) { -#line 1961 "cs.ATG" +#line 1959 "cs.ATG" List typeList; Expect(47); Identifier(); -#line 1965 "cs.ATG" +#line 1963 "cs.ATG" expr = new PointerReferenceExpression(target, t.val); if ( -#line 1966 "cs.ATG" +#line 1964 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 1967 "cs.ATG" +#line 1965 "cs.ATG" out typeList, false); -#line 1968 "cs.ATG" +#line 1966 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void MemberAccess( -#line 1941 "cs.ATG" +#line 1939 "cs.ATG" out Expression expr, Expression target) { -#line 1942 "cs.ATG" +#line 1940 "cs.ATG" List typeList; -#line 1944 "cs.ATG" +#line 1942 "cs.ATG" if (ShouldConvertTargetExpressionToTypeReference(target)) { TypeReference type = GetTypeReferenceFromExpression(target); if (type != null) { @@ -5079,44 +5053,44 @@ out Expression expr, Expression target) { Expect(15); Identifier(); -#line 1953 "cs.ATG" +#line 1951 "cs.ATG" expr = new MemberReferenceExpression(target, t.val); if ( -#line 1954 "cs.ATG" +#line 1952 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 1955 "cs.ATG" +#line 1953 "cs.ATG" out typeList, false); -#line 1956 "cs.ATG" +#line 1954 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void LambdaExpressionParameter( -#line 2059 "cs.ATG" +#line 2057 "cs.ATG" out ParameterDeclarationExpression p) { -#line 2060 "cs.ATG" +#line 2058 "cs.ATG" Location start = la.Location; p = null; TypeReference type; if ( -#line 2064 "cs.ATG" +#line 2062 "cs.ATG" Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { Identifier(); -#line 2066 "cs.ATG" +#line 2064 "cs.ATG" p = new ParameterDeclarationExpression(null, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; } else if (StartOf(10)) { Type( -#line 2069 "cs.ATG" +#line 2067 "cs.ATG" out type); Identifier(); -#line 2071 "cs.ATG" +#line 2069 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5124,263 +5098,263 @@ out type); } void LambdaExpressionBody( -#line 2077 "cs.ATG" +#line 2075 "cs.ATG" LambdaExpression lambda) { -#line 2078 "cs.ATG" +#line 2076 "cs.ATG" Expression expr; BlockStatement stmt; if (la.kind == 16) { BlockInsideExpression( -#line 2081 "cs.ATG" +#line 2079 "cs.ATG" out stmt); -#line 2081 "cs.ATG" +#line 2079 "cs.ATG" lambda.StatementBody = stmt; } else if (StartOf(6)) { Expr( -#line 2082 "cs.ATG" +#line 2080 "cs.ATG" out expr); -#line 2082 "cs.ATG" +#line 2080 "cs.ATG" lambda.ExpressionBody = expr; } else SynErr(215); -#line 2084 "cs.ATG" +#line 2082 "cs.ATG" lambda.EndLocation = t.EndLocation; -#line 2085 "cs.ATG" +#line 2083 "cs.ATG" lambda.ExtendedEndLocation = la.Location; } void BlockInsideExpression( -#line 2107 "cs.ATG" +#line 2105 "cs.ATG" out BlockStatement outStmt) { -#line 2108 "cs.ATG" +#line 2106 "cs.ATG" Statement stmt = null; outStmt = null; -#line 2112 "cs.ATG" +#line 2110 "cs.ATG" if (compilationUnit != null) { Block( -#line 2113 "cs.ATG" +#line 2111 "cs.ATG" out stmt); -#line 2113 "cs.ATG" +#line 2111 "cs.ATG" outStmt = (BlockStatement)stmt; -#line 2114 "cs.ATG" +#line 2112 "cs.ATG" } else { Expect(16); -#line 2116 "cs.ATG" +#line 2114 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 2118 "cs.ATG" +#line 2116 "cs.ATG" } } void ConditionalAndExpr( -#line 2127 "cs.ATG" +#line 2125 "cs.ATG" ref Expression outExpr) { -#line 2128 "cs.ATG" +#line 2126 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2130 "cs.ATG" +#line 2128 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2130 "cs.ATG" +#line 2128 "cs.ATG" out expr); InclusiveOrExpr( -#line 2130 "cs.ATG" +#line 2128 "cs.ATG" ref expr); -#line 2130 "cs.ATG" +#line 2128 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2133 "cs.ATG" +#line 2131 "cs.ATG" ref Expression outExpr) { -#line 2134 "cs.ATG" +#line 2132 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2136 "cs.ATG" +#line 2134 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2136 "cs.ATG" +#line 2134 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2136 "cs.ATG" +#line 2134 "cs.ATG" ref expr); -#line 2136 "cs.ATG" +#line 2134 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2139 "cs.ATG" +#line 2137 "cs.ATG" ref Expression outExpr) { -#line 2140 "cs.ATG" +#line 2138 "cs.ATG" Expression expr; AndExpr( -#line 2142 "cs.ATG" +#line 2140 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2142 "cs.ATG" +#line 2140 "cs.ATG" out expr); AndExpr( -#line 2142 "cs.ATG" +#line 2140 "cs.ATG" ref expr); -#line 2142 "cs.ATG" +#line 2140 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2145 "cs.ATG" +#line 2143 "cs.ATG" ref Expression outExpr) { -#line 2146 "cs.ATG" +#line 2144 "cs.ATG" Expression expr; EqualityExpr( -#line 2148 "cs.ATG" +#line 2146 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2148 "cs.ATG" +#line 2146 "cs.ATG" out expr); EqualityExpr( -#line 2148 "cs.ATG" +#line 2146 "cs.ATG" ref expr); -#line 2148 "cs.ATG" +#line 2146 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2151 "cs.ATG" +#line 2149 "cs.ATG" ref Expression outExpr) { -#line 2153 "cs.ATG" +#line 2151 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2157 "cs.ATG" +#line 2155 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2160 "cs.ATG" +#line 2158 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2161 "cs.ATG" +#line 2159 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2163 "cs.ATG" +#line 2161 "cs.ATG" out expr); RelationalExpr( -#line 2163 "cs.ATG" +#line 2161 "cs.ATG" ref expr); -#line 2163 "cs.ATG" +#line 2161 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2167 "cs.ATG" +#line 2165 "cs.ATG" ref Expression outExpr) { -#line 2169 "cs.ATG" +#line 2167 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2174 "cs.ATG" +#line 2172 "cs.ATG" ref outExpr); while (StartOf(37)) { if (StartOf(38)) { if (la.kind == 23) { lexer.NextToken(); -#line 2176 "cs.ATG" +#line 2174 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2177 "cs.ATG" +#line 2175 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2178 "cs.ATG" +#line 2176 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2179 "cs.ATG" +#line 2177 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(216); UnaryExpr( -#line 2181 "cs.ATG" +#line 2179 "cs.ATG" out expr); ShiftExpr( -#line 2182 "cs.ATG" +#line 2180 "cs.ATG" ref expr); -#line 2183 "cs.ATG" +#line 2181 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 85) { lexer.NextToken(); TypeWithRestriction( -#line 2186 "cs.ATG" +#line 2184 "cs.ATG" out type, false, false); if ( -#line 2187 "cs.ATG" +#line 2185 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2188 "cs.ATG" +#line 2186 "cs.ATG" ref type); } -#line 2189 "cs.ATG" +#line 2187 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 50) { lexer.NextToken(); TypeWithRestriction( -#line 2191 "cs.ATG" +#line 2189 "cs.ATG" out type, false, false); if ( -#line 2192 "cs.ATG" +#line 2190 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2193 "cs.ATG" +#line 2191 "cs.ATG" ref type); } -#line 2194 "cs.ATG" +#line 2192 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(217); } @@ -5388,83 +5362,83 @@ ref type); } void ShiftExpr( -#line 2199 "cs.ATG" +#line 2197 "cs.ATG" ref Expression outExpr) { -#line 2201 "cs.ATG" +#line 2199 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2205 "cs.ATG" +#line 2203 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2208 "cs.ATG" +#line 2206 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2207 "cs.ATG" +#line 2205 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2209 "cs.ATG" +#line 2207 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2212 "cs.ATG" +#line 2210 "cs.ATG" out expr); AdditiveExpr( -#line 2212 "cs.ATG" +#line 2210 "cs.ATG" ref expr); -#line 2212 "cs.ATG" +#line 2210 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2216 "cs.ATG" +#line 2214 "cs.ATG" ref Expression outExpr) { -#line 2218 "cs.ATG" +#line 2216 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2222 "cs.ATG" +#line 2220 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2225 "cs.ATG" +#line 2223 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2226 "cs.ATG" +#line 2224 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2228 "cs.ATG" +#line 2226 "cs.ATG" out expr); MultiplicativeExpr( -#line 2228 "cs.ATG" +#line 2226 "cs.ATG" ref expr); -#line 2228 "cs.ATG" +#line 2226 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2232 "cs.ATG" +#line 2230 "cs.ATG" ref Expression outExpr) { -#line 2234 "cs.ATG" +#line 2232 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5472,82 +5446,82 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2240 "cs.ATG" +#line 2238 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2241 "cs.ATG" +#line 2239 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2242 "cs.ATG" +#line 2240 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2244 "cs.ATG" +#line 2242 "cs.ATG" out expr); -#line 2244 "cs.ATG" +#line 2242 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2348 "cs.ATG" +#line 2346 "cs.ATG" out TypeReference type) { -#line 2349 "cs.ATG" +#line 2347 "cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); -#line 2351 "cs.ATG" +#line 2349 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); -#line 2352 "cs.ATG" +#line 2350 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); -#line 2353 "cs.ATG" +#line 2351 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( -#line 2354 "cs.ATG" +#line 2352 "cs.ATG" out t); -#line 2354 "cs.ATG" +#line 2352 "cs.ATG" type = t; } else SynErr(218); } void QueryExpressionFromClause( -#line 2369 "cs.ATG" +#line 2367 "cs.ATG" out QueryExpressionFromClause fc) { -#line 2370 "cs.ATG" +#line 2368 "cs.ATG" fc = new QueryExpressionFromClause(); fc.StartLocation = la.Location; Expect(137); QueryExpressionFromOrJoinClause( -#line 2374 "cs.ATG" +#line 2372 "cs.ATG" fc); -#line 2375 "cs.ATG" +#line 2373 "cs.ATG" fc.EndLocation = t.EndLocation; } void QueryExpressionBody( -#line 2405 "cs.ATG" +#line 2403 "cs.ATG" ref QueryExpression q) { -#line 2406 "cs.ATG" +#line 2404 "cs.ATG" QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; QueryExpressionOrderClause orderClause; @@ -5556,249 +5530,249 @@ ref QueryExpression q) { while (StartOf(39)) { if (la.kind == 137) { QueryExpressionFromClause( -#line 2412 "cs.ATG" +#line 2410 "cs.ATG" out fromClause); -#line 2412 "cs.ATG" +#line 2410 "cs.ATG" SafeAdd(q, q.MiddleClauses, fromClause); } else if (la.kind == 127) { QueryExpressionWhereClause( -#line 2413 "cs.ATG" +#line 2411 "cs.ATG" out whereClause); -#line 2413 "cs.ATG" +#line 2411 "cs.ATG" SafeAdd(q, q.MiddleClauses, whereClause); } else if (la.kind == 141) { QueryExpressionLetClause( -#line 2414 "cs.ATG" +#line 2412 "cs.ATG" out letClause); -#line 2414 "cs.ATG" +#line 2412 "cs.ATG" SafeAdd(q, q.MiddleClauses, letClause); } else if (la.kind == 142) { QueryExpressionJoinClause( -#line 2415 "cs.ATG" +#line 2413 "cs.ATG" out joinClause); -#line 2415 "cs.ATG" +#line 2413 "cs.ATG" SafeAdd(q, q.MiddleClauses, joinClause); } else { QueryExpressionOrderByClause( -#line 2416 "cs.ATG" +#line 2414 "cs.ATG" out orderClause); -#line 2416 "cs.ATG" +#line 2414 "cs.ATG" SafeAdd(q, q.MiddleClauses, orderClause); } } if (la.kind == 133) { QueryExpressionSelectClause( -#line 2418 "cs.ATG" +#line 2416 "cs.ATG" out selectClause); -#line 2418 "cs.ATG" +#line 2416 "cs.ATG" q.SelectOrGroupClause = selectClause; } else if (la.kind == 134) { QueryExpressionGroupClause( -#line 2419 "cs.ATG" +#line 2417 "cs.ATG" out groupClause); -#line 2419 "cs.ATG" +#line 2417 "cs.ATG" q.SelectOrGroupClause = groupClause; } else SynErr(219); if (la.kind == 136) { QueryExpressionIntoClause( -#line 2421 "cs.ATG" +#line 2419 "cs.ATG" ref q); } } void QueryExpressionFromOrJoinClause( -#line 2395 "cs.ATG" +#line 2393 "cs.ATG" QueryExpressionFromOrJoinClause fjc) { -#line 2396 "cs.ATG" +#line 2394 "cs.ATG" TypeReference type; Expression expr; -#line 2398 "cs.ATG" +#line 2396 "cs.ATG" fjc.Type = null; if ( -#line 2399 "cs.ATG" +#line 2397 "cs.ATG" IsLocalVarDecl()) { Type( -#line 2399 "cs.ATG" +#line 2397 "cs.ATG" out type); -#line 2399 "cs.ATG" +#line 2397 "cs.ATG" fjc.Type = type; } Identifier(); -#line 2400 "cs.ATG" +#line 2398 "cs.ATG" fjc.Identifier = t.val; Expect(81); Expr( -#line 2402 "cs.ATG" +#line 2400 "cs.ATG" out expr); -#line 2402 "cs.ATG" +#line 2400 "cs.ATG" fjc.InExpression = expr; } void QueryExpressionJoinClause( -#line 2378 "cs.ATG" +#line 2376 "cs.ATG" out QueryExpressionJoinClause jc) { -#line 2379 "cs.ATG" +#line 2377 "cs.ATG" jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; Expression expr; Expect(142); QueryExpressionFromOrJoinClause( -#line 2384 "cs.ATG" +#line 2382 "cs.ATG" jc); Expect(143); Expr( -#line 2386 "cs.ATG" +#line 2384 "cs.ATG" out expr); -#line 2386 "cs.ATG" +#line 2384 "cs.ATG" jc.OnExpression = expr; Expect(144); Expr( -#line 2388 "cs.ATG" +#line 2386 "cs.ATG" out expr); -#line 2388 "cs.ATG" +#line 2386 "cs.ATG" jc.EqualsExpression = expr; if (la.kind == 136) { lexer.NextToken(); Identifier(); -#line 2390 "cs.ATG" +#line 2388 "cs.ATG" jc.IntoIdentifier = t.val; } -#line 2392 "cs.ATG" +#line 2390 "cs.ATG" jc.EndLocation = t.EndLocation; } void QueryExpressionWhereClause( -#line 2424 "cs.ATG" +#line 2422 "cs.ATG" out QueryExpressionWhereClause wc) { -#line 2425 "cs.ATG" +#line 2423 "cs.ATG" Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; Expect(127); Expr( -#line 2428 "cs.ATG" +#line 2426 "cs.ATG" out expr); -#line 2428 "cs.ATG" +#line 2426 "cs.ATG" wc.Condition = expr; -#line 2429 "cs.ATG" +#line 2427 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionLetClause( -#line 2432 "cs.ATG" +#line 2430 "cs.ATG" out QueryExpressionLetClause wc) { -#line 2433 "cs.ATG" +#line 2431 "cs.ATG" Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; Expect(141); Identifier(); -#line 2436 "cs.ATG" +#line 2434 "cs.ATG" wc.Identifier = t.val; Expect(3); Expr( -#line 2438 "cs.ATG" +#line 2436 "cs.ATG" out expr); -#line 2438 "cs.ATG" +#line 2436 "cs.ATG" wc.Expression = expr; -#line 2439 "cs.ATG" +#line 2437 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionOrderByClause( -#line 2442 "cs.ATG" +#line 2440 "cs.ATG" out QueryExpressionOrderClause oc) { -#line 2443 "cs.ATG" +#line 2441 "cs.ATG" QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; Expect(140); QueryExpressionOrdering( -#line 2446 "cs.ATG" +#line 2444 "cs.ATG" out ordering); -#line 2446 "cs.ATG" +#line 2444 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); while (la.kind == 14) { lexer.NextToken(); QueryExpressionOrdering( -#line 2448 "cs.ATG" +#line 2446 "cs.ATG" out ordering); -#line 2448 "cs.ATG" +#line 2446 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); } -#line 2450 "cs.ATG" +#line 2448 "cs.ATG" oc.EndLocation = t.EndLocation; } void QueryExpressionSelectClause( -#line 2463 "cs.ATG" +#line 2461 "cs.ATG" out QueryExpressionSelectClause sc) { -#line 2464 "cs.ATG" +#line 2462 "cs.ATG" Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; Expect(133); Expr( -#line 2467 "cs.ATG" +#line 2465 "cs.ATG" out expr); -#line 2467 "cs.ATG" +#line 2465 "cs.ATG" sc.Projection = expr; -#line 2468 "cs.ATG" +#line 2466 "cs.ATG" sc.EndLocation = t.EndLocation; } void QueryExpressionGroupClause( -#line 2471 "cs.ATG" +#line 2469 "cs.ATG" out QueryExpressionGroupClause gc) { -#line 2472 "cs.ATG" +#line 2470 "cs.ATG" Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; Expect(134); Expr( -#line 2475 "cs.ATG" +#line 2473 "cs.ATG" out expr); -#line 2475 "cs.ATG" +#line 2473 "cs.ATG" gc.Projection = expr; Expect(135); Expr( -#line 2477 "cs.ATG" +#line 2475 "cs.ATG" out expr); -#line 2477 "cs.ATG" +#line 2475 "cs.ATG" gc.GroupBy = expr; -#line 2478 "cs.ATG" +#line 2476 "cs.ATG" gc.EndLocation = t.EndLocation; } void QueryExpressionIntoClause( -#line 2481 "cs.ATG" +#line 2479 "cs.ATG" ref QueryExpression q) { -#line 2482 "cs.ATG" +#line 2480 "cs.ATG" QueryExpression firstQuery = q; QueryExpression continuedQuery = new QueryExpression(); continuedQuery.StartLocation = q.StartLocation; @@ -5813,49 +5787,49 @@ ref QueryExpression q) { Expect(136); Identifier(); -#line 2495 "cs.ATG" +#line 2493 "cs.ATG" continuedQuery.FromClause.Identifier = t.val; -#line 2496 "cs.ATG" +#line 2494 "cs.ATG" continuedQuery.FromClause.EndLocation = t.EndLocation; QueryExpressionBody( -#line 2497 "cs.ATG" +#line 2495 "cs.ATG" ref q); } void QueryExpressionOrdering( -#line 2453 "cs.ATG" +#line 2451 "cs.ATG" out QueryExpressionOrdering ordering) { -#line 2454 "cs.ATG" +#line 2452 "cs.ATG" Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; Expr( -#line 2456 "cs.ATG" +#line 2454 "cs.ATG" out expr); -#line 2456 "cs.ATG" +#line 2454 "cs.ATG" ordering.Criteria = expr; if (la.kind == 138 || la.kind == 139) { if (la.kind == 138) { lexer.NextToken(); -#line 2457 "cs.ATG" +#line 2455 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2458 "cs.ATG" +#line 2456 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2460 "cs.ATG" +#line 2458 "cs.ATG" ordering.EndLocation = t.EndLocation; } - public override void Parse() + void ParseRoot() { CS(); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 01718543cb..29f270893a 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -364,7 +364,7 @@ TypeDecl attributes> Identifier (. newType.Name = t.val; .) /* .NET 2.0 */ - [ TypeParameterList ] (. SetParentNonNullable(templates, newType); .) + [ TypeParameterList ] [ ClassBase (. newType.BaseTypes = names; .) ] @@ -389,7 +389,7 @@ TypeDecl attributes> Identifier (. newType.Name = t.val; .) /* .NET 2.0 */ - [ TypeParameterList ] (. SetParentNonNullable(templates, newType); .) + [ TypeParameterList ] [ StructInterfaces (. newType.BaseTypes = names; .) ] @@ -413,7 +413,7 @@ TypeDecl attributes> Identifier (. newType.Name = t.val; .) /* .NET 2.0 */ - [ TypeParameterList ] (. SetParentNonNullable(templates, newType); .) + [ TypeParameterList ] [ InterfaceBase (. newType.BaseTypes = names; .) ] @@ -451,7 +451,7 @@ TypeDecl attributes> Identifier (. delegateDeclr.Name = t.val; .) /* .NET 2.0 */ - [ TypeParameterList ] (. SetParentNonNullable(templates, delegateDeclr); .) + [ TypeParameterList ] "(" [ FormalParameterList

(. delegateDeclr.Parameters = p; .) ] ")" @@ -778,9 +778,8 @@ StructMemberDecl attributes> Templates = templates, IsExtensionMethod = isExtensionMethod }; - SetParentNonNullable(templates, methodDeclaration); if (explicitInterface != null) - methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); + SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident)); compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); .) @@ -833,7 +832,7 @@ StructMemberDecl attributes> [ (. m.Check(Modifiers.Constructors); .) ConstructorInitializer ] (. - ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); + ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; .) @@ -865,7 +864,6 @@ StructMemberDecl attributes> StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; - SetParent(parameters, operatorDeclaration); compilationUnit.AddChild(operatorDeclaration); .) @@ -892,22 +890,19 @@ StructMemberDecl attributes> (. Location endPos = t.Location; .) ")" ( Block | ";" ) (. - List parameters = new List(); - parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); - if (secondType != null) { - parameters.Add(new ParameterDeclarationExpression(secondType, secondName)); - } OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, - Parameters = parameters, TypeReference = type, OverloadableOperator = op, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; - SetParent(parameters, operatorDeclaration); + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(firstType, firstName)); + if (secondType != null) { + SafeAdd(operatorDeclaration, operatorDeclaration.Parameters, new ParameterDeclarationExpression(secondType, secondName)); + } compilationUnit.AddChild(operatorDeclaration); .) @@ -984,7 +979,6 @@ StructMemberDecl attributes> methodDeclaration.EndLocation = t.EndLocation; methodDeclaration.IsExtensionMethod = isExtensionMethod; methodDeclaration.Templates = templates; - SetParentNonNullable(templates, methodDeclaration); compilationUnit.AddChild(methodDeclaration); .) { TypeParameterConstraintsClause } @@ -1016,7 +1010,7 @@ StructMemberDecl attributes> indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; if (explicitInterface != null) - indexer.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, "this")); + SafeAdd(indexer, indexer.InterfaceImplementations, new InterfaceImplementation(explicitInterface, "this")); PropertyGetRegion getRegion; PropertySetRegion setRegion; .) @@ -1066,7 +1060,7 @@ InterfaceMemberDecl [ "new" (. mod = Modifiers.New; startLocation = t.Location; .) ] ( /*--- interface void method (procedure) declaration: */ - IF (NotVoidPointer()) "void" (. if (startLocation.X == -1) startLocation = t.Location; .) + IF (NotVoidPointer()) "void" (. if (startLocation.IsEmpty) startLocation = t.Location; .) Identifier (. name = t.val; .) [ TypeParameterList ] "(" [ FormalParameterList ] ")" @@ -1077,11 +1071,10 @@ InterfaceMemberDecl Parameters = parameters, Attributes = attributes, Templates = templates, StartLocation = startLocation, EndLocation = t.EndLocation }; - SetParentNonNullable(templates, md); compilationUnit.AddChild(md); .) | ( - Type (. if (startLocation.X == -1) startLocation = t.Location; .) + Type (. if (startLocation.IsEmpty) startLocation = t.Location; .) ( Identifier (. name = t.val; Location qualIdentEndLocation = t.EndLocation; .) ( @@ -1096,26 +1089,37 @@ InterfaceMemberDecl Parameters = parameters, Attributes = attributes, Templates = templates, StartLocation = startLocation, EndLocation = t.EndLocation }; - SetParentNonNullable(templates, md); compilationUnit.AddChild(md); .) /*--- interface property declaration: */ - | (. PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); .) - "{" (. Location bodyStart = t.Location;.) InterfaceAccessors "}" (. pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; .) + | + (. PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); + compilationUnit.AddChild(pd); .) + "{" + (. Location bodyStart = t.Location;.) + InterfaceAccessors + "}" (. pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; .) ) /*--- interface indexer declaration: */ - | "this" "[" FormalParameterList "]" (.Location bracketEndLocation = t.EndLocation; .) (. IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); .) - "{" (. Location bodyStart = t.Location;.) InterfaceAccessors "}" (. id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;.) + | "this" "[" FormalParameterList "]" + (. Location bracketEndLocation = t.EndLocation; .) + (. IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); + compilationUnit.AddChild(id); .) + "{" (. Location bodyStart = t.Location;.) + InterfaceAccessors + "}" + (. id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;.) ) /*--- interface event declaration: */ - | "event" (. if (startLocation.X == -1) startLocation = t.Location; .) + | "event" (. if (startLocation.IsEmpty) startLocation = t.Location; .) Type Identifier (. EventDeclaration ed = new EventDeclaration { TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes }; compilationUnit.AddChild(ed); .) - ";" (. ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; .) + ";" + (. ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; .) ) ) . @@ -1507,7 +1511,6 @@ EmbeddedStatement "{" SwitchSections "}" (. statement = new SwitchStatement(expr, switchSections); .) - (. SetParent(switchSections, statement); .) /*--- iteration statements (while, do, for, foreach): */ | "while" "(" Expr ")" @@ -1523,10 +1526,7 @@ EmbeddedStatement [ Expr ] ";" [ ForIterator ] ")" EmbeddedStatement - (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); - SetParent(initializer, statement); - SetParent(iterator, statement); - .) + (. statement = new ForStatement(initializer, expr, iterator, embeddedStatement); .) | "foreach" "(" Type Identifier (. string varName = t.val; .) "in" Expr ")" @@ -1597,8 +1597,6 @@ IfStatement (elseStatement as IfElseStatement).TrueStatement[0])); (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; - SetParent((statement as IfElseStatement).FalseStatement, statement); - SetParent((statement as IfElseStatement).ElseIfSections, statement); } .) . @@ -2049,7 +2047,7 @@ ShortedLambdaExpression /* not an IdentifierExpression, but a short lambda expression*/ (. lambda.StartLocation = ident.StartLocation; - lambda.Parameters.Add(new ParameterDeclarationExpression(null, ident.Identifier)); + SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); lambda.Parameters[0].StartLocation = ident.StartLocation; lambda.Parameters[0].EndLocation = ident.EndLocation; .) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/trace.txt b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/trace.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame index bf0d166702..5602370fd6 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame +++ b/src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame @@ -22,7 +22,7 @@ partial class Parser : AbstractParser -->productions - public override void Parse() + void ParseRoot() { -->parseRoot } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/ModifierList.cs b/src/Libraries/NRefactory/Project/Src/Parser/ModifierList.cs index 1f88ac191b..115fb44b4e 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/ModifierList.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/ModifierList.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.Parser public Location GetDeclarationLocation(Location keywordLocation) { - if(location.X == -1 && location.Y == -1) { + if(location.IsEmpty) { return keywordLocation; } return location; @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.Parser public void Add(Modifiers m, Location tokenLocation) { - if(location.X == -1 && location.Y == -1) { + if(location.IsEmpty) { location = tokenLocation; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs index b48d960cba..29dd214f20 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs @@ -180,7 +180,7 @@ out u); void GlobalAttributeSection() { Expect(28); -#line 2540 "VBNET.ATG" +#line 2521 "VBNET.ATG" Location startPos = t.Location; if (la.kind == 52) { lexer.NextToken(); @@ -188,20 +188,20 @@ out u); lexer.NextToken(); } else SynErr(226); -#line 2542 "VBNET.ATG" +#line 2523 "VBNET.ATG" string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null; List attributes = new List(); ASTAttribute attribute; Expect(11); Attribute( -#line 2546 "VBNET.ATG" +#line 2527 "VBNET.ATG" out attribute); -#line 2546 "VBNET.ATG" +#line 2527 "VBNET.ATG" attributes.Add(attribute); while ( -#line 2547 "VBNET.ATG" +#line 2528 "VBNET.ATG" NotFinalComma()) { if (la.kind == 12) { lexer.NextToken(); @@ -213,10 +213,10 @@ NotFinalComma()) { Expect(11); } Attribute( -#line 2547 "VBNET.ATG" +#line 2528 "VBNET.ATG" out attribute); -#line 2547 "VBNET.ATG" +#line 2528 "VBNET.ATG" attributes.Add(attribute); } if (la.kind == 12) { @@ -225,7 +225,7 @@ out attribute); Expect(27); EndOfStmt(); -#line 2552 "VBNET.ATG" +#line 2533 "VBNET.ATG" AttributeSection section = new AttributeSection { AttributeTarget = attributeTarget, Attributes = attributes, @@ -334,47 +334,47 @@ out aliasedType); } void Qualident( -#line 3310 "VBNET.ATG" +#line 3279 "VBNET.ATG" out string qualident) { -#line 3312 "VBNET.ATG" +#line 3281 "VBNET.ATG" string name; qualidentBuilder.Length = 0; Identifier(); -#line 3316 "VBNET.ATG" +#line 3285 "VBNET.ATG" qualidentBuilder.Append(t.val); while ( -#line 3317 "VBNET.ATG" +#line 3286 "VBNET.ATG" DotAndIdentOrKw()) { Expect(16); IdentifierOrKeyword( -#line 3317 "VBNET.ATG" +#line 3286 "VBNET.ATG" out name); -#line 3317 "VBNET.ATG" +#line 3286 "VBNET.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(name); } -#line 3319 "VBNET.ATG" +#line 3288 "VBNET.ATG" qualident = qualidentBuilder.ToString(); } void TypeName( -#line 2413 "VBNET.ATG" +#line 2394 "VBNET.ATG" out TypeReference typeref) { -#line 2414 "VBNET.ATG" +#line 2395 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( -#line 2416 "VBNET.ATG" +#line 2397 "VBNET.ATG" out typeref, false); ArrayTypeModifiers( -#line 2420 "VBNET.ATG" +#line 2401 "VBNET.ATG" out rank); -#line 2421 "VBNET.ATG" +#line 2402 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } @@ -397,35 +397,35 @@ out rank); } void AttributeSection( -#line 2617 "VBNET.ATG" +#line 2596 "VBNET.ATG" out AttributeSection section) { -#line 2619 "VBNET.ATG" +#line 2598 "VBNET.ATG" string attributeTarget = "";List attributes = new List(); ASTAttribute attribute; Expect(28); -#line 2623 "VBNET.ATG" +#line 2602 "VBNET.ATG" Location startPos = t.Location; if ( -#line 2624 "VBNET.ATG" +#line 2603 "VBNET.ATG" IsLocalAttrTarget()) { if (la.kind == 106) { lexer.NextToken(); -#line 2625 "VBNET.ATG" +#line 2604 "VBNET.ATG" attributeTarget = "event"; } else if (la.kind == 180) { lexer.NextToken(); -#line 2626 "VBNET.ATG" +#line 2605 "VBNET.ATG" attributeTarget = "return"; } else { Identifier(); -#line 2629 "VBNET.ATG" +#line 2608 "VBNET.ATG" string val = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture); if (val != "field" || val != "method" || val != "module" || val != "param" || @@ -438,20 +438,20 @@ IsLocalAttrTarget()) { Expect(11); } Attribute( -#line 2639 "VBNET.ATG" +#line 2618 "VBNET.ATG" out attribute); -#line 2639 "VBNET.ATG" +#line 2618 "VBNET.ATG" attributes.Add(attribute); while ( -#line 2640 "VBNET.ATG" +#line 2619 "VBNET.ATG" NotFinalComma()) { Expect(12); Attribute( -#line 2640 "VBNET.ATG" +#line 2619 "VBNET.ATG" out attribute); -#line 2640 "VBNET.ATG" +#line 2619 "VBNET.ATG" attributes.Add(attribute); } if (la.kind == 12) { @@ -459,7 +459,7 @@ out attribute); } Expect(27); -#line 2644 "VBNET.ATG" +#line 2623 "VBNET.ATG" section = new AttributeSection { AttributeTarget = attributeTarget, Attributes = attributes, @@ -470,69 +470,69 @@ out attribute); } void TypeModifier( -#line 3393 "VBNET.ATG" +#line 3362 "VBNET.ATG" ModifierList m) { switch (la.kind) { case 173: { lexer.NextToken(); -#line 3394 "VBNET.ATG" +#line 3363 "VBNET.ATG" m.Add(Modifiers.Public, t.Location); break; } case 172: { lexer.NextToken(); -#line 3395 "VBNET.ATG" +#line 3364 "VBNET.ATG" m.Add(Modifiers.Protected, t.Location); break; } case 112: { lexer.NextToken(); -#line 3396 "VBNET.ATG" +#line 3365 "VBNET.ATG" m.Add(Modifiers.Internal, t.Location); break; } case 170: { lexer.NextToken(); -#line 3397 "VBNET.ATG" +#line 3366 "VBNET.ATG" m.Add(Modifiers.Private, t.Location); break; } case 185: { lexer.NextToken(); -#line 3398 "VBNET.ATG" +#line 3367 "VBNET.ATG" m.Add(Modifiers.Static, t.Location); break; } case 184: { lexer.NextToken(); -#line 3399 "VBNET.ATG" +#line 3368 "VBNET.ATG" m.Add(Modifiers.New, t.Location); break; } case 142: { lexer.NextToken(); -#line 3400 "VBNET.ATG" +#line 3369 "VBNET.ATG" m.Add(Modifiers.Abstract, t.Location); break; } case 152: { lexer.NextToken(); -#line 3401 "VBNET.ATG" +#line 3370 "VBNET.ATG" m.Add(Modifiers.Sealed, t.Location); break; } case 168: { lexer.NextToken(); -#line 3402 "VBNET.ATG" +#line 3371 "VBNET.ATG" m.Add(Modifiers.Partial, t.Location); break; } @@ -570,9 +570,6 @@ ModifierList m, List attributes) { TypeParameterList( #line 440 "VBNET.ATG" newType.Templates); - -#line 440 "VBNET.ATG" - SetParent(newType.Templates, newType); EndOfStmt(); #line 442 "VBNET.ATG" @@ -654,9 +651,6 @@ newType); TypeParameterList( #line 477 "VBNET.ATG" newType.Templates); - -#line 477 "VBNET.ATG" - SetParent(newType.Templates, newType); EndOfStmt(); #line 479 "VBNET.ATG" @@ -734,9 +728,6 @@ newType); TypeParameterList( #line 515 "VBNET.ATG" newType.Templates); - -#line 515 "VBNET.ATG" - SetParent(newType.Templates, newType); EndOfStmt(); #line 517 "VBNET.ATG" @@ -777,9 +768,6 @@ newType); TypeParameterList( #line 534 "VBNET.ATG" delegateDeclr.Templates); - -#line 534 "VBNET.ATG" - SetParent(delegateDeclr.Templates, delegateDeclr); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { @@ -801,9 +789,6 @@ p); TypeParameterList( #line 538 "VBNET.ATG" delegateDeclr.Templates); - -#line 538 "VBNET.ATG" - SetParent(delegateDeclr.Templates, delegateDeclr); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { @@ -963,42 +948,42 @@ out constraint); } void ClassBaseType( -#line 768 "VBNET.ATG" +#line 765 "VBNET.ATG" out TypeReference typeRef) { -#line 770 "VBNET.ATG" +#line 767 "VBNET.ATG" typeRef = null; Expect(127); TypeName( -#line 773 "VBNET.ATG" +#line 770 "VBNET.ATG" out typeRef); EndOfStmt(); } void TypeImplementsClause( -#line 1572 "VBNET.ATG" +#line 1563 "VBNET.ATG" out List baseInterfaces) { -#line 1574 "VBNET.ATG" +#line 1565 "VBNET.ATG" baseInterfaces = new List(); TypeReference type = null; Expect(123); TypeName( -#line 1577 "VBNET.ATG" +#line 1568 "VBNET.ATG" out type); -#line 1579 "VBNET.ATG" +#line 1570 "VBNET.ATG" baseInterfaces.Add(type); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 1582 "VBNET.ATG" +#line 1573 "VBNET.ATG" out type); -#line 1583 "VBNET.ATG" +#line 1574 "VBNET.ATG" baseInterfaces.Add(type); } EndOfStmt(); @@ -1128,10 +1113,10 @@ m, attributes); } void NonArrayTypeName( -#line 2439 "VBNET.ATG" +#line 2420 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { -#line 2441 "VBNET.ATG" +#line 2422 "VBNET.ATG" string name; typeref = null; bool isGlobal = false; @@ -1141,36 +1126,36 @@ out TypeReference typeref, bool canBeUnbound) { lexer.NextToken(); Expect(16); -#line 2446 "VBNET.ATG" +#line 2427 "VBNET.ATG" isGlobal = true; } QualIdentAndTypeArguments( -#line 2447 "VBNET.ATG" +#line 2428 "VBNET.ATG" out typeref, canBeUnbound); -#line 2448 "VBNET.ATG" +#line 2429 "VBNET.ATG" typeref.IsGlobal = isGlobal; while (la.kind == 16) { lexer.NextToken(); -#line 2449 "VBNET.ATG" +#line 2430 "VBNET.ATG" TypeReference nestedTypeRef; QualIdentAndTypeArguments( -#line 2450 "VBNET.ATG" +#line 2431 "VBNET.ATG" out nestedTypeRef, canBeUnbound); -#line 2451 "VBNET.ATG" +#line 2432 "VBNET.ATG" typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); } } else if (la.kind == 154) { lexer.NextToken(); -#line 2454 "VBNET.ATG" +#line 2435 "VBNET.ATG" typeref = new TypeReference("System.Object", true); if (la.kind == 21) { lexer.NextToken(); -#line 2458 "VBNET.ATG" +#line 2439 "VBNET.ATG" List typeArguments = new List(1); if (typeref != null) typeArguments.Add(typeref); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -1178,15 +1163,15 @@ out nestedTypeRef, canBeUnbound); } } else if (StartOf(11)) { PrimitiveTypeName( -#line 2464 "VBNET.ATG" +#line 2445 "VBNET.ATG" out name); -#line 2464 "VBNET.ATG" +#line 2445 "VBNET.ATG" typeref = new TypeReference(name, true); if (la.kind == 21) { lexer.NextToken(); -#line 2468 "VBNET.ATG" +#line 2449 "VBNET.ATG" List typeArguments = new List(1); if (typeref != null) typeArguments.Add(typeref); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -1210,7 +1195,6 @@ TypeDeclaration newType) { out f); #line 612 "VBNET.ATG" - SetParent(f.Fields, f); compilationUnit.AddChild(f); while (la.kind == 1 || la.kind == 11) { @@ -1220,40 +1204,40 @@ out f); Expect(100); Expect(102); -#line 617 "VBNET.ATG" +#line 616 "VBNET.ATG" newType.EndLocation = t.EndLocation; EndOfStmt(); } void InterfaceBase( -#line 1557 "VBNET.ATG" +#line 1548 "VBNET.ATG" out List bases) { -#line 1559 "VBNET.ATG" +#line 1550 "VBNET.ATG" TypeReference type; bases = new List(); Expect(127); TypeName( -#line 1563 "VBNET.ATG" +#line 1554 "VBNET.ATG" out type); -#line 1563 "VBNET.ATG" +#line 1554 "VBNET.ATG" bases.Add(type); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 1566 "VBNET.ATG" +#line 1557 "VBNET.ATG" out type); -#line 1566 "VBNET.ATG" +#line 1557 "VBNET.ATG" bases.Add(type); } EndOfStmt(); } void InterfaceBody( -#line 621 "VBNET.ATG" +#line 620 "VBNET.ATG" TypeDeclaration newType) { while (la.kind == 1 || la.kind == 11) { EndOfStmt(); @@ -1267,168 +1251,168 @@ TypeDeclaration newType) { Expect(100); Expect(129); -#line 627 "VBNET.ATG" +#line 626 "VBNET.ATG" newType.EndLocation = t.EndLocation; EndOfStmt(); } void FormalParameterList( -#line 2654 "VBNET.ATG" +#line 2633 "VBNET.ATG" List parameter) { -#line 2655 "VBNET.ATG" +#line 2634 "VBNET.ATG" ParameterDeclarationExpression p; FormalParameter( -#line 2657 "VBNET.ATG" +#line 2636 "VBNET.ATG" out p); -#line 2657 "VBNET.ATG" +#line 2636 "VBNET.ATG" if (p != null) parameter.Add(p); while (la.kind == 12) { lexer.NextToken(); FormalParameter( -#line 2659 "VBNET.ATG" +#line 2638 "VBNET.ATG" out p); -#line 2659 "VBNET.ATG" +#line 2638 "VBNET.ATG" if (p != null) parameter.Add(p); } } void MemberModifier( -#line 3405 "VBNET.ATG" +#line 3374 "VBNET.ATG" ModifierList m) { switch (la.kind) { case 142: { lexer.NextToken(); -#line 3406 "VBNET.ATG" +#line 3375 "VBNET.ATG" m.Add(Modifiers.Abstract, t.Location); break; } case 89: { lexer.NextToken(); -#line 3407 "VBNET.ATG" +#line 3376 "VBNET.ATG" m.Add(Modifiers.Default, t.Location); break; } case 112: { lexer.NextToken(); -#line 3408 "VBNET.ATG" +#line 3377 "VBNET.ATG" m.Add(Modifiers.Internal, t.Location); break; } case 184: { lexer.NextToken(); -#line 3409 "VBNET.ATG" +#line 3378 "VBNET.ATG" m.Add(Modifiers.New, t.Location); break; } case 166: { lexer.NextToken(); -#line 3410 "VBNET.ATG" +#line 3379 "VBNET.ATG" m.Add(Modifiers.Override, t.Location); break; } case 143: { lexer.NextToken(); -#line 3411 "VBNET.ATG" +#line 3380 "VBNET.ATG" m.Add(Modifiers.Abstract, t.Location); break; } case 170: { lexer.NextToken(); -#line 3412 "VBNET.ATG" +#line 3381 "VBNET.ATG" m.Add(Modifiers.Private, t.Location); break; } case 172: { lexer.NextToken(); -#line 3413 "VBNET.ATG" +#line 3382 "VBNET.ATG" m.Add(Modifiers.Protected, t.Location); break; } case 173: { lexer.NextToken(); -#line 3414 "VBNET.ATG" +#line 3383 "VBNET.ATG" m.Add(Modifiers.Public, t.Location); break; } case 152: { lexer.NextToken(); -#line 3415 "VBNET.ATG" +#line 3384 "VBNET.ATG" m.Add(Modifiers.Sealed, t.Location); break; } case 153: { lexer.NextToken(); -#line 3416 "VBNET.ATG" +#line 3385 "VBNET.ATG" m.Add(Modifiers.Sealed, t.Location); break; } case 185: { lexer.NextToken(); -#line 3417 "VBNET.ATG" +#line 3386 "VBNET.ATG" m.Add(Modifiers.Static, t.Location); break; } case 165: { lexer.NextToken(); -#line 3418 "VBNET.ATG" +#line 3387 "VBNET.ATG" m.Add(Modifiers.Virtual, t.Location); break; } case 164: { lexer.NextToken(); -#line 3419 "VBNET.ATG" +#line 3388 "VBNET.ATG" m.Add(Modifiers.Overloads, t.Location); break; } case 175: { lexer.NextToken(); -#line 3420 "VBNET.ATG" +#line 3389 "VBNET.ATG" m.Add(Modifiers.ReadOnly, t.Location); break; } case 220: { lexer.NextToken(); -#line 3421 "VBNET.ATG" +#line 3390 "VBNET.ATG" m.Add(Modifiers.WriteOnly, t.Location); break; } case 219: { lexer.NextToken(); -#line 3422 "VBNET.ATG" +#line 3391 "VBNET.ATG" m.Add(Modifiers.WithEvents, t.Location); break; } case 92: { lexer.NextToken(); -#line 3423 "VBNET.ATG" +#line 3392 "VBNET.ATG" m.Add(Modifiers.Dim, t.Location); break; } case 168: { lexer.NextToken(); -#line 3424 "VBNET.ATG" +#line 3393 "VBNET.ATG" m.Add(Modifiers.Partial, t.Location); break; } @@ -1437,18 +1421,18 @@ ModifierList m) { } void ClassMemberDecl( -#line 764 "VBNET.ATG" +#line 761 "VBNET.ATG" ModifierList m, List attributes) { StructureMemberDecl( -#line 765 "VBNET.ATG" +#line 762 "VBNET.ATG" m, attributes); } void StructureMemberDecl( -#line 778 "VBNET.ATG" +#line 775 "VBNET.ATG" ModifierList m, List attributes) { -#line 780 "VBNET.ATG" +#line 777 "VBNET.ATG" TypeReference type = null; List p = new List(); Statement stmt = null; @@ -1458,37 +1442,37 @@ ModifierList m, List attributes) { switch (la.kind) { case 71: case 90: case 102: case 129: case 141: case 194: { NonModuleDeclaration( -#line 787 "VBNET.ATG" +#line 784 "VBNET.ATG" m, attributes); break; } case 195: { lexer.NextToken(); -#line 791 "VBNET.ATG" +#line 788 "VBNET.ATG" Location startPos = t.Location; if (StartOf(14)) { -#line 795 "VBNET.ATG" +#line 792 "VBNET.ATG" string name = String.Empty; MethodDeclaration methodDeclaration; List handlesClause = null; List implementsClause = null; Identifier(); -#line 801 "VBNET.ATG" +#line 798 "VBNET.ATG" name = t.val; m.Check(Modifiers.VBMethods); TypeParameterList( -#line 804 "VBNET.ATG" +#line 801 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 805 "VBNET.ATG" +#line 802 "VBNET.ATG" p); } Expect(26); @@ -1496,23 +1480,23 @@ p); if (la.kind == 121 || la.kind == 123) { if (la.kind == 123) { ImplementsClause( -#line 808 "VBNET.ATG" +#line 805 "VBNET.ATG" out implementsClause); } else { HandlesClause( -#line 810 "VBNET.ATG" +#line 807 "VBNET.ATG" out handlesClause); } } -#line 813 "VBNET.ATG" +#line 810 "VBNET.ATG" Location endLocation = t.EndLocation; if ( -#line 816 "VBNET.ATG" +#line 813 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); -#line 819 "VBNET.ATG" +#line 816 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, @@ -1521,13 +1505,12 @@ IsMustOverride(m)) { HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); compilationUnit.AddChild(methodDeclaration); } else if (la.kind == 1) { lexer.NextToken(); -#line 833 "VBNET.ATG" +#line 829 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, @@ -1536,29 +1519,28 @@ IsMustOverride(m)) { HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); compilationUnit.AddChild(methodDeclaration); -#line 845 "VBNET.ATG" +#line 840 "VBNET.ATG" if (ParseMethodBodies) { Block( -#line 846 "VBNET.ATG" +#line 841 "VBNET.ATG" out stmt); Expect(100); Expect(195); -#line 848 "VBNET.ATG" +#line 843 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } -#line 854 "VBNET.ATG" +#line 849 "VBNET.ATG" methodDeclaration.Body = (BlockStatement)stmt; -#line 855 "VBNET.ATG" +#line 850 "VBNET.ATG" methodDeclaration.Body.EndLocation = t.EndLocation; EndOfStmt(); } else SynErr(238); @@ -1568,40 +1550,40 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 859 "VBNET.ATG" +#line 854 "VBNET.ATG" p); } Expect(26); } -#line 860 "VBNET.ATG" +#line 855 "VBNET.ATG" m.Check(Modifiers.Constructors); -#line 861 "VBNET.ATG" +#line 856 "VBNET.ATG" Location constructorEndLocation = t.EndLocation; Expect(1); -#line 864 "VBNET.ATG" +#line 859 "VBNET.ATG" if (ParseMethodBodies) { Block( -#line 865 "VBNET.ATG" +#line 860 "VBNET.ATG" out stmt); Expect(100); Expect(195); -#line 867 "VBNET.ATG" +#line 862 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } -#line 873 "VBNET.ATG" +#line 868 "VBNET.ATG" Location endLocation = t.EndLocation; EndOfStmt(); -#line 876 "VBNET.ATG" - ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); +#line 871 "VBNET.ATG" + ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); cd.EndLocation = constructorEndLocation; cd.Body = (BlockStatement)stmt; @@ -1614,7 +1596,7 @@ out stmt); case 114: { lexer.NextToken(); -#line 888 "VBNET.ATG" +#line 883 "VBNET.ATG" m.Check(Modifiers.VBMethods); string name = String.Empty; Location startPos = t.Location; @@ -1624,16 +1606,16 @@ out stmt); Identifier(); -#line 895 "VBNET.ATG" +#line 890 "VBNET.ATG" name = t.val; TypeParameterList( -#line 896 "VBNET.ATG" +#line 891 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 897 "VBNET.ATG" +#line 892 "VBNET.ATG" p); } Expect(26); @@ -1642,15 +1624,15 @@ p); lexer.NextToken(); while (la.kind == 28) { AttributeSection( -#line 898 "VBNET.ATG" +#line 893 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( -#line 898 "VBNET.ATG" +#line 893 "VBNET.ATG" out type); } -#line 900 "VBNET.ATG" +#line 895 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } @@ -1658,20 +1640,20 @@ out type); if (la.kind == 121 || la.kind == 123) { if (la.kind == 123) { ImplementsClause( -#line 906 "VBNET.ATG" +#line 901 "VBNET.ATG" out implementsClause); } else { HandlesClause( -#line 908 "VBNET.ATG" +#line 903 "VBNET.ATG" out handlesClause); } } if ( -#line 913 "VBNET.ATG" +#line 908 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); -#line 916 "VBNET.ATG" +#line 911 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, @@ -1681,7 +1663,6 @@ IsMustOverride(m)) { Templates = templates, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); @@ -1691,7 +1672,7 @@ IsMustOverride(m)) { } else if (la.kind == 1) { lexer.NextToken(); -#line 935 "VBNET.ATG" +#line 929 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, @@ -1701,7 +1682,6 @@ IsMustOverride(m)) { HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); @@ -1711,12 +1691,12 @@ IsMustOverride(m)) { if (ParseMethodBodies) { Block( -#line 953 "VBNET.ATG" +#line 946 "VBNET.ATG" out stmt); Expect(100); Expect(114); -#line 955 "VBNET.ATG" +#line 948 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement(); @@ -1732,7 +1712,7 @@ out stmt); case 88: { lexer.NextToken(); -#line 969 "VBNET.ATG" +#line 962 "VBNET.ATG" m.Check(Modifiers.VBExternalMethods); Location startPos = t.Location; CharsetModifier charsetModifer = CharsetModifier.None; @@ -1742,39 +1722,39 @@ out stmt); if (StartOf(15)) { Charset( -#line 976 "VBNET.ATG" +#line 969 "VBNET.ATG" out charsetModifer); } if (la.kind == 195) { lexer.NextToken(); Identifier(); -#line 979 "VBNET.ATG" +#line 972 "VBNET.ATG" name = t.val; Expect(135); Expect(3); -#line 980 "VBNET.ATG" +#line 973 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 46) { lexer.NextToken(); Expect(3); -#line 981 "VBNET.ATG" +#line 974 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 982 "VBNET.ATG" +#line 975 "VBNET.ATG" p); } Expect(26); } EndOfStmt(); -#line 985 "VBNET.ATG" +#line 978 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; @@ -1784,25 +1764,25 @@ p); lexer.NextToken(); Identifier(); -#line 992 "VBNET.ATG" +#line 985 "VBNET.ATG" name = t.val; Expect(135); Expect(3); -#line 993 "VBNET.ATG" +#line 986 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 46) { lexer.NextToken(); Expect(3); -#line 994 "VBNET.ATG" +#line 987 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 995 "VBNET.ATG" +#line 988 "VBNET.ATG" p); } Expect(26); @@ -1810,12 +1790,12 @@ p); if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 996 "VBNET.ATG" +#line 989 "VBNET.ATG" out type); } EndOfStmt(); -#line 999 "VBNET.ATG" +#line 992 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; @@ -1827,7 +1807,7 @@ out type); case 106: { lexer.NextToken(); -#line 1009 "VBNET.ATG" +#line 1002 "VBNET.ATG" m.Check(Modifiers.VBEvents); Location startPos = t.Location; EventDeclaration eventDeclaration; @@ -1836,19 +1816,19 @@ out type); Identifier(); -#line 1015 "VBNET.ATG" +#line 1008 "VBNET.ATG" name= t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 1017 "VBNET.ATG" +#line 1010 "VBNET.ATG" out type); } else if (StartOf(16)) { if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1019 "VBNET.ATG" +#line 1012 "VBNET.ATG" p); } Expect(26); @@ -1856,11 +1836,11 @@ p); } else SynErr(242); if (la.kind == 123) { ImplementsClause( -#line 1021 "VBNET.ATG" +#line 1014 "VBNET.ATG" out implementsClause); } -#line 1023 "VBNET.ATG" +#line 1016 "VBNET.ATG" eventDeclaration = new EventDeclaration { Name = name, TypeReference = type, Modifier = m.Modifier, Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause, @@ -1874,68 +1854,67 @@ out implementsClause); } case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: { -#line 1033 "VBNET.ATG" +#line 1026 "VBNET.ATG" Location startPos = t.Location; -#line 1035 "VBNET.ATG" +#line 1028 "VBNET.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); IdentifierForFieldDeclaration(); -#line 1039 "VBNET.ATG" +#line 1032 "VBNET.ATG" string name = t.val; VariableDeclaratorPartAfterIdentifier( -#line 1040 "VBNET.ATG" +#line 1033 "VBNET.ATG" variableDeclarators, name); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 1041 "VBNET.ATG" +#line 1034 "VBNET.ATG" variableDeclarators); } EndOfStmt(); -#line 1044 "VBNET.ATG" +#line 1037 "VBNET.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; - SetParent(variableDeclarators, fd); compilationUnit.AddChild(fd); break; } case 75: { -#line 1050 "VBNET.ATG" +#line 1042 "VBNET.ATG" m.Check(Modifiers.Fields); lexer.NextToken(); -#line 1051 "VBNET.ATG" +#line 1043 "VBNET.ATG" m.Add(Modifiers.Const, t.Location); -#line 1053 "VBNET.ATG" +#line 1045 "VBNET.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(t.Location); List constantDeclarators = new List(); ConstantDeclarator( -#line 1057 "VBNET.ATG" +#line 1049 "VBNET.ATG" constantDeclarators); while (la.kind == 12) { lexer.NextToken(); ConstantDeclarator( -#line 1058 "VBNET.ATG" +#line 1050 "VBNET.ATG" constantDeclarators); } -#line 1060 "VBNET.ATG" +#line 1052 "VBNET.ATG" fd.Fields = constantDeclarators; fd.EndLocation = t.Location; EndOfStmt(); -#line 1065 "VBNET.ATG" +#line 1057 "VBNET.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); @@ -1944,20 +1923,20 @@ constantDeclarators); case 171: { lexer.NextToken(); -#line 1071 "VBNET.ATG" +#line 1063 "VBNET.ATG" m.Check(Modifiers.VBProperties); Location startPos = t.Location; List implementsClause = null; Identifier(); -#line 1075 "VBNET.ATG" +#line 1067 "VBNET.ATG" string propertyName = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1076 "VBNET.ATG" +#line 1068 "VBNET.ATG" p); } Expect(26); @@ -1965,26 +1944,26 @@ p); if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 1077 "VBNET.ATG" +#line 1069 "VBNET.ATG" out type); } -#line 1079 "VBNET.ATG" +#line 1071 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } if (la.kind == 123) { ImplementsClause( -#line 1083 "VBNET.ATG" +#line 1075 "VBNET.ATG" out implementsClause); } EndOfStmt(); if ( -#line 1087 "VBNET.ATG" +#line 1079 "VBNET.ATG" IsMustOverride(m)) { -#line 1089 "VBNET.ATG" +#line 1081 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; @@ -1995,7 +1974,7 @@ IsMustOverride(m)) { } else if (StartOf(17)) { -#line 1099 "VBNET.ATG" +#line 1091 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; @@ -2007,13 +1986,13 @@ IsMustOverride(m)) { PropertySetRegion setRegion; AccessorDecls( -#line 1109 "VBNET.ATG" +#line 1101 "VBNET.ATG" out getRegion, out setRegion); Expect(100); Expect(171); EndOfStmt(); -#line 1113 "VBNET.ATG" +#line 1105 "VBNET.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2025,11 +2004,11 @@ out getRegion, out setRegion); case 85: { lexer.NextToken(); -#line 1120 "VBNET.ATG" +#line 1112 "VBNET.ATG" Location startPos = t.Location; Expect(106); -#line 1122 "VBNET.ATG" +#line 1114 "VBNET.ATG" m.Check(Modifiers.VBCustomEvents); EventAddRemoveRegion eventAccessorDeclaration; EventAddRegion addHandlerAccessorDeclaration = null; @@ -2039,24 +2018,24 @@ out getRegion, out setRegion); Identifier(); -#line 1129 "VBNET.ATG" +#line 1121 "VBNET.ATG" string customEventName = t.val; Expect(50); TypeName( -#line 1130 "VBNET.ATG" +#line 1122 "VBNET.ATG" out type); if (la.kind == 123) { ImplementsClause( -#line 1131 "VBNET.ATG" +#line 1123 "VBNET.ATG" out implementsClause); } EndOfStmt(); while (StartOf(18)) { EventAccessorDeclaration( -#line 1134 "VBNET.ATG" +#line 1126 "VBNET.ATG" out eventAccessorDeclaration); -#line 1136 "VBNET.ATG" +#line 1128 "VBNET.ATG" if(eventAccessorDeclaration is EventAddRegion) { addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration; @@ -2075,7 +2054,7 @@ out eventAccessorDeclaration); Expect(106); EndOfStmt(); -#line 1152 "VBNET.ATG" +#line 1144 "VBNET.ATG" if(addHandlerAccessorDeclaration == null) { Error("Need to provide AddHandler accessor."); @@ -2106,24 +2085,24 @@ out eventAccessorDeclaration); } case 147: case 158: case 217: { -#line 1178 "VBNET.ATG" +#line 1170 "VBNET.ATG" ConversionType opConversionType = ConversionType.None; if (la.kind == 147 || la.kind == 217) { if (la.kind == 217) { lexer.NextToken(); -#line 1179 "VBNET.ATG" +#line 1171 "VBNET.ATG" opConversionType = ConversionType.Implicit; } else { lexer.NextToken(); -#line 1180 "VBNET.ATG" +#line 1172 "VBNET.ATG" opConversionType = ConversionType.Explicit; } } Expect(158); -#line 1183 "VBNET.ATG" +#line 1175 "VBNET.ATG" m.Check(Modifiers.VBOperators); Location startPos = t.Location; TypeReference returnType = NullTypeReference.Instance; @@ -2135,7 +2114,7 @@ out eventAccessorDeclaration); List returnTypeAttributes = new List(); OverloadableOperator( -#line 1193 "VBNET.ATG" +#line 1185 "VBNET.ATG" out operatorType); Expect(25); if (la.kind == 59) { @@ -2143,16 +2122,16 @@ out operatorType); } Identifier(); -#line 1194 "VBNET.ATG" +#line 1186 "VBNET.ATG" operandName = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 1195 "VBNET.ATG" +#line 1187 "VBNET.ATG" out operandType); } -#line 1196 "VBNET.ATG" +#line 1188 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); while (la.kind == 12) { lexer.NextToken(); @@ -2161,48 +2140,48 @@ out operandType); } Identifier(); -#line 1200 "VBNET.ATG" +#line 1192 "VBNET.ATG" operandName = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 1201 "VBNET.ATG" +#line 1193 "VBNET.ATG" out operandType); } -#line 1202 "VBNET.ATG" +#line 1194 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); } Expect(26); -#line 1205 "VBNET.ATG" +#line 1197 "VBNET.ATG" Location endPos = t.EndLocation; if (la.kind == 50) { lexer.NextToken(); while (la.kind == 28) { AttributeSection( -#line 1206 "VBNET.ATG" +#line 1198 "VBNET.ATG" out section); -#line 1206 "VBNET.ATG" +#line 1198 "VBNET.ATG" returnTypeAttributes.Add(section); } TypeName( -#line 1206 "VBNET.ATG" +#line 1198 "VBNET.ATG" out returnType); -#line 1206 "VBNET.ATG" +#line 1198 "VBNET.ATG" endPos = t.EndLocation; } Expect(1); Block( -#line 1208 "VBNET.ATG" +#line 1200 "VBNET.ATG" out stmt); Expect(100); Expect(158); EndOfStmt(); -#line 1210 "VBNET.ATG" +#line 1202 "VBNET.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, @@ -2226,25 +2205,25 @@ out stmt); } void EnumMemberDecl( -#line 746 "VBNET.ATG" +#line 743 "VBNET.ATG" out FieldDeclaration f) { -#line 748 "VBNET.ATG" +#line 745 "VBNET.ATG" Expression expr = null;List attributes = new List(); AttributeSection section = null; VariableDeclaration varDecl = null; while (la.kind == 28) { AttributeSection( -#line 752 "VBNET.ATG" +#line 749 "VBNET.ATG" out section); -#line 752 "VBNET.ATG" +#line 749 "VBNET.ATG" attributes.Add(section); } Identifier(); -#line 755 "VBNET.ATG" +#line 752 "VBNET.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2253,10 +2232,10 @@ out section); if (la.kind == 10) { lexer.NextToken(); Expr( -#line 760 "VBNET.ATG" +#line 757 "VBNET.ATG" out expr); -#line 760 "VBNET.ATG" +#line 757 "VBNET.ATG" varDecl.Initializer = expr; } EndOfStmt(); @@ -2264,7 +2243,7 @@ out expr); void InterfaceMemberDecl() { -#line 635 "VBNET.ATG" +#line 634 "VBNET.ATG" TypeReference type =null; List p = new List(); List templates = new List(); @@ -2276,33 +2255,33 @@ out expr); if (StartOf(19)) { while (la.kind == 28) { AttributeSection( -#line 643 "VBNET.ATG" +#line 642 "VBNET.ATG" out section); -#line 643 "VBNET.ATG" +#line 642 "VBNET.ATG" attributes.Add(section); } while (StartOf(9)) { MemberModifier( -#line 646 "VBNET.ATG" +#line 645 "VBNET.ATG" mod); } if (la.kind == 106) { lexer.NextToken(); -#line 650 "VBNET.ATG" +#line 649 "VBNET.ATG" mod.Check(Modifiers.VBInterfaceEvents); Location startLocation = t.Location; Identifier(); -#line 653 "VBNET.ATG" +#line 652 "VBNET.ATG" name = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 654 "VBNET.ATG" +#line 653 "VBNET.ATG" p); } Expect(26); @@ -2310,12 +2289,12 @@ p); if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 655 "VBNET.ATG" +#line 654 "VBNET.ATG" out type); } EndOfStmt(); -#line 658 "VBNET.ATG" +#line 657 "VBNET.ATG" EventDeclaration ed = new EventDeclaration { Name = name, TypeReference = type, Modifier = mod.Modifier, Parameters = p, Attributes = attributes, @@ -2326,29 +2305,29 @@ out type); } else if (la.kind == 195) { lexer.NextToken(); -#line 668 "VBNET.ATG" +#line 667 "VBNET.ATG" Location startLocation = t.Location; mod.Check(Modifiers.VBInterfaceMethods); Identifier(); -#line 671 "VBNET.ATG" +#line 670 "VBNET.ATG" name = t.val; TypeParameterList( -#line 672 "VBNET.ATG" +#line 671 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 673 "VBNET.ATG" +#line 672 "VBNET.ATG" p); } Expect(26); } EndOfStmt(); -#line 676 "VBNET.ATG" +#line 675 "VBNET.ATG" MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod.Modifier, @@ -2359,28 +2338,27 @@ p); EndLocation = t.EndLocation, Templates = templates }; - SetParent(templates, md); compilationUnit.AddChild(md); } else if (la.kind == 114) { lexer.NextToken(); -#line 692 "VBNET.ATG" +#line 690 "VBNET.ATG" mod.Check(Modifiers.VBInterfaceMethods); Location startLocation = t.Location; Identifier(); -#line 695 "VBNET.ATG" +#line 693 "VBNET.ATG" name = t.val; TypeParameterList( -#line 696 "VBNET.ATG" +#line 694 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 697 "VBNET.ATG" +#line 695 "VBNET.ATG" p); } Expect(26); @@ -2389,15 +2367,15 @@ p); lexer.NextToken(); while (la.kind == 28) { AttributeSection( -#line 698 "VBNET.ATG" +#line 696 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( -#line 698 "VBNET.ATG" +#line 696 "VBNET.ATG" out type); } -#line 700 "VBNET.ATG" +#line 698 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } @@ -2412,26 +2390,25 @@ out type); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; md.Templates = templates; - SetParent(templates, md); compilationUnit.AddChild(md); EndOfStmt(); } else if (la.kind == 171) { lexer.NextToken(); -#line 721 "VBNET.ATG" +#line 718 "VBNET.ATG" Location startLocation = t.Location; mod.Check(Modifiers.VBInterfaceProperties); Identifier(); -#line 724 "VBNET.ATG" +#line 721 "VBNET.ATG" name = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 725 "VBNET.ATG" +#line 722 "VBNET.ATG" p); } Expect(26); @@ -2439,18 +2416,18 @@ p); if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 726 "VBNET.ATG" +#line 723 "VBNET.ATG" out type); } -#line 728 "VBNET.ATG" +#line 725 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } EndOfStmt(); -#line 734 "VBNET.ATG" +#line 731 "VBNET.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes); pd.Parameters = p; pd.EndLocation = t.EndLocation; @@ -2460,113 +2437,113 @@ out type); } else SynErr(245); } else if (StartOf(20)) { NonModuleDeclaration( -#line 742 "VBNET.ATG" +#line 739 "VBNET.ATG" mod, attributes); } else SynErr(246); } void Expr( -#line 1616 "VBNET.ATG" +#line 1607 "VBNET.ATG" out Expression expr) { -#line 1617 "VBNET.ATG" +#line 1608 "VBNET.ATG" expr = null; if ( -#line 1618 "VBNET.ATG" +#line 1609 "VBNET.ATG" IsQueryExpression() ) { QueryExpr( -#line 1619 "VBNET.ATG" +#line 1610 "VBNET.ATG" out expr); } else if (la.kind == 114) { LambdaExpr( -#line 1620 "VBNET.ATG" +#line 1611 "VBNET.ATG" out expr); } else if (StartOf(21)) { DisjunctionExpr( -#line 1621 "VBNET.ATG" +#line 1612 "VBNET.ATG" out expr); } else SynErr(247); } void ImplementsClause( -#line 1589 "VBNET.ATG" +#line 1580 "VBNET.ATG" out List baseInterfaces) { -#line 1591 "VBNET.ATG" +#line 1582 "VBNET.ATG" baseInterfaces = new List(); TypeReference type = null; string memberName = null; Expect(123); NonArrayTypeName( -#line 1596 "VBNET.ATG" +#line 1587 "VBNET.ATG" out type, false); -#line 1597 "VBNET.ATG" +#line 1588 "VBNET.ATG" if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); -#line 1598 "VBNET.ATG" +#line 1589 "VBNET.ATG" baseInterfaces.Add(new InterfaceImplementation(type, memberName)); while (la.kind == 12) { lexer.NextToken(); NonArrayTypeName( -#line 1600 "VBNET.ATG" +#line 1591 "VBNET.ATG" out type, false); -#line 1601 "VBNET.ATG" +#line 1592 "VBNET.ATG" if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); -#line 1602 "VBNET.ATG" +#line 1593 "VBNET.ATG" baseInterfaces.Add(new InterfaceImplementation(type, memberName)); } } void HandlesClause( -#line 1547 "VBNET.ATG" +#line 1538 "VBNET.ATG" out List handlesClause) { -#line 1549 "VBNET.ATG" +#line 1540 "VBNET.ATG" handlesClause = new List(); string name; Expect(121); EventMemberSpecifier( -#line 1552 "VBNET.ATG" +#line 1543 "VBNET.ATG" out name); -#line 1552 "VBNET.ATG" +#line 1543 "VBNET.ATG" handlesClause.Add(name); while (la.kind == 12) { lexer.NextToken(); EventMemberSpecifier( -#line 1553 "VBNET.ATG" +#line 1544 "VBNET.ATG" out name); -#line 1553 "VBNET.ATG" +#line 1544 "VBNET.ATG" handlesClause.Add(name); } } void Block( -#line 2701 "VBNET.ATG" +#line 2680 "VBNET.ATG" out Statement stmt) { -#line 2704 "VBNET.ATG" +#line 2683 "VBNET.ATG" BlockStatement blockStmt = new BlockStatement(); /* in snippet parsing mode, t might be null */ if (t != null) blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); while (StartOf(22) || -#line 2710 "VBNET.ATG" +#line 2689 "VBNET.ATG" IsEndStmtAhead()) { if ( -#line 2710 "VBNET.ATG" +#line 2689 "VBNET.ATG" IsEndStmtAhead()) { Expect(100); EndOfStmt(); -#line 2710 "VBNET.ATG" +#line 2689 "VBNET.ATG" compilationUnit.AddChild(new EndStatement()); } else { Statement(); @@ -2574,7 +2551,7 @@ IsEndStmtAhead()) { } } -#line 2715 "VBNET.ATG" +#line 2694 "VBNET.ATG" stmt = blockStmt; if (t != null) blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2582,26 +2559,26 @@ IsEndStmtAhead()) { } void Charset( -#line 1539 "VBNET.ATG" +#line 1530 "VBNET.ATG" out CharsetModifier charsetModifier) { -#line 1540 "VBNET.ATG" +#line 1531 "VBNET.ATG" charsetModifier = CharsetModifier.None; if (la.kind == 114 || la.kind == 195) { } else if (la.kind == 49) { lexer.NextToken(); -#line 1541 "VBNET.ATG" +#line 1532 "VBNET.ATG" charsetModifier = CharsetModifier.Ansi; } else if (la.kind == 53) { lexer.NextToken(); -#line 1542 "VBNET.ATG" +#line 1533 "VBNET.ATG" charsetModifier = CharsetModifier.Auto; } else if (la.kind == 208) { lexer.NextToken(); -#line 1543 "VBNET.ATG" +#line 1534 "VBNET.ATG" charsetModifier = CharsetModifier.Unicode; } else SynErr(248); } @@ -2721,10 +2698,10 @@ out CharsetModifier charsetModifier) { } void VariableDeclaratorPartAfterIdentifier( -#line 1414 "VBNET.ATG" +#line 1406 "VBNET.ATG" List fieldDeclaration, string name) { -#line 1416 "VBNET.ATG" +#line 1408 "VBNET.ATG" Expression expr = null; TypeReference type = null; ArrayList rank = null; @@ -2732,42 +2709,42 @@ List fieldDeclaration, string name) { Location startLocation = t.Location; if ( -#line 1422 "VBNET.ATG" +#line 1414 "VBNET.ATG" IsSize() && !IsDims()) { ArrayInitializationModifier( -#line 1422 "VBNET.ATG" +#line 1414 "VBNET.ATG" out dimension); } if ( -#line 1423 "VBNET.ATG" +#line 1415 "VBNET.ATG" IsDims()) { ArrayNameModifier( -#line 1423 "VBNET.ATG" +#line 1415 "VBNET.ATG" out rank); } if ( -#line 1425 "VBNET.ATG" +#line 1417 "VBNET.ATG" IsObjectCreation()) { Expect(50); ObjectCreateExpression( -#line 1425 "VBNET.ATG" +#line 1417 "VBNET.ATG" out expr); -#line 1427 "VBNET.ATG" +#line 1419 "VBNET.ATG" if (expr is ObjectCreateExpression) { - type = ((ObjectCreateExpression)expr).CreateType; + type = ((ObjectCreateExpression)expr).CreateType.Clone(); } else { - type = ((ArrayCreateExpression)expr).CreateType; + type = ((ArrayCreateExpression)expr).CreateType.Clone(); } } else if (StartOf(23)) { if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 1434 "VBNET.ATG" +#line 1426 "VBNET.ATG" out type); -#line 1436 "VBNET.ATG" +#line 1428 "VBNET.ATG" if (type != null) { for (int i = fieldDeclaration.Count - 1; i >= 0; i--) { VariableDeclaration vd = fieldDeclaration[i]; @@ -2780,7 +2757,7 @@ out type); } -#line 1448 "VBNET.ATG" +#line 1440 "VBNET.ATG" if (type == null && (dimension != null || rank != null)) { type = new TypeReference(""); } @@ -2794,8 +2771,7 @@ out type); rank.Insert(0, dimension.Count - 1); type.RankSpecifier = (int[])rank.ToArray(typeof(int)); } - expr = new ArrayCreateExpression(type, dimension); - SetParent(dimension, expr); + expr = new ArrayCreateExpression(type.Clone(), dimension); } } else if (rank != null) { if(type.RankSpecifier != null) { @@ -2808,12 +2784,12 @@ out type); if (la.kind == 10) { lexer.NextToken(); VariableInitializer( -#line 1472 "VBNET.ATG" +#line 1463 "VBNET.ATG" out expr); } } else SynErr(250); -#line 1475 "VBNET.ATG" +#line 1466 "VBNET.ATG" VariableDeclaration varDecl = new VariableDeclaration(name, expr, type); varDecl.StartLocation = startLocation; varDecl.EndLocation = t.Location; @@ -2822,22 +2798,22 @@ out expr); } void VariableDeclarator( -#line 1408 "VBNET.ATG" +#line 1400 "VBNET.ATG" List fieldDeclaration) { Identifier(); -#line 1410 "VBNET.ATG" +#line 1402 "VBNET.ATG" string name = t.val; VariableDeclaratorPartAfterIdentifier( -#line 1411 "VBNET.ATG" +#line 1403 "VBNET.ATG" fieldDeclaration, name); } void ConstantDeclarator( -#line 1389 "VBNET.ATG" +#line 1381 "VBNET.ATG" List constantDeclaration) { -#line 1391 "VBNET.ATG" +#line 1383 "VBNET.ATG" Expression expr = null; TypeReference type = null; string name = String.Empty; @@ -2845,20 +2821,20 @@ List constantDeclaration) { Identifier(); -#line 1396 "VBNET.ATG" +#line 1388 "VBNET.ATG" name = t.val; location = t.Location; if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 1397 "VBNET.ATG" +#line 1389 "VBNET.ATG" out type); } Expect(10); Expr( -#line 1398 "VBNET.ATG" +#line 1390 "VBNET.ATG" out expr); -#line 1400 "VBNET.ATG" +#line 1392 "VBNET.ATG" VariableDeclaration f = new VariableDeclaration(name, expr); f.TypeReference = type; f.StartLocation = location; @@ -2867,10 +2843,10 @@ out expr); } void AccessorDecls( -#line 1323 "VBNET.ATG" +#line 1315 "VBNET.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1325 "VBNET.ATG" +#line 1317 "VBNET.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2878,60 +2854,60 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 28) { AttributeSection( -#line 1330 "VBNET.ATG" +#line 1322 "VBNET.ATG" out section); -#line 1330 "VBNET.ATG" +#line 1322 "VBNET.ATG" attributes.Add(section); } if (StartOf(24)) { GetAccessorDecl( -#line 1332 "VBNET.ATG" +#line 1324 "VBNET.ATG" out getBlock, attributes); if (StartOf(25)) { -#line 1334 "VBNET.ATG" +#line 1326 "VBNET.ATG" attributes = new List(); while (la.kind == 28) { AttributeSection( -#line 1335 "VBNET.ATG" +#line 1327 "VBNET.ATG" out section); -#line 1335 "VBNET.ATG" +#line 1327 "VBNET.ATG" attributes.Add(section); } SetAccessorDecl( -#line 1336 "VBNET.ATG" +#line 1328 "VBNET.ATG" out setBlock, attributes); } } else if (StartOf(26)) { SetAccessorDecl( -#line 1339 "VBNET.ATG" +#line 1331 "VBNET.ATG" out setBlock, attributes); if (StartOf(27)) { -#line 1341 "VBNET.ATG" +#line 1333 "VBNET.ATG" attributes = new List(); while (la.kind == 28) { AttributeSection( -#line 1342 "VBNET.ATG" +#line 1334 "VBNET.ATG" out section); -#line 1342 "VBNET.ATG" +#line 1334 "VBNET.ATG" attributes.Add(section); } GetAccessorDecl( -#line 1343 "VBNET.ATG" +#line 1335 "VBNET.ATG" out getBlock, attributes); } } else SynErr(251); } void EventAccessorDeclaration( -#line 1286 "VBNET.ATG" +#line 1278 "VBNET.ATG" out EventAddRemoveRegion eventAccessorDeclaration) { -#line 1288 "VBNET.ATG" +#line 1280 "VBNET.ATG" Statement stmt = null; List p = new List(); AttributeSection section; @@ -2940,10 +2916,10 @@ out EventAddRemoveRegion eventAccessorDeclaration) { while (la.kind == 28) { AttributeSection( -#line 1294 "VBNET.ATG" +#line 1286 "VBNET.ATG" out section); -#line 1294 "VBNET.ATG" +#line 1286 "VBNET.ATG" attributes.Add(section); } if (la.kind == 43) { @@ -2952,20 +2928,20 @@ out section); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1296 "VBNET.ATG" +#line 1288 "VBNET.ATG" p); } Expect(26); } Expect(1); Block( -#line 1297 "VBNET.ATG" +#line 1289 "VBNET.ATG" out stmt); Expect(100); Expect(43); EndOfStmt(); -#line 1299 "VBNET.ATG" +#line 1291 "VBNET.ATG" eventAccessorDeclaration = new EventAddRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -2976,20 +2952,20 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1304 "VBNET.ATG" +#line 1296 "VBNET.ATG" p); } Expect(26); } Expect(1); Block( -#line 1305 "VBNET.ATG" +#line 1297 "VBNET.ATG" out stmt); Expect(100); Expect(178); EndOfStmt(); -#line 1307 "VBNET.ATG" +#line 1299 "VBNET.ATG" eventAccessorDeclaration = new EventRemoveRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -3000,20 +2976,20 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1312 "VBNET.ATG" +#line 1304 "VBNET.ATG" p); } Expect(26); } Expect(1); Block( -#line 1313 "VBNET.ATG" +#line 1305 "VBNET.ATG" out stmt); Expect(100); Expect(174); EndOfStmt(); -#line 1315 "VBNET.ATG" +#line 1307 "VBNET.ATG" eventAccessorDeclaration = new EventRaiseRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -3022,163 +2998,163 @@ out stmt); } void OverloadableOperator( -#line 1228 "VBNET.ATG" +#line 1220 "VBNET.ATG" out OverloadableOperatorType operatorType) { -#line 1229 "VBNET.ATG" +#line 1221 "VBNET.ATG" operatorType = OverloadableOperatorType.None; switch (la.kind) { case 19: { lexer.NextToken(); -#line 1231 "VBNET.ATG" +#line 1223 "VBNET.ATG" operatorType = OverloadableOperatorType.Add; break; } case 18: { lexer.NextToken(); -#line 1233 "VBNET.ATG" +#line 1225 "VBNET.ATG" operatorType = OverloadableOperatorType.Subtract; break; } case 22: { lexer.NextToken(); -#line 1235 "VBNET.ATG" +#line 1227 "VBNET.ATG" operatorType = OverloadableOperatorType.Multiply; break; } case 14: { lexer.NextToken(); -#line 1237 "VBNET.ATG" +#line 1229 "VBNET.ATG" operatorType = OverloadableOperatorType.Divide; break; } case 15: { lexer.NextToken(); -#line 1239 "VBNET.ATG" +#line 1231 "VBNET.ATG" operatorType = OverloadableOperatorType.DivideInteger; break; } case 13: { lexer.NextToken(); -#line 1241 "VBNET.ATG" +#line 1233 "VBNET.ATG" operatorType = OverloadableOperatorType.Concat; break; } case 136: { lexer.NextToken(); -#line 1243 "VBNET.ATG" +#line 1235 "VBNET.ATG" operatorType = OverloadableOperatorType.Like; break; } case 140: { lexer.NextToken(); -#line 1245 "VBNET.ATG" +#line 1237 "VBNET.ATG" operatorType = OverloadableOperatorType.Modulus; break; } case 47: { lexer.NextToken(); -#line 1247 "VBNET.ATG" +#line 1239 "VBNET.ATG" operatorType = OverloadableOperatorType.BitwiseAnd; break; } case 161: { lexer.NextToken(); -#line 1249 "VBNET.ATG" +#line 1241 "VBNET.ATG" operatorType = OverloadableOperatorType.BitwiseOr; break; } case 221: { lexer.NextToken(); -#line 1251 "VBNET.ATG" +#line 1243 "VBNET.ATG" operatorType = OverloadableOperatorType.ExclusiveOr; break; } case 20: { lexer.NextToken(); -#line 1253 "VBNET.ATG" +#line 1245 "VBNET.ATG" operatorType = OverloadableOperatorType.Power; break; } case 32: { lexer.NextToken(); -#line 1255 "VBNET.ATG" +#line 1247 "VBNET.ATG" operatorType = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1257 "VBNET.ATG" +#line 1249 "VBNET.ATG" operatorType = OverloadableOperatorType.ShiftRight; break; } case 10: { lexer.NextToken(); -#line 1259 "VBNET.ATG" +#line 1251 "VBNET.ATG" operatorType = OverloadableOperatorType.Equality; break; } case 29: { lexer.NextToken(); -#line 1261 "VBNET.ATG" +#line 1253 "VBNET.ATG" operatorType = OverloadableOperatorType.InEquality; break; } case 28: { lexer.NextToken(); -#line 1263 "VBNET.ATG" +#line 1255 "VBNET.ATG" operatorType = OverloadableOperatorType.LessThan; break; } case 31: { lexer.NextToken(); -#line 1265 "VBNET.ATG" +#line 1257 "VBNET.ATG" operatorType = OverloadableOperatorType.LessThanOrEqual; break; } case 27: { lexer.NextToken(); -#line 1267 "VBNET.ATG" +#line 1259 "VBNET.ATG" operatorType = OverloadableOperatorType.GreaterThan; break; } case 30: { lexer.NextToken(); -#line 1269 "VBNET.ATG" +#line 1261 "VBNET.ATG" operatorType = OverloadableOperatorType.GreaterThanOrEqual; break; } case 81: { lexer.NextToken(); -#line 1271 "VBNET.ATG" +#line 1263 "VBNET.ATG" operatorType = OverloadableOperatorType.CType; break; } case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 85: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: { Identifier(); -#line 1275 "VBNET.ATG" +#line 1267 "VBNET.ATG" string opName = t.val; if (string.Equals(opName, "istrue", StringComparison.InvariantCultureIgnoreCase)) { operatorType = OverloadableOperatorType.IsTrue; @@ -3195,67 +3171,67 @@ out OverloadableOperatorType operatorType) { } void GetAccessorDecl( -#line 1349 "VBNET.ATG" +#line 1341 "VBNET.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1350 "VBNET.ATG" +#line 1342 "VBNET.ATG" Statement stmt = null; Modifiers m; PropertyAccessorAccessModifier( -#line 1352 "VBNET.ATG" +#line 1344 "VBNET.ATG" out m); Expect(115); -#line 1354 "VBNET.ATG" +#line 1346 "VBNET.ATG" Location startLocation = t.Location; Expect(1); Block( -#line 1356 "VBNET.ATG" +#line 1348 "VBNET.ATG" out stmt); -#line 1357 "VBNET.ATG" +#line 1349 "VBNET.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); Expect(100); Expect(115); -#line 1359 "VBNET.ATG" +#line 1351 "VBNET.ATG" getBlock.Modifier = m; -#line 1360 "VBNET.ATG" +#line 1352 "VBNET.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; EndOfStmt(); } void SetAccessorDecl( -#line 1365 "VBNET.ATG" +#line 1357 "VBNET.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1367 "VBNET.ATG" +#line 1359 "VBNET.ATG" Statement stmt = null; List p = new List(); Modifiers m; PropertyAccessorAccessModifier( -#line 1372 "VBNET.ATG" +#line 1364 "VBNET.ATG" out m); Expect(183); -#line 1374 "VBNET.ATG" +#line 1366 "VBNET.ATG" Location startLocation = t.Location; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1375 "VBNET.ATG" +#line 1367 "VBNET.ATG" p); } Expect(26); } Expect(1); Block( -#line 1377 "VBNET.ATG" +#line 1369 "VBNET.ATG" out stmt); -#line 1379 "VBNET.ATG" +#line 1371 "VBNET.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); setBlock.Modifier = m; setBlock.Parameters = p; @@ -3263,73 +3239,73 @@ out stmt); Expect(100); Expect(183); -#line 1384 "VBNET.ATG" +#line 1376 "VBNET.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; EndOfStmt(); } void PropertyAccessorAccessModifier( -#line 3427 "VBNET.ATG" +#line 3396 "VBNET.ATG" out Modifiers m) { -#line 3428 "VBNET.ATG" +#line 3397 "VBNET.ATG" m = Modifiers.None; while (StartOf(28)) { if (la.kind == 173) { lexer.NextToken(); -#line 3430 "VBNET.ATG" +#line 3399 "VBNET.ATG" m |= Modifiers.Public; } else if (la.kind == 172) { lexer.NextToken(); -#line 3431 "VBNET.ATG" +#line 3400 "VBNET.ATG" m |= Modifiers.Protected; } else if (la.kind == 112) { lexer.NextToken(); -#line 3432 "VBNET.ATG" +#line 3401 "VBNET.ATG" m |= Modifiers.Internal; } else { lexer.NextToken(); -#line 3433 "VBNET.ATG" +#line 3402 "VBNET.ATG" m |= Modifiers.Private; } } } void ArrayInitializationModifier( -#line 1483 "VBNET.ATG" +#line 1474 "VBNET.ATG" out List arrayModifiers) { -#line 1485 "VBNET.ATG" +#line 1476 "VBNET.ATG" arrayModifiers = null; Expect(25); InitializationRankList( -#line 1487 "VBNET.ATG" +#line 1478 "VBNET.ATG" out arrayModifiers); Expect(26); } void ArrayNameModifier( -#line 2492 "VBNET.ATG" +#line 2473 "VBNET.ATG" out ArrayList arrayModifiers) { -#line 2494 "VBNET.ATG" +#line 2475 "VBNET.ATG" arrayModifiers = null; ArrayTypeModifiers( -#line 2496 "VBNET.ATG" +#line 2477 "VBNET.ATG" out arrayModifiers); } void ObjectCreateExpression( -#line 1945 "VBNET.ATG" +#line 1935 "VBNET.ATG" out Expression oce) { -#line 1947 "VBNET.ATG" +#line 1937 "VBNET.ATG" TypeReference type = null; Expression initializer = null; List arguments = null; @@ -3340,82 +3316,80 @@ out Expression oce) { Expect(148); if (StartOf(7)) { NonArrayTypeName( -#line 1955 "VBNET.ATG" +#line 1945 "VBNET.ATG" out type, false); if (la.kind == 25) { lexer.NextToken(); NormalOrReDimArgumentList( -#line 1956 "VBNET.ATG" +#line 1946 "VBNET.ATG" out arguments, out canBeNormal, out canBeReDim); Expect(26); if (la.kind == 23 || -#line 1957 "VBNET.ATG" +#line 1947 "VBNET.ATG" la.kind == Tokens.OpenParenthesis) { if ( -#line 1957 "VBNET.ATG" +#line 1947 "VBNET.ATG" la.kind == Tokens.OpenParenthesis) { ArrayTypeModifiers( -#line 1958 "VBNET.ATG" +#line 1948 "VBNET.ATG" out dimensions); CollectionInitializer( -#line 1959 "VBNET.ATG" +#line 1949 "VBNET.ATG" out initializer); } else { CollectionInitializer( -#line 1960 "VBNET.ATG" +#line 1950 "VBNET.ATG" out initializer); } } -#line 1962 "VBNET.ATG" +#line 1952 "VBNET.ATG" if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression(); } } -#line 1966 "VBNET.ATG" +#line 1956 "VBNET.ATG" if (initializer == null) { oce = new ObjectCreateExpression(type, arguments); - SetParent(arguments, oce); } else { if (dimensions == null) dimensions = new ArrayList(); dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0)); type.RankSpecifier = (int[])dimensions.ToArray(typeof(int)); ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer as CollectionInitializerExpression); ace.Arguments = arguments; - SetParent(arguments, ace); oce = ace; } if (la.kind == 218) { -#line 1982 "VBNET.ATG" +#line 1970 "VBNET.ATG" NamedArgumentExpression memberInitializer = null; lexer.NextToken(); -#line 1986 "VBNET.ATG" +#line 1974 "VBNET.ATG" CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression(); memberInitializers.StartLocation = la.Location; Expect(23); MemberInitializer( -#line 1990 "VBNET.ATG" +#line 1978 "VBNET.ATG" out memberInitializer); -#line 1991 "VBNET.ATG" +#line 1979 "VBNET.ATG" memberInitializers.CreateExpressions.Add(memberInitializer); while (la.kind == 12) { lexer.NextToken(); MemberInitializer( -#line 1993 "VBNET.ATG" +#line 1981 "VBNET.ATG" out memberInitializer); -#line 1994 "VBNET.ATG" +#line 1982 "VBNET.ATG" memberInitializers.CreateExpressions.Add(memberInitializer); } Expect(24); -#line 1998 "VBNET.ATG" +#line 1986 "VBNET.ATG" memberInitializers.EndLocation = t.Location; if(oce is ObjectCreateExpression) { @@ -3426,106 +3400,106 @@ out memberInitializer); } void VariableInitializer( -#line 1511 "VBNET.ATG" +#line 1502 "VBNET.ATG" out Expression initializerExpression) { -#line 1513 "VBNET.ATG" +#line 1504 "VBNET.ATG" initializerExpression = null; if (StartOf(29)) { Expr( -#line 1515 "VBNET.ATG" +#line 1506 "VBNET.ATG" out initializerExpression); } else if (la.kind == 23) { CollectionInitializer( -#line 1516 "VBNET.ATG" +#line 1507 "VBNET.ATG" out initializerExpression); } else SynErr(254); } void InitializationRankList( -#line 1491 "VBNET.ATG" +#line 1482 "VBNET.ATG" out List rank) { -#line 1493 "VBNET.ATG" +#line 1484 "VBNET.ATG" rank = new List(); Expression expr = null; Expr( -#line 1496 "VBNET.ATG" +#line 1487 "VBNET.ATG" out expr); if (la.kind == 201) { lexer.NextToken(); -#line 1497 "VBNET.ATG" +#line 1488 "VBNET.ATG" EnsureIsZero(expr); Expr( -#line 1498 "VBNET.ATG" +#line 1489 "VBNET.ATG" out expr); } -#line 1500 "VBNET.ATG" +#line 1491 "VBNET.ATG" if (expr != null) { rank.Add(expr); } while (la.kind == 12) { lexer.NextToken(); Expr( -#line 1502 "VBNET.ATG" +#line 1493 "VBNET.ATG" out expr); if (la.kind == 201) { lexer.NextToken(); -#line 1503 "VBNET.ATG" +#line 1494 "VBNET.ATG" EnsureIsZero(expr); Expr( -#line 1504 "VBNET.ATG" +#line 1495 "VBNET.ATG" out expr); } -#line 1506 "VBNET.ATG" +#line 1497 "VBNET.ATG" if (expr != null) { rank.Add(expr); } } } void CollectionInitializer( -#line 1520 "VBNET.ATG" +#line 1511 "VBNET.ATG" out Expression outExpr) { -#line 1522 "VBNET.ATG" +#line 1513 "VBNET.ATG" Expression expr = null; CollectionInitializerExpression initializer = new CollectionInitializerExpression(); Expect(23); if (StartOf(30)) { VariableInitializer( -#line 1527 "VBNET.ATG" +#line 1518 "VBNET.ATG" out expr); -#line 1529 "VBNET.ATG" +#line 1520 "VBNET.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1532 "VBNET.ATG" +#line 1523 "VBNET.ATG" NotFinalComma()) { Expect(12); VariableInitializer( -#line 1532 "VBNET.ATG" +#line 1523 "VBNET.ATG" out expr); -#line 1533 "VBNET.ATG" +#line 1524 "VBNET.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } } Expect(24); -#line 1536 "VBNET.ATG" +#line 1527 "VBNET.ATG" outExpr = initializer; } void EventMemberSpecifier( -#line 1606 "VBNET.ATG" +#line 1597 "VBNET.ATG" out string name) { -#line 1607 "VBNET.ATG" +#line 1598 "VBNET.ATG" string eventName; if (StartOf(14)) { Identifier(); @@ -3535,54 +3509,54 @@ out string name) { lexer.NextToken(); } else SynErr(255); -#line 1610 "VBNET.ATG" +#line 1601 "VBNET.ATG" name = t.val; Expect(16); IdentifierOrKeyword( -#line 1612 "VBNET.ATG" +#line 1603 "VBNET.ATG" out eventName); -#line 1613 "VBNET.ATG" +#line 1604 "VBNET.ATG" name = name + "." + eventName; } void IdentifierOrKeyword( -#line 3360 "VBNET.ATG" +#line 3329 "VBNET.ATG" out string name) { -#line 3362 "VBNET.ATG" +#line 3331 "VBNET.ATG" lexer.NextToken(); name = t.val; } void QueryExpr( -#line 2025 "VBNET.ATG" +#line 2013 "VBNET.ATG" out Expression expr) { -#line 2027 "VBNET.ATG" +#line 2015 "VBNET.ATG" QueryExpression qexpr = new QueryExpression(); qexpr.StartLocation = la.Location; List middleClauses = new List(); expr = qexpr; FromOrAggregateQueryOperator( -#line 2032 "VBNET.ATG" +#line 2020 "VBNET.ATG" middleClauses); while (StartOf(31)) { QueryOperator( -#line 2033 "VBNET.ATG" +#line 2021 "VBNET.ATG" middleClauses); } -#line 2035 "VBNET.ATG" +#line 2023 "VBNET.ATG" qexpr.EndLocation = t.EndLocation; } void LambdaExpr( -#line 2007 "VBNET.ATG" +#line 1995 "VBNET.ATG" out Expression expr) { -#line 2009 "VBNET.ATG" +#line 1997 "VBNET.ATG" Expression inner = null; LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; @@ -3592,16 +3566,16 @@ out Expression expr) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 2015 "VBNET.ATG" +#line 2003 "VBNET.ATG" lambda.Parameters); } Expect(26); } Expr( -#line 2016 "VBNET.ATG" +#line 2004 "VBNET.ATG" out inner); -#line 2018 "VBNET.ATG" +#line 2006 "VBNET.ATG" lambda.ExpressionBody = inner; lambda.EndLocation = t.EndLocation; // la.Location? @@ -3610,116 +3584,116 @@ out inner); } void DisjunctionExpr( -#line 1789 "VBNET.ATG" +#line 1779 "VBNET.ATG" out Expression outExpr) { -#line 1791 "VBNET.ATG" +#line 1781 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ConjunctionExpr( -#line 1794 "VBNET.ATG" +#line 1784 "VBNET.ATG" out outExpr); while (la.kind == 161 || la.kind == 163 || la.kind == 221) { if (la.kind == 161) { lexer.NextToken(); -#line 1797 "VBNET.ATG" +#line 1787 "VBNET.ATG" op = BinaryOperatorType.BitwiseOr; } else if (la.kind == 163) { lexer.NextToken(); -#line 1798 "VBNET.ATG" +#line 1788 "VBNET.ATG" op = BinaryOperatorType.LogicalOr; } else { lexer.NextToken(); -#line 1799 "VBNET.ATG" +#line 1789 "VBNET.ATG" op = BinaryOperatorType.ExclusiveOr; } ConjunctionExpr( -#line 1801 "VBNET.ATG" +#line 1791 "VBNET.ATG" out expr); -#line 1801 "VBNET.ATG" +#line 1791 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AssignmentOperator( -#line 1624 "VBNET.ATG" +#line 1615 "VBNET.ATG" out AssignmentOperatorType op) { -#line 1625 "VBNET.ATG" +#line 1616 "VBNET.ATG" op = AssignmentOperatorType.None; switch (la.kind) { case 10: { lexer.NextToken(); -#line 1626 "VBNET.ATG" +#line 1617 "VBNET.ATG" op = AssignmentOperatorType.Assign; break; } case 42: { lexer.NextToken(); -#line 1627 "VBNET.ATG" +#line 1618 "VBNET.ATG" op = AssignmentOperatorType.ConcatString; break; } case 34: { lexer.NextToken(); -#line 1628 "VBNET.ATG" +#line 1619 "VBNET.ATG" op = AssignmentOperatorType.Add; break; } case 36: { lexer.NextToken(); -#line 1629 "VBNET.ATG" +#line 1620 "VBNET.ATG" op = AssignmentOperatorType.Subtract; break; } case 37: { lexer.NextToken(); -#line 1630 "VBNET.ATG" +#line 1621 "VBNET.ATG" op = AssignmentOperatorType.Multiply; break; } case 38: { lexer.NextToken(); -#line 1631 "VBNET.ATG" +#line 1622 "VBNET.ATG" op = AssignmentOperatorType.Divide; break; } case 39: { lexer.NextToken(); -#line 1632 "VBNET.ATG" +#line 1623 "VBNET.ATG" op = AssignmentOperatorType.DivideInteger; break; } case 35: { lexer.NextToken(); -#line 1633 "VBNET.ATG" +#line 1624 "VBNET.ATG" op = AssignmentOperatorType.Power; break; } case 40: { lexer.NextToken(); -#line 1634 "VBNET.ATG" +#line 1625 "VBNET.ATG" op = AssignmentOperatorType.ShiftLeft; break; } case 41: { lexer.NextToken(); -#line 1635 "VBNET.ATG" +#line 1626 "VBNET.ATG" op = AssignmentOperatorType.ShiftRight; break; } @@ -3728,54 +3702,54 @@ out AssignmentOperatorType op) { } void SimpleExpr( -#line 1639 "VBNET.ATG" +#line 1630 "VBNET.ATG" out Expression pexpr) { -#line 1640 "VBNET.ATG" +#line 1631 "VBNET.ATG" string name; SimpleNonInvocationExpression( -#line 1642 "VBNET.ATG" +#line 1633 "VBNET.ATG" out pexpr); while (la.kind == 16 || la.kind == 17 || la.kind == 25) { if (la.kind == 16) { lexer.NextToken(); IdentifierOrKeyword( -#line 1644 "VBNET.ATG" +#line 1635 "VBNET.ATG" out name); -#line 1645 "VBNET.ATG" +#line 1636 "VBNET.ATG" pexpr = new MemberReferenceExpression(pexpr, name); if ( -#line 1646 "VBNET.ATG" +#line 1637 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(155); TypeArgumentList( -#line 1647 "VBNET.ATG" +#line 1638 "VBNET.ATG" ((MemberReferenceExpression)pexpr).TypeArguments); Expect(26); } } else if (la.kind == 17) { lexer.NextToken(); IdentifierOrKeyword( -#line 1649 "VBNET.ATG" +#line 1640 "VBNET.ATG" out name); -#line 1649 "VBNET.ATG" +#line 1640 "VBNET.ATG" pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name)); } else { InvocationExpression( -#line 1650 "VBNET.ATG" +#line 1641 "VBNET.ATG" ref pexpr); } } } void SimpleNonInvocationExpression( -#line 1654 "VBNET.ATG" +#line 1645 "VBNET.ATG" out Expression pexpr) { -#line 1656 "VBNET.ATG" +#line 1647 "VBNET.ATG" Expression expr; TypeReference type = null; string name = String.Empty; @@ -3786,98 +3760,98 @@ out Expression pexpr) { case 3: { lexer.NextToken(); -#line 1664 "VBNET.ATG" +#line 1655 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 4: { lexer.NextToken(); -#line 1665 "VBNET.ATG" +#line 1656 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 7: { lexer.NextToken(); -#line 1666 "VBNET.ATG" +#line 1657 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 6: { lexer.NextToken(); -#line 1667 "VBNET.ATG" +#line 1658 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 5: { lexer.NextToken(); -#line 1668 "VBNET.ATG" +#line 1659 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 9: { lexer.NextToken(); -#line 1669 "VBNET.ATG" +#line 1660 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 8: { lexer.NextToken(); -#line 1670 "VBNET.ATG" +#line 1661 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; break; } case 202: { lexer.NextToken(); -#line 1672 "VBNET.ATG" +#line 1663 "VBNET.ATG" pexpr = new PrimitiveExpression(true, "true"); break; } case 109: { lexer.NextToken(); -#line 1673 "VBNET.ATG" +#line 1664 "VBNET.ATG" pexpr = new PrimitiveExpression(false, "false"); break; } case 151: { lexer.NextToken(); -#line 1674 "VBNET.ATG" +#line 1665 "VBNET.ATG" pexpr = new PrimitiveExpression(null, "null"); break; } case 25: { lexer.NextToken(); Expr( -#line 1675 "VBNET.ATG" +#line 1666 "VBNET.ATG" out expr); Expect(26); -#line 1675 "VBNET.ATG" +#line 1666 "VBNET.ATG" pexpr = new ParenthesizedExpression(expr); break; } case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 85: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: { Identifier(); -#line 1677 "VBNET.ATG" +#line 1668 "VBNET.ATG" pexpr = new IdentifierExpression(t.val); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; if ( -#line 1680 "VBNET.ATG" +#line 1671 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(155); TypeArgumentList( -#line 1681 "VBNET.ATG" +#line 1672 "VBNET.ATG" ((IdentifierExpression)pexpr).TypeArguments); Expect(26); } @@ -3885,51 +3859,51 @@ la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { } case 55: case 58: case 69: case 86: case 87: case 96: case 128: case 137: case 154: case 181: case 186: case 187: case 193: case 206: case 207: case 210: { -#line 1683 "VBNET.ATG" +#line 1674 "VBNET.ATG" string val = String.Empty; if (StartOf(11)) { PrimitiveTypeName( -#line 1684 "VBNET.ATG" +#line 1675 "VBNET.ATG" out val); } else if (la.kind == 154) { lexer.NextToken(); -#line 1684 "VBNET.ATG" +#line 1675 "VBNET.ATG" val = "System.Object"; } else SynErr(257); -#line 1685 "VBNET.ATG" +#line 1676 "VBNET.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)); break; } case 139: { lexer.NextToken(); -#line 1686 "VBNET.ATG" +#line 1677 "VBNET.ATG" pexpr = new ThisReferenceExpression(); break; } case 144: case 145: { -#line 1687 "VBNET.ATG" +#line 1678 "VBNET.ATG" Expression retExpr = null; if (la.kind == 144) { lexer.NextToken(); -#line 1688 "VBNET.ATG" +#line 1679 "VBNET.ATG" retExpr = new BaseReferenceExpression(); } else if (la.kind == 145) { lexer.NextToken(); -#line 1689 "VBNET.ATG" +#line 1680 "VBNET.ATG" retExpr = new ClassReferenceExpression(); } else SynErr(258); Expect(16); IdentifierOrKeyword( -#line 1691 "VBNET.ATG" +#line 1682 "VBNET.ATG" out name); -#line 1691 "VBNET.ATG" +#line 1682 "VBNET.ATG" pexpr = new MemberReferenceExpression(retExpr, name); break; } @@ -3938,77 +3912,77 @@ out name); Expect(16); Identifier(); -#line 1693 "VBNET.ATG" +#line 1684 "VBNET.ATG" type = new TypeReference(t.val ?? ""); -#line 1695 "VBNET.ATG" +#line 1686 "VBNET.ATG" type.IsGlobal = true; -#line 1696 "VBNET.ATG" +#line 1687 "VBNET.ATG" pexpr = new TypeReferenceExpression(type); break; } case 148: { ObjectCreateExpression( -#line 1697 "VBNET.ATG" +#line 1688 "VBNET.ATG" out expr); -#line 1697 "VBNET.ATG" +#line 1688 "VBNET.ATG" pexpr = expr; break; } case 81: case 93: case 204: { -#line 1699 "VBNET.ATG" +#line 1690 "VBNET.ATG" CastType castType = CastType.Cast; if (la.kind == 93) { lexer.NextToken(); } else if (la.kind == 81) { lexer.NextToken(); -#line 1701 "VBNET.ATG" +#line 1692 "VBNET.ATG" castType = CastType.Conversion; } else if (la.kind == 204) { lexer.NextToken(); -#line 1702 "VBNET.ATG" +#line 1693 "VBNET.ATG" castType = CastType.TryCast; } else SynErr(259); Expect(25); Expr( -#line 1704 "VBNET.ATG" +#line 1695 "VBNET.ATG" out expr); Expect(12); TypeName( -#line 1704 "VBNET.ATG" +#line 1695 "VBNET.ATG" out type); Expect(26); -#line 1705 "VBNET.ATG" +#line 1696 "VBNET.ATG" pexpr = new CastExpression(type, expr, castType); break; } case 63: case 64: case 65: case 66: case 67: case 68: case 70: case 72: case 73: case 77: case 78: case 79: case 80: case 82: case 83: case 84: { CastTarget( -#line 1706 "VBNET.ATG" +#line 1697 "VBNET.ATG" out type); Expect(25); Expr( -#line 1706 "VBNET.ATG" +#line 1697 "VBNET.ATG" out expr); Expect(26); -#line 1706 "VBNET.ATG" +#line 1697 "VBNET.ATG" pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); break; } case 44: { lexer.NextToken(); Expr( -#line 1707 "VBNET.ATG" +#line 1698 "VBNET.ATG" out expr); -#line 1707 "VBNET.ATG" +#line 1698 "VBNET.ATG" pexpr = new AddressOfExpression(expr); break; } @@ -4016,31 +3990,31 @@ out expr); lexer.NextToken(); Expect(25); GetTypeTypeName( -#line 1708 "VBNET.ATG" +#line 1699 "VBNET.ATG" out type); Expect(26); -#line 1708 "VBNET.ATG" +#line 1699 "VBNET.ATG" pexpr = new TypeOfExpression(type); break; } case 205: { lexer.NextToken(); SimpleExpr( -#line 1709 "VBNET.ATG" +#line 1700 "VBNET.ATG" out expr); Expect(131); TypeName( -#line 1709 "VBNET.ATG" +#line 1700 "VBNET.ATG" out type); -#line 1709 "VBNET.ATG" +#line 1700 "VBNET.ATG" pexpr = new TypeOfIsExpression(expr, type); break; } case 122: { ConditionalExpression( -#line 1710 "VBNET.ATG" +#line 1701 "VBNET.ATG" out pexpr); break; } @@ -4048,171 +4022,170 @@ out pexpr); } else if (la.kind == 16) { lexer.NextToken(); IdentifierOrKeyword( -#line 1714 "VBNET.ATG" +#line 1705 "VBNET.ATG" out name); -#line 1714 "VBNET.ATG" +#line 1705 "VBNET.ATG" pexpr = new MemberReferenceExpression(null, name); } else SynErr(260); } void TypeArgumentList( -#line 2528 "VBNET.ATG" +#line 2509 "VBNET.ATG" List typeArguments) { -#line 2530 "VBNET.ATG" +#line 2511 "VBNET.ATG" TypeReference typeref; TypeName( -#line 2532 "VBNET.ATG" +#line 2513 "VBNET.ATG" out typeref); -#line 2532 "VBNET.ATG" +#line 2513 "VBNET.ATG" if (typeref != null) typeArguments.Add(typeref); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 2535 "VBNET.ATG" +#line 2516 "VBNET.ATG" out typeref); -#line 2535 "VBNET.ATG" +#line 2516 "VBNET.ATG" if (typeref != null) typeArguments.Add(typeref); } } void InvocationExpression( -#line 1752 "VBNET.ATG" +#line 1743 "VBNET.ATG" ref Expression pexpr) { -#line 1753 "VBNET.ATG" +#line 1744 "VBNET.ATG" List parameters = null; Expect(25); -#line 1755 "VBNET.ATG" +#line 1746 "VBNET.ATG" Location start = t.Location; ArgumentList( -#line 1756 "VBNET.ATG" +#line 1747 "VBNET.ATG" out parameters); Expect(26); -#line 1759 "VBNET.ATG" +#line 1750 "VBNET.ATG" pexpr = new InvocationExpression(pexpr, parameters); - SetParent(parameters, pexpr); -#line 1762 "VBNET.ATG" +#line 1752 "VBNET.ATG" pexpr.StartLocation = start; pexpr.EndLocation = t.Location; } void PrimitiveTypeName( -#line 3367 "VBNET.ATG" +#line 3336 "VBNET.ATG" out string type) { -#line 3368 "VBNET.ATG" +#line 3337 "VBNET.ATG" type = String.Empty; switch (la.kind) { case 55: { lexer.NextToken(); -#line 3369 "VBNET.ATG" +#line 3338 "VBNET.ATG" type = "System.Boolean"; break; } case 86: { lexer.NextToken(); -#line 3370 "VBNET.ATG" +#line 3339 "VBNET.ATG" type = "System.DateTime"; break; } case 69: { lexer.NextToken(); -#line 3371 "VBNET.ATG" +#line 3340 "VBNET.ATG" type = "System.Char"; break; } case 193: { lexer.NextToken(); -#line 3372 "VBNET.ATG" +#line 3341 "VBNET.ATG" type = "System.String"; break; } case 87: { lexer.NextToken(); -#line 3373 "VBNET.ATG" +#line 3342 "VBNET.ATG" type = "System.Decimal"; break; } case 58: { lexer.NextToken(); -#line 3374 "VBNET.ATG" +#line 3343 "VBNET.ATG" type = "System.Byte"; break; } case 186: { lexer.NextToken(); -#line 3375 "VBNET.ATG" +#line 3344 "VBNET.ATG" type = "System.Int16"; break; } case 128: { lexer.NextToken(); -#line 3376 "VBNET.ATG" +#line 3345 "VBNET.ATG" type = "System.Int32"; break; } case 137: { lexer.NextToken(); -#line 3377 "VBNET.ATG" +#line 3346 "VBNET.ATG" type = "System.Int64"; break; } case 187: { lexer.NextToken(); -#line 3378 "VBNET.ATG" +#line 3347 "VBNET.ATG" type = "System.Single"; break; } case 96: { lexer.NextToken(); -#line 3379 "VBNET.ATG" +#line 3348 "VBNET.ATG" type = "System.Double"; break; } case 206: { lexer.NextToken(); -#line 3380 "VBNET.ATG" +#line 3349 "VBNET.ATG" type = "System.UInt32"; break; } case 207: { lexer.NextToken(); -#line 3381 "VBNET.ATG" +#line 3350 "VBNET.ATG" type = "System.UInt64"; break; } case 210: { lexer.NextToken(); -#line 3382 "VBNET.ATG" +#line 3351 "VBNET.ATG" type = "System.UInt16"; break; } case 181: { lexer.NextToken(); -#line 3383 "VBNET.ATG" +#line 3352 "VBNET.ATG" type = "System.SByte"; break; } @@ -4221,122 +4194,122 @@ out string type) { } void CastTarget( -#line 1767 "VBNET.ATG" +#line 1757 "VBNET.ATG" out TypeReference type) { -#line 1769 "VBNET.ATG" +#line 1759 "VBNET.ATG" type = null; switch (la.kind) { case 63: { lexer.NextToken(); -#line 1771 "VBNET.ATG" +#line 1761 "VBNET.ATG" type = new TypeReference("System.Boolean", true); break; } case 64: { lexer.NextToken(); -#line 1772 "VBNET.ATG" +#line 1762 "VBNET.ATG" type = new TypeReference("System.Byte", true); break; } case 77: { lexer.NextToken(); -#line 1773 "VBNET.ATG" +#line 1763 "VBNET.ATG" type = new TypeReference("System.SByte", true); break; } case 65: { lexer.NextToken(); -#line 1774 "VBNET.ATG" +#line 1764 "VBNET.ATG" type = new TypeReference("System.Char", true); break; } case 66: { lexer.NextToken(); -#line 1775 "VBNET.ATG" +#line 1765 "VBNET.ATG" type = new TypeReference("System.DateTime", true); break; } case 68: { lexer.NextToken(); -#line 1776 "VBNET.ATG" +#line 1766 "VBNET.ATG" type = new TypeReference("System.Decimal", true); break; } case 67: { lexer.NextToken(); -#line 1777 "VBNET.ATG" +#line 1767 "VBNET.ATG" type = new TypeReference("System.Double", true); break; } case 78: { lexer.NextToken(); -#line 1778 "VBNET.ATG" +#line 1768 "VBNET.ATG" type = new TypeReference("System.Int16", true); break; } case 70: { lexer.NextToken(); -#line 1779 "VBNET.ATG" +#line 1769 "VBNET.ATG" type = new TypeReference("System.Int32", true); break; } case 72: { lexer.NextToken(); -#line 1780 "VBNET.ATG" +#line 1770 "VBNET.ATG" type = new TypeReference("System.Int64", true); break; } case 84: { lexer.NextToken(); -#line 1781 "VBNET.ATG" +#line 1771 "VBNET.ATG" type = new TypeReference("System.UInt16", true); break; } case 82: { lexer.NextToken(); -#line 1782 "VBNET.ATG" +#line 1772 "VBNET.ATG" type = new TypeReference("System.UInt32", true); break; } case 83: { lexer.NextToken(); -#line 1783 "VBNET.ATG" +#line 1773 "VBNET.ATG" type = new TypeReference("System.UInt64", true); break; } case 73: { lexer.NextToken(); -#line 1784 "VBNET.ATG" +#line 1774 "VBNET.ATG" type = new TypeReference("System.Object", true); break; } case 79: { lexer.NextToken(); -#line 1785 "VBNET.ATG" +#line 1775 "VBNET.ATG" type = new TypeReference("System.Single", true); break; } case 80: { lexer.NextToken(); -#line 1786 "VBNET.ATG" +#line 1776 "VBNET.ATG" type = new TypeReference("System.String", true); break; } @@ -4345,19 +4318,19 @@ out TypeReference type) { } void GetTypeTypeName( -#line 2427 "VBNET.ATG" +#line 2408 "VBNET.ATG" out TypeReference typeref) { -#line 2428 "VBNET.ATG" +#line 2409 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( -#line 2430 "VBNET.ATG" +#line 2411 "VBNET.ATG" out typeref, true); ArrayTypeModifiers( -#line 2431 "VBNET.ATG" +#line 2412 "VBNET.ATG" out rank); -#line 2432 "VBNET.ATG" +#line 2413 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } @@ -4365,10 +4338,10 @@ out rank); } void ConditionalExpression( -#line 1718 "VBNET.ATG" +#line 1709 "VBNET.ATG" out Expression expr) { -#line 1720 "VBNET.ATG" +#line 1711 "VBNET.ATG" ConditionalExpression conditionalExpression = new ConditionalExpression(); BinaryOperatorExpression binaryOperatorExpression = new BinaryOperatorExpression(); conditionalExpression.StartLocation = binaryOperatorExpression.StartLocation = la.Location; @@ -4380,21 +4353,21 @@ out Expression expr) { Expect(122); Expect(25); Expr( -#line 1729 "VBNET.ATG" +#line 1720 "VBNET.ATG" out condition); Expect(12); Expr( -#line 1729 "VBNET.ATG" +#line 1720 "VBNET.ATG" out trueExpr); if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1729 "VBNET.ATG" +#line 1720 "VBNET.ATG" out falseExpr); } Expect(26); -#line 1731 "VBNET.ATG" +#line 1722 "VBNET.ATG" if(falseExpr != null) { conditionalExpression.Condition = condition; @@ -4417,348 +4390,348 @@ out falseExpr); } void ArgumentList( -#line 2359 "VBNET.ATG" +#line 2340 "VBNET.ATG" out List arguments) { -#line 2361 "VBNET.ATG" +#line 2342 "VBNET.ATG" arguments = new List(); Expression expr = null; if (StartOf(29)) { Argument( -#line 2364 "VBNET.ATG" +#line 2345 "VBNET.ATG" out expr); } while (la.kind == 12) { lexer.NextToken(); -#line 2365 "VBNET.ATG" +#line 2346 "VBNET.ATG" arguments.Add(expr ?? Expression.Null); expr = null; if (StartOf(29)) { Argument( -#line 2366 "VBNET.ATG" +#line 2347 "VBNET.ATG" out expr); } -#line 2367 "VBNET.ATG" +#line 2348 "VBNET.ATG" if (expr == null) expr = Expression.Null; } -#line 2369 "VBNET.ATG" +#line 2350 "VBNET.ATG" if (expr != null) arguments.Add(expr); } void ConjunctionExpr( -#line 1805 "VBNET.ATG" +#line 1795 "VBNET.ATG" out Expression outExpr) { -#line 1807 "VBNET.ATG" +#line 1797 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; NotExpr( -#line 1810 "VBNET.ATG" +#line 1800 "VBNET.ATG" out outExpr); while (la.kind == 47 || la.kind == 48) { if (la.kind == 47) { lexer.NextToken(); -#line 1813 "VBNET.ATG" +#line 1803 "VBNET.ATG" op = BinaryOperatorType.BitwiseAnd; } else { lexer.NextToken(); -#line 1814 "VBNET.ATG" +#line 1804 "VBNET.ATG" op = BinaryOperatorType.LogicalAnd; } NotExpr( -#line 1816 "VBNET.ATG" +#line 1806 "VBNET.ATG" out expr); -#line 1816 "VBNET.ATG" +#line 1806 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void NotExpr( -#line 1820 "VBNET.ATG" +#line 1810 "VBNET.ATG" out Expression outExpr) { -#line 1821 "VBNET.ATG" +#line 1811 "VBNET.ATG" UnaryOperatorType uop = UnaryOperatorType.None; while (la.kind == 150) { lexer.NextToken(); -#line 1822 "VBNET.ATG" +#line 1812 "VBNET.ATG" uop = UnaryOperatorType.Not; } ComparisonExpr( -#line 1823 "VBNET.ATG" +#line 1813 "VBNET.ATG" out outExpr); -#line 1824 "VBNET.ATG" +#line 1814 "VBNET.ATG" if (uop != UnaryOperatorType.None) outExpr = new UnaryOperatorExpression(outExpr, uop); } void ComparisonExpr( -#line 1829 "VBNET.ATG" +#line 1819 "VBNET.ATG" out Expression outExpr) { -#line 1831 "VBNET.ATG" +#line 1821 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 1834 "VBNET.ATG" +#line 1824 "VBNET.ATG" out outExpr); while (StartOf(33)) { switch (la.kind) { case 28: { lexer.NextToken(); -#line 1837 "VBNET.ATG" +#line 1827 "VBNET.ATG" op = BinaryOperatorType.LessThan; break; } case 27: { lexer.NextToken(); -#line 1838 "VBNET.ATG" +#line 1828 "VBNET.ATG" op = BinaryOperatorType.GreaterThan; break; } case 31: { lexer.NextToken(); -#line 1839 "VBNET.ATG" +#line 1829 "VBNET.ATG" op = BinaryOperatorType.LessThanOrEqual; break; } case 30: { lexer.NextToken(); -#line 1840 "VBNET.ATG" +#line 1830 "VBNET.ATG" op = BinaryOperatorType.GreaterThanOrEqual; break; } case 29: { lexer.NextToken(); -#line 1841 "VBNET.ATG" +#line 1831 "VBNET.ATG" op = BinaryOperatorType.InEquality; break; } case 10: { lexer.NextToken(); -#line 1842 "VBNET.ATG" +#line 1832 "VBNET.ATG" op = BinaryOperatorType.Equality; break; } case 136: { lexer.NextToken(); -#line 1843 "VBNET.ATG" +#line 1833 "VBNET.ATG" op = BinaryOperatorType.Like; break; } case 131: { lexer.NextToken(); -#line 1844 "VBNET.ATG" +#line 1834 "VBNET.ATG" op = BinaryOperatorType.ReferenceEquality; break; } case 132: { lexer.NextToken(); -#line 1845 "VBNET.ATG" +#line 1835 "VBNET.ATG" op = BinaryOperatorType.ReferenceInequality; break; } } if (StartOf(34)) { ShiftExpr( -#line 1848 "VBNET.ATG" +#line 1838 "VBNET.ATG" out expr); -#line 1848 "VBNET.ATG" +#line 1838 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else if (la.kind == 150) { lexer.NextToken(); ShiftExpr( -#line 1851 "VBNET.ATG" +#line 1841 "VBNET.ATG" out expr); -#line 1851 "VBNET.ATG" +#line 1841 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not)); } else SynErr(263); } } void ShiftExpr( -#line 1856 "VBNET.ATG" +#line 1846 "VBNET.ATG" out Expression outExpr) { -#line 1858 "VBNET.ATG" +#line 1848 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ConcatenationExpr( -#line 1861 "VBNET.ATG" +#line 1851 "VBNET.ATG" out outExpr); while (la.kind == 32 || la.kind == 33) { if (la.kind == 32) { lexer.NextToken(); -#line 1864 "VBNET.ATG" +#line 1854 "VBNET.ATG" op = BinaryOperatorType.ShiftLeft; } else { lexer.NextToken(); -#line 1865 "VBNET.ATG" +#line 1855 "VBNET.ATG" op = BinaryOperatorType.ShiftRight; } ConcatenationExpr( -#line 1867 "VBNET.ATG" +#line 1857 "VBNET.ATG" out expr); -#line 1867 "VBNET.ATG" +#line 1857 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ConcatenationExpr( -#line 1871 "VBNET.ATG" +#line 1861 "VBNET.ATG" out Expression outExpr) { -#line 1872 "VBNET.ATG" +#line 1862 "VBNET.ATG" Expression expr; AdditiveExpr( -#line 1874 "VBNET.ATG" +#line 1864 "VBNET.ATG" out outExpr); while (la.kind == 13) { lexer.NextToken(); AdditiveExpr( -#line 1874 "VBNET.ATG" +#line 1864 "VBNET.ATG" out expr); -#line 1874 "VBNET.ATG" +#line 1864 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr); } } void AdditiveExpr( -#line 1877 "VBNET.ATG" +#line 1867 "VBNET.ATG" out Expression outExpr) { -#line 1879 "VBNET.ATG" +#line 1869 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ModuloExpr( -#line 1882 "VBNET.ATG" +#line 1872 "VBNET.ATG" out outExpr); while (la.kind == 18 || la.kind == 19) { if (la.kind == 19) { lexer.NextToken(); -#line 1885 "VBNET.ATG" +#line 1875 "VBNET.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 1886 "VBNET.ATG" +#line 1876 "VBNET.ATG" op = BinaryOperatorType.Subtract; } ModuloExpr( -#line 1888 "VBNET.ATG" +#line 1878 "VBNET.ATG" out expr); -#line 1888 "VBNET.ATG" +#line 1878 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ModuloExpr( -#line 1892 "VBNET.ATG" +#line 1882 "VBNET.ATG" out Expression outExpr) { -#line 1893 "VBNET.ATG" +#line 1883 "VBNET.ATG" Expression expr; IntegerDivisionExpr( -#line 1895 "VBNET.ATG" +#line 1885 "VBNET.ATG" out outExpr); while (la.kind == 140) { lexer.NextToken(); IntegerDivisionExpr( -#line 1895 "VBNET.ATG" +#line 1885 "VBNET.ATG" out expr); -#line 1895 "VBNET.ATG" +#line 1885 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr); } } void IntegerDivisionExpr( -#line 1898 "VBNET.ATG" +#line 1888 "VBNET.ATG" out Expression outExpr) { -#line 1899 "VBNET.ATG" +#line 1889 "VBNET.ATG" Expression expr; MultiplicativeExpr( -#line 1901 "VBNET.ATG" +#line 1891 "VBNET.ATG" out outExpr); while (la.kind == 15) { lexer.NextToken(); MultiplicativeExpr( -#line 1901 "VBNET.ATG" +#line 1891 "VBNET.ATG" out expr); -#line 1901 "VBNET.ATG" +#line 1891 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr); } } void MultiplicativeExpr( -#line 1904 "VBNET.ATG" +#line 1894 "VBNET.ATG" out Expression outExpr) { -#line 1906 "VBNET.ATG" +#line 1896 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; UnaryExpr( -#line 1909 "VBNET.ATG" +#line 1899 "VBNET.ATG" out outExpr); while (la.kind == 14 || la.kind == 22) { if (la.kind == 22) { lexer.NextToken(); -#line 1912 "VBNET.ATG" +#line 1902 "VBNET.ATG" op = BinaryOperatorType.Multiply; } else { lexer.NextToken(); -#line 1913 "VBNET.ATG" +#line 1903 "VBNET.ATG" op = BinaryOperatorType.Divide; } UnaryExpr( -#line 1915 "VBNET.ATG" +#line 1905 "VBNET.ATG" out expr); -#line 1915 "VBNET.ATG" +#line 1905 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void UnaryExpr( -#line 1919 "VBNET.ATG" +#line 1909 "VBNET.ATG" out Expression uExpr) { -#line 1921 "VBNET.ATG" +#line 1911 "VBNET.ATG" Expression expr; UnaryOperatorType uop = UnaryOperatorType.None; bool isUOp = false; @@ -4767,25 +4740,25 @@ out Expression uExpr) { if (la.kind == 19) { lexer.NextToken(); -#line 1925 "VBNET.ATG" +#line 1915 "VBNET.ATG" uop = UnaryOperatorType.Plus; isUOp = true; } else if (la.kind == 18) { lexer.NextToken(); -#line 1926 "VBNET.ATG" +#line 1916 "VBNET.ATG" uop = UnaryOperatorType.Minus; isUOp = true; } else { lexer.NextToken(); -#line 1927 "VBNET.ATG" +#line 1917 "VBNET.ATG" uop = UnaryOperatorType.Dereference; isUOp = true; } } ExponentiationExpr( -#line 1929 "VBNET.ATG" +#line 1919 "VBNET.ATG" out expr); -#line 1931 "VBNET.ATG" +#line 1921 "VBNET.ATG" if (isUOp) { uExpr = new UnaryOperatorExpression(expr, uop); } else { @@ -4795,107 +4768,107 @@ out expr); } void ExponentiationExpr( -#line 1939 "VBNET.ATG" +#line 1929 "VBNET.ATG" out Expression outExpr) { -#line 1940 "VBNET.ATG" +#line 1930 "VBNET.ATG" Expression expr; SimpleExpr( -#line 1942 "VBNET.ATG" +#line 1932 "VBNET.ATG" out outExpr); while (la.kind == 20) { lexer.NextToken(); SimpleExpr( -#line 1942 "VBNET.ATG" +#line 1932 "VBNET.ATG" out expr); -#line 1942 "VBNET.ATG" +#line 1932 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr); } } void NormalOrReDimArgumentList( -#line 2373 "VBNET.ATG" +#line 2354 "VBNET.ATG" out List arguments, out bool canBeNormal, out bool canBeRedim) { -#line 2375 "VBNET.ATG" +#line 2356 "VBNET.ATG" arguments = new List(); canBeNormal = true; canBeRedim = !IsNamedAssign(); Expression expr = null; if (StartOf(29)) { Argument( -#line 2380 "VBNET.ATG" +#line 2361 "VBNET.ATG" out expr); if (la.kind == 201) { lexer.NextToken(); -#line 2381 "VBNET.ATG" +#line 2362 "VBNET.ATG" EnsureIsZero(expr); canBeNormal = false; Expr( -#line 2382 "VBNET.ATG" +#line 2363 "VBNET.ATG" out expr); } } while (la.kind == 12) { lexer.NextToken(); -#line 2385 "VBNET.ATG" +#line 2366 "VBNET.ATG" if (expr == null) canBeRedim = false; -#line 2386 "VBNET.ATG" +#line 2367 "VBNET.ATG" arguments.Add(expr ?? Expression.Null); expr = null; -#line 2387 "VBNET.ATG" +#line 2368 "VBNET.ATG" canBeRedim &= !IsNamedAssign(); if (StartOf(29)) { Argument( -#line 2388 "VBNET.ATG" +#line 2369 "VBNET.ATG" out expr); if (la.kind == 201) { lexer.NextToken(); -#line 2389 "VBNET.ATG" +#line 2370 "VBNET.ATG" EnsureIsZero(expr); canBeNormal = false; Expr( -#line 2390 "VBNET.ATG" +#line 2371 "VBNET.ATG" out expr); } } -#line 2392 "VBNET.ATG" +#line 2373 "VBNET.ATG" if (expr == null) { canBeRedim = false; expr = Expression.Null; } } -#line 2394 "VBNET.ATG" +#line 2375 "VBNET.ATG" if (expr != null) arguments.Add(expr); else canBeRedim = false; } void ArrayTypeModifiers( -#line 2501 "VBNET.ATG" +#line 2482 "VBNET.ATG" out ArrayList arrayModifiers) { -#line 2503 "VBNET.ATG" +#line 2484 "VBNET.ATG" arrayModifiers = new ArrayList(); int i = 0; while ( -#line 2506 "VBNET.ATG" +#line 2487 "VBNET.ATG" IsDims()) { Expect(25); if (la.kind == 12 || la.kind == 26) { RankList( -#line 2508 "VBNET.ATG" +#line 2489 "VBNET.ATG" out i); } -#line 2510 "VBNET.ATG" +#line 2491 "VBNET.ATG" arrayModifiers.Add(i); Expect(26); } -#line 2515 "VBNET.ATG" +#line 2496 "VBNET.ATG" if(arrayModifiers.Count == 0) { arrayModifiers = null; } @@ -4903,10 +4876,10 @@ out i); } void MemberInitializer( -#line 2343 "VBNET.ATG" +#line 2324 "VBNET.ATG" out NamedArgumentExpression memberInitializer) { -#line 2345 "VBNET.ATG" +#line 2326 "VBNET.ATG" memberInitializer = new NamedArgumentExpression(); memberInitializer.StartLocation = la.Location; Expression initExpr = null; @@ -4914,14 +4887,14 @@ out NamedArgumentExpression memberInitializer) { Expect(16); IdentifierOrKeyword( -#line 2350 "VBNET.ATG" +#line 2331 "VBNET.ATG" out name); Expect(10); Expr( -#line 2350 "VBNET.ATG" +#line 2331 "VBNET.ATG" out initExpr); -#line 2352 "VBNET.ATG" +#line 2333 "VBNET.ATG" memberInitializer.Name = name; memberInitializer.Expression = initExpr; memberInitializer.EndLocation = t.EndLocation; @@ -4929,27 +4902,27 @@ out initExpr); } void FromOrAggregateQueryOperator( -#line 2039 "VBNET.ATG" +#line 2027 "VBNET.ATG" List middleClauses) { -#line 2040 "VBNET.ATG" +#line 2028 "VBNET.ATG" if (la.kind == 113) { FromQueryOperator( -#line 2041 "VBNET.ATG" +#line 2029 "VBNET.ATG" middleClauses); } else if (la.kind == 45) { AggregateQueryOperator( -#line 2042 "VBNET.ATG" +#line 2030 "VBNET.ATG" middleClauses); } else SynErr(264); } void QueryOperator( -#line 2045 "VBNET.ATG" +#line 2033 "VBNET.ATG" List middleClauses) { -#line 2047 "VBNET.ATG" +#line 2035 "VBNET.ATG" QueryExpressionJoinVBClause joinClause = null; QueryExpressionGroupVBClause groupByClause = null; QueryExpressionPartitionVBClause partitionClause = null; @@ -4957,79 +4930,79 @@ List middleClauses) { if (la.kind == 113) { FromQueryOperator( -#line 2052 "VBNET.ATG" +#line 2040 "VBNET.ATG" middleClauses); } else if (la.kind == 45) { AggregateQueryOperator( -#line 2053 "VBNET.ATG" +#line 2041 "VBNET.ATG" middleClauses); } else if (la.kind == 182) { SelectQueryOperator( -#line 2054 "VBNET.ATG" +#line 2042 "VBNET.ATG" middleClauses); } else if (la.kind == 94) { DistinctQueryOperator( -#line 2055 "VBNET.ATG" +#line 2043 "VBNET.ATG" middleClauses); } else if (la.kind == 215) { WhereQueryOperator( -#line 2056 "VBNET.ATG" +#line 2044 "VBNET.ATG" middleClauses); } else if (la.kind == 162) { OrderByQueryOperator( -#line 2057 "VBNET.ATG" +#line 2045 "VBNET.ATG" middleClauses); } else if (la.kind == 188 || la.kind == 197) { PartitionQueryOperator( -#line 2058 "VBNET.ATG" +#line 2046 "VBNET.ATG" out partitionClause); } else if (la.kind == 134) { LetQueryOperator( -#line 2059 "VBNET.ATG" +#line 2047 "VBNET.ATG" middleClauses); } else if (la.kind == 133) { JoinQueryOperator( -#line 2060 "VBNET.ATG" +#line 2048 "VBNET.ATG" out joinClause); -#line 2061 "VBNET.ATG" +#line 2049 "VBNET.ATG" middleClauses.Add(joinClause); } else if ( -#line 2062 "VBNET.ATG" +#line 2050 "VBNET.ATG" la.kind == Tokens.Group && Peek(1).kind == Tokens.Join) { GroupJoinQueryOperator( -#line 2062 "VBNET.ATG" +#line 2050 "VBNET.ATG" out groupJoinClause); -#line 2063 "VBNET.ATG" +#line 2051 "VBNET.ATG" middleClauses.Add(groupJoinClause); } else if (la.kind == 120) { GroupByQueryOperator( -#line 2064 "VBNET.ATG" +#line 2052 "VBNET.ATG" out groupByClause); -#line 2065 "VBNET.ATG" +#line 2053 "VBNET.ATG" middleClauses.Add(groupByClause); } else SynErr(265); } void FromQueryOperator( -#line 2144 "VBNET.ATG" +#line 2128 "VBNET.ATG" List middleClauses) { -#line 2146 "VBNET.ATG" +#line 2130 "VBNET.ATG" Expect(113); CollectionRangeVariableDeclarationList( -#line 2147 "VBNET.ATG" +#line 2131 "VBNET.ATG" middleClauses); } void AggregateQueryOperator( -#line 2208 "VBNET.ATG" +#line 2191 "VBNET.ATG" List middleClauses) { -#line 2210 "VBNET.ATG" +#line 2193 "VBNET.ATG" QueryExpressionFromClause fromClause = null; QueryExpressionAggregateClause aggregateClause = new QueryExpressionAggregateClause(); aggregateClause.IntoVariables = new List(); @@ -5037,83 +5010,78 @@ List middleClauses) { Expect(45); CollectionRangeVariableDeclaration( -#line 2215 "VBNET.ATG" +#line 2198 "VBNET.ATG" out fromClause); -#line 2217 "VBNET.ATG" +#line 2200 "VBNET.ATG" aggregateClause.FromClause = fromClause; while (StartOf(31)) { QueryOperator( -#line 2220 "VBNET.ATG" +#line 2203 "VBNET.ATG" aggregateClause.MiddleClauses); } - -#line 2222 "VBNET.ATG" - SetParent(aggregateClause.MiddleClauses, aggregateClause); Expect(130); ExpressionRangeVariableDeclarationList( -#line 2223 "VBNET.ATG" +#line 2205 "VBNET.ATG" aggregateClause.IntoVariables); -#line 2225 "VBNET.ATG" - SetParent(aggregateClause.IntoVariables, aggregateClause); +#line 2207 "VBNET.ATG" aggregateClause.EndLocation = t.EndLocation; middleClauses.Add(aggregateClause); } void SelectQueryOperator( -#line 2150 "VBNET.ATG" +#line 2134 "VBNET.ATG" List middleClauses) { -#line 2152 "VBNET.ATG" +#line 2136 "VBNET.ATG" QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause(); selectClause.StartLocation = la.Location; Expect(182); ExpressionRangeVariableDeclarationList( -#line 2155 "VBNET.ATG" +#line 2139 "VBNET.ATG" selectClause.Variables); -#line 2157 "VBNET.ATG" - SetParent(selectClause.Variables, selectClause); +#line 2141 "VBNET.ATG" selectClause.EndLocation = t.Location; middleClauses.Add(selectClause); } void DistinctQueryOperator( -#line 2163 "VBNET.ATG" +#line 2146 "VBNET.ATG" List middleClauses) { -#line 2165 "VBNET.ATG" +#line 2148 "VBNET.ATG" QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause(); distinctClause.StartLocation = la.Location; Expect(94); -#line 2170 "VBNET.ATG" +#line 2153 "VBNET.ATG" distinctClause.EndLocation = t.EndLocation; middleClauses.Add(distinctClause); } void WhereQueryOperator( -#line 2175 "VBNET.ATG" +#line 2158 "VBNET.ATG" List middleClauses) { -#line 2177 "VBNET.ATG" +#line 2160 "VBNET.ATG" QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause(); whereClause.StartLocation = la.Location; Expression operand = null; Expect(215); Expr( -#line 2181 "VBNET.ATG" +#line 2164 "VBNET.ATG" out operand); -#line 2183 "VBNET.ATG" +#line 2166 "VBNET.ATG" whereClause.Condition = operand; whereClause.EndLocation = t.EndLocation; @@ -5122,10 +5090,10 @@ out operand); } void OrderByQueryOperator( -#line 2068 "VBNET.ATG" +#line 2056 "VBNET.ATG" List middleClauses) { -#line 2070 "VBNET.ATG" +#line 2058 "VBNET.ATG" QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause(); orderClause.StartLocation = la.Location; List orderings = null; @@ -5133,10 +5101,10 @@ List middleClauses) { Expect(162); Expect(57); OrderExpressionList( -#line 2074 "VBNET.ATG" +#line 2062 "VBNET.ATG" out orderings); -#line 2076 "VBNET.ATG" +#line 2064 "VBNET.ATG" orderClause.Orderings = orderings; orderClause.EndLocation = t.EndLocation; middleClauses.Add(orderClause); @@ -5144,10 +5112,10 @@ out orderings); } void PartitionQueryOperator( -#line 2190 "VBNET.ATG" +#line 2173 "VBNET.ATG" out QueryExpressionPartitionVBClause partitionClause) { -#line 2192 "VBNET.ATG" +#line 2175 "VBNET.ATG" partitionClause = new QueryExpressionPartitionVBClause(); partitionClause.StartLocation = la.Location; Expression expr = null; @@ -5155,33 +5123,33 @@ out QueryExpressionPartitionVBClause partitionClause) { if (la.kind == 197) { lexer.NextToken(); -#line 2196 "VBNET.ATG" +#line 2179 "VBNET.ATG" partitionClause.PartitionType = QueryExpressionPartitionType.Take; if (la.kind == 216) { lexer.NextToken(); -#line 2197 "VBNET.ATG" +#line 2180 "VBNET.ATG" partitionClause.PartitionType = QueryExpressionPartitionType.TakeWhile; } Expr( -#line 2198 "VBNET.ATG" +#line 2181 "VBNET.ATG" out expr); } else if (la.kind == 188) { lexer.NextToken(); -#line 2199 "VBNET.ATG" +#line 2182 "VBNET.ATG" partitionClause.PartitionType = QueryExpressionPartitionType.Skip; if (la.kind == 216) { lexer.NextToken(); } -#line 2200 "VBNET.ATG" +#line 2183 "VBNET.ATG" partitionClause.PartitionType = QueryExpressionPartitionType.SkipWhile; Expr( -#line 2201 "VBNET.ATG" +#line 2184 "VBNET.ATG" out expr); -#line 2203 "VBNET.ATG" +#line 2186 "VBNET.ATG" partitionClause.Expression = expr; partitionClause.EndLocation = t.EndLocation; @@ -5189,29 +5157,29 @@ out expr); } void LetQueryOperator( -#line 2231 "VBNET.ATG" +#line 2212 "VBNET.ATG" List middleClauses) { -#line 2233 "VBNET.ATG" +#line 2214 "VBNET.ATG" QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause(); letClause.StartLocation = la.Location; Expect(134); ExpressionRangeVariableDeclarationList( -#line 2236 "VBNET.ATG" +#line 2217 "VBNET.ATG" letClause.Variables); -#line 2238 "VBNET.ATG" +#line 2219 "VBNET.ATG" letClause.EndLocation = t.EndLocation; middleClauses.Add(letClause); } void JoinQueryOperator( -#line 2275 "VBNET.ATG" +#line 2256 "VBNET.ATG" out QueryExpressionJoinVBClause joinClause) { -#line 2277 "VBNET.ATG" +#line 2258 "VBNET.ATG" joinClause = new QueryExpressionJoinVBClause(); joinClause.StartLocation = la.Location; QueryExpressionFromClause joinVariable = null; @@ -5221,208 +5189,204 @@ out QueryExpressionJoinVBClause joinClause) { Expect(133); CollectionRangeVariableDeclaration( -#line 2284 "VBNET.ATG" +#line 2265 "VBNET.ATG" out joinVariable); -#line 2285 "VBNET.ATG" +#line 2266 "VBNET.ATG" joinClause.JoinVariable = joinVariable; if (la.kind == 133) { JoinQueryOperator( -#line 2287 "VBNET.ATG" +#line 2268 "VBNET.ATG" out subJoin); -#line 2288 "VBNET.ATG" +#line 2269 "VBNET.ATG" joinClause.SubJoin = subJoin; } Expect(157); JoinCondition( -#line 2291 "VBNET.ATG" +#line 2272 "VBNET.ATG" out condition); -#line 2292 "VBNET.ATG" +#line 2273 "VBNET.ATG" SafeAdd(joinClause, joinClause.Conditions, condition); while (la.kind == 47) { lexer.NextToken(); JoinCondition( -#line 2294 "VBNET.ATG" +#line 2275 "VBNET.ATG" out condition); -#line 2295 "VBNET.ATG" +#line 2276 "VBNET.ATG" SafeAdd(joinClause, joinClause.Conditions, condition); } -#line 2298 "VBNET.ATG" +#line 2279 "VBNET.ATG" joinClause.EndLocation = t.EndLocation; } void GroupJoinQueryOperator( -#line 2130 "VBNET.ATG" +#line 2114 "VBNET.ATG" out QueryExpressionGroupJoinVBClause groupJoinClause) { -#line 2132 "VBNET.ATG" +#line 2116 "VBNET.ATG" groupJoinClause = new QueryExpressionGroupJoinVBClause(); groupJoinClause.StartLocation = la.Location; QueryExpressionJoinVBClause joinClause = null; Expect(120); JoinQueryOperator( -#line 2136 "VBNET.ATG" +#line 2120 "VBNET.ATG" out joinClause); Expect(130); ExpressionRangeVariableDeclarationList( -#line 2137 "VBNET.ATG" +#line 2121 "VBNET.ATG" groupJoinClause.IntoVariables); -#line 2139 "VBNET.ATG" +#line 2123 "VBNET.ATG" groupJoinClause.JoinClause = joinClause; groupJoinClause.EndLocation = t.EndLocation; } void GroupByQueryOperator( -#line 2113 "VBNET.ATG" +#line 2101 "VBNET.ATG" out QueryExpressionGroupVBClause groupByClause) { -#line 2115 "VBNET.ATG" +#line 2103 "VBNET.ATG" groupByClause = new QueryExpressionGroupVBClause(); groupByClause.StartLocation = la.Location; Expect(120); ExpressionRangeVariableDeclarationList( -#line 2118 "VBNET.ATG" +#line 2106 "VBNET.ATG" groupByClause.GroupVariables); Expect(57); ExpressionRangeVariableDeclarationList( -#line 2119 "VBNET.ATG" +#line 2107 "VBNET.ATG" groupByClause.ByVariables); Expect(130); ExpressionRangeVariableDeclarationList( -#line 2120 "VBNET.ATG" +#line 2108 "VBNET.ATG" groupByClause.IntoVariables); -#line 2122 "VBNET.ATG" - SetParent(groupByClause.GroupVariables, groupByClause); - SetParent(groupByClause.ByVariables, groupByClause); - SetParent(groupByClause.IntoVariables, groupByClause); - +#line 2110 "VBNET.ATG" groupByClause.EndLocation = t.EndLocation; } void OrderExpressionList( -#line 2082 "VBNET.ATG" +#line 2070 "VBNET.ATG" out List orderings) { -#line 2084 "VBNET.ATG" +#line 2072 "VBNET.ATG" orderings = new List(); QueryExpressionOrdering ordering = null; OrderExpression( -#line 2087 "VBNET.ATG" +#line 2075 "VBNET.ATG" out ordering); -#line 2088 "VBNET.ATG" +#line 2076 "VBNET.ATG" orderings.Add(ordering); while (la.kind == 12) { lexer.NextToken(); OrderExpression( -#line 2090 "VBNET.ATG" +#line 2078 "VBNET.ATG" out ordering); -#line 2091 "VBNET.ATG" +#line 2079 "VBNET.ATG" orderings.Add(ordering); } } void OrderExpression( -#line 2095 "VBNET.ATG" +#line 2083 "VBNET.ATG" out QueryExpressionOrdering ordering) { -#line 2097 "VBNET.ATG" +#line 2085 "VBNET.ATG" ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; ordering.Direction = QueryExpressionOrderingDirection.None; Expression orderExpr = null; Expr( -#line 2102 "VBNET.ATG" +#line 2090 "VBNET.ATG" out orderExpr); -#line 2104 "VBNET.ATG" +#line 2092 "VBNET.ATG" ordering.Criteria = orderExpr; if (la.kind == 51 || la.kind == 91) { if (la.kind == 51) { lexer.NextToken(); -#line 2107 "VBNET.ATG" +#line 2095 "VBNET.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2108 "VBNET.ATG" +#line 2096 "VBNET.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2110 "VBNET.ATG" +#line 2098 "VBNET.ATG" ordering.EndLocation = t.EndLocation; } void ExpressionRangeVariableDeclarationList( -#line 2243 "VBNET.ATG" +#line 2224 "VBNET.ATG" List variables) { -#line 2245 "VBNET.ATG" +#line 2226 "VBNET.ATG" ExpressionRangeVariable variable = null; ExpressionRangeVariableDeclaration( -#line 2247 "VBNET.ATG" +#line 2228 "VBNET.ATG" out variable); -#line 2248 "VBNET.ATG" +#line 2229 "VBNET.ATG" variables.Add(variable); while (la.kind == 12) { lexer.NextToken(); ExpressionRangeVariableDeclaration( -#line 2249 "VBNET.ATG" +#line 2230 "VBNET.ATG" out variable); -#line 2249 "VBNET.ATG" +#line 2230 "VBNET.ATG" variables.Add(variable); } } void CollectionRangeVariableDeclarationList( -#line 2302 "VBNET.ATG" +#line 2283 "VBNET.ATG" List middleClauses) { -#line 2304 "VBNET.ATG" +#line 2285 "VBNET.ATG" QueryExpressionFromClause fromClause = null; CollectionRangeVariableDeclaration( -#line 2306 "VBNET.ATG" +#line 2287 "VBNET.ATG" out fromClause); -#line 2307 "VBNET.ATG" +#line 2288 "VBNET.ATG" middleClauses.Add(fromClause); while (la.kind == 12) { lexer.NextToken(); CollectionRangeVariableDeclaration( -#line 2308 "VBNET.ATG" +#line 2289 "VBNET.ATG" out fromClause); -#line 2308 "VBNET.ATG" +#line 2289 "VBNET.ATG" middleClauses.Add(fromClause); } } void CollectionRangeVariableDeclaration( -#line 2311 "VBNET.ATG" +#line 2292 "VBNET.ATG" out QueryExpressionFromClause fromClause) { -#line 2313 "VBNET.ATG" +#line 2294 "VBNET.ATG" fromClause = new QueryExpressionFromClause(); fromClause.StartLocation = la.Location; TypeReference typeName = null; @@ -5432,66 +5396,66 @@ out QueryExpressionFromClause fromClause) { if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 2319 "VBNET.ATG" +#line 2300 "VBNET.ATG" out typeName); -#line 2319 "VBNET.ATG" +#line 2300 "VBNET.ATG" fromClause.Type = typeName; } Expect(125); Expr( -#line 2320 "VBNET.ATG" +#line 2301 "VBNET.ATG" out inExpr); -#line 2322 "VBNET.ATG" +#line 2303 "VBNET.ATG" fromClause.InExpression = inExpr; fromClause.EndLocation = t.EndLocation; } void ExpressionRangeVariableDeclaration( -#line 2252 "VBNET.ATG" +#line 2233 "VBNET.ATG" out ExpressionRangeVariable variable) { -#line 2254 "VBNET.ATG" +#line 2235 "VBNET.ATG" variable = new ExpressionRangeVariable(); variable.StartLocation = la.Location; Expression rhs = null; TypeReference typeName = null; if ( -#line 2260 "VBNET.ATG" +#line 2241 "VBNET.ATG" IsIdentifiedExpressionRange()) { Identifier(); -#line 2261 "VBNET.ATG" +#line 2242 "VBNET.ATG" variable.Identifier = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 2263 "VBNET.ATG" +#line 2244 "VBNET.ATG" out typeName); -#line 2264 "VBNET.ATG" +#line 2245 "VBNET.ATG" variable.Type = typeName; } Expect(10); } Expr( -#line 2268 "VBNET.ATG" +#line 2249 "VBNET.ATG" out rhs); -#line 2270 "VBNET.ATG" +#line 2251 "VBNET.ATG" variable.Expression = rhs; variable.EndLocation = t.EndLocation; } void JoinCondition( -#line 2327 "VBNET.ATG" +#line 2308 "VBNET.ATG" out QueryExpressionJoinConditionVB condition) { -#line 2329 "VBNET.ATG" +#line 2310 "VBNET.ATG" condition = new QueryExpressionJoinConditionVB(); condition.StartLocation = la.Location; @@ -5499,14 +5463,14 @@ out QueryExpressionJoinConditionVB condition) { Expression rhs = null; Expr( -#line 2335 "VBNET.ATG" +#line 2316 "VBNET.ATG" out lhs); Expect(103); Expr( -#line 2335 "VBNET.ATG" +#line 2316 "VBNET.ATG" out rhs); -#line 2337 "VBNET.ATG" +#line 2318 "VBNET.ATG" condition.LeftSide = lhs; condition.RightSide = rhs; condition.EndLocation = t.EndLocation; @@ -5514,69 +5478,69 @@ out rhs); } void Argument( -#line 2398 "VBNET.ATG" +#line 2379 "VBNET.ATG" out Expression argumentexpr) { -#line 2400 "VBNET.ATG" +#line 2381 "VBNET.ATG" Expression expr; argumentexpr = null; string name; if ( -#line 2404 "VBNET.ATG" +#line 2385 "VBNET.ATG" IsNamedAssign()) { Identifier(); -#line 2404 "VBNET.ATG" +#line 2385 "VBNET.ATG" name = t.val; Expect(11); Expect(10); Expr( -#line 2404 "VBNET.ATG" +#line 2385 "VBNET.ATG" out expr); -#line 2406 "VBNET.ATG" +#line 2387 "VBNET.ATG" argumentexpr = new NamedArgumentExpression(name, expr); } else if (StartOf(29)) { Expr( -#line 2409 "VBNET.ATG" +#line 2390 "VBNET.ATG" out argumentexpr); } else SynErr(267); } void QualIdentAndTypeArguments( -#line 2475 "VBNET.ATG" +#line 2456 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { -#line 2476 "VBNET.ATG" +#line 2457 "VBNET.ATG" string name; typeref = null; Qualident( -#line 2478 "VBNET.ATG" +#line 2459 "VBNET.ATG" out name); -#line 2479 "VBNET.ATG" +#line 2460 "VBNET.ATG" typeref = new TypeReference(name); if ( -#line 2480 "VBNET.ATG" +#line 2461 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(155); if ( -#line 2482 "VBNET.ATG" +#line 2463 "VBNET.ATG" canBeUnbound && (la.kind == Tokens.CloseParenthesis || la.kind == Tokens.Comma)) { -#line 2483 "VBNET.ATG" +#line 2464 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); while (la.kind == 12) { lexer.NextToken(); -#line 2484 "VBNET.ATG" +#line 2465 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); } } else if (StartOf(7)) { TypeArgumentList( -#line 2485 "VBNET.ATG" +#line 2466 "VBNET.ATG" typeref.GenericTypes); } else SynErr(268); Expect(26); @@ -5584,24 +5548,24 @@ typeref.GenericTypes); } void RankList( -#line 2522 "VBNET.ATG" +#line 2503 "VBNET.ATG" out int i) { -#line 2523 "VBNET.ATG" +#line 2504 "VBNET.ATG" i = 0; while (la.kind == 12) { lexer.NextToken(); -#line 2524 "VBNET.ATG" +#line 2505 "VBNET.ATG" ++i; } } void Attribute( -#line 2563 "VBNET.ATG" +#line 2544 "VBNET.ATG" out ASTAttribute attribute) { -#line 2564 "VBNET.ATG" +#line 2545 "VBNET.ATG" string name; List positional = new List(); List named = new List(); @@ -5611,42 +5575,40 @@ out ASTAttribute attribute) { Expect(16); } Qualident( -#line 2569 "VBNET.ATG" +#line 2550 "VBNET.ATG" out name); if (la.kind == 25) { AttributeArguments( -#line 2570 "VBNET.ATG" +#line 2551 "VBNET.ATG" positional, named); } -#line 2572 "VBNET.ATG" +#line 2553 "VBNET.ATG" attribute = new ASTAttribute(name, positional, named); - SetParent(positional, attribute); - SetParent(named, attribute); } void AttributeArguments( -#line 2579 "VBNET.ATG" +#line 2558 "VBNET.ATG" List positional, List named) { -#line 2581 "VBNET.ATG" +#line 2560 "VBNET.ATG" bool nameFound = false; string name = ""; Expression expr; Expect(25); if ( -#line 2587 "VBNET.ATG" +#line 2566 "VBNET.ATG" IsNotClosingParenthesis()) { if ( -#line 2589 "VBNET.ATG" +#line 2568 "VBNET.ATG" IsNamedAssign()) { -#line 2589 "VBNET.ATG" +#line 2568 "VBNET.ATG" nameFound = true; IdentifierOrKeyword( -#line 2590 "VBNET.ATG" +#line 2569 "VBNET.ATG" out name); if (la.kind == 11) { lexer.NextToken(); @@ -5654,10 +5616,10 @@ out name); Expect(10); } Expr( -#line 2592 "VBNET.ATG" +#line 2571 "VBNET.ATG" out expr); -#line 2594 "VBNET.ATG" +#line 2573 "VBNET.ATG" if (expr != null) { if (string.IsNullOrEmpty(name)) { positional.Add(expr); } else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } @@ -5666,13 +5628,13 @@ out expr); while (la.kind == 12) { lexer.NextToken(); if ( -#line 2602 "VBNET.ATG" +#line 2581 "VBNET.ATG" IsNamedAssign()) { -#line 2602 "VBNET.ATG" +#line 2581 "VBNET.ATG" nameFound = true; IdentifierOrKeyword( -#line 2603 "VBNET.ATG" +#line 2582 "VBNET.ATG" out name); if (la.kind == 11) { lexer.NextToken(); @@ -5680,14 +5642,14 @@ out name); Expect(10); } else if (StartOf(29)) { -#line 2605 "VBNET.ATG" +#line 2584 "VBNET.ATG" if (nameFound) Error("no positional argument after named argument"); } else SynErr(269); Expr( -#line 2606 "VBNET.ATG" +#line 2585 "VBNET.ATG" out expr); -#line 2606 "VBNET.ATG" +#line 2585 "VBNET.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -5698,10 +5660,10 @@ out expr); } void FormalParameter( -#line 2663 "VBNET.ATG" +#line 2642 "VBNET.ATG" out ParameterDeclarationExpression p) { -#line 2665 "VBNET.ATG" +#line 2644 "VBNET.ATG" AttributeSection section; List attributes = new List(); TypeReference type = null; @@ -5712,36 +5674,36 @@ out ParameterDeclarationExpression p) { while (la.kind == 28) { AttributeSection( -#line 2674 "VBNET.ATG" +#line 2653 "VBNET.ATG" out section); -#line 2674 "VBNET.ATG" +#line 2653 "VBNET.ATG" attributes.Add(section); } while (StartOf(35)) { ParameterModifier( -#line 2675 "VBNET.ATG" +#line 2654 "VBNET.ATG" mod); } Identifier(); -#line 2676 "VBNET.ATG" +#line 2655 "VBNET.ATG" string parameterName = t.val; if ( -#line 2677 "VBNET.ATG" +#line 2656 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( -#line 2677 "VBNET.ATG" +#line 2656 "VBNET.ATG" out arrayModifiers); } if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 2678 "VBNET.ATG" +#line 2657 "VBNET.ATG" out type); } -#line 2680 "VBNET.ATG" +#line 2659 "VBNET.ATG" if(type != null) { if (arrayModifiers != null) { if (type.RankSpecifier != null) { @@ -5757,11 +5719,11 @@ out type); if (la.kind == 10) { lexer.NextToken(); Expr( -#line 2692 "VBNET.ATG" +#line 2671 "VBNET.ATG" out expr); } -#line 2694 "VBNET.ATG" +#line 2673 "VBNET.ATG" mod.Check(); p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr); p.Attributes = attributes; @@ -5769,34 +5731,34 @@ out expr); } void ParameterModifier( -#line 3386 "VBNET.ATG" +#line 3355 "VBNET.ATG" ParamModifierList m) { if (la.kind == 59) { lexer.NextToken(); -#line 3387 "VBNET.ATG" +#line 3356 "VBNET.ATG" m.Add(ParameterModifiers.In); } else if (la.kind == 56) { lexer.NextToken(); -#line 3388 "VBNET.ATG" +#line 3357 "VBNET.ATG" m.Add(ParameterModifiers.Ref); } else if (la.kind == 160) { lexer.NextToken(); -#line 3389 "VBNET.ATG" +#line 3358 "VBNET.ATG" m.Add(ParameterModifiers.Optional); } else if (la.kind == 167) { lexer.NextToken(); -#line 3390 "VBNET.ATG" +#line 3359 "VBNET.ATG" m.Add(ParameterModifiers.Params); } else SynErr(270); } void Statement() { -#line 2723 "VBNET.ATG" +#line 2702 "VBNET.ATG" Statement stmt = null; Location startPos = la.Location; string label = String.Empty; @@ -5804,27 +5766,27 @@ ParamModifierList m) { if (la.kind == 1 || la.kind == 11) { } else if ( -#line 2729 "VBNET.ATG" +#line 2708 "VBNET.ATG" IsLabel()) { LabelName( -#line 2729 "VBNET.ATG" +#line 2708 "VBNET.ATG" out label); -#line 2731 "VBNET.ATG" +#line 2710 "VBNET.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(11); Statement(); } else if (StartOf(36)) { EmbeddedStatement( -#line 2734 "VBNET.ATG" +#line 2713 "VBNET.ATG" out stmt); -#line 2734 "VBNET.ATG" +#line 2713 "VBNET.ATG" compilationUnit.AddChild(stmt); } else SynErr(271); -#line 2737 "VBNET.ATG" +#line 2716 "VBNET.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.Location; @@ -5833,30 +5795,30 @@ out stmt); } void LabelName( -#line 3161 "VBNET.ATG" +#line 3131 "VBNET.ATG" out string name) { -#line 3163 "VBNET.ATG" +#line 3133 "VBNET.ATG" name = String.Empty; if (StartOf(14)) { Identifier(); -#line 3165 "VBNET.ATG" +#line 3135 "VBNET.ATG" name = t.val; } else if (la.kind == 5) { lexer.NextToken(); -#line 3166 "VBNET.ATG" +#line 3136 "VBNET.ATG" name = t.val; } else SynErr(272); } void EmbeddedStatement( -#line 2777 "VBNET.ATG" +#line 2755 "VBNET.ATG" out Statement statement) { -#line 2779 "VBNET.ATG" +#line 2757 "VBNET.ATG" Statement embeddedStatement = null; statement = null; Expression expr = null; @@ -5866,225 +5828,224 @@ out Statement statement) { if (la.kind == 107) { lexer.NextToken(); -#line 2785 "VBNET.ATG" +#line 2763 "VBNET.ATG" ExitType exitType = ExitType.None; switch (la.kind) { case 195: { lexer.NextToken(); -#line 2787 "VBNET.ATG" +#line 2765 "VBNET.ATG" exitType = ExitType.Sub; break; } case 114: { lexer.NextToken(); -#line 2789 "VBNET.ATG" +#line 2767 "VBNET.ATG" exitType = ExitType.Function; break; } case 171: { lexer.NextToken(); -#line 2791 "VBNET.ATG" +#line 2769 "VBNET.ATG" exitType = ExitType.Property; break; } case 95: { lexer.NextToken(); -#line 2793 "VBNET.ATG" +#line 2771 "VBNET.ATG" exitType = ExitType.Do; break; } case 111: { lexer.NextToken(); -#line 2795 "VBNET.ATG" +#line 2773 "VBNET.ATG" exitType = ExitType.For; break; } case 203: { lexer.NextToken(); -#line 2797 "VBNET.ATG" +#line 2775 "VBNET.ATG" exitType = ExitType.Try; break; } case 216: { lexer.NextToken(); -#line 2799 "VBNET.ATG" +#line 2777 "VBNET.ATG" exitType = ExitType.While; break; } case 182: { lexer.NextToken(); -#line 2801 "VBNET.ATG" +#line 2779 "VBNET.ATG" exitType = ExitType.Select; break; } default: SynErr(273); break; } -#line 2803 "VBNET.ATG" +#line 2781 "VBNET.ATG" statement = new ExitStatement(exitType); } else if (la.kind == 203) { TryStatement( -#line 2804 "VBNET.ATG" +#line 2782 "VBNET.ATG" out statement); } else if (la.kind == 76) { lexer.NextToken(); -#line 2805 "VBNET.ATG" +#line 2783 "VBNET.ATG" ContinueType continueType = ContinueType.None; if (la.kind == 95 || la.kind == 111 || la.kind == 216) { if (la.kind == 95) { lexer.NextToken(); -#line 2805 "VBNET.ATG" +#line 2783 "VBNET.ATG" continueType = ContinueType.Do; } else if (la.kind == 111) { lexer.NextToken(); -#line 2805 "VBNET.ATG" +#line 2783 "VBNET.ATG" continueType = ContinueType.For; } else { lexer.NextToken(); -#line 2805 "VBNET.ATG" +#line 2783 "VBNET.ATG" continueType = ContinueType.While; } } -#line 2805 "VBNET.ATG" +#line 2783 "VBNET.ATG" statement = new ContinueStatement(continueType); } else if (la.kind == 200) { lexer.NextToken(); if (StartOf(29)) { Expr( -#line 2807 "VBNET.ATG" +#line 2785 "VBNET.ATG" out expr); } -#line 2807 "VBNET.ATG" +#line 2785 "VBNET.ATG" statement = new ThrowStatement(expr); } else if (la.kind == 180) { lexer.NextToken(); if (StartOf(29)) { Expr( -#line 2809 "VBNET.ATG" +#line 2787 "VBNET.ATG" out expr); } -#line 2809 "VBNET.ATG" +#line 2787 "VBNET.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 196) { lexer.NextToken(); Expr( -#line 2811 "VBNET.ATG" +#line 2789 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2811 "VBNET.ATG" +#line 2789 "VBNET.ATG" out embeddedStatement); Expect(100); Expect(196); -#line 2812 "VBNET.ATG" +#line 2790 "VBNET.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 174) { lexer.NextToken(); Identifier(); -#line 2814 "VBNET.ATG" +#line 2792 "VBNET.ATG" name = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(37)) { ArgumentList( -#line 2815 "VBNET.ATG" +#line 2793 "VBNET.ATG" out p); } Expect(26); } -#line 2817 "VBNET.ATG" +#line 2795 "VBNET.ATG" statement = new RaiseEventStatement(name, p); - SetParent(p, statement); } else if (la.kind == 218) { WithStatement( -#line 2821 "VBNET.ATG" +#line 2798 "VBNET.ATG" out statement); } else if (la.kind == 43) { lexer.NextToken(); -#line 2823 "VBNET.ATG" +#line 2800 "VBNET.ATG" Expression handlerExpr = null; Expr( -#line 2824 "VBNET.ATG" +#line 2801 "VBNET.ATG" out expr); Expect(12); Expr( -#line 2824 "VBNET.ATG" +#line 2801 "VBNET.ATG" out handlerExpr); -#line 2826 "VBNET.ATG" +#line 2803 "VBNET.ATG" statement = new AddHandlerStatement(expr, handlerExpr); } else if (la.kind == 178) { lexer.NextToken(); -#line 2829 "VBNET.ATG" +#line 2806 "VBNET.ATG" Expression handlerExpr = null; Expr( -#line 2830 "VBNET.ATG" +#line 2807 "VBNET.ATG" out expr); Expect(12); Expr( -#line 2830 "VBNET.ATG" +#line 2807 "VBNET.ATG" out handlerExpr); -#line 2832 "VBNET.ATG" +#line 2809 "VBNET.ATG" statement = new RemoveHandlerStatement(expr, handlerExpr); } else if (la.kind == 216) { lexer.NextToken(); Expr( -#line 2835 "VBNET.ATG" +#line 2812 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2836 "VBNET.ATG" +#line 2813 "VBNET.ATG" out embeddedStatement); Expect(100); Expect(216); -#line 2838 "VBNET.ATG" +#line 2815 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 95) { lexer.NextToken(); -#line 2843 "VBNET.ATG" +#line 2820 "VBNET.ATG" ConditionType conditionType = ConditionType.None; if (la.kind == 209 || la.kind == 216) { WhileOrUntil( -#line 2846 "VBNET.ATG" +#line 2823 "VBNET.ATG" out conditionType); Expr( -#line 2846 "VBNET.ATG" +#line 2823 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2847 "VBNET.ATG" +#line 2824 "VBNET.ATG" out embeddedStatement); Expect(138); -#line 2850 "VBNET.ATG" +#line 2827 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType, @@ -6093,26 +6054,26 @@ out embeddedStatement); } else if (la.kind == 1 || la.kind == 11) { EndOfStmt(); Block( -#line 2857 "VBNET.ATG" +#line 2834 "VBNET.ATG" out embeddedStatement); Expect(138); if (la.kind == 209 || la.kind == 216) { WhileOrUntil( -#line 2858 "VBNET.ATG" +#line 2835 "VBNET.ATG" out conditionType); Expr( -#line 2858 "VBNET.ATG" +#line 2835 "VBNET.ATG" out expr); } -#line 2860 "VBNET.ATG" +#line 2837 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End); } else SynErr(274); } else if (la.kind == 111) { lexer.NextToken(); -#line 2865 "VBNET.ATG" +#line 2842 "VBNET.ATG" Expression group = null; TypeReference typeReference; string typeName; @@ -6121,24 +6082,24 @@ out expr); if (la.kind == 97) { lexer.NextToken(); LoopControlVariable( -#line 2872 "VBNET.ATG" +#line 2849 "VBNET.ATG" out typeReference, out typeName); Expect(125); Expr( -#line 2873 "VBNET.ATG" +#line 2850 "VBNET.ATG" out group); EndOfStmt(); Block( -#line 2874 "VBNET.ATG" +#line 2851 "VBNET.ATG" out embeddedStatement); Expect(149); if (StartOf(29)) { Expr( -#line 2875 "VBNET.ATG" +#line 2852 "VBNET.ATG" out expr); } -#line 2877 "VBNET.ATG" +#line 2854 "VBNET.ATG" statement = new ForeachStatement(typeReference, typeName, group, @@ -6150,7 +6111,7 @@ out expr); } else if (StartOf(38)) { -#line 2888 "VBNET.ATG" +#line 2865 "VBNET.ATG" Expression start = null; Expression end = null; Expression step = null; @@ -6159,59 +6120,59 @@ out expr); List nextExpressions = null; if ( -#line 2895 "VBNET.ATG" +#line 2872 "VBNET.ATG" IsLoopVariableDeclaration()) { LoopControlVariable( -#line 2896 "VBNET.ATG" +#line 2873 "VBNET.ATG" out typeReference, out typeName); } else { -#line 2898 "VBNET.ATG" +#line 2875 "VBNET.ATG" typeReference = null; typeName = null; SimpleExpr( -#line 2899 "VBNET.ATG" +#line 2876 "VBNET.ATG" out variableExpr); } Expect(10); Expr( -#line 2901 "VBNET.ATG" +#line 2878 "VBNET.ATG" out start); Expect(201); Expr( -#line 2901 "VBNET.ATG" +#line 2878 "VBNET.ATG" out end); if (la.kind == 190) { lexer.NextToken(); Expr( -#line 2901 "VBNET.ATG" +#line 2878 "VBNET.ATG" out step); } EndOfStmt(); Block( -#line 2902 "VBNET.ATG" +#line 2879 "VBNET.ATG" out embeddedStatement); Expect(149); if (StartOf(29)) { Expr( -#line 2905 "VBNET.ATG" +#line 2882 "VBNET.ATG" out nextExpr); -#line 2907 "VBNET.ATG" +#line 2884 "VBNET.ATG" nextExpressions = new List(); nextExpressions.Add(nextExpr); while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2910 "VBNET.ATG" +#line 2887 "VBNET.ATG" out nextExpr); -#line 2910 "VBNET.ATG" +#line 2887 "VBNET.ATG" nextExpressions.Add(nextExpr); } } -#line 2913 "VBNET.ATG" +#line 2890 "VBNET.ATG" statement = new ForNextStatement { TypeReference = typeReference, VariableName = typeName, @@ -6222,33 +6183,32 @@ out nextExpr); EmbeddedStatement = embeddedStatement, NextExpressions = nextExpressions }; - SetParent(nextExpressions, statement); } else SynErr(275); } else if (la.kind == 105) { lexer.NextToken(); Expr( -#line 2927 "VBNET.ATG" +#line 2903 "VBNET.ATG" out expr); -#line 2927 "VBNET.ATG" +#line 2903 "VBNET.ATG" statement = new ErrorStatement(expr); } else if (la.kind == 176) { lexer.NextToken(); -#line 2929 "VBNET.ATG" +#line 2905 "VBNET.ATG" bool isPreserve = false; if (la.kind == 169) { lexer.NextToken(); -#line 2929 "VBNET.ATG" +#line 2905 "VBNET.ATG" isPreserve = true; } ReDimClause( -#line 2930 "VBNET.ATG" +#line 2906 "VBNET.ATG" out expr); -#line 2932 "VBNET.ATG" +#line 2908 "VBNET.ATG" ReDimStatement reDimStatement = new ReDimStatement(isPreserve); statement = reDimStatement; SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); @@ -6256,48 +6216,48 @@ out expr); while (la.kind == 12) { lexer.NextToken(); ReDimClause( -#line 2936 "VBNET.ATG" +#line 2912 "VBNET.ATG" out expr); -#line 2937 "VBNET.ATG" +#line 2913 "VBNET.ATG" SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); } } else if (la.kind == 104) { lexer.NextToken(); Expr( -#line 2941 "VBNET.ATG" +#line 2917 "VBNET.ATG" out expr); -#line 2943 "VBNET.ATG" +#line 2919 "VBNET.ATG" EraseStatement eraseStatement = new EraseStatement(); if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr);} while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2946 "VBNET.ATG" +#line 2922 "VBNET.ATG" out expr); -#line 2946 "VBNET.ATG" +#line 2922 "VBNET.ATG" if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr); } } -#line 2947 "VBNET.ATG" +#line 2923 "VBNET.ATG" statement = eraseStatement; } else if (la.kind == 191) { lexer.NextToken(); -#line 2949 "VBNET.ATG" +#line 2925 "VBNET.ATG" statement = new StopStatement(); } else if ( -#line 2951 "VBNET.ATG" +#line 2927 "VBNET.ATG" la.kind == Tokens.If) { Expect(122); -#line 2952 "VBNET.ATG" +#line 2928 "VBNET.ATG" Location ifStartLocation = t.Location; Expr( -#line 2952 "VBNET.ATG" +#line 2928 "VBNET.ATG" out expr); if (la.kind == 199) { lexer.NextToken(); @@ -6305,46 +6265,46 @@ out expr); if (la.kind == 1 || la.kind == 11) { EndOfStmt(); Block( -#line 2955 "VBNET.ATG" +#line 2931 "VBNET.ATG" out embeddedStatement); -#line 2957 "VBNET.ATG" +#line 2933 "VBNET.ATG" IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement); ifStatement.StartLocation = ifStartLocation; Location elseIfStart; while (la.kind == 99 || -#line 2963 "VBNET.ATG" +#line 2939 "VBNET.ATG" IsElseIf()) { if ( -#line 2963 "VBNET.ATG" +#line 2939 "VBNET.ATG" IsElseIf()) { Expect(98); -#line 2963 "VBNET.ATG" +#line 2939 "VBNET.ATG" elseIfStart = t.Location; Expect(122); } else { lexer.NextToken(); -#line 2964 "VBNET.ATG" +#line 2940 "VBNET.ATG" elseIfStart = t.Location; } -#line 2966 "VBNET.ATG" +#line 2942 "VBNET.ATG" Expression condition = null; Statement block = null; Expr( -#line 2967 "VBNET.ATG" +#line 2943 "VBNET.ATG" out condition); if (la.kind == 199) { lexer.NextToken(); } EndOfStmt(); Block( -#line 2968 "VBNET.ATG" +#line 2944 "VBNET.ATG" out block); -#line 2970 "VBNET.ATG" +#line 2946 "VBNET.ATG" ElseIfSection elseIfSection = new ElseIfSection(condition, block); elseIfSection.StartLocation = elseIfStart; elseIfSection.EndLocation = t.Location; @@ -6356,43 +6316,39 @@ out block); lexer.NextToken(); EndOfStmt(); Block( -#line 2979 "VBNET.ATG" +#line 2955 "VBNET.ATG" out embeddedStatement); -#line 2981 "VBNET.ATG" +#line 2957 "VBNET.ATG" ifStatement.FalseStatement.Add(embeddedStatement); } Expect(100); Expect(122); -#line 2985 "VBNET.ATG" +#line 2961 "VBNET.ATG" ifStatement.EndLocation = t.Location; statement = ifStatement; } else if (StartOf(39)) { -#line 2990 "VBNET.ATG" +#line 2966 "VBNET.ATG" IfElseStatement ifStatement = new IfElseStatement(expr); ifStatement.StartLocation = ifStartLocation; SingleLineStatementList( -#line 2993 "VBNET.ATG" +#line 2969 "VBNET.ATG" ifStatement.TrueStatement); - -#line 2995 "VBNET.ATG" - SetParent(ifStatement.TrueStatement, ifStatement); - if (la.kind == 98) { lexer.NextToken(); if (StartOf(39)) { SingleLineStatementList( -#line 2999 "VBNET.ATG" +#line 2972 "VBNET.ATG" ifStatement.FalseStatement); } } -#line 3001 "VBNET.ATG" +#line 2974 "VBNET.ATG" ifStatement.EndLocation = t.Location; statement = ifStatement; } else SynErr(276); } else if (la.kind == 182) { @@ -6401,84 +6357,82 @@ ifStatement.FalseStatement); lexer.NextToken(); } Expr( -#line 3004 "VBNET.ATG" +#line 2977 "VBNET.ATG" out expr); EndOfStmt(); -#line 3005 "VBNET.ATG" +#line 2978 "VBNET.ATG" List selectSections = new List(); Statement block = null; while (la.kind == 61) { -#line 3009 "VBNET.ATG" +#line 2982 "VBNET.ATG" List caseClauses = null; Location caseLocation = la.Location; lexer.NextToken(); CaseClauses( -#line 3010 "VBNET.ATG" +#line 2983 "VBNET.ATG" out caseClauses); if ( -#line 3010 "VBNET.ATG" +#line 2983 "VBNET.ATG" IsNotStatementSeparator()) { lexer.NextToken(); } EndOfStmt(); -#line 3012 "VBNET.ATG" +#line 2985 "VBNET.ATG" SwitchSection selectSection = new SwitchSection(caseClauses); - SetParent(caseClauses, selectSection); selectSection.StartLocation = caseLocation; Block( -#line 3016 "VBNET.ATG" +#line 2988 "VBNET.ATG" out block); -#line 3018 "VBNET.ATG" +#line 2990 "VBNET.ATG" selectSection.Children = block.Children; selectSection.EndLocation = t.EndLocation; selectSections.Add(selectSection); } -#line 3024 "VBNET.ATG" +#line 2996 "VBNET.ATG" statement = new SwitchStatement(expr, selectSections); - SetParent(selectSections, statement); Expect(100); Expect(182); } else if (la.kind == 157) { -#line 3028 "VBNET.ATG" +#line 2999 "VBNET.ATG" OnErrorStatement onErrorStatement = null; OnErrorStatement( -#line 3029 "VBNET.ATG" +#line 3000 "VBNET.ATG" out onErrorStatement); -#line 3029 "VBNET.ATG" +#line 3000 "VBNET.ATG" statement = onErrorStatement; } else if (la.kind == 119) { -#line 3030 "VBNET.ATG" +#line 3001 "VBNET.ATG" GotoStatement goToStatement = null; GotoStatement( -#line 3031 "VBNET.ATG" +#line 3002 "VBNET.ATG" out goToStatement); -#line 3031 "VBNET.ATG" +#line 3002 "VBNET.ATG" statement = goToStatement; } else if (la.kind == 179) { -#line 3032 "VBNET.ATG" +#line 3003 "VBNET.ATG" ResumeStatement resumeStatement = null; ResumeStatement( -#line 3033 "VBNET.ATG" +#line 3004 "VBNET.ATG" out resumeStatement); -#line 3033 "VBNET.ATG" +#line 3004 "VBNET.ATG" statement = resumeStatement; } else if (StartOf(38)) { -#line 3036 "VBNET.ATG" +#line 3007 "VBNET.ATG" Expression val = null; AssignmentOperatorType op; @@ -6486,25 +6440,25 @@ out resumeStatement); la.kind == Tokens.Not || la.kind == Tokens.Times; SimpleExpr( -#line 3042 "VBNET.ATG" +#line 3013 "VBNET.ATG" out expr); if (StartOf(40)) { AssignmentOperator( -#line 3044 "VBNET.ATG" +#line 3015 "VBNET.ATG" out op); Expr( -#line 3044 "VBNET.ATG" +#line 3015 "VBNET.ATG" out val); -#line 3044 "VBNET.ATG" +#line 3015 "VBNET.ATG" expr = new AssignmentExpression(expr, op, val); } else if (la.kind == 1 || la.kind == 11 || la.kind == 98) { -#line 3045 "VBNET.ATG" +#line 3016 "VBNET.ATG" if (mustBeAssignment) Error("error in assignment."); } else SynErr(277); -#line 3048 "VBNET.ATG" +#line 3019 "VBNET.ATG" // a field reference expression that stands alone is a // invocation expression without parantheses and arguments if(expr is MemberReferenceExpression || expr is IdentifierExpression) { @@ -6515,64 +6469,63 @@ out val); } else if (la.kind == 60) { lexer.NextToken(); SimpleExpr( -#line 3055 "VBNET.ATG" +#line 3026 "VBNET.ATG" out expr); -#line 3055 "VBNET.ATG" +#line 3026 "VBNET.ATG" statement = new ExpressionStatement(expr); } else if (la.kind == 211) { lexer.NextToken(); -#line 3057 "VBNET.ATG" +#line 3028 "VBNET.ATG" Statement block; if ( -#line 3058 "VBNET.ATG" +#line 3029 "VBNET.ATG" Peek(1).kind == Tokens.As) { -#line 3059 "VBNET.ATG" +#line 3030 "VBNET.ATG" LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifiers.None); VariableDeclarator( -#line 3060 "VBNET.ATG" +#line 3031 "VBNET.ATG" resourceAquisition.Variables); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 3062 "VBNET.ATG" +#line 3033 "VBNET.ATG" resourceAquisition.Variables); } Block( -#line 3064 "VBNET.ATG" +#line 3035 "VBNET.ATG" out block); -#line 3066 "VBNET.ATG" +#line 3037 "VBNET.ATG" statement = new UsingStatement(resourceAquisition, block); - SetParent(resourceAquisition.Variables, resourceAquisition); } else if (StartOf(29)) { Expr( -#line 3069 "VBNET.ATG" +#line 3039 "VBNET.ATG" out expr); Block( -#line 3070 "VBNET.ATG" +#line 3040 "VBNET.ATG" out block); -#line 3071 "VBNET.ATG" +#line 3041 "VBNET.ATG" statement = new UsingStatement(new ExpressionStatement(expr), block); } else SynErr(278); Expect(100); Expect(211); } else if (StartOf(41)) { LocalDeclarationStatement( -#line 3074 "VBNET.ATG" +#line 3044 "VBNET.ATG" out statement); } else SynErr(279); } void LocalDeclarationStatement( -#line 2745 "VBNET.ATG" +#line 2724 "VBNET.ATG" out Statement statement) { -#line 2747 "VBNET.ATG" +#line 2726 "VBNET.ATG" ModifierList m = new ModifierList(); LocalVariableDeclaration localVariableDeclaration; bool dimfound = false; @@ -6581,22 +6534,22 @@ out Statement statement) { if (la.kind == 75) { lexer.NextToken(); -#line 2753 "VBNET.ATG" +#line 2732 "VBNET.ATG" m.Add(Modifiers.Const, t.Location); } else if (la.kind == 189) { lexer.NextToken(); -#line 2754 "VBNET.ATG" +#line 2733 "VBNET.ATG" m.Add(Modifiers.Static, t.Location); } else { lexer.NextToken(); -#line 2755 "VBNET.ATG" +#line 2734 "VBNET.ATG" dimfound = true; } } -#line 2758 "VBNET.ATG" +#line 2737 "VBNET.ATG" if(dimfound && (m.Modifier & Modifiers.Const) != 0) { Error("Dim is not allowed on constants."); } @@ -6609,136 +6562,135 @@ out Statement statement) { localVariableDeclaration.StartLocation = t.Location; VariableDeclarator( -#line 2769 "VBNET.ATG" +#line 2748 "VBNET.ATG" localVariableDeclaration.Variables); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 2770 "VBNET.ATG" +#line 2749 "VBNET.ATG" localVariableDeclaration.Variables); } -#line 2772 "VBNET.ATG" - SetParent(localVariableDeclaration.Variables, localVariableDeclaration); +#line 2751 "VBNET.ATG" statement = localVariableDeclaration; } void TryStatement( -#line 3276 "VBNET.ATG" +#line 3245 "VBNET.ATG" out Statement tryStatement) { -#line 3278 "VBNET.ATG" +#line 3247 "VBNET.ATG" Statement blockStmt = null, finallyStmt = null;List catchClauses = null; Expect(203); EndOfStmt(); Block( -#line 3281 "VBNET.ATG" +#line 3250 "VBNET.ATG" out blockStmt); if (la.kind == 62 || la.kind == 100 || la.kind == 110) { CatchClauses( -#line 3282 "VBNET.ATG" +#line 3251 "VBNET.ATG" out catchClauses); } if (la.kind == 110) { lexer.NextToken(); EndOfStmt(); Block( -#line 3283 "VBNET.ATG" +#line 3252 "VBNET.ATG" out finallyStmt); } Expect(100); Expect(203); -#line 3286 "VBNET.ATG" +#line 3255 "VBNET.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void WithStatement( -#line 3256 "VBNET.ATG" +#line 3225 "VBNET.ATG" out Statement withStatement) { -#line 3258 "VBNET.ATG" +#line 3227 "VBNET.ATG" Statement blockStmt = null; Expression expr = null; Expect(218); -#line 3261 "VBNET.ATG" +#line 3230 "VBNET.ATG" Location start = t.Location; Expr( -#line 3262 "VBNET.ATG" +#line 3231 "VBNET.ATG" out expr); EndOfStmt(); -#line 3264 "VBNET.ATG" +#line 3233 "VBNET.ATG" withStatement = new WithStatement(expr); withStatement.StartLocation = start; Block( -#line 3267 "VBNET.ATG" +#line 3236 "VBNET.ATG" out blockStmt); -#line 3269 "VBNET.ATG" +#line 3238 "VBNET.ATG" ((WithStatement)withStatement).Body = (BlockStatement)blockStmt; Expect(100); Expect(218); -#line 3272 "VBNET.ATG" +#line 3241 "VBNET.ATG" withStatement.EndLocation = t.Location; } void WhileOrUntil( -#line 3249 "VBNET.ATG" +#line 3218 "VBNET.ATG" out ConditionType conditionType) { -#line 3250 "VBNET.ATG" +#line 3219 "VBNET.ATG" conditionType = ConditionType.None; if (la.kind == 216) { lexer.NextToken(); -#line 3251 "VBNET.ATG" +#line 3220 "VBNET.ATG" conditionType = ConditionType.While; } else if (la.kind == 209) { lexer.NextToken(); -#line 3252 "VBNET.ATG" +#line 3221 "VBNET.ATG" conditionType = ConditionType.Until; } else SynErr(280); } void LoopControlVariable( -#line 3091 "VBNET.ATG" +#line 3061 "VBNET.ATG" out TypeReference type, out string name) { -#line 3092 "VBNET.ATG" +#line 3062 "VBNET.ATG" ArrayList arrayModifiers = null; type = null; Qualident( -#line 3096 "VBNET.ATG" +#line 3066 "VBNET.ATG" out name); if ( -#line 3097 "VBNET.ATG" +#line 3067 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( -#line 3097 "VBNET.ATG" +#line 3067 "VBNET.ATG" out arrayModifiers); } if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 3098 "VBNET.ATG" +#line 3068 "VBNET.ATG" out type); -#line 3098 "VBNET.ATG" +#line 3068 "VBNET.ATG" if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } } -#line 3100 "VBNET.ATG" +#line 3070 "VBNET.ATG" if (type != null) { if(type.RankSpecifier != null && arrayModifiers != null) { Error("array rank only allowed one time"); @@ -6750,34 +6702,34 @@ out type); } void ReDimClause( -#line 3170 "VBNET.ATG" +#line 3140 "VBNET.ATG" out Expression expr) { SimpleNonInvocationExpression( -#line 3172 "VBNET.ATG" +#line 3142 "VBNET.ATG" out expr); ReDimClauseInternal( -#line 3173 "VBNET.ATG" +#line 3143 "VBNET.ATG" ref expr); } void SingleLineStatementList( -#line 3077 "VBNET.ATG" +#line 3047 "VBNET.ATG" List list) { -#line 3078 "VBNET.ATG" +#line 3048 "VBNET.ATG" Statement embeddedStatement = null; if (la.kind == 100) { lexer.NextToken(); -#line 3080 "VBNET.ATG" +#line 3050 "VBNET.ATG" embeddedStatement = new EndStatement(); } else if (StartOf(36)) { EmbeddedStatement( -#line 3081 "VBNET.ATG" +#line 3051 "VBNET.ATG" out embeddedStatement); } else SynErr(281); -#line 3082 "VBNET.ATG" +#line 3052 "VBNET.ATG" if (embeddedStatement != null) list.Add(embeddedStatement); while (la.kind == 11) { lexer.NextToken(); @@ -6787,62 +6739,62 @@ out embeddedStatement); if (la.kind == 100) { lexer.NextToken(); -#line 3084 "VBNET.ATG" +#line 3054 "VBNET.ATG" embeddedStatement = new EndStatement(); } else if (StartOf(36)) { EmbeddedStatement( -#line 3085 "VBNET.ATG" +#line 3055 "VBNET.ATG" out embeddedStatement); } else SynErr(282); -#line 3086 "VBNET.ATG" +#line 3056 "VBNET.ATG" if (embeddedStatement != null) list.Add(embeddedStatement); } } void CaseClauses( -#line 3209 "VBNET.ATG" +#line 3178 "VBNET.ATG" out List caseClauses) { -#line 3211 "VBNET.ATG" +#line 3180 "VBNET.ATG" caseClauses = new List(); CaseLabel caseClause = null; CaseClause( -#line 3214 "VBNET.ATG" +#line 3183 "VBNET.ATG" out caseClause); -#line 3214 "VBNET.ATG" +#line 3183 "VBNET.ATG" if (caseClause != null) { caseClauses.Add(caseClause); } while (la.kind == 12) { lexer.NextToken(); CaseClause( -#line 3215 "VBNET.ATG" +#line 3184 "VBNET.ATG" out caseClause); -#line 3215 "VBNET.ATG" +#line 3184 "VBNET.ATG" if (caseClause != null) { caseClauses.Add(caseClause); } } } void OnErrorStatement( -#line 3111 "VBNET.ATG" +#line 3081 "VBNET.ATG" out OnErrorStatement stmt) { -#line 3113 "VBNET.ATG" +#line 3083 "VBNET.ATG" stmt = null; GotoStatement goToStatement = null; Expect(157); Expect(105); if ( -#line 3119 "VBNET.ATG" +#line 3089 "VBNET.ATG" IsNegativeLabelName()) { Expect(119); Expect(18); Expect(5); -#line 3121 "VBNET.ATG" +#line 3091 "VBNET.ATG" long intLabel = Int64.Parse(t.val); if(intLabel != 1) { Error("invalid label in on error statement."); @@ -6851,10 +6803,10 @@ IsNegativeLabelName()) { } else if (la.kind == 119) { GotoStatement( -#line 3127 "VBNET.ATG" +#line 3097 "VBNET.ATG" out goToStatement); -#line 3129 "VBNET.ATG" +#line 3099 "VBNET.ATG" string val = goToStatement.Label; // if value is numeric, make sure that is 0 @@ -6871,90 +6823,89 @@ out goToStatement); lexer.NextToken(); Expect(149); -#line 3143 "VBNET.ATG" +#line 3113 "VBNET.ATG" stmt = new OnErrorStatement(new ResumeStatement(true)); } else SynErr(283); } void GotoStatement( -#line 3149 "VBNET.ATG" +#line 3119 "VBNET.ATG" out GotoStatement goToStatement) { -#line 3151 "VBNET.ATG" +#line 3121 "VBNET.ATG" string label = String.Empty; Expect(119); LabelName( -#line 3154 "VBNET.ATG" +#line 3124 "VBNET.ATG" out label); -#line 3156 "VBNET.ATG" +#line 3126 "VBNET.ATG" goToStatement = new GotoStatement(label); } void ResumeStatement( -#line 3198 "VBNET.ATG" +#line 3167 "VBNET.ATG" out ResumeStatement resumeStatement) { -#line 3200 "VBNET.ATG" +#line 3169 "VBNET.ATG" resumeStatement = null; string label = String.Empty; if ( -#line 3203 "VBNET.ATG" +#line 3172 "VBNET.ATG" IsResumeNext()) { Expect(179); Expect(149); -#line 3204 "VBNET.ATG" +#line 3173 "VBNET.ATG" resumeStatement = new ResumeStatement(true); } else if (la.kind == 179) { lexer.NextToken(); if (StartOf(42)) { LabelName( -#line 3205 "VBNET.ATG" +#line 3174 "VBNET.ATG" out label); } -#line 3205 "VBNET.ATG" +#line 3174 "VBNET.ATG" resumeStatement = new ResumeStatement(label); } else SynErr(284); } void ReDimClauseInternal( -#line 3176 "VBNET.ATG" +#line 3146 "VBNET.ATG" ref Expression expr) { -#line 3177 "VBNET.ATG" +#line 3147 "VBNET.ATG" List arguments; bool canBeNormal; bool canBeRedim; string name; while (la.kind == 16 || -#line 3180 "VBNET.ATG" +#line 3150 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { if (la.kind == 16) { lexer.NextToken(); IdentifierOrKeyword( -#line 3179 "VBNET.ATG" +#line 3149 "VBNET.ATG" out name); -#line 3179 "VBNET.ATG" +#line 3149 "VBNET.ATG" expr = new MemberReferenceExpression(expr, name); } else { InvocationExpression( -#line 3181 "VBNET.ATG" +#line 3151 "VBNET.ATG" ref expr); } } Expect(25); NormalOrReDimArgumentList( -#line 3184 "VBNET.ATG" +#line 3154 "VBNET.ATG" out arguments, out canBeNormal, out canBeRedim); Expect(26); -#line 3186 "VBNET.ATG" +#line 3156 "VBNET.ATG" expr = new InvocationExpression(expr, arguments); - SetParent(arguments, expr); if (canBeRedim == false || canBeNormal && (la.kind == Tokens.Dot || la.kind == Tokens.OpenParenthesis)) { if (this.Errors.Count == 0) { // don't recurse on parse errors - could result in endless recursion @@ -6965,10 +6916,10 @@ out arguments, out canBeNormal, out canBeRedim); } void CaseClause( -#line 3219 "VBNET.ATG" +#line 3188 "VBNET.ATG" out CaseLabel caseClause) { -#line 3221 "VBNET.ATG" +#line 3190 "VBNET.ATG" Expression expr = null; Expression sexpr = null; BinaryOperatorType op = BinaryOperatorType.None; @@ -6977,7 +6928,7 @@ out CaseLabel caseClause) { if (la.kind == 98) { lexer.NextToken(); -#line 3227 "VBNET.ATG" +#line 3196 "VBNET.ATG" caseClause = new CaseLabel(); } else if (StartOf(43)) { if (la.kind == 131) { @@ -6987,76 +6938,76 @@ out CaseLabel caseClause) { case 28: { lexer.NextToken(); -#line 3231 "VBNET.ATG" +#line 3200 "VBNET.ATG" op = BinaryOperatorType.LessThan; break; } case 27: { lexer.NextToken(); -#line 3232 "VBNET.ATG" +#line 3201 "VBNET.ATG" op = BinaryOperatorType.GreaterThan; break; } case 31: { lexer.NextToken(); -#line 3233 "VBNET.ATG" +#line 3202 "VBNET.ATG" op = BinaryOperatorType.LessThanOrEqual; break; } case 30: { lexer.NextToken(); -#line 3234 "VBNET.ATG" +#line 3203 "VBNET.ATG" op = BinaryOperatorType.GreaterThanOrEqual; break; } case 10: { lexer.NextToken(); -#line 3235 "VBNET.ATG" +#line 3204 "VBNET.ATG" op = BinaryOperatorType.Equality; break; } case 29: { lexer.NextToken(); -#line 3236 "VBNET.ATG" +#line 3205 "VBNET.ATG" op = BinaryOperatorType.InEquality; break; } default: SynErr(285); break; } Expr( -#line 3238 "VBNET.ATG" +#line 3207 "VBNET.ATG" out expr); -#line 3240 "VBNET.ATG" +#line 3209 "VBNET.ATG" caseClause = new CaseLabel(op, expr); } else if (StartOf(29)) { Expr( -#line 3242 "VBNET.ATG" +#line 3211 "VBNET.ATG" out expr); if (la.kind == 201) { lexer.NextToken(); Expr( -#line 3242 "VBNET.ATG" +#line 3211 "VBNET.ATG" out sexpr); } -#line 3244 "VBNET.ATG" +#line 3213 "VBNET.ATG" caseClause = new CaseLabel(expr, sexpr); } else SynErr(286); } void CatchClauses( -#line 3291 "VBNET.ATG" +#line 3260 "VBNET.ATG" out List catchClauses) { -#line 3293 "VBNET.ATG" +#line 3262 "VBNET.ATG" catchClauses = new List(); TypeReference type = null; Statement blockStmt = null; @@ -7068,34 +7019,34 @@ out List catchClauses) { if (StartOf(14)) { Identifier(); -#line 3301 "VBNET.ATG" +#line 3270 "VBNET.ATG" name = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( -#line 3301 "VBNET.ATG" +#line 3270 "VBNET.ATG" out type); } } if (la.kind == 214) { lexer.NextToken(); Expr( -#line 3302 "VBNET.ATG" +#line 3271 "VBNET.ATG" out expr); } EndOfStmt(); Block( -#line 3304 "VBNET.ATG" +#line 3273 "VBNET.ATG" out blockStmt); -#line 3305 "VBNET.ATG" +#line 3274 "VBNET.ATG" catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); } } - public override void Parse() + void ParseRoot() { VBNET(); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG index 8b47607c7b..16f6c08f75 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG @@ -437,7 +437,7 @@ NonModuleDeclaration attributes> newType.Type = ClassType.Class; .) Identifier (. newType.Name = t.val; .) - TypeParameterList (. SetParent(newType.Templates, newType); .) + TypeParameterList EndOfStmt (. newType.BodyStartLocation = t.Location; .) [ ClassBaseType (. newType.BaseTypes.Add(typeRef); .) ] @@ -474,7 +474,7 @@ NonModuleDeclaration attributes> newType.Type = ClassType.Struct; .) Identifier (. newType.Name = t.val; .) - TypeParameterList (. SetParent(newType.Templates, newType); .) + TypeParameterList EndOfStmt (. newType.BodyStartLocation = t.Location; .) { TypeImplementsClause (. newType.BaseTypes.AddRange(baseInterfaces);.) } @@ -512,7 +512,7 @@ NonModuleDeclaration attributes> newType.Type = ClassType.Interface; .) Identifier (. newType.Name = t.val; .) - TypeParameterList (. SetParent(newType.Templates, newType); .) + TypeParameterList EndOfStmt (. newType.BodyStartLocation = t.Location; .) { InterfaceBase (. newType.BaseTypes.AddRange(baseInterfaces); .) } @@ -531,11 +531,11 @@ NonModuleDeclaration attributes> .) ( "Sub" Identifier (. delegateDeclr.Name = t.val; .) - TypeParameterList (. SetParent(delegateDeclr.Templates, delegateDeclr); .) + TypeParameterList [ "(" [ FormalParameterList

] ")" (. delegateDeclr.Parameters = p; .) ] | "Function" Identifier (. delegateDeclr.Name = t.val; .) - TypeParameterList (. SetParent(delegateDeclr.Templates, delegateDeclr); .) + TypeParameterList [ "(" [ FormalParameterList

] ")" (. delegateDeclr.Parameters = p; .) ] [ "As" (. TypeReference type; .) TypeName (. delegateDeclr.ReturnType = type; .)] ) @@ -609,7 +609,6 @@ EnumBody { EnumMemberDecl (. - SetParent(f.Fields, f); compilationUnit.AddChild(f); .) { EndOfStmt } /* allow empty lines in body */ @@ -683,7 +682,6 @@ InterfaceMemberDecl EndLocation = t.EndLocation, Templates = templates }; - SetParent(templates, md); compilationUnit.AddChild(md); .) | @@ -711,7 +709,6 @@ InterfaceMemberDecl md.StartLocation = startLocation; md.EndLocation = t.EndLocation; md.Templates = templates; - SetParent(templates, md); compilationUnit.AddChild(md); .) EndOfStmt @@ -824,7 +821,6 @@ StructureMemberDecl attributes> HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); compilationUnit.AddChild(methodDeclaration); .) | @@ -838,7 +834,6 @@ StructureMemberDecl attributes> HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); compilationUnit.AddChild(methodDeclaration); .) @@ -873,7 +868,7 @@ StructureMemberDecl attributes> (. Location endLocation = t.EndLocation; .) EndOfStmt (. - ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); + ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); cd.EndLocation = constructorEndLocation; cd.Body = (BlockStatement)stmt; @@ -922,7 +917,6 @@ StructureMemberDecl attributes> Templates = templates, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); @@ -941,7 +935,6 @@ StructureMemberDecl attributes> HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; - SetParent(templates, methodDeclaration); if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); @@ -1043,7 +1036,6 @@ StructureMemberDecl attributes> (. fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; - SetParent(variableDeclarators, fd); compilationUnit.AddChild(fd); .) | /* 9.4 */ @@ -1425,9 +1417,9 @@ VariableDeclaratorPartAfterIdentifier fieldDeclaration IF (IsObjectCreation()) "As" ObjectCreateExpression (. if (expr is ObjectCreateExpression) { - type = ((ObjectCreateExpression)expr).CreateType; + type = ((ObjectCreateExpression)expr).CreateType.Clone(); } else { - type = ((ArrayCreateExpression)expr).CreateType; + type = ((ArrayCreateExpression)expr).CreateType.Clone(); } .) | @@ -1458,8 +1450,7 @@ VariableDeclaratorPartAfterIdentifier fieldDeclaration rank.Insert(0, dimension.Count - 1); type.RankSpecifier = (int[])rank.ToArray(typeof(int)); } - expr = new ArrayCreateExpression(type, dimension); - SetParent(dimension, expr); + expr = new ArrayCreateExpression(type.Clone(), dimension); } } else if (rank != null) { if(type.RankSpecifier != null) { @@ -1757,7 +1748,6 @@ InvocationExpression ")" (. pexpr = new InvocationExpression(pexpr, parameters); - SetParent(parameters, pexpr); .) (. pexpr.StartLocation = start; pexpr.EndLocation = t.Location; .) . @@ -1965,14 +1955,12 @@ ObjectCreateExpression (. if (initializer == null) { oce = new ObjectCreateExpression(type, arguments); - SetParent(arguments, oce); } else { if (dimensions == null) dimensions = new ArrayList(); dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0)); type.RankSpecifier = (int[])dimensions.ToArray(typeof(int)); ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer as CollectionInitializerExpression); ace.Arguments = arguments; - SetParent(arguments, ace); oce = ace; } .) @@ -2119,10 +2107,6 @@ GroupByQueryOperator "By" ExpressionRangeVariableDeclarationList "Into" ExpressionRangeVariableDeclarationList (. - SetParent(groupByClause.GroupVariables, groupByClause); - SetParent(groupByClause.ByVariables, groupByClause); - SetParent(groupByClause.IntoVariables, groupByClause); - groupByClause.EndLocation = t.EndLocation; .) . @@ -2154,7 +2138,6 @@ SelectQueryOperator middleClauses> .) = "Select" ExpressionRangeVariableDeclarationList (. - SetParent(selectClause.Variables, selectClause); selectClause.EndLocation = t.Location; middleClauses.Add(selectClause); .) @@ -2219,10 +2202,8 @@ AggregateQueryOperator middleClauses> { QueryOperator } - (. SetParent(aggregateClause.MiddleClauses, aggregateClause); .) "Into" ExpressionRangeVariableDeclarationList (. - SetParent(aggregateClause.IntoVariables, aggregateClause); aggregateClause.EndLocation = t.EndLocation; middleClauses.Add(aggregateClause); .) @@ -2570,8 +2551,6 @@ Attribute [ AttributeArguments ] (. attribute = new ASTAttribute(name, positional, named); - SetParent(positional, attribute); - SetParent(named, attribute); .) . @@ -2769,7 +2748,6 @@ LocalDeclarationStatement VariableDeclarator { "," VariableDeclarator } (. - SetParent(localVariableDeclaration.Variables, localVariableDeclaration); statement = localVariableDeclaration; .) . @@ -2815,7 +2793,6 @@ EmbeddedStatement [ "(" [ ArgumentList ] ")" ] (. statement = new RaiseEventStatement(name, p); - SetParent(p, statement); .) | /* 10.3 */ WithStatement @@ -2920,7 +2897,6 @@ EmbeddedStatement EmbeddedStatement = embeddedStatement, NextExpressions = nextExpressions }; - SetParent(nextExpressions, statement); .) ) | /* 10.10.2.1 */ @@ -2991,9 +2967,6 @@ EmbeddedStatement ifStatement.StartLocation = ifStartLocation; .) SingleLineStatementList - (. - SetParent(ifStatement.TrueStatement, ifStatement); - .) [ "Else" [ SingleLineStatementList ] @@ -3010,7 +2983,6 @@ EmbeddedStatement "Case" CaseClauses [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt (. SwitchSection selectSection = new SwitchSection(caseClauses); - SetParent(caseClauses, selectSection); selectSection.StartLocation = caseLocation; .) Block @@ -3022,7 +2994,6 @@ EmbeddedStatement } (. statement = new SwitchStatement(expr, selectSections); - SetParent(selectSections, statement); .) "End" "Select" | (. OnErrorStatement onErrorStatement = null; .) @@ -3064,7 +3035,6 @@ EmbeddedStatement Block (. statement = new UsingStatement(resourceAquisition, block); - SetParent(resourceAquisition.Variables, resourceAquisition); .) | Expr Block @@ -3184,7 +3154,6 @@ ReDimClauseInternal NormalOrReDimArgumentList ")" (. expr = new InvocationExpression(expr, arguments); - SetParent(arguments, expr); if (canBeRedim == false || canBeNormal && (la.kind == Tokens.Dot || la.kind == Tokens.OpenParenthesis)) { if (this.Errors.Count == 0) { // don't recurse on parse errors - could result in endless recursion diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs index fd89abbca4..3bdcdae99d 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs @@ -5,11 +5,11 @@ // $Revision$ // +using ICSharpCode.NRefactory.Visitors; using System; using System.Collections.Generic; -using System.Text; using System.Diagnostics; - +using System.Text; using ICSharpCode.NRefactory.Ast; namespace ICSharpCode.NRefactory.Parser.VB @@ -59,6 +59,12 @@ namespace ICSharpCode.NRefactory.Parser.VB errDist = 0; } + public override void Parse() + { + ParseRoot(); + compilationUnit.AcceptVisitor(new SetParentVisitor(), null); + } + public override Expression ParseExpression() { lexer.NextToken(); @@ -69,6 +75,7 @@ namespace ICSharpCode.NRefactory.Parser.VB if (expr != null) { expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; + expr.AcceptVisitor(new SetParentVisitor(), null); } Expect(Tokens.EOF); return expr; @@ -88,6 +95,7 @@ namespace ICSharpCode.NRefactory.Parser.VB st.EndLocation = t.EndLocation; else st.EndLocation = la.Location; + st.AcceptVisitor(new SetParentVisitor(), null); } Expect(Tokens.EOF); return st as BlockStatement; @@ -103,6 +111,7 @@ namespace ICSharpCode.NRefactory.Parser.VB ClassBody(newType); compilationUnit.BlockEnd(); Expect(Tokens.EOF); + newType.AcceptVisitor(new SetParentVisitor(), null); return newType.Children; } @@ -306,18 +315,5 @@ namespace ICSharpCode.NRefactory.Parser.VB item.Parent = parent; } } - - static void SetParent(List list, INode parent) where T : class, INode - { - if (list != null) { - foreach (T x in list) { - - INullable xNull = x as INullable; - - if (xNull == null || !xNull.IsNull) - x.Parent = parent; - } - } - } } } diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index 1bf8da9f85..4266e4576a 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -78,7 +78,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter void Error(INode node, string message) { outputFormatter.PrintText(" // ERROR: " + message + Environment.NewLine); - errors.Error(node.StartLocation.Y, node.StartLocation.X, message); + errors.Error(node.StartLocation.Line, node.StartLocation.Column, message); } void NotSupported(INode node) diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs index d54235e068..df0bdf0caf 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs @@ -85,7 +85,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter void Error(string text, Location position) { - errors.Error(position.Y, position.X, text); + errors.Error(position.Line, position.Column, text); } void UnsupportedNode(INode node) diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/SetParentVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/SetParentVisitor.cs new file mode 100644 index 0000000000..e5166d5723 --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Visitors/SetParentVisitor.cs @@ -0,0 +1,37 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.NRefactory.Ast; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.Visitors +{ + ///

+ /// Sets the parent property on all nodes in the tree. + /// + public class SetParentVisitor : NodeTrackingAstVisitor + { + Stack nodeStack = new Stack(); + + public SetParentVisitor() + { + nodeStack.Push(null); + } + + protected override void BeginVisit(INode node) + { + node.Parent = nodeStack.Peek(); + nodeStack.Push(node); + } + + protected override void EndVisit(INode node) + { + nodeStack.Pop(); + } + } +} diff --git a/src/Libraries/NRefactory/Test/Parser/CheckParentVisitor.cs b/src/Libraries/NRefactory/Test/Parser/CheckParentVisitor.cs index 91468c9f80..1b52d59ad0 100644 --- a/src/Libraries/NRefactory/Test/Parser/CheckParentVisitor.cs +++ b/src/Libraries/NRefactory/Test/Parser/CheckParentVisitor.cs @@ -19,8 +19,6 @@ namespace ICSharpCode.NRefactory.Tests.Ast { Stack nodeStack = new Stack(); - public bool StrictCheck; - public CheckParentVisitor() { nodeStack.Push(null); @@ -34,13 +32,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast protected override void EndVisit(INode node) { Assert.AreSame(node, nodeStack.Pop(), "nodeStack was corrupted!"); - if (StrictCheck - || !(node is TypeReference) && !(node is InterfaceImplementation) - && !(node is ParameterDeclarationExpression) - && !(node is ICSharpCode.NRefactory.Ast.Attribute) && !(node is AttributeSection)) - { - Assert.AreSame(nodeStack.Peek(), node.Parent, "node " + node + " is missing parent: " + nodeStack.Peek()); - } + Assert.AreSame(nodeStack.Peek(), node.Parent, "node " + node + " is missing parent: " + nodeStack.Peek()); } } } diff --git a/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs index eef1c06779..9106d94914 100644 --- a/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs @@ -31,11 +31,11 @@ namespace ICSharpCode.NRefactory.Tests.Ast { const string program = "class MyClass\n{\n}\n"; TypeDeclaration td = ParseUtilCSharp.ParseGlobal(program); - Assert.AreEqual(1, td.StartLocation.Y, "StartLocation.Y"); - Assert.AreEqual(1, td.StartLocation.X, "StartLocation.X"); - Assert.AreEqual(1, td.BodyStartLocation.Y, "BodyStartLocation.Y"); - Assert.AreEqual(14, td.BodyStartLocation.X, "BodyStartLocation.X"); - Assert.AreEqual(3, td.EndLocation.Y, "EndLocation.Y"); + Assert.AreEqual(1, td.StartLocation.Line, "StartLocation.Y"); + Assert.AreEqual(1, td.StartLocation.Column, "StartLocation.X"); + Assert.AreEqual(1, td.BodyStartLocation.Line, "BodyStartLocation.Y"); + Assert.AreEqual(14, td.BodyStartLocation.Column, "BodyStartLocation.X"); + Assert.AreEqual(3, td.EndLocation.Line, "EndLocation.Y"); } [Test] @@ -190,10 +190,10 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 Assert.AreEqual("TestClass", td.Name); Assert.AreEqual(ClassType.Class, td.Type); - Assert.AreEqual(1, td.StartLocation.Y, "start line"); - Assert.AreEqual(1, td.BodyStartLocation.Y, "bodystart line"); - Assert.AreEqual(16, td.BodyStartLocation.X, "bodystart col"); - Assert.AreEqual(2, td.EndLocation.Y, "end line"); + Assert.AreEqual(1, td.StartLocation.Line, "start line"); + Assert.AreEqual(1, td.BodyStartLocation.Line, "bodystart line"); + Assert.AreEqual(16, td.BodyStartLocation.Column, "bodystart col"); + Assert.AreEqual(2, td.EndLocation.Line, "end line"); } [Test] @@ -254,8 +254,8 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 Assert.AreEqual("TestClass", td.Name); Assert.AreEqual(ClassType.Class, td.Type); - Assert.AreEqual(1, td.StartLocation.Y, "start line"); - Assert.AreEqual(2, td.EndLocation.Y, "end line"); + Assert.AreEqual(1, td.StartLocation.Line, "start line"); + Assert.AreEqual(2, td.EndLocation.Line, "end line"); } [Test] diff --git a/src/Libraries/NRefactory/Test/Parser/Statements/BlockStatementTests.cs b/src/Libraries/NRefactory/Test/Parser/Statements/BlockStatementTests.cs index 1e77b701e2..a7da53e1cd 100644 --- a/src/Libraries/NRefactory/Test/Parser/Statements/BlockStatementTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Statements/BlockStatementTests.cs @@ -36,10 +36,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast }; }"; BlockStatement blockStmt = ParseUtilCSharp.ParseStatement(code); - //Assert.AreEqual(1, blockStmt.StartLocation.X); // does not work because ParseStatement inserts special code - Assert.AreEqual(1, blockStmt.StartLocation.Y); - Assert.AreEqual(2, blockStmt.EndLocation.X); - Assert.AreEqual(9, blockStmt.EndLocation.Y); + //Assert.AreEqual(1, blockStmt.StartLocation.Column); // does not work because ParseStatement inserts special code + Assert.AreEqual(1, blockStmt.StartLocation.Line); + Assert.AreEqual(2, blockStmt.EndLocation.Column); + Assert.AreEqual(9, blockStmt.EndLocation.Line); } #endregion diff --git a/src/Libraries/NRefactory/Test/Parser/Statements/IfElseStatementTests.cs b/src/Libraries/NRefactory/Test/Parser/Statements/IfElseStatementTests.cs index cbb7e7fb81..c3752f0142 100644 --- a/src/Libraries/NRefactory/Test/Parser/Statements/IfElseStatementTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Statements/IfElseStatementTests.cs @@ -90,10 +90,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast "ElseIf False Then\n" + "DoIt()\n" + "End If"); - Assert.AreEqual(3, (ifElseStatement.StartLocation).Y); - Assert.AreEqual(7, (ifElseStatement.EndLocation).Y); - Assert.AreEqual(5, (ifElseStatement.ElseIfSections[0].StartLocation).Y); - Assert.AreEqual(6, (ifElseStatement.ElseIfSections[0].EndLocation).Y); + Assert.AreEqual(3, (ifElseStatement.StartLocation).Line); + Assert.AreEqual(7, (ifElseStatement.EndLocation).Line); + Assert.AreEqual(5, (ifElseStatement.ElseIfSections[0].StartLocation).Line); + Assert.AreEqual(6, (ifElseStatement.ElseIfSections[0].EndLocation).Line); Assert.IsNotNull(ifElseStatement.ElseIfSections[0].Parent); } diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs index 393b10c8de..5222d5b962 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs @@ -67,9 +67,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast } "; MethodDeclaration md = ParseUtilCSharp.ParseTypeMember(program); - Assert.AreEqual(2, md.StartLocation.Y, "StartLocation.Y"); - Assert.AreEqual(2, md.EndLocation.Y, "EndLocation.Y"); - Assert.AreEqual(3, md.StartLocation.X, "StartLocation.X"); + Assert.AreEqual(2, md.StartLocation.Line, "StartLocation.Y"); + Assert.AreEqual(2, md.EndLocation.Line, "EndLocation.Y"); + Assert.AreEqual(3, md.StartLocation.Column, "StartLocation.X"); // endLocation.X is currently 20. It should be 18, but that error is not critical //Assert.AreEqual(18, md.EndLocation.X, "EndLocation.X"); @@ -85,9 +85,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast } "; MethodDeclaration md = ParseUtilCSharp.ParseTypeMember(program); - Assert.AreEqual(2, md.StartLocation.Y, "StartLocation.Y"); - Assert.AreEqual(2, md.EndLocation.Y, "EndLocation.Y"); - Assert.AreEqual(3, md.StartLocation.X, "StartLocation.X"); + Assert.AreEqual(2, md.StartLocation.Line, "StartLocation.Y"); + Assert.AreEqual(2, md.EndLocation.Line, "EndLocation.Y"); + Assert.AreEqual(3, md.StartLocation.Column, "StartLocation.X"); } [Test] @@ -307,9 +307,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast MethodDeclaration md = ParseUtilVBNet.ParseTypeMember(program); Assert.AreEqual(Modifiers.Public | Modifiers.Static, md.Modifier); - Assert.AreEqual(2, md.StartLocation.Y, "StartLocation.Y"); - Assert.AreEqual(2, md.EndLocation.Y, "EndLocation.Y"); - Assert.AreEqual(2, md.StartLocation.X, "StartLocation.X"); + Assert.AreEqual(2, md.StartLocation.Line, "StartLocation.Y"); + Assert.AreEqual(2, md.EndLocation.Line, "EndLocation.Y"); + Assert.AreEqual(2, md.StartLocation.Column, "StartLocation.X"); } [Test]