diff --git a/src/Libraries/NRefactory/Project/NRefactory.csproj b/src/Libraries/NRefactory/Project/NRefactory.csproj index 648eb9bb09..d2492c6253 100644 --- a/src/Libraries/NRefactory/Project/NRefactory.csproj +++ b/src/Libraries/NRefactory/Project/NRefactory.csproj @@ -92,6 +92,7 @@ + diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs index 9025d4fae5..7427b05f79 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AbstractParser.cs @@ -6,6 +6,7 @@ // using System; +using System.Collections.Generic; using ICSharpCode.NRefactory.Ast; namespace ICSharpCode.NRefactory.Parser @@ -53,7 +54,7 @@ namespace ICSharpCode.NRefactory.Parser } } - protected AbstractParser(ILexer lexer) + internal AbstractParser(ILexer lexer) { this.errors = lexer.Errors; this.lexer = lexer; @@ -63,9 +64,11 @@ namespace ICSharpCode.NRefactory.Parser public abstract void Parse(); public abstract Expression ParseExpression(); + public abstract BlockStatement ParseBlock(); + public abstract List ParseTypeMembers(); protected abstract void SynErr(int line, int col, int errorNumber); - + protected void SynErr(int n) { if (errDist >= MinErrDist) { @@ -96,7 +99,9 @@ namespace ICSharpCode.NRefactory.Parser public void Dispose() { errors = null; - lexer.Dispose(); + if (lexer != null) { + lexer.Dispose(); + } lexer = null; } #endregion diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs index 5c3b838e96..f84dbb4d22 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs @@ -53,6 +53,41 @@ namespace ICSharpCode.NRefactory.Parser.CSharp Expr(out expr); return expr; } + + public override BlockStatement ParseBlock() + { + lexer.NextToken(); + compilationUnit = new CompilationUnit(); + + BlockStatement blockStmt = new BlockStatement(); + blockStmt.StartLocation = la.Location; + compilationUnit.BlockStart(blockStmt); + + while (la.kind != Tokens.EOF) { + Token oldLa = la; + Statement(); + if (la == oldLa) { + // did not advance lexer position, we cannot parse this as a statement block + return null; + } + } + + compilationUnit.BlockEnd(); + return blockStmt; + } + + public override List ParseTypeMembers() + { + lexer.NextToken(); + compilationUnit = new CompilationUnit(); + + TypeDeclaration newType = new TypeDeclaration(Modifiers.None, null); + compilationUnit.BlockStart(newType); + ClassBody(); + compilationUnit.BlockEnd(); + return newType.Children; + } + // Begin ISTypeCast bool IsTypeCast() { diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index b547d201dd..6b04d80371 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -214,47 +214,47 @@ DotAndIdent()) { } void NonArrayType( -#line 552 "cs.ATG" +#line 550 "cs.ATG" out TypeReference type) { -#line 554 "cs.ATG" +#line 552 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 90 || la.kind == 107) { ClassType( -#line 559 "cs.ATG" +#line 557 "cs.ATG" out type, false); } else if (StartOf(4)) { SimpleType( -#line 560 "cs.ATG" +#line 558 "cs.ATG" out name); -#line 560 "cs.ATG" +#line 558 "cs.ATG" type = new TypeReference(name); } else if (la.kind == 122) { lexer.NextToken(); Expect(6); -#line 561 "cs.ATG" +#line 559 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(127); if (la.kind == 12) { NullableQuestionMark( -#line 564 "cs.ATG" +#line 562 "cs.ATG" ref type); } while ( -#line 566 "cs.ATG" +#line 564 "cs.ATG" IsPointer()) { Expect(6); -#line 567 "cs.ATG" +#line 565 "cs.ATG" ++pointer; } -#line 569 "cs.ATG" +#line 567 "cs.ATG" if (type != null) { type.PointerNestingLevel = pointer; } } @@ -359,60 +359,60 @@ out expr); } void Expr( -#line 1611 "cs.ATG" +#line 1609 "cs.ATG" out Expression expr) { -#line 1612 "cs.ATG" +#line 1610 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; UnaryExpr( -#line 1614 "cs.ATG" +#line 1612 "cs.ATG" out expr); if (StartOf(6)) { AssignmentOperator( -#line 1617 "cs.ATG" +#line 1615 "cs.ATG" out op); Expr( -#line 1617 "cs.ATG" +#line 1615 "cs.ATG" out expr1); -#line 1617 "cs.ATG" +#line 1615 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1618 "cs.ATG" +#line 1616 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1619 "cs.ATG" +#line 1617 "cs.ATG" out op); Expr( -#line 1619 "cs.ATG" +#line 1617 "cs.ATG" out expr1); -#line 1619 "cs.ATG" +#line 1617 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(7)) { ConditionalOrExpr( -#line 1621 "cs.ATG" +#line 1619 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1622 "cs.ATG" +#line 1620 "cs.ATG" out expr1); -#line 1622 "cs.ATG" +#line 1620 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1623 "cs.ATG" +#line 1621 "cs.ATG" out expr1); Expect(9); Expr( -#line 1623 "cs.ATG" +#line 1621 "cs.ATG" out expr2); -#line 1623 "cs.ATG" +#line 1621 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(129); @@ -489,76 +489,76 @@ out attribute); } void TypeModifier( -#line 639 "cs.ATG" +#line 637 "cs.ATG" ModifierList m) { switch (la.kind) { case 88: { lexer.NextToken(); -#line 641 "cs.ATG" +#line 639 "cs.ATG" m.Add(Modifiers.New, t.Location); break; } case 97: { lexer.NextToken(); -#line 642 "cs.ATG" +#line 640 "cs.ATG" m.Add(Modifiers.Public, t.Location); break; } case 96: { lexer.NextToken(); -#line 643 "cs.ATG" +#line 641 "cs.ATG" m.Add(Modifiers.Protected, t.Location); break; } case 83: { lexer.NextToken(); -#line 644 "cs.ATG" +#line 642 "cs.ATG" m.Add(Modifiers.Internal, t.Location); break; } case 95: { lexer.NextToken(); -#line 645 "cs.ATG" +#line 643 "cs.ATG" m.Add(Modifiers.Private, t.Location); break; } case 118: { lexer.NextToken(); -#line 646 "cs.ATG" +#line 644 "cs.ATG" m.Add(Modifiers.Unsafe, t.Location); break; } case 48: { lexer.NextToken(); -#line 647 "cs.ATG" +#line 645 "cs.ATG" m.Add(Modifiers.Abstract, t.Location); break; } case 102: { lexer.NextToken(); -#line 648 "cs.ATG" +#line 646 "cs.ATG" m.Add(Modifiers.Sealed, t.Location); break; } case 106: { lexer.NextToken(); -#line 649 "cs.ATG" +#line 647 "cs.ATG" m.Add(Modifiers.Static, t.Location); break; } case 1: { lexer.NextToken(); -#line 650 "cs.ATG" +#line 648 "cs.ATG" if (t.val == "partial") { m.Add(Modifiers.Partial, t.Location); } else { Error("Unexpected identifier"); } break; } @@ -619,7 +619,9 @@ templates); #line 345 "cs.ATG" newType.BodyStartLocation = t.EndLocation; + Expect(16); ClassBody(); + Expect(17); if (la.kind == 11) { lexer.NextToken(); } @@ -821,39 +823,39 @@ templates); } void TypeParameterList( -#line 2013 "cs.ATG" +#line 2011 "cs.ATG" List templates) { -#line 2015 "cs.ATG" +#line 2013 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2019 "cs.ATG" +#line 2017 "cs.ATG" out section); -#line 2019 "cs.ATG" +#line 2017 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2020 "cs.ATG" +#line 2018 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2021 "cs.ATG" +#line 2019 "cs.ATG" out section); -#line 2021 "cs.ATG" +#line 2019 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2022 "cs.ATG" +#line 2020 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -886,25 +888,25 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2026 "cs.ATG" +#line 2024 "cs.ATG" List templates) { -#line 2027 "cs.ATG" +#line 2025 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2029 "cs.ATG" +#line 2027 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2030 "cs.ATG" +#line 2028 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2032 "cs.ATG" +#line 2030 "cs.ATG" out type); -#line 2033 "cs.ATG" +#line 2031 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -917,10 +919,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2042 "cs.ATG" +#line 2040 "cs.ATG" out type); -#line 2043 "cs.ATG" +#line 2041 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -937,108 +939,106 @@ out type); #line 457 "cs.ATG" AttributeSection section; - Expect(16); while (StartOf(11)) { -#line 460 "cs.ATG" +#line 459 "cs.ATG" List attributes = new List(); ModifierList m = new ModifierList(); while (la.kind == 18) { AttributeSection( -#line 463 "cs.ATG" +#line 462 "cs.ATG" out section); -#line 463 "cs.ATG" +#line 462 "cs.ATG" attributes.Add(section); } MemberModifiers( -#line 464 "cs.ATG" +#line 463 "cs.ATG" m); ClassMemberDecl( -#line 465 "cs.ATG" +#line 464 "cs.ATG" m, attributes); } - Expect(17); } void StructInterfaces( -#line 470 "cs.ATG" +#line 468 "cs.ATG" out List names) { -#line 472 "cs.ATG" +#line 470 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 476 "cs.ATG" +#line 474 "cs.ATG" out typeRef, false); -#line 476 "cs.ATG" +#line 474 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 477 "cs.ATG" +#line 475 "cs.ATG" out typeRef, false); -#line 477 "cs.ATG" +#line 475 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } void StructBody() { -#line 481 "cs.ATG" +#line 479 "cs.ATG" AttributeSection section; Expect(16); while (StartOf(12)) { -#line 484 "cs.ATG" +#line 482 "cs.ATG" List attributes = new List(); ModifierList m = new ModifierList(); while (la.kind == 18) { AttributeSection( -#line 487 "cs.ATG" +#line 485 "cs.ATG" out section); -#line 487 "cs.ATG" +#line 485 "cs.ATG" attributes.Add(section); } MemberModifiers( -#line 488 "cs.ATG" +#line 486 "cs.ATG" m); StructMemberDecl( -#line 489 "cs.ATG" +#line 487 "cs.ATG" m, attributes); } Expect(17); } void InterfaceBase( -#line 494 "cs.ATG" +#line 492 "cs.ATG" out List names) { -#line 496 "cs.ATG" +#line 494 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 500 "cs.ATG" +#line 498 "cs.ATG" out typeRef, false); -#line 500 "cs.ATG" +#line 498 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 501 "cs.ATG" +#line 499 "cs.ATG" out typeRef, false); -#line 501 "cs.ATG" +#line 499 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } @@ -1052,72 +1052,72 @@ out typeRef, false); } void IntegralType( -#line 661 "cs.ATG" +#line 659 "cs.ATG" out string name) { -#line 661 "cs.ATG" +#line 659 "cs.ATG" name = ""; switch (la.kind) { case 101: { lexer.NextToken(); -#line 663 "cs.ATG" +#line 661 "cs.ATG" name = "sbyte"; break; } case 53: { lexer.NextToken(); -#line 664 "cs.ATG" +#line 662 "cs.ATG" name = "byte"; break; } case 103: { lexer.NextToken(); -#line 665 "cs.ATG" +#line 663 "cs.ATG" name = "short"; break; } case 119: { lexer.NextToken(); -#line 666 "cs.ATG" +#line 664 "cs.ATG" name = "ushort"; break; } case 81: { lexer.NextToken(); -#line 667 "cs.ATG" +#line 665 "cs.ATG" name = "int"; break; } case 115: { lexer.NextToken(); -#line 668 "cs.ATG" +#line 666 "cs.ATG" name = "uint"; break; } case 86: { lexer.NextToken(); -#line 669 "cs.ATG" +#line 667 "cs.ATG" name = "long"; break; } case 116: { lexer.NextToken(); -#line 670 "cs.ATG" +#line 668 "cs.ATG" name = "ulong"; break; } case 56: { lexer.NextToken(); -#line 671 "cs.ATG" +#line 669 "cs.ATG" name = "char"; break; } @@ -1127,25 +1127,25 @@ out string name) { void EnumBody() { -#line 510 "cs.ATG" +#line 508 "cs.ATG" FieldDeclaration f; Expect(16); if (la.kind == 1 || la.kind == 18) { EnumMemberDecl( -#line 513 "cs.ATG" +#line 511 "cs.ATG" out f); -#line 513 "cs.ATG" +#line 511 "cs.ATG" compilationUnit.AddChild(f); while ( -#line 514 "cs.ATG" +#line 512 "cs.ATG" NotFinalComma()) { Expect(14); EnumMemberDecl( -#line 515 "cs.ATG" +#line 513 "cs.ATG" out f); -#line 515 "cs.ATG" +#line 513 "cs.ATG" compilationUnit.AddChild(f); } if (la.kind == 14) { @@ -1156,36 +1156,36 @@ out f); } void Type( -#line 520 "cs.ATG" +#line 518 "cs.ATG" out TypeReference type) { TypeWithRestriction( -#line 522 "cs.ATG" +#line 520 "cs.ATG" out type, true, false); } void FormalParameterList( -#line 583 "cs.ATG" +#line 581 "cs.ATG" List parameter) { -#line 586 "cs.ATG" +#line 584 "cs.ATG" ParameterDeclarationExpression p; AttributeSection section; List attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 591 "cs.ATG" +#line 589 "cs.ATG" out section); -#line 591 "cs.ATG" +#line 589 "cs.ATG" attributes.Add(section); } if (StartOf(14)) { FixedParameter( -#line 593 "cs.ATG" +#line 591 "cs.ATG" out p); -#line 593 "cs.ATG" +#line 591 "cs.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1193,96 +1193,96 @@ out p); while (la.kind == 14) { lexer.NextToken(); -#line 598 "cs.ATG" +#line 596 "cs.ATG" attributes = new List(); if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 18) { AttributeSection( -#line 599 "cs.ATG" +#line 597 "cs.ATG" out section); -#line 599 "cs.ATG" +#line 597 "cs.ATG" attributes.Add(section); } if (StartOf(14)) { FixedParameter( -#line 601 "cs.ATG" +#line 599 "cs.ATG" out p); -#line 601 "cs.ATG" +#line 599 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else if (la.kind == 94) { ParameterArray( -#line 602 "cs.ATG" +#line 600 "cs.ATG" out p); -#line 602 "cs.ATG" +#line 600 "cs.ATG" paramsFound = true; p.Attributes = attributes; parameter.Add(p); } else SynErr(134); } } else if (la.kind == 94) { ParameterArray( -#line 605 "cs.ATG" +#line 603 "cs.ATG" out p); -#line 605 "cs.ATG" +#line 603 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else SynErr(135); } void ClassType( -#line 653 "cs.ATG" +#line 651 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 654 "cs.ATG" +#line 652 "cs.ATG" TypeReference r; typeRef = null; if (la.kind == 1) { TypeName( -#line 656 "cs.ATG" +#line 654 "cs.ATG" out r, canBeUnbound); -#line 656 "cs.ATG" +#line 654 "cs.ATG" typeRef = r; } else if (la.kind == 90) { lexer.NextToken(); -#line 657 "cs.ATG" +#line 655 "cs.ATG" typeRef = new TypeReference("object"); } else if (la.kind == 107) { lexer.NextToken(); -#line 658 "cs.ATG" +#line 656 "cs.ATG" typeRef = new TypeReference("string"); } else SynErr(136); } void TypeName( -#line 1956 "cs.ATG" +#line 1954 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 1957 "cs.ATG" +#line 1955 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 1962 "cs.ATG" +#line 1960 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 1963 "cs.ATG" +#line 1961 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 1966 "cs.ATG" +#line 1964 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 1967 "cs.ATG" +#line 1965 "cs.ATG" out typeArguments, canBeUnbound); } -#line 1969 "cs.ATG" +#line 1967 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1293,134 +1293,134 @@ out typeArguments, canBeUnbound); } while ( -#line 1978 "cs.ATG" +#line 1976 "cs.ATG" DotAndIdent()) { Expect(15); -#line 1979 "cs.ATG" +#line 1977 "cs.ATG" typeArguments = null; Qualident( -#line 1980 "cs.ATG" +#line 1978 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 1981 "cs.ATG" +#line 1979 "cs.ATG" out typeArguments, canBeUnbound); } -#line 1982 "cs.ATG" +#line 1980 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } } void MemberModifiers( -#line 674 "cs.ATG" +#line 672 "cs.ATG" ModifierList m) { while (StartOf(15) || -#line 692 "cs.ATG" +#line 690 "cs.ATG" la.kind == Tokens.Identifier && la.val == "partial") { if (la.kind == 48) { lexer.NextToken(); -#line 677 "cs.ATG" +#line 675 "cs.ATG" m.Add(Modifiers.Abstract, t.Location); } else if (la.kind == 70) { lexer.NextToken(); -#line 678 "cs.ATG" +#line 676 "cs.ATG" m.Add(Modifiers.Extern, t.Location); } else if (la.kind == 83) { lexer.NextToken(); -#line 679 "cs.ATG" +#line 677 "cs.ATG" m.Add(Modifiers.Internal, t.Location); } else if (la.kind == 88) { lexer.NextToken(); -#line 680 "cs.ATG" +#line 678 "cs.ATG" m.Add(Modifiers.New, t.Location); } else if (la.kind == 93) { lexer.NextToken(); -#line 681 "cs.ATG" +#line 679 "cs.ATG" m.Add(Modifiers.Override, t.Location); } else if (la.kind == 95) { lexer.NextToken(); -#line 682 "cs.ATG" +#line 680 "cs.ATG" m.Add(Modifiers.Private, t.Location); } else if (la.kind == 96) { lexer.NextToken(); -#line 683 "cs.ATG" +#line 681 "cs.ATG" m.Add(Modifiers.Protected, t.Location); } else if (la.kind == 97) { lexer.NextToken(); -#line 684 "cs.ATG" +#line 682 "cs.ATG" m.Add(Modifiers.Public, t.Location); } else if (la.kind == 98) { lexer.NextToken(); -#line 685 "cs.ATG" +#line 683 "cs.ATG" m.Add(Modifiers.ReadOnly, t.Location); } else if (la.kind == 102) { lexer.NextToken(); -#line 686 "cs.ATG" +#line 684 "cs.ATG" m.Add(Modifiers.Sealed, t.Location); } else if (la.kind == 106) { lexer.NextToken(); -#line 687 "cs.ATG" +#line 685 "cs.ATG" m.Add(Modifiers.Static, t.Location); } else if (la.kind == 73) { lexer.NextToken(); -#line 688 "cs.ATG" +#line 686 "cs.ATG" m.Add(Modifiers.Fixed, t.Location); } else if (la.kind == 118) { lexer.NextToken(); -#line 689 "cs.ATG" +#line 687 "cs.ATG" m.Add(Modifiers.Unsafe, t.Location); } else if (la.kind == 121) { lexer.NextToken(); -#line 690 "cs.ATG" +#line 688 "cs.ATG" m.Add(Modifiers.Virtual, t.Location); } else if (la.kind == 123) { lexer.NextToken(); -#line 691 "cs.ATG" +#line 689 "cs.ATG" m.Add(Modifiers.Volatile, t.Location); } else { Expect(1); -#line 693 "cs.ATG" +#line 691 "cs.ATG" m.Add(Modifiers.Partial, t.Location); } } } void ClassMemberDecl( -#line 985 "cs.ATG" +#line 983 "cs.ATG" ModifierList m, List attributes) { -#line 986 "cs.ATG" +#line 984 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 988 "cs.ATG" +#line 986 "cs.ATG" m, attributes); } else if (la.kind == 27) { -#line 989 "cs.ATG" +#line 987 "cs.ATG" m.Check(Modifiers.Destructors); Location startPos = t.Location; lexer.NextToken(); Expect(1); -#line 990 "cs.ATG" +#line 988 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1428,17 +1428,17 @@ m, attributes); Expect(20); Expect(21); -#line 994 "cs.ATG" +#line 992 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 994 "cs.ATG" +#line 992 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(137); -#line 995 "cs.ATG" +#line 993 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1446,10 +1446,10 @@ out stmt); } void StructMemberDecl( -#line 698 "cs.ATG" +#line 696 "cs.ATG" ModifierList m, List attributes) { -#line 700 "cs.ATG" +#line 698 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1461,18 +1461,18 @@ ModifierList m, List attributes) { if (la.kind == 59) { -#line 710 "cs.ATG" +#line 708 "cs.ATG" m.Check(Modifiers.Constants); lexer.NextToken(); -#line 711 "cs.ATG" +#line 709 "cs.ATG" Location startPos = t.Location; Type( -#line 712 "cs.ATG" +#line 710 "cs.ATG" out type); Expect(1); -#line 712 "cs.ATG" +#line 710 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifiers.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); @@ -1480,72 +1480,72 @@ out type); Expect(3); Expr( -#line 717 "cs.ATG" +#line 715 "cs.ATG" out expr); -#line 717 "cs.ATG" +#line 715 "cs.ATG" f.Initializer = expr; while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 718 "cs.ATG" +#line 716 "cs.ATG" f = new VariableDeclaration(t.val); fd.Fields.Add(f); Expect(3); Expr( -#line 721 "cs.ATG" +#line 719 "cs.ATG" out expr); -#line 721 "cs.ATG" +#line 719 "cs.ATG" f.Initializer = expr; } Expect(11); -#line 722 "cs.ATG" +#line 720 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( -#line 726 "cs.ATG" +#line 724 "cs.ATG" NotVoidPointer()) { -#line 726 "cs.ATG" +#line 724 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); Expect(122); -#line 727 "cs.ATG" +#line 725 "cs.ATG" Location startPos = t.Location; if ( -#line 728 "cs.ATG" +#line 726 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 729 "cs.ATG" +#line 727 "cs.ATG" out explicitInterface, false); -#line 730 "cs.ATG" +#line 728 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (la.kind == 1) { lexer.NextToken(); -#line 733 "cs.ATG" +#line 731 "cs.ATG" qualident = t.val; } else SynErr(139); if (la.kind == 23) { TypeParameterList( -#line 736 "cs.ATG" +#line 734 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 739 "cs.ATG" +#line 737 "cs.ATG" p); } Expect(21); -#line 740 "cs.ATG" +#line 738 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, new TypeReference("void"), @@ -1560,31 +1560,31 @@ p); compilationUnit.BlockStart(methodDeclaration); while ( -#line 755 "cs.ATG" +#line 753 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 755 "cs.ATG" +#line 753 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 757 "cs.ATG" +#line 755 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(140); -#line 757 "cs.ATG" +#line 755 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 68) { -#line 761 "cs.ATG" +#line 759 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); lexer.NextToken(); -#line 762 "cs.ATG" +#line 760 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration(null, null, m.Modifier, attributes, null); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); @@ -1593,113 +1593,113 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 769 "cs.ATG" +#line 767 "cs.ATG" out type); -#line 769 "cs.ATG" +#line 767 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 770 "cs.ATG" +#line 768 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 771 "cs.ATG" +#line 769 "cs.ATG" out explicitInterface, false); -#line 772 "cs.ATG" +#line 770 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); -#line 773 "cs.ATG" +#line 771 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (la.kind == 1) { lexer.NextToken(); -#line 775 "cs.ATG" +#line 773 "cs.ATG" qualident = t.val; } else SynErr(141); -#line 777 "cs.ATG" +#line 775 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 3) { lexer.NextToken(); Expr( -#line 778 "cs.ATG" +#line 776 "cs.ATG" out expr); -#line 778 "cs.ATG" +#line 776 "cs.ATG" eventDecl.Initializer = expr; } if (la.kind == 16) { lexer.NextToken(); -#line 779 "cs.ATG" +#line 777 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 780 "cs.ATG" +#line 778 "cs.ATG" out addBlock, out removeBlock); Expect(17); -#line 781 "cs.ATG" +#line 779 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } -#line 784 "cs.ATG" +#line 782 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 790 "cs.ATG" +#line 788 "cs.ATG" IdentAndLPar()) { -#line 790 "cs.ATG" +#line 788 "cs.ATG" m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); Expect(1); -#line 791 "cs.ATG" +#line 789 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(10)) { -#line 791 "cs.ATG" +#line 789 "cs.ATG" m.Check(Modifiers.Constructors); FormalParameterList( -#line 792 "cs.ATG" +#line 790 "cs.ATG" p); } Expect(21); -#line 794 "cs.ATG" +#line 792 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 795 "cs.ATG" +#line 793 "cs.ATG" m.Check(Modifiers.Constructors); ConstructorInitializer( -#line 796 "cs.ATG" +#line 794 "cs.ATG" out init); } -#line 798 "cs.ATG" +#line 796 "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 803 "cs.ATG" +#line 801 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(142); -#line 803 "cs.ATG" +#line 801 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 69 || la.kind == 79) { -#line 806 "cs.ATG" +#line 804 "cs.ATG" m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -1708,45 +1708,45 @@ out stmt); if (la.kind == 79) { lexer.NextToken(); -#line 811 "cs.ATG" +#line 809 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); -#line 811 "cs.ATG" +#line 809 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(91); Type( -#line 812 "cs.ATG" +#line 810 "cs.ATG" out type); -#line 812 "cs.ATG" +#line 810 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( -#line 813 "cs.ATG" +#line 811 "cs.ATG" out type); Expect(1); -#line 813 "cs.ATG" +#line 811 "cs.ATG" string varName = t.val; Expect(21); -#line 814 "cs.ATG" +#line 812 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( -#line 815 "cs.ATG" +#line 813 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 815 "cs.ATG" +#line 813 "cs.ATG" stmt = null; } else SynErr(143); -#line 818 "cs.ATG" +#line 816 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -1762,61 +1762,61 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 834 "cs.ATG" +#line 832 "cs.ATG" m, attributes); } else if (StartOf(9)) { Type( -#line 836 "cs.ATG" +#line 834 "cs.ATG" out type); -#line 836 "cs.ATG" +#line 834 "cs.ATG" Location startPos = t.Location; if (la.kind == 91) { -#line 838 "cs.ATG" +#line 836 "cs.ATG" OverloadableOperatorType op; m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 842 "cs.ATG" +#line 840 "cs.ATG" out op); -#line 842 "cs.ATG" +#line 840 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( -#line 843 "cs.ATG" +#line 841 "cs.ATG" out firstType); Expect(1); -#line 843 "cs.ATG" +#line 841 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( -#line 844 "cs.ATG" +#line 842 "cs.ATG" out secondType); Expect(1); -#line 844 "cs.ATG" +#line 842 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(144); -#line 852 "cs.ATG" +#line 850 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( -#line 853 "cs.ATG" +#line 851 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(145); -#line 855 "cs.ATG" +#line 853 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -1833,75 +1833,75 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 872 "cs.ATG" +#line 870 "cs.ATG" IsVarDecl()) { -#line 873 "cs.ATG" +#line 871 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( -#line 877 "cs.ATG" +#line 875 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( -#line 878 "cs.ATG" +#line 876 "cs.ATG" variableDeclarators); Expect(18); Expr( -#line 880 "cs.ATG" +#line 878 "cs.ATG" out expr); -#line 880 "cs.ATG" +#line 878 "cs.ATG" if (variableDeclarators.Count > 0) variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr; Expect(19); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 884 "cs.ATG" +#line 882 "cs.ATG" variableDeclarators); Expect(18); Expr( -#line 886 "cs.ATG" +#line 884 "cs.ATG" out expr); -#line 886 "cs.ATG" +#line 884 "cs.ATG" if (variableDeclarators.Count > 0) variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr; Expect(19); } } else if (la.kind == 1) { VariableDeclarator( -#line 891 "cs.ATG" +#line 889 "cs.ATG" variableDeclarators); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 892 "cs.ATG" +#line 890 "cs.ATG" variableDeclarators); } } else SynErr(146); Expect(11); -#line 894 "cs.ATG" +#line 892 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 110) { -#line 897 "cs.ATG" +#line 895 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( -#line 898 "cs.ATG" +#line 896 "cs.ATG" p); Expect(19); -#line 898 "cs.ATG" +#line 896 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); -#line 899 "cs.ATG" +#line 897 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -1910,58 +1910,58 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 906 "cs.ATG" +#line 904 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 907 "cs.ATG" +#line 905 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( -#line 912 "cs.ATG" +#line 910 "cs.ATG" la.kind == Tokens.Identifier) { if ( -#line 913 "cs.ATG" +#line 911 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 914 "cs.ATG" +#line 912 "cs.ATG" out explicitInterface, false); -#line 915 "cs.ATG" +#line 913 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (la.kind == 1) { lexer.NextToken(); -#line 918 "cs.ATG" +#line 916 "cs.ATG" qualident = t.val; } else SynErr(147); -#line 920 "cs.ATG" +#line 918 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { -#line 924 "cs.ATG" +#line 922 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( -#line 926 "cs.ATG" +#line 924 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 927 "cs.ATG" +#line 925 "cs.ATG" p); } Expect(21); -#line 928 "cs.ATG" +#line 926 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, type, @@ -1975,26 +1975,26 @@ p); compilationUnit.AddChild(methodDeclaration); while ( -#line 940 "cs.ATG" +#line 938 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 940 "cs.ATG" +#line 938 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 941 "cs.ATG" +#line 939 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(148); -#line 941 "cs.ATG" +#line 939 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 944 "cs.ATG" +#line 942 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); @@ -2005,11 +2005,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 953 "cs.ATG" +#line 951 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 955 "cs.ATG" +#line 953 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2018,17 +2018,17 @@ out getRegion, out setRegion); } } else if (la.kind == 15) { -#line 963 "cs.ATG" +#line 961 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(110); Expect(18); FormalParameterList( -#line 964 "cs.ATG" +#line 962 "cs.ATG" p); Expect(19); -#line 965 "cs.ATG" +#line 963 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; @@ -2039,14 +2039,14 @@ p); Expect(16); -#line 973 "cs.ATG" +#line 971 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( -#line 974 "cs.ATG" +#line 972 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 975 "cs.ATG" +#line 973 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2060,7 +2060,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1002 "cs.ATG" +#line 1000 "cs.ATG" TypeReference type; AttributeSection section; @@ -2075,51 +2075,51 @@ out getRegion, out setRegion); while (la.kind == 18) { AttributeSection( -#line 1015 "cs.ATG" +#line 1013 "cs.ATG" out section); -#line 1015 "cs.ATG" +#line 1013 "cs.ATG" attributes.Add(section); } if (la.kind == 88) { lexer.NextToken(); -#line 1016 "cs.ATG" +#line 1014 "cs.ATG" mod = Modifiers.New; startLocation = t.Location; } if ( -#line 1019 "cs.ATG" +#line 1017 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 1019 "cs.ATG" +#line 1017 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1019 "cs.ATG" +#line 1017 "cs.ATG" name = t.val; if (la.kind == 23) { TypeParameterList( -#line 1020 "cs.ATG" +#line 1018 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1021 "cs.ATG" +#line 1019 "cs.ATG" parameters); } Expect(21); while ( -#line 1022 "cs.ATG" +#line 1020 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1022 "cs.ATG" +#line 1020 "cs.ATG" templates); } Expect(11); -#line 1024 "cs.ATG" +#line 1022 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2129,39 +2129,39 @@ templates); } else if (StartOf(18)) { if (StartOf(9)) { Type( -#line 1031 "cs.ATG" +#line 1029 "cs.ATG" out type); -#line 1031 "cs.ATG" +#line 1029 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1033 "cs.ATG" +#line 1031 "cs.ATG" name = t.val; Location qualIdentEndLocation = t.EndLocation; if (la.kind == 20 || la.kind == 23) { if (la.kind == 23) { TypeParameterList( -#line 1037 "cs.ATG" +#line 1035 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1038 "cs.ATG" +#line 1036 "cs.ATG" parameters); } Expect(21); while ( -#line 1040 "cs.ATG" +#line 1038 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1040 "cs.ATG" +#line 1038 "cs.ATG" templates); } Expect(11); -#line 1041 "cs.ATG" +#line 1039 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2170,72 +2170,72 @@ templates); } else if (la.kind == 16) { -#line 1048 "cs.ATG" +#line 1046 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1049 "cs.ATG" +#line 1047 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1049 "cs.ATG" +#line 1047 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1049 "cs.ATG" +#line 1047 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(152); } else if (la.kind == 110) { lexer.NextToken(); Expect(18); FormalParameterList( -#line 1052 "cs.ATG" +#line 1050 "cs.ATG" parameters); Expect(19); -#line 1052 "cs.ATG" +#line 1050 "cs.ATG" Location bracketEndLocation = t.EndLocation; -#line 1052 "cs.ATG" +#line 1050 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); Expect(16); -#line 1053 "cs.ATG" +#line 1051 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1053 "cs.ATG" +#line 1051 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1053 "cs.ATG" +#line 1051 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(153); } else { lexer.NextToken(); -#line 1056 "cs.ATG" +#line 1054 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1056 "cs.ATG" +#line 1054 "cs.ATG" out type); Expect(1); -#line 1056 "cs.ATG" +#line 1054 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null); compilationUnit.AddChild(ed); Expect(11); -#line 1059 "cs.ATG" +#line 1057 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(154); } void EnumMemberDecl( -#line 1064 "cs.ATG" +#line 1062 "cs.ATG" out FieldDeclaration f) { -#line 1066 "cs.ATG" +#line 1064 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2243,15 +2243,15 @@ out FieldDeclaration f) { while (la.kind == 18) { AttributeSection( -#line 1072 "cs.ATG" +#line 1070 "cs.ATG" out section); -#line 1072 "cs.ATG" +#line 1070 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1073 "cs.ATG" +#line 1071 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2260,78 +2260,78 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1078 "cs.ATG" +#line 1076 "cs.ATG" out expr); -#line 1078 "cs.ATG" +#line 1076 "cs.ATG" varDecl.Initializer = expr; } } void TypeWithRestriction( -#line 525 "cs.ATG" +#line 523 "cs.ATG" out TypeReference type, bool allowNullable, bool canBeUnbound) { -#line 527 "cs.ATG" +#line 525 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 90 || la.kind == 107) { ClassType( -#line 532 "cs.ATG" +#line 530 "cs.ATG" out type, canBeUnbound); } else if (StartOf(4)) { SimpleType( -#line 533 "cs.ATG" +#line 531 "cs.ATG" out name); -#line 533 "cs.ATG" +#line 531 "cs.ATG" type = new TypeReference(name); } else if (la.kind == 122) { lexer.NextToken(); Expect(6); -#line 534 "cs.ATG" +#line 532 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(155); -#line 535 "cs.ATG" +#line 533 "cs.ATG" List r = new List(); if ( -#line 537 "cs.ATG" +#line 535 "cs.ATG" allowNullable && la.kind == Tokens.Question) { NullableQuestionMark( -#line 537 "cs.ATG" +#line 535 "cs.ATG" ref type); } while ( -#line 539 "cs.ATG" +#line 537 "cs.ATG" IsPointerOrDims()) { -#line 539 "cs.ATG" +#line 537 "cs.ATG" int i = 0; if (la.kind == 6) { lexer.NextToken(); -#line 540 "cs.ATG" +#line 538 "cs.ATG" ++pointer; } else if (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 541 "cs.ATG" +#line 539 "cs.ATG" ++i; } Expect(19); -#line 541 "cs.ATG" +#line 539 "cs.ATG" r.Add(i); } else SynErr(156); } -#line 544 "cs.ATG" +#line 542 "cs.ATG" if (type != null) { type.RankSpecifier = r.ToArray(); type.PointerNestingLevel = pointer; @@ -2340,57 +2340,57 @@ IsPointerOrDims()) { } void SimpleType( -#line 572 "cs.ATG" +#line 570 "cs.ATG" out string name) { -#line 573 "cs.ATG" +#line 571 "cs.ATG" name = String.Empty; if (StartOf(19)) { IntegralType( -#line 575 "cs.ATG" +#line 573 "cs.ATG" out name); } else if (la.kind == 74) { lexer.NextToken(); -#line 576 "cs.ATG" +#line 574 "cs.ATG" name = "float"; } else if (la.kind == 65) { lexer.NextToken(); -#line 577 "cs.ATG" +#line 575 "cs.ATG" name = "double"; } else if (la.kind == 61) { lexer.NextToken(); -#line 578 "cs.ATG" +#line 576 "cs.ATG" name = "decimal"; } else if (la.kind == 51) { lexer.NextToken(); -#line 579 "cs.ATG" +#line 577 "cs.ATG" name = "bool"; } else SynErr(157); } void NullableQuestionMark( -#line 1987 "cs.ATG" +#line 1985 "cs.ATG" ref TypeReference typeRef) { -#line 1988 "cs.ATG" +#line 1986 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 1992 "cs.ATG" +#line 1990 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments); } void FixedParameter( -#line 609 "cs.ATG" +#line 607 "cs.ATG" out ParameterDeclarationExpression p) { -#line 611 "cs.ATG" +#line 609 "cs.ATG" TypeReference type; ParameterModifiers mod = ParameterModifiers.In; Location start = t.Location; @@ -2399,82 +2399,82 @@ out ParameterDeclarationExpression p) { if (la.kind == 99) { lexer.NextToken(); -#line 617 "cs.ATG" +#line 615 "cs.ATG" mod = ParameterModifiers.Ref; } else { lexer.NextToken(); -#line 618 "cs.ATG" +#line 616 "cs.ATG" mod = ParameterModifiers.Out; } } Type( -#line 620 "cs.ATG" +#line 618 "cs.ATG" out type); Expect(1); -#line 620 "cs.ATG" +#line 618 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.Location; } void ParameterArray( -#line 623 "cs.ATG" +#line 621 "cs.ATG" out ParameterDeclarationExpression p) { -#line 624 "cs.ATG" +#line 622 "cs.ATG" TypeReference type; Expect(94); Type( -#line 626 "cs.ATG" +#line 624 "cs.ATG" out type); Expect(1); -#line 626 "cs.ATG" +#line 624 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, ParameterModifiers.Params); } void AccessorModifiers( -#line 629 "cs.ATG" +#line 627 "cs.ATG" out ModifierList m) { -#line 630 "cs.ATG" +#line 628 "cs.ATG" m = new ModifierList(); if (la.kind == 95) { lexer.NextToken(); -#line 632 "cs.ATG" +#line 630 "cs.ATG" m.Add(Modifiers.Private, t.Location); } else if (la.kind == 96) { lexer.NextToken(); -#line 633 "cs.ATG" +#line 631 "cs.ATG" m.Add(Modifiers.Protected, t.Location); if (la.kind == 83) { lexer.NextToken(); -#line 634 "cs.ATG" +#line 632 "cs.ATG" m.Add(Modifiers.Internal, t.Location); } } else if (la.kind == 83) { lexer.NextToken(); -#line 635 "cs.ATG" +#line 633 "cs.ATG" m.Add(Modifiers.Internal, t.Location); if (la.kind == 96) { lexer.NextToken(); -#line 636 "cs.ATG" +#line 634 "cs.ATG" m.Add(Modifiers.Protected, t.Location); } } else SynErr(158); } void Block( -#line 1203 "cs.ATG" +#line 1201 "cs.ATG" out Statement stmt) { Expect(16); -#line 1205 "cs.ATG" +#line 1203 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.Location; compilationUnit.BlockStart(blockStmt); @@ -2485,7 +2485,7 @@ out Statement stmt) { } Expect(17); -#line 1212 "cs.ATG" +#line 1210 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2493,10 +2493,10 @@ out Statement stmt) { } void EventAccessorDecls( -#line 1138 "cs.ATG" +#line 1136 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1139 "cs.ATG" +#line 1137 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2505,102 +2505,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 18) { AttributeSection( -#line 1146 "cs.ATG" +#line 1144 "cs.ATG" out section); -#line 1146 "cs.ATG" +#line 1144 "cs.ATG" attributes.Add(section); } if ( -#line 1148 "cs.ATG" +#line 1146 "cs.ATG" IdentIsAdd()) { -#line 1148 "cs.ATG" +#line 1146 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1149 "cs.ATG" +#line 1147 "cs.ATG" out stmt); -#line 1149 "cs.ATG" +#line 1147 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 18) { AttributeSection( -#line 1150 "cs.ATG" +#line 1148 "cs.ATG" out section); -#line 1150 "cs.ATG" +#line 1148 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1151 "cs.ATG" +#line 1149 "cs.ATG" out stmt); -#line 1151 "cs.ATG" +#line 1149 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1152 "cs.ATG" +#line 1150 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1153 "cs.ATG" +#line 1151 "cs.ATG" out stmt); -#line 1153 "cs.ATG" +#line 1151 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1154 "cs.ATG" +#line 1152 "cs.ATG" out section); -#line 1154 "cs.ATG" +#line 1152 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1155 "cs.ATG" +#line 1153 "cs.ATG" out stmt); -#line 1155 "cs.ATG" +#line 1153 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1156 "cs.ATG" +#line 1154 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(159); } void ConstructorInitializer( -#line 1234 "cs.ATG" +#line 1232 "cs.ATG" out ConstructorInitializer ci) { -#line 1235 "cs.ATG" +#line 1233 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 50) { lexer.NextToken(); -#line 1239 "cs.ATG" +#line 1237 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 110) { lexer.NextToken(); -#line 1240 "cs.ATG" +#line 1238 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(160); Expect(20); if (StartOf(21)) { Argument( -#line 1243 "cs.ATG" +#line 1241 "cs.ATG" out expr); -#line 1243 "cs.ATG" +#line 1241 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1243 "cs.ATG" +#line 1241 "cs.ATG" out expr); -#line 1243 "cs.ATG" +#line 1241 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -2608,161 +2608,161 @@ out expr); } void OverloadableOperator( -#line 1255 "cs.ATG" +#line 1253 "cs.ATG" out OverloadableOperatorType op) { -#line 1256 "cs.ATG" +#line 1254 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1258 "cs.ATG" +#line 1256 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1259 "cs.ATG" +#line 1257 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 24: { lexer.NextToken(); -#line 1261 "cs.ATG" +#line 1259 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 27: { lexer.NextToken(); -#line 1262 "cs.ATG" +#line 1260 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 31: { lexer.NextToken(); -#line 1264 "cs.ATG" +#line 1262 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 32: { lexer.NextToken(); -#line 1265 "cs.ATG" +#line 1263 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 112: { lexer.NextToken(); -#line 1267 "cs.ATG" +#line 1265 "cs.ATG" op = OverloadableOperatorType.IsTrue; break; } case 71: { lexer.NextToken(); -#line 1268 "cs.ATG" +#line 1266 "cs.ATG" op = OverloadableOperatorType.IsFalse; break; } case 6: { lexer.NextToken(); -#line 1270 "cs.ATG" +#line 1268 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1271 "cs.ATG" +#line 1269 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1272 "cs.ATG" +#line 1270 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 28: { lexer.NextToken(); -#line 1274 "cs.ATG" +#line 1272 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 29: { lexer.NextToken(); -#line 1275 "cs.ATG" +#line 1273 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 30: { lexer.NextToken(); -#line 1276 "cs.ATG" +#line 1274 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 37: { lexer.NextToken(); -#line 1278 "cs.ATG" +#line 1276 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1279 "cs.ATG" +#line 1277 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 34: { lexer.NextToken(); -#line 1280 "cs.ATG" +#line 1278 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 23: { lexer.NextToken(); -#line 1281 "cs.ATG" +#line 1279 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 35: { lexer.NextToken(); -#line 1282 "cs.ATG" +#line 1280 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 36: { lexer.NextToken(); -#line 1283 "cs.ATG" +#line 1281 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 22: { lexer.NextToken(); -#line 1284 "cs.ATG" +#line 1282 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 22) { lexer.NextToken(); -#line 1284 "cs.ATG" +#line 1282 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2772,34 +2772,34 @@ out OverloadableOperatorType op) { } void VariableDeclarator( -#line 1196 "cs.ATG" +#line 1194 "cs.ATG" List fieldDeclaration) { -#line 1197 "cs.ATG" +#line 1195 "cs.ATG" Expression expr = null; Expect(1); -#line 1199 "cs.ATG" +#line 1197 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1200 "cs.ATG" +#line 1198 "cs.ATG" out expr); -#line 1200 "cs.ATG" +#line 1198 "cs.ATG" f.Initializer = expr; } -#line 1200 "cs.ATG" +#line 1198 "cs.ATG" fieldDeclaration.Add(f); } void AccessorDecls( -#line 1082 "cs.ATG" +#line 1080 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1084 "cs.ATG" +#line 1082 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2808,96 +2808,96 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1091 "cs.ATG" +#line 1089 "cs.ATG" out section); -#line 1091 "cs.ATG" +#line 1089 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1092 "cs.ATG" +#line 1090 "cs.ATG" out modifiers); } if ( -#line 1094 "cs.ATG" +#line 1092 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1095 "cs.ATG" +#line 1093 "cs.ATG" out getBlock, attributes); -#line 1096 "cs.ATG" +#line 1094 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1097 "cs.ATG" +#line 1095 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1098 "cs.ATG" +#line 1096 "cs.ATG" out section); -#line 1098 "cs.ATG" +#line 1096 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1099 "cs.ATG" +#line 1097 "cs.ATG" out modifiers); } SetAccessorDecl( -#line 1100 "cs.ATG" +#line 1098 "cs.ATG" out setBlock, attributes); -#line 1101 "cs.ATG" +#line 1099 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } } } else if ( -#line 1103 "cs.ATG" +#line 1101 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1104 "cs.ATG" +#line 1102 "cs.ATG" out setBlock, attributes); -#line 1105 "cs.ATG" +#line 1103 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1106 "cs.ATG" +#line 1104 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1107 "cs.ATG" +#line 1105 "cs.ATG" out section); -#line 1107 "cs.ATG" +#line 1105 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1108 "cs.ATG" +#line 1106 "cs.ATG" out modifiers); } GetAccessorDecl( -#line 1109 "cs.ATG" +#line 1107 "cs.ATG" out getBlock, attributes); -#line 1110 "cs.ATG" +#line 1108 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } } } else if (la.kind == 1) { lexer.NextToken(); -#line 1112 "cs.ATG" +#line 1110 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(162); } void InterfaceAccessors( -#line 1160 "cs.ATG" +#line 1158 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1162 "cs.ATG" +#line 1160 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; @@ -2905,274 +2905,274 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1168 "cs.ATG" +#line 1166 "cs.ATG" out section); -#line 1168 "cs.ATG" +#line 1166 "cs.ATG" attributes.Add(section); } -#line 1169 "cs.ATG" +#line 1167 "cs.ATG" Location startLocation = la.Location; if ( -#line 1171 "cs.ATG" +#line 1169 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1171 "cs.ATG" +#line 1169 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1172 "cs.ATG" +#line 1170 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1172 "cs.ATG" +#line 1170 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1173 "cs.ATG" +#line 1171 "cs.ATG" Error("set or get expected"); } else SynErr(163); Expect(11); -#line 1176 "cs.ATG" +#line 1174 "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 == 1 || la.kind == 18) { while (la.kind == 18) { AttributeSection( -#line 1180 "cs.ATG" +#line 1178 "cs.ATG" out section); -#line 1180 "cs.ATG" +#line 1178 "cs.ATG" attributes.Add(section); } -#line 1181 "cs.ATG" +#line 1179 "cs.ATG" startLocation = la.Location; if ( -#line 1183 "cs.ATG" +#line 1181 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1183 "cs.ATG" +#line 1181 "cs.ATG" if (getBlock != null) Error("get already declared"); else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } } else if ( -#line 1186 "cs.ATG" +#line 1184 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1186 "cs.ATG" +#line 1184 "cs.ATG" if (setBlock != null) Error("set already declared"); else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } } else if (la.kind == 1) { lexer.NextToken(); -#line 1189 "cs.ATG" +#line 1187 "cs.ATG" Error("set or get expected"); } else SynErr(164); Expect(11); -#line 1192 "cs.ATG" +#line 1190 "cs.ATG" if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } } } void GetAccessorDecl( -#line 1116 "cs.ATG" +#line 1114 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1117 "cs.ATG" +#line 1115 "cs.ATG" Statement stmt = null; Expect(1); -#line 1120 "cs.ATG" +#line 1118 "cs.ATG" if (t.val != "get") Error("get expected"); -#line 1121 "cs.ATG" +#line 1119 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1122 "cs.ATG" +#line 1120 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); -#line 1123 "cs.ATG" +#line 1121 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); -#line 1124 "cs.ATG" +#line 1122 "cs.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } void SetAccessorDecl( -#line 1127 "cs.ATG" +#line 1125 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1128 "cs.ATG" +#line 1126 "cs.ATG" Statement stmt = null; Expect(1); -#line 1131 "cs.ATG" +#line 1129 "cs.ATG" if (t.val != "set") Error("set expected"); -#line 1132 "cs.ATG" +#line 1130 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1133 "cs.ATG" +#line 1131 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(166); -#line 1134 "cs.ATG" +#line 1132 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); -#line 1135 "cs.ATG" +#line 1133 "cs.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } void AddAccessorDecl( -#line 1218 "cs.ATG" +#line 1216 "cs.ATG" out Statement stmt) { -#line 1219 "cs.ATG" +#line 1217 "cs.ATG" stmt = null; Expect(1); -#line 1222 "cs.ATG" +#line 1220 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1223 "cs.ATG" +#line 1221 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1226 "cs.ATG" +#line 1224 "cs.ATG" out Statement stmt) { -#line 1227 "cs.ATG" +#line 1225 "cs.ATG" stmt = null; Expect(1); -#line 1230 "cs.ATG" +#line 1228 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1231 "cs.ATG" +#line 1229 "cs.ATG" out stmt); } void VariableInitializer( -#line 1247 "cs.ATG" +#line 1245 "cs.ATG" out Expression initializerExpression) { -#line 1248 "cs.ATG" +#line 1246 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(5)) { Expr( -#line 1250 "cs.ATG" +#line 1248 "cs.ATG" out initializerExpression); } else if (la.kind == 16) { ArrayInitializer( -#line 1251 "cs.ATG" +#line 1249 "cs.ATG" out initializerExpression); } else if (la.kind == 105) { lexer.NextToken(); Type( -#line 1252 "cs.ATG" +#line 1250 "cs.ATG" out type); Expect(18); Expr( -#line 1252 "cs.ATG" +#line 1250 "cs.ATG" out expr); Expect(19); -#line 1252 "cs.ATG" +#line 1250 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(167); } void Statement() { -#line 1364 "cs.ATG" +#line 1362 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; Location startPos = la.Location; if ( -#line 1372 "cs.ATG" +#line 1370 "cs.ATG" IsLabel()) { Expect(1); -#line 1372 "cs.ATG" +#line 1370 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 59) { lexer.NextToken(); Type( -#line 1375 "cs.ATG" +#line 1373 "cs.ATG" out type); -#line 1375 "cs.ATG" +#line 1373 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1376 "cs.ATG" +#line 1374 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1377 "cs.ATG" +#line 1375 "cs.ATG" out expr); -#line 1377 "cs.ATG" +#line 1375 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1378 "cs.ATG" +#line 1376 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1378 "cs.ATG" +#line 1376 "cs.ATG" out expr); -#line 1378 "cs.ATG" +#line 1376 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1379 "cs.ATG" +#line 1377 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1381 "cs.ATG" +#line 1379 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1381 "cs.ATG" +#line 1379 "cs.ATG" out stmt); Expect(11); -#line 1381 "cs.ATG" +#line 1379 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(23)) { EmbeddedStatement( -#line 1382 "cs.ATG" +#line 1380 "cs.ATG" out stmt); -#line 1382 "cs.ATG" +#line 1380 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(168); -#line 1388 "cs.ATG" +#line 1386 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3181,10 +3181,10 @@ out stmt); } void Argument( -#line 1287 "cs.ATG" +#line 1285 "cs.ATG" out Expression argumentexpr) { -#line 1289 "cs.ATG" +#line 1287 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3192,48 +3192,48 @@ out Expression argumentexpr) { if (la.kind == 99) { lexer.NextToken(); -#line 1294 "cs.ATG" +#line 1292 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1295 "cs.ATG" +#line 1293 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1297 "cs.ATG" +#line 1295 "cs.ATG" out expr); -#line 1297 "cs.ATG" +#line 1295 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1317 "cs.ATG" +#line 1315 "cs.ATG" out Expression outExpr) { -#line 1319 "cs.ATG" +#line 1317 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(16); if (StartOf(24)) { VariableInitializer( -#line 1324 "cs.ATG" +#line 1322 "cs.ATG" out expr); -#line 1325 "cs.ATG" +#line 1323 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1326 "cs.ATG" +#line 1324 "cs.ATG" NotFinalComma()) { Expect(14); VariableInitializer( -#line 1327 "cs.ATG" +#line 1325 "cs.ATG" out expr); -#line 1328 "cs.ATG" +#line 1326 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 14) { @@ -3242,138 +3242,138 @@ out expr); } Expect(17); -#line 1332 "cs.ATG" +#line 1330 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1300 "cs.ATG" +#line 1298 "cs.ATG" out AssignmentOperatorType op) { -#line 1301 "cs.ATG" +#line 1299 "cs.ATG" op = AssignmentOperatorType.None; if (la.kind == 3) { lexer.NextToken(); -#line 1303 "cs.ATG" +#line 1301 "cs.ATG" op = AssignmentOperatorType.Assign; } else if (la.kind == 38) { lexer.NextToken(); -#line 1304 "cs.ATG" +#line 1302 "cs.ATG" op = AssignmentOperatorType.Add; } else if (la.kind == 39) { lexer.NextToken(); -#line 1305 "cs.ATG" +#line 1303 "cs.ATG" op = AssignmentOperatorType.Subtract; } else if (la.kind == 40) { lexer.NextToken(); -#line 1306 "cs.ATG" +#line 1304 "cs.ATG" op = AssignmentOperatorType.Multiply; } else if (la.kind == 41) { lexer.NextToken(); -#line 1307 "cs.ATG" +#line 1305 "cs.ATG" op = AssignmentOperatorType.Divide; } else if (la.kind == 42) { lexer.NextToken(); -#line 1308 "cs.ATG" +#line 1306 "cs.ATG" op = AssignmentOperatorType.Modulus; } else if (la.kind == 43) { lexer.NextToken(); -#line 1309 "cs.ATG" +#line 1307 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; } else if (la.kind == 44) { lexer.NextToken(); -#line 1310 "cs.ATG" +#line 1308 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; } else if (la.kind == 45) { lexer.NextToken(); -#line 1311 "cs.ATG" +#line 1309 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; } else if (la.kind == 46) { lexer.NextToken(); -#line 1312 "cs.ATG" +#line 1310 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; } else if ( -#line 1313 "cs.ATG" +#line 1311 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { Expect(22); Expect(35); -#line 1314 "cs.ATG" +#line 1312 "cs.ATG" op = AssignmentOperatorType.ShiftRight; } else SynErr(169); } void LocalVariableDecl( -#line 1335 "cs.ATG" +#line 1333 "cs.ATG" out Statement stmt) { -#line 1337 "cs.ATG" +#line 1335 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1342 "cs.ATG" +#line 1340 "cs.ATG" out type); -#line 1342 "cs.ATG" +#line 1340 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1343 "cs.ATG" +#line 1341 "cs.ATG" out var); -#line 1343 "cs.ATG" +#line 1341 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 14) { lexer.NextToken(); LocalVariableDeclarator( -#line 1344 "cs.ATG" +#line 1342 "cs.ATG" out var); -#line 1344 "cs.ATG" +#line 1342 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1345 "cs.ATG" +#line 1343 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1348 "cs.ATG" +#line 1346 "cs.ATG" out VariableDeclaration var) { -#line 1349 "cs.ATG" +#line 1347 "cs.ATG" Expression expr = null; Expect(1); -#line 1352 "cs.ATG" +#line 1350 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1352 "cs.ATG" +#line 1350 "cs.ATG" out expr); -#line 1352 "cs.ATG" +#line 1350 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1395 "cs.ATG" +#line 1393 "cs.ATG" out Statement statement) { -#line 1397 "cs.ATG" +#line 1395 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3381,57 +3381,57 @@ out Statement statement) { if (la.kind == 16) { Block( -#line 1403 "cs.ATG" +#line 1401 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1405 "cs.ATG" +#line 1403 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1407 "cs.ATG" +#line 1405 "cs.ATG" UnCheckedAndLBrace()) { -#line 1407 "cs.ATG" +#line 1405 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 57) { lexer.NextToken(); } else if (la.kind == 117) { lexer.NextToken(); -#line 1408 "cs.ATG" +#line 1406 "cs.ATG" isChecked = false; } else SynErr(170); Block( -#line 1409 "cs.ATG" +#line 1407 "cs.ATG" out block); -#line 1409 "cs.ATG" +#line 1407 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 78) { lexer.NextToken(); -#line 1411 "cs.ATG" +#line 1409 "cs.ATG" Statement elseStatement = null; Expect(20); Expr( -#line 1412 "cs.ATG" +#line 1410 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1413 "cs.ATG" +#line 1411 "cs.ATG" out embeddedStatement); if (la.kind == 66) { lexer.NextToken(); EmbeddedStatement( -#line 1414 "cs.ATG" +#line 1412 "cs.ATG" out elseStatement); } -#line 1415 "cs.ATG" +#line 1413 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1416 "cs.ATG" +#line 1414 "cs.ATG" if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { /* else if-section (otherwise we would have a BlockStatment) */ (statement as IfElseStatement).ElseIfSections.Add( @@ -3443,99 +3443,99 @@ out elseStatement); } else if (la.kind == 109) { lexer.NextToken(); -#line 1424 "cs.ATG" +#line 1422 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1425 "cs.ATG" +#line 1423 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1426 "cs.ATG" +#line 1424 "cs.ATG" switchSections); Expect(17); -#line 1427 "cs.ATG" +#line 1425 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 124) { lexer.NextToken(); Expect(20); Expr( -#line 1429 "cs.ATG" +#line 1427 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1431 "cs.ATG" +#line 1429 "cs.ATG" out embeddedStatement); -#line 1431 "cs.ATG" +#line 1429 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 64) { lexer.NextToken(); EmbeddedStatement( -#line 1432 "cs.ATG" +#line 1430 "cs.ATG" out embeddedStatement); Expect(124); Expect(20); Expr( -#line 1433 "cs.ATG" +#line 1431 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1433 "cs.ATG" +#line 1431 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 75) { lexer.NextToken(); -#line 1434 "cs.ATG" +#line 1432 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(5)) { ForInitializer( -#line 1435 "cs.ATG" +#line 1433 "cs.ATG" out initializer); } Expect(11); if (StartOf(5)) { Expr( -#line 1436 "cs.ATG" +#line 1434 "cs.ATG" out expr); } Expect(11); if (StartOf(5)) { ForIterator( -#line 1437 "cs.ATG" +#line 1435 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1438 "cs.ATG" +#line 1436 "cs.ATG" out embeddedStatement); -#line 1438 "cs.ATG" +#line 1436 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 76) { lexer.NextToken(); Expect(20); Type( -#line 1439 "cs.ATG" +#line 1437 "cs.ATG" out type); Expect(1); -#line 1439 "cs.ATG" +#line 1437 "cs.ATG" string varName = t.val; Location start = t.Location; Expect(80); Expr( -#line 1440 "cs.ATG" +#line 1438 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1441 "cs.ATG" +#line 1439 "cs.ATG" out embeddedStatement); -#line 1441 "cs.ATG" +#line 1439 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -3543,34 +3543,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1445 "cs.ATG" +#line 1443 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 60) { lexer.NextToken(); Expect(11); -#line 1446 "cs.ATG" +#line 1444 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 77) { GotoStatement( -#line 1447 "cs.ATG" +#line 1445 "cs.ATG" out statement); } else if ( -#line 1448 "cs.ATG" +#line 1446 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 100) { lexer.NextToken(); Expr( -#line 1448 "cs.ATG" +#line 1446 "cs.ATG" out expr); -#line 1448 "cs.ATG" +#line 1446 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 52) { lexer.NextToken(); -#line 1449 "cs.ATG" +#line 1447 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(171); Expect(11); @@ -3578,140 +3578,140 @@ out expr); lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1450 "cs.ATG" +#line 1448 "cs.ATG" out expr); } Expect(11); -#line 1450 "cs.ATG" +#line 1448 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 111) { lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1451 "cs.ATG" +#line 1449 "cs.ATG" out expr); } Expect(11); -#line 1451 "cs.ATG" +#line 1449 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(5)) { StatementExpr( -#line 1454 "cs.ATG" +#line 1452 "cs.ATG" out statement); Expect(11); } else if (la.kind == 113) { TryStatement( -#line 1456 "cs.ATG" +#line 1454 "cs.ATG" out statement); } else if (la.kind == 85) { lexer.NextToken(); Expect(20); Expr( -#line 1458 "cs.ATG" +#line 1456 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1459 "cs.ATG" +#line 1457 "cs.ATG" out embeddedStatement); -#line 1459 "cs.ATG" +#line 1457 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 120) { -#line 1461 "cs.ATG" +#line 1459 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1463 "cs.ATG" +#line 1461 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1464 "cs.ATG" +#line 1462 "cs.ATG" out embeddedStatement); -#line 1464 "cs.ATG" +#line 1462 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 118) { lexer.NextToken(); Block( -#line 1466 "cs.ATG" +#line 1464 "cs.ATG" out embeddedStatement); -#line 1466 "cs.ATG" +#line 1464 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 73) { lexer.NextToken(); Expect(20); Type( -#line 1469 "cs.ATG" +#line 1467 "cs.ATG" out type); -#line 1469 "cs.ATG" +#line 1467 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); List pointerDeclarators = new List(1); Expect(1); -#line 1472 "cs.ATG" +#line 1470 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1473 "cs.ATG" +#line 1471 "cs.ATG" out expr); -#line 1473 "cs.ATG" +#line 1471 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1475 "cs.ATG" +#line 1473 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1476 "cs.ATG" +#line 1474 "cs.ATG" out expr); -#line 1476 "cs.ATG" +#line 1474 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(21); EmbeddedStatement( -#line 1478 "cs.ATG" +#line 1476 "cs.ATG" out embeddedStatement); -#line 1478 "cs.ATG" +#line 1476 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(172); } void SwitchSections( -#line 1500 "cs.ATG" +#line 1498 "cs.ATG" List switchSections) { -#line 1502 "cs.ATG" +#line 1500 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1506 "cs.ATG" +#line 1504 "cs.ATG" out label); -#line 1506 "cs.ATG" +#line 1504 "cs.ATG" if (label != null) { switchSection.SwitchLabels.Add(label); } -#line 1507 "cs.ATG" +#line 1505 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(25)) { if (la.kind == 54 || la.kind == 62) { SwitchLabel( -#line 1509 "cs.ATG" +#line 1507 "cs.ATG" out label); -#line 1510 "cs.ATG" +#line 1508 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -3727,346 +3727,346 @@ out label); } } -#line 1522 "cs.ATG" +#line 1520 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1481 "cs.ATG" +#line 1479 "cs.ATG" out List initializer) { -#line 1483 "cs.ATG" +#line 1481 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1487 "cs.ATG" +#line 1485 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1487 "cs.ATG" +#line 1485 "cs.ATG" out stmt); -#line 1487 "cs.ATG" +#line 1485 "cs.ATG" initializer.Add(stmt); } else if (StartOf(5)) { StatementExpr( -#line 1488 "cs.ATG" +#line 1486 "cs.ATG" out stmt); -#line 1488 "cs.ATG" +#line 1486 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1488 "cs.ATG" +#line 1486 "cs.ATG" out stmt); -#line 1488 "cs.ATG" +#line 1486 "cs.ATG" initializer.Add(stmt); } } else SynErr(173); } void ForIterator( -#line 1491 "cs.ATG" +#line 1489 "cs.ATG" out List iterator) { -#line 1493 "cs.ATG" +#line 1491 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1497 "cs.ATG" +#line 1495 "cs.ATG" out stmt); -#line 1497 "cs.ATG" +#line 1495 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1497 "cs.ATG" +#line 1495 "cs.ATG" out stmt); -#line 1497 "cs.ATG" +#line 1495 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1575 "cs.ATG" +#line 1573 "cs.ATG" out Statement stmt) { -#line 1576 "cs.ATG" +#line 1574 "cs.ATG" Expression expr; stmt = null; Expect(77); if (la.kind == 1) { lexer.NextToken(); -#line 1580 "cs.ATG" +#line 1578 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 54) { lexer.NextToken(); Expr( -#line 1581 "cs.ATG" +#line 1579 "cs.ATG" out expr); Expect(11); -#line 1581 "cs.ATG" +#line 1579 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(11); -#line 1582 "cs.ATG" +#line 1580 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(174); } void StatementExpr( -#line 1602 "cs.ATG" +#line 1600 "cs.ATG" out Statement stmt) { -#line 1603 "cs.ATG" +#line 1601 "cs.ATG" Expression expr; Expr( -#line 1605 "cs.ATG" +#line 1603 "cs.ATG" out expr); -#line 1608 "cs.ATG" +#line 1606 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1532 "cs.ATG" +#line 1530 "cs.ATG" out Statement tryStatement) { -#line 1534 "cs.ATG" +#line 1532 "cs.ATG" Statement blockStmt = null, finallyStmt = null; List catchClauses = null; Expect(113); Block( -#line 1538 "cs.ATG" +#line 1536 "cs.ATG" out blockStmt); if (la.kind == 55) { CatchClauses( -#line 1540 "cs.ATG" +#line 1538 "cs.ATG" out catchClauses); if (la.kind == 72) { lexer.NextToken(); Block( -#line 1540 "cs.ATG" +#line 1538 "cs.ATG" out finallyStmt); } } else if (la.kind == 72) { lexer.NextToken(); Block( -#line 1541 "cs.ATG" +#line 1539 "cs.ATG" out finallyStmt); } else SynErr(175); -#line 1544 "cs.ATG" +#line 1542 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 1586 "cs.ATG" +#line 1584 "cs.ATG" out Statement stmt) { -#line 1588 "cs.ATG" +#line 1586 "cs.ATG" stmt = null; Expression expr; if ( -#line 1593 "cs.ATG" +#line 1591 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1593 "cs.ATG" +#line 1591 "cs.ATG" out stmt); } else if (StartOf(5)) { Expr( -#line 1594 "cs.ATG" +#line 1592 "cs.ATG" out expr); -#line 1598 "cs.ATG" +#line 1596 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(176); } void SwitchLabel( -#line 1525 "cs.ATG" +#line 1523 "cs.ATG" out CaseLabel label) { -#line 1526 "cs.ATG" +#line 1524 "cs.ATG" Expression expr = null; label = null; if (la.kind == 54) { lexer.NextToken(); Expr( -#line 1528 "cs.ATG" +#line 1526 "cs.ATG" out expr); Expect(9); -#line 1528 "cs.ATG" +#line 1526 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(9); -#line 1529 "cs.ATG" +#line 1527 "cs.ATG" label = new CaseLabel(); } else SynErr(177); } void CatchClauses( -#line 1549 "cs.ATG" +#line 1547 "cs.ATG" out List catchClauses) { -#line 1551 "cs.ATG" +#line 1549 "cs.ATG" catchClauses = new List(); Expect(55); -#line 1554 "cs.ATG" +#line 1552 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; if (la.kind == 16) { Block( -#line 1560 "cs.ATG" +#line 1558 "cs.ATG" out stmt); -#line 1560 "cs.ATG" +#line 1558 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1562 "cs.ATG" +#line 1560 "cs.ATG" out typeRef, false); -#line 1562 "cs.ATG" +#line 1560 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1563 "cs.ATG" +#line 1561 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1564 "cs.ATG" +#line 1562 "cs.ATG" out stmt); -#line 1565 "cs.ATG" +#line 1563 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); while ( -#line 1566 "cs.ATG" +#line 1564 "cs.ATG" IsTypedCatch()) { Expect(55); Expect(20); ClassType( -#line 1566 "cs.ATG" +#line 1564 "cs.ATG" out typeRef, false); -#line 1566 "cs.ATG" +#line 1564 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1567 "cs.ATG" +#line 1565 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1568 "cs.ATG" +#line 1566 "cs.ATG" out stmt); -#line 1569 "cs.ATG" +#line 1567 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); } if (la.kind == 55) { lexer.NextToken(); Block( -#line 1571 "cs.ATG" +#line 1569 "cs.ATG" out stmt); -#line 1571 "cs.ATG" +#line 1569 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(178); } void UnaryExpr( -#line 1629 "cs.ATG" +#line 1627 "cs.ATG" out Expression uExpr) { -#line 1631 "cs.ATG" +#line 1629 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(26) || -#line 1653 "cs.ATG" +#line 1651 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1640 "cs.ATG" +#line 1638 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1641 "cs.ATG" +#line 1639 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 1642 "cs.ATG" +#line 1640 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1643 "cs.ATG" +#line 1641 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1644 "cs.ATG" +#line 1642 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1645 "cs.ATG" +#line 1643 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 1646 "cs.ATG" +#line 1644 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 1647 "cs.ATG" +#line 1645 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(20); Type( -#line 1653 "cs.ATG" +#line 1651 "cs.ATG" out type); Expect(21); -#line 1653 "cs.ATG" +#line 1651 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 1657 "cs.ATG" +#line 1655 "cs.ATG" out expr); -#line 1657 "cs.ATG" +#line 1655 "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) { @@ -4084,33 +4084,33 @@ out expr); } void ConditionalOrExpr( -#line 1827 "cs.ATG" +#line 1825 "cs.ATG" ref Expression outExpr) { -#line 1828 "cs.ATG" +#line 1826 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 1830 "cs.ATG" +#line 1828 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 1830 "cs.ATG" +#line 1828 "cs.ATG" out expr); ConditionalAndExpr( -#line 1830 "cs.ATG" +#line 1828 "cs.ATG" ref expr); -#line 1830 "cs.ATG" +#line 1828 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1674 "cs.ATG" +#line 1672 "cs.ATG" out Expression pexpr) { -#line 1676 "cs.ATG" +#line 1674 "cs.ATG" TypeReference type = null; List typeList = null; bool isArrayCreation = false; @@ -4120,332 +4120,332 @@ out Expression pexpr) { if (la.kind == 112) { lexer.NextToken(); -#line 1684 "cs.ATG" +#line 1682 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 71) { lexer.NextToken(); -#line 1685 "cs.ATG" +#line 1683 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 89) { lexer.NextToken(); -#line 1686 "cs.ATG" +#line 1684 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1687 "cs.ATG" +#line 1685 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); } else if ( -#line 1688 "cs.ATG" +#line 1686 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { Expect(1); -#line 1689 "cs.ATG" +#line 1687 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1690 "cs.ATG" +#line 1688 "cs.ATG" pexpr = new TypeReferenceExpression(type); Expect(1); -#line 1691 "cs.ATG" +#line 1689 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); } else if (la.kind == 1) { lexer.NextToken(); -#line 1693 "cs.ATG" +#line 1691 "cs.ATG" pexpr = new IdentifierExpression(t.val); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1695 "cs.ATG" +#line 1693 "cs.ATG" out expr); Expect(21); -#line 1695 "cs.ATG" +#line 1693 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(27)) { -#line 1697 "cs.ATG" +#line 1695 "cs.ATG" string val = null; switch (la.kind) { case 51: { lexer.NextToken(); -#line 1699 "cs.ATG" +#line 1697 "cs.ATG" val = "bool"; break; } case 53: { lexer.NextToken(); -#line 1700 "cs.ATG" +#line 1698 "cs.ATG" val = "byte"; break; } case 56: { lexer.NextToken(); -#line 1701 "cs.ATG" +#line 1699 "cs.ATG" val = "char"; break; } case 61: { lexer.NextToken(); -#line 1702 "cs.ATG" +#line 1700 "cs.ATG" val = "decimal"; break; } case 65: { lexer.NextToken(); -#line 1703 "cs.ATG" +#line 1701 "cs.ATG" val = "double"; break; } case 74: { lexer.NextToken(); -#line 1704 "cs.ATG" +#line 1702 "cs.ATG" val = "float"; break; } case 81: { lexer.NextToken(); -#line 1705 "cs.ATG" +#line 1703 "cs.ATG" val = "int"; break; } case 86: { lexer.NextToken(); -#line 1706 "cs.ATG" +#line 1704 "cs.ATG" val = "long"; break; } case 90: { lexer.NextToken(); -#line 1707 "cs.ATG" +#line 1705 "cs.ATG" val = "object"; break; } case 101: { lexer.NextToken(); -#line 1708 "cs.ATG" +#line 1706 "cs.ATG" val = "sbyte"; break; } case 103: { lexer.NextToken(); -#line 1709 "cs.ATG" +#line 1707 "cs.ATG" val = "short"; break; } case 107: { lexer.NextToken(); -#line 1710 "cs.ATG" +#line 1708 "cs.ATG" val = "string"; break; } case 115: { lexer.NextToken(); -#line 1711 "cs.ATG" +#line 1709 "cs.ATG" val = "uint"; break; } case 116: { lexer.NextToken(); -#line 1712 "cs.ATG" +#line 1710 "cs.ATG" val = "ulong"; break; } case 119: { lexer.NextToken(); -#line 1713 "cs.ATG" +#line 1711 "cs.ATG" val = "ushort"; break; } } -#line 1714 "cs.ATG" +#line 1712 "cs.ATG" t.val = ""; Expect(15); Expect(1); -#line 1714 "cs.ATG" +#line 1712 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); } else if (la.kind == 110) { lexer.NextToken(); -#line 1716 "cs.ATG" +#line 1714 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 50) { lexer.NextToken(); -#line 1718 "cs.ATG" +#line 1716 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 1720 "cs.ATG" +#line 1718 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 18) { lexer.NextToken(); Expr( -#line 1721 "cs.ATG" +#line 1719 "cs.ATG" out expr); -#line 1721 "cs.ATG" +#line 1719 "cs.ATG" List indices = new List(); if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1722 "cs.ATG" +#line 1720 "cs.ATG" out expr); -#line 1722 "cs.ATG" +#line 1720 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 1723 "cs.ATG" +#line 1721 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(179); -#line 1724 "cs.ATG" +#line 1722 "cs.ATG" pexpr = retExpr; } else if (la.kind == 88) { lexer.NextToken(); NonArrayType( -#line 1725 "cs.ATG" +#line 1723 "cs.ATG" out type); -#line 1726 "cs.ATG" +#line 1724 "cs.ATG" List parameters = new List(); if (la.kind == 20) { lexer.NextToken(); -#line 1731 "cs.ATG" +#line 1729 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 1732 "cs.ATG" +#line 1730 "cs.ATG" out expr); -#line 1732 "cs.ATG" +#line 1730 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1733 "cs.ATG" +#line 1731 "cs.ATG" out expr); -#line 1733 "cs.ATG" +#line 1731 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(21); -#line 1735 "cs.ATG" +#line 1733 "cs.ATG" pexpr = oce; } else if (la.kind == 18) { lexer.NextToken(); -#line 1737 "cs.ATG" +#line 1735 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; -#line 1738 "cs.ATG" +#line 1736 "cs.ATG" int dims = 0; List ranks = new List(); if (la.kind == 14 || la.kind == 19) { while (la.kind == 14) { lexer.NextToken(); -#line 1740 "cs.ATG" +#line 1738 "cs.ATG" dims += 1; } Expect(19); -#line 1741 "cs.ATG" +#line 1739 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1742 "cs.ATG" +#line 1740 "cs.ATG" ++dims; } Expect(19); -#line 1742 "cs.ATG" +#line 1740 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 1743 "cs.ATG" +#line 1741 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); ArrayInitializer( -#line 1744 "cs.ATG" +#line 1742 "cs.ATG" out expr); -#line 1744 "cs.ATG" +#line 1742 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } else if (StartOf(5)) { Expr( -#line 1745 "cs.ATG" +#line 1743 "cs.ATG" out expr); -#line 1745 "cs.ATG" +#line 1743 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 1746 "cs.ATG" +#line 1744 "cs.ATG" dims += 1; Expr( -#line 1747 "cs.ATG" +#line 1745 "cs.ATG" out expr); -#line 1747 "cs.ATG" +#line 1745 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 1749 "cs.ATG" +#line 1747 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1750 "cs.ATG" +#line 1748 "cs.ATG" ++dims; } Expect(19); -#line 1750 "cs.ATG" +#line 1748 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 1751 "cs.ATG" +#line 1749 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { ArrayInitializer( -#line 1752 "cs.ATG" +#line 1750 "cs.ATG" out expr); -#line 1752 "cs.ATG" +#line 1750 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else SynErr(180); @@ -4454,202 +4454,202 @@ out expr); lexer.NextToken(); Expect(20); if ( -#line 1757 "cs.ATG" +#line 1755 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 1757 "cs.ATG" +#line 1755 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(9)) { TypeWithRestriction( -#line 1758 "cs.ATG" +#line 1756 "cs.ATG" out type, true, true); } else SynErr(182); Expect(21); -#line 1759 "cs.ATG" +#line 1757 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 62) { lexer.NextToken(); Expect(20); Type( -#line 1761 "cs.ATG" +#line 1759 "cs.ATG" out type); Expect(21); -#line 1761 "cs.ATG" +#line 1759 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 104) { lexer.NextToken(); Expect(20); Type( -#line 1762 "cs.ATG" +#line 1760 "cs.ATG" out type); Expect(21); -#line 1762 "cs.ATG" +#line 1760 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 57) { lexer.NextToken(); Expect(20); Expr( -#line 1763 "cs.ATG" +#line 1761 "cs.ATG" out expr); Expect(21); -#line 1763 "cs.ATG" +#line 1761 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 117) { lexer.NextToken(); Expect(20); Expr( -#line 1764 "cs.ATG" +#line 1762 "cs.ATG" out expr); Expect(21); -#line 1764 "cs.ATG" +#line 1762 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 63) { lexer.NextToken(); AnonymousMethodExpr( -#line 1765 "cs.ATG" +#line 1763 "cs.ATG" out expr); -#line 1765 "cs.ATG" +#line 1763 "cs.ATG" pexpr = expr; } else SynErr(183); while (StartOf(28) || -#line 1776 "cs.ATG" +#line 1774 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || -#line 1785 "cs.ATG" +#line 1783 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { lexer.NextToken(); -#line 1769 "cs.ATG" +#line 1767 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 1770 "cs.ATG" +#line 1768 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(184); } else if (la.kind == 47) { lexer.NextToken(); Expect(1); -#line 1773 "cs.ATG" +#line 1771 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 1774 "cs.ATG" +#line 1772 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if ( -#line 1776 "cs.ATG" +#line 1774 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) { TypeArgumentList( -#line 1777 "cs.ATG" +#line 1775 "cs.ATG" out typeList, false); Expect(15); Expect(1); -#line 1779 "cs.ATG" +#line 1777 "cs.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeList), t.val); } else if (la.kind == 20) { lexer.NextToken(); -#line 1781 "cs.ATG" +#line 1779 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 1782 "cs.ATG" +#line 1780 "cs.ATG" out expr); -#line 1782 "cs.ATG" +#line 1780 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1783 "cs.ATG" +#line 1781 "cs.ATG" out expr); -#line 1783 "cs.ATG" +#line 1781 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 1784 "cs.ATG" +#line 1782 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else if ( -#line 1785 "cs.ATG" +#line 1783 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { TypeArgumentList( -#line 1785 "cs.ATG" +#line 1783 "cs.ATG" out typeList, false); Expect(20); -#line 1786 "cs.ATG" +#line 1784 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 1787 "cs.ATG" +#line 1785 "cs.ATG" out expr); -#line 1787 "cs.ATG" +#line 1785 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1788 "cs.ATG" +#line 1786 "cs.ATG" out expr); -#line 1788 "cs.ATG" +#line 1786 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 1789 "cs.ATG" +#line 1787 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 1791 "cs.ATG" +#line 1789 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); List indices = new List(); lexer.NextToken(); Expr( -#line 1794 "cs.ATG" +#line 1792 "cs.ATG" out expr); -#line 1794 "cs.ATG" +#line 1792 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1795 "cs.ATG" +#line 1793 "cs.ATG" out expr); -#line 1795 "cs.ATG" +#line 1793 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 1796 "cs.ATG" +#line 1794 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void AnonymousMethodExpr( -#line 1800 "cs.ATG" +#line 1798 "cs.ATG" out Expression outExpr) { -#line 1802 "cs.ATG" +#line 1800 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; Statement stmt; @@ -4660,77 +4660,77 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(10)) { FormalParameterList( -#line 1811 "cs.ATG" +#line 1809 "cs.ATG" p); -#line 1811 "cs.ATG" +#line 1809 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 1813 "cs.ATG" +#line 1811 "cs.ATG" expr.HasParameterList = true; } -#line 1817 "cs.ATG" +#line 1815 "cs.ATG" if (compilationUnit != null) { Block( -#line 1818 "cs.ATG" +#line 1816 "cs.ATG" out stmt); -#line 1818 "cs.ATG" +#line 1816 "cs.ATG" expr.Body = (BlockStatement)stmt; -#line 1819 "cs.ATG" +#line 1817 "cs.ATG" } else { Expect(16); -#line 1821 "cs.ATG" +#line 1819 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 1823 "cs.ATG" +#line 1821 "cs.ATG" } -#line 1824 "cs.ATG" +#line 1822 "cs.ATG" expr.EndLocation = t.Location; } void TypeArgumentList( -#line 1997 "cs.ATG" +#line 1995 "cs.ATG" out List types, bool canBeUnbound) { -#line 1999 "cs.ATG" +#line 1997 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2004 "cs.ATG" +#line 2002 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2005 "cs.ATG" +#line 2003 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2006 "cs.ATG" +#line 2004 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(9)) { Type( -#line 2007 "cs.ATG" +#line 2005 "cs.ATG" out type); -#line 2007 "cs.ATG" +#line 2005 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2008 "cs.ATG" +#line 2006 "cs.ATG" out type); -#line 2008 "cs.ATG" +#line 2006 "cs.ATG" if (type != null) { types.Add(type); } } } else SynErr(185); @@ -4738,206 +4738,206 @@ out type); } void ConditionalAndExpr( -#line 1833 "cs.ATG" +#line 1831 "cs.ATG" ref Expression outExpr) { -#line 1834 "cs.ATG" +#line 1832 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 1836 "cs.ATG" +#line 1834 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 1836 "cs.ATG" +#line 1834 "cs.ATG" out expr); InclusiveOrExpr( -#line 1836 "cs.ATG" +#line 1834 "cs.ATG" ref expr); -#line 1836 "cs.ATG" +#line 1834 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 1839 "cs.ATG" +#line 1837 "cs.ATG" ref Expression outExpr) { -#line 1840 "cs.ATG" +#line 1838 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 1842 "cs.ATG" +#line 1840 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 1842 "cs.ATG" +#line 1840 "cs.ATG" out expr); ExclusiveOrExpr( -#line 1842 "cs.ATG" +#line 1840 "cs.ATG" ref expr); -#line 1842 "cs.ATG" +#line 1840 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 1845 "cs.ATG" +#line 1843 "cs.ATG" ref Expression outExpr) { -#line 1846 "cs.ATG" +#line 1844 "cs.ATG" Expression expr; AndExpr( -#line 1848 "cs.ATG" +#line 1846 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 1848 "cs.ATG" +#line 1846 "cs.ATG" out expr); AndExpr( -#line 1848 "cs.ATG" +#line 1846 "cs.ATG" ref expr); -#line 1848 "cs.ATG" +#line 1846 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 1851 "cs.ATG" +#line 1849 "cs.ATG" ref Expression outExpr) { -#line 1852 "cs.ATG" +#line 1850 "cs.ATG" Expression expr; EqualityExpr( -#line 1854 "cs.ATG" +#line 1852 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 1854 "cs.ATG" +#line 1852 "cs.ATG" out expr); EqualityExpr( -#line 1854 "cs.ATG" +#line 1852 "cs.ATG" ref expr); -#line 1854 "cs.ATG" +#line 1852 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 1857 "cs.ATG" +#line 1855 "cs.ATG" ref Expression outExpr) { -#line 1859 "cs.ATG" +#line 1857 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 1863 "cs.ATG" +#line 1861 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 1866 "cs.ATG" +#line 1864 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 1867 "cs.ATG" +#line 1865 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 1869 "cs.ATG" +#line 1867 "cs.ATG" out expr); RelationalExpr( -#line 1869 "cs.ATG" +#line 1867 "cs.ATG" ref expr); -#line 1869 "cs.ATG" +#line 1867 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 1873 "cs.ATG" +#line 1871 "cs.ATG" ref Expression outExpr) { -#line 1875 "cs.ATG" +#line 1873 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 1880 "cs.ATG" +#line 1878 "cs.ATG" ref outExpr); while (StartOf(29)) { if (StartOf(30)) { if (la.kind == 23) { lexer.NextToken(); -#line 1882 "cs.ATG" +#line 1880 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 1883 "cs.ATG" +#line 1881 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 1884 "cs.ATG" +#line 1882 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 1885 "cs.ATG" +#line 1883 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(186); UnaryExpr( -#line 1887 "cs.ATG" +#line 1885 "cs.ATG" out expr); ShiftExpr( -#line 1888 "cs.ATG" +#line 1886 "cs.ATG" ref expr); -#line 1889 "cs.ATG" +#line 1887 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 84) { lexer.NextToken(); TypeWithRestriction( -#line 1892 "cs.ATG" +#line 1890 "cs.ATG" out type, false, false); if ( -#line 1893 "cs.ATG" +#line 1891 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 1894 "cs.ATG" +#line 1892 "cs.ATG" ref type); } -#line 1895 "cs.ATG" +#line 1893 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 49) { lexer.NextToken(); TypeWithRestriction( -#line 1897 "cs.ATG" +#line 1895 "cs.ATG" out type, false, false); if ( -#line 1898 "cs.ATG" +#line 1896 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 1899 "cs.ATG" +#line 1897 "cs.ATG" ref type); } -#line 1900 "cs.ATG" +#line 1898 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(187); } @@ -4945,83 +4945,83 @@ ref type); } void ShiftExpr( -#line 1905 "cs.ATG" +#line 1903 "cs.ATG" ref Expression outExpr) { -#line 1907 "cs.ATG" +#line 1905 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 1911 "cs.ATG" +#line 1909 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 1914 "cs.ATG" +#line 1912 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 1913 "cs.ATG" +#line 1911 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 1915 "cs.ATG" +#line 1913 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 1918 "cs.ATG" +#line 1916 "cs.ATG" out expr); AdditiveExpr( -#line 1918 "cs.ATG" +#line 1916 "cs.ATG" ref expr); -#line 1918 "cs.ATG" +#line 1916 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 1922 "cs.ATG" +#line 1920 "cs.ATG" ref Expression outExpr) { -#line 1924 "cs.ATG" +#line 1922 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 1928 "cs.ATG" +#line 1926 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 1931 "cs.ATG" +#line 1929 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 1932 "cs.ATG" +#line 1930 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 1934 "cs.ATG" +#line 1932 "cs.ATG" out expr); MultiplicativeExpr( -#line 1934 "cs.ATG" +#line 1932 "cs.ATG" ref expr); -#line 1934 "cs.ATG" +#line 1932 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 1938 "cs.ATG" +#line 1936 "cs.ATG" ref Expression outExpr) { -#line 1940 "cs.ATG" +#line 1938 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5029,57 +5029,57 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 1946 "cs.ATG" +#line 1944 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 1947 "cs.ATG" +#line 1945 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 1948 "cs.ATG" +#line 1946 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 1950 "cs.ATG" +#line 1948 "cs.ATG" out expr); -#line 1950 "cs.ATG" +#line 1948 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2054 "cs.ATG" +#line 2052 "cs.ATG" out TypeReference type) { -#line 2055 "cs.ATG" +#line 2053 "cs.ATG" TypeReference t; type = null; if (la.kind == 108) { lexer.NextToken(); -#line 2057 "cs.ATG" +#line 2055 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 58) { lexer.NextToken(); -#line 2058 "cs.ATG" +#line 2056 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 88) { lexer.NextToken(); Expect(20); Expect(21); -#line 2059 "cs.ATG" +#line 2057 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(9)) { Type( -#line 2060 "cs.ATG" +#line 2058 "cs.ATG" out t); -#line 2060 "cs.ATG" +#line 2058 "cs.ATG" type = t; } else SynErr(188); } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 8f394bcbbe..a8ecd2146a 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -343,7 +343,7 @@ TypeDecl attributes> { IF (IdentIsWhere()) TypeParameterConstraintsClause } (. newType.BodyStartLocation = t.EndLocation; .) - ClassBody + "{" ClassBody "}" [ ";" ] (. newType.EndLocation = t.Location; compilationUnit.BlockEnd(); .) @@ -456,7 +456,6 @@ ClassBase names> ClassBody (. AttributeSection section; .) = - "{" { (.List attributes = new List(); ModifierList m = new ModifierList(); .) @@ -464,7 +463,6 @@ ClassBody MemberModifiers ClassMemberDecl } - "}" . StructInterfaces names> diff --git a/src/Libraries/NRefactory/Project/Src/Parser/IParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/IParser.cs index 10b6dbc33e..aa93957246 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/IParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/IParser.cs @@ -6,6 +6,7 @@ // using System; +using System.Collections.Generic; using ICSharpCode.NRefactory.Ast; namespace ICSharpCode.NRefactory @@ -34,5 +35,7 @@ namespace ICSharpCode.NRefactory void Parse(); Expression ParseExpression(); + BlockStatement ParseBlock(); + List ParseTypeMembers(); } } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs index 3d82863836..4608567e3d 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs @@ -562,8 +562,14 @@ out baseInterfaces); ClassBody( #line 425 "VBNET.ATG" newType); + Expect(88); + Expect(67); + +#line 426 "VBNET.ATG" + newType.EndLocation = t.EndLocation; + Expect(1); -#line 427 "VBNET.ATG" +#line 429 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -571,7 +577,7 @@ newType); case 121: { lexer.NextToken(); -#line 431 "VBNET.ATG" +#line 433 "VBNET.ATG" m.Check(Modifiers.VBModules); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); @@ -581,17 +587,17 @@ newType); Identifier(); -#line 438 "VBNET.ATG" +#line 440 "VBNET.ATG" newType.Name = t.val; Expect(1); -#line 440 "VBNET.ATG" +#line 442 "VBNET.ATG" newType.BodyStartLocation = t.Location; ModuleBody( -#line 441 "VBNET.ATG" +#line 443 "VBNET.ATG" newType); -#line 443 "VBNET.ATG" +#line 445 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -599,7 +605,7 @@ newType); case 166: { lexer.NextToken(); -#line 447 "VBNET.ATG" +#line 449 "VBNET.ATG" m.Check(Modifiers.VBStructures); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); @@ -609,28 +615,28 @@ newType); Identifier(); -#line 454 "VBNET.ATG" +#line 456 "VBNET.ATG" newType.Name = t.val; TypeParameterList( -#line 455 "VBNET.ATG" +#line 457 "VBNET.ATG" newType.Templates); Expect(1); -#line 457 "VBNET.ATG" +#line 459 "VBNET.ATG" newType.BodyStartLocation = t.Location; while (la.kind == 107) { TypeImplementsClause( -#line 458 "VBNET.ATG" +#line 460 "VBNET.ATG" out baseInterfaces); -#line 458 "VBNET.ATG" +#line 460 "VBNET.ATG" newType.BaseTypes.AddRange(baseInterfaces); } StructureBody( -#line 459 "VBNET.ATG" +#line 461 "VBNET.ATG" newType); -#line 461 "VBNET.ATG" +#line 463 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -638,7 +644,7 @@ newType); case 90: { lexer.NextToken(); -#line 466 "VBNET.ATG" +#line 468 "VBNET.ATG" m.Check(Modifiers.VBEnums); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); newType.StartLocation = m.GetDeclarationLocation(t.Location); @@ -649,26 +655,26 @@ newType); Identifier(); -#line 474 "VBNET.ATG" +#line 476 "VBNET.ATG" newType.Name = t.val; if (la.kind == 48) { lexer.NextToken(); NonArrayTypeName( -#line 475 "VBNET.ATG" +#line 477 "VBNET.ATG" out typeRef, false); -#line 475 "VBNET.ATG" +#line 477 "VBNET.ATG" newType.BaseTypes.Add(typeRef); } Expect(1); -#line 477 "VBNET.ATG" +#line 479 "VBNET.ATG" newType.BodyStartLocation = t.Location; EnumBody( -#line 478 "VBNET.ATG" +#line 480 "VBNET.ATG" newType); -#line 480 "VBNET.ATG" +#line 482 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -676,7 +682,7 @@ newType); case 112: { lexer.NextToken(); -#line 485 "VBNET.ATG" +#line 487 "VBNET.ATG" m.Check(Modifiers.VBInterfacs); TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); newType.StartLocation = m.GetDeclarationLocation(t.Location); @@ -686,28 +692,28 @@ newType); Identifier(); -#line 492 "VBNET.ATG" +#line 494 "VBNET.ATG" newType.Name = t.val; TypeParameterList( -#line 493 "VBNET.ATG" +#line 495 "VBNET.ATG" newType.Templates); EndOfStmt(); -#line 495 "VBNET.ATG" +#line 497 "VBNET.ATG" newType.BodyStartLocation = t.Location; while (la.kind == 110) { InterfaceBase( -#line 496 "VBNET.ATG" +#line 498 "VBNET.ATG" out baseInterfaces); -#line 496 "VBNET.ATG" +#line 498 "VBNET.ATG" newType.BaseTypes.AddRange(baseInterfaces); } InterfaceBody( -#line 497 "VBNET.ATG" +#line 499 "VBNET.ATG" newType); -#line 499 "VBNET.ATG" +#line 501 "VBNET.ATG" compilationUnit.BlockEnd(); break; @@ -715,7 +721,7 @@ newType); case 80: { lexer.NextToken(); -#line 504 "VBNET.ATG" +#line 506 "VBNET.ATG" m.Check(Modifiers.VBDelegates); DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); delegateDeclr.ReturnType = new TypeReference("", "System.Void"); @@ -726,63 +732,63 @@ newType); lexer.NextToken(); Identifier(); -#line 511 "VBNET.ATG" +#line 513 "VBNET.ATG" delegateDeclr.Name = t.val; TypeParameterList( -#line 512 "VBNET.ATG" +#line 514 "VBNET.ATG" delegateDeclr.Templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 513 "VBNET.ATG" +#line 515 "VBNET.ATG" p); } Expect(25); -#line 513 "VBNET.ATG" +#line 515 "VBNET.ATG" delegateDeclr.Parameters = p; } } else if (la.kind == 100) { lexer.NextToken(); Identifier(); -#line 515 "VBNET.ATG" +#line 517 "VBNET.ATG" delegateDeclr.Name = t.val; TypeParameterList( -#line 516 "VBNET.ATG" +#line 518 "VBNET.ATG" delegateDeclr.Templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 517 "VBNET.ATG" +#line 519 "VBNET.ATG" p); } Expect(25); -#line 517 "VBNET.ATG" +#line 519 "VBNET.ATG" delegateDeclr.Parameters = p; } if (la.kind == 48) { lexer.NextToken(); -#line 518 "VBNET.ATG" +#line 520 "VBNET.ATG" TypeReference type; TypeName( -#line 518 "VBNET.ATG" +#line 520 "VBNET.ATG" out type); -#line 518 "VBNET.ATG" +#line 520 "VBNET.ATG" delegateDeclr.ReturnType = type; } } else SynErr(214); -#line 520 "VBNET.ATG" +#line 522 "VBNET.ATG" delegateDeclr.EndLocation = t.EndLocation; Expect(1); -#line 523 "VBNET.ATG" +#line 525 "VBNET.ATG" compilationUnit.AddChild(delegateDeclr); break; @@ -1003,40 +1009,34 @@ out type); } void ClassBody( -#line 533 "VBNET.ATG" +#line 535 "VBNET.ATG" TypeDeclaration newType) { -#line 534 "VBNET.ATG" +#line 536 "VBNET.ATG" AttributeSection section; while (StartOf(7)) { -#line 536 "VBNET.ATG" +#line 538 "VBNET.ATG" List attributes = new List(); ModifierList m = new ModifierList(); while (la.kind == 27) { AttributeSection( -#line 539 "VBNET.ATG" +#line 541 "VBNET.ATG" out section); -#line 539 "VBNET.ATG" +#line 541 "VBNET.ATG" attributes.Add(section); } while (StartOf(8)) { MemberModifier( -#line 540 "VBNET.ATG" +#line 542 "VBNET.ATG" m); } ClassMemberDecl( -#line 541 "VBNET.ATG" +#line 543 "VBNET.ATG" m, attributes); } - Expect(88); - Expect(67); - -#line 543 "VBNET.ATG" - newType.EndLocation = t.EndLocation; - Expect(1); } void ModuleBody( diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG index 702aa2e8c0..2885ce8d83 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG @@ -423,6 +423,8 @@ NonModuleDeclaration attributes> [ ClassBaseType (. newType.BaseTypes.Add(typeRef); .) ] { TypeImplementsClause (. newType.BaseTypes.AddRange(baseInterfaces); .) } ClassBody + "End" "Class" (. newType.EndLocation = t.EndLocation; .) + EOL (. compilationUnit.BlockEnd(); .) @@ -540,8 +542,6 @@ ClassBody { MemberModifier } ClassMemberDecl } - "End" "Class" (. newType.EndLocation = t.EndLocation; .) - EOL . StructureBody diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs index 31850d4eaa..6a98d89078 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNetParser.cs @@ -65,6 +65,28 @@ namespace ICSharpCode.NRefactory.Parser.VB Expr(out expr); return expr; } + + public override BlockStatement ParseBlock() + { + lexer.NextToken(); + compilationUnit = new CompilationUnit(); + + Statement st; + Block(out st); + return st as BlockStatement; + } + + public override List ParseTypeMembers() + { + lexer.NextToken(); + compilationUnit = new CompilationUnit(); + + TypeDeclaration newType = new TypeDeclaration(Modifiers.None, null); + compilationUnit.BlockStart(newType); + ClassBody(newType); + compilationUnit.BlockEnd(); + return newType.Children; + } bool LeaveBlock() { diff --git a/src/Libraries/NRefactory/Project/Src/SnippetParser.cs b/src/Libraries/NRefactory/Project/Src/SnippetParser.cs new file mode 100644 index 0000000000..328b803195 --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/SnippetParser.cs @@ -0,0 +1,129 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.IO; +using ICSharpCode.NRefactory.Ast; +using ICSharpCode.NRefactory.Parser; + +namespace ICSharpCode.NRefactory +{ + /// + /// The snippet parser supports parsing code snippets that are not valid as a full compilation unit. + /// + public class SnippetParser + { + readonly SupportedLanguage language; + + public SnippetParser(SupportedLanguage language) + { + this.language = language; + } + + Errors errors; + List specials; + + /// + /// Gets the errors of the last call to Parse(). Returns null if parse was not yet called. + /// + public Errors Errors { + get { return errors; } + } + + /// + /// Gets the specials of the last call to Parse(). Returns null if parse was not yet called. + /// + public List Specials { + get { return specials; } + } + + /// + /// Parse the code. The result may be a CompilationUnit, an Expression, a BlockStatement or a list of class + /// members. + /// + public INode Parse(string code) + { + IParser parser = ParserFactory.CreateParser(language, new StringReader(code)); + parser.Parse(); + errors = parser.Errors; + specials = parser.Lexer.SpecialTracker.RetrieveSpecials(); + INode result = parser.CompilationUnit; + + if (errors.Count > 0) { + parser = ParserFactory.CreateParser(language, new StringReader(code)); + Expression expression = parser.ParseExpression(); + if (expression != null && parser.Errors.Count < errors.Count) { + errors = parser.Errors; + specials = parser.Lexer.SpecialTracker.RetrieveSpecials(); + result = expression; + } + } + if (errors.Count > 0) { + parser = ParserFactory.CreateParser(language, new StringReader(code)); + BlockStatement block = parser.ParseBlock(); + if (block != null && parser.Errors.Count < errors.Count) { + errors = parser.Errors; + specials = parser.Lexer.SpecialTracker.RetrieveSpecials(); + result = block; + } + } + if (errors.Count > 0) { + parser = ParserFactory.CreateParser(language, new StringReader(code)); + List members = parser.ParseTypeMembers(); + if (members != null && members.Count > 0 && parser.Errors.Count < errors.Count) { + errors = parser.Errors; + specials = parser.Lexer.SpecialTracker.RetrieveSpecials(); + result = new MemberListNode(members); + } + } + return result; + } + + sealed class MemberListNode : INode + { + List members; + + public MemberListNode(List members) + { + this.members = members; + } + + public INode Parent { + get { return null; } + set { throw new NotSupportedException(); } + } + + public List Children { + get { return members; } + } + + public Location StartLocation { + get { return Location.Empty; } + set { throw new NotSupportedException(); } + } + + public Location EndLocation { + get { return Location.Empty; } + set { throw new NotSupportedException(); } + } + + public object AcceptChildren(IAstVisitor visitor, object data) + { + foreach (INode n in members) { + n.AcceptVisitor(visitor, data); + } + return null; + } + + public object AcceptVisitor(IAstVisitor visitor, object data) + { + return AcceptChildren(visitor, data); + } + } + } +} diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/CSharpToVBNetConvertVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/CSharpToVBNetConvertVisitor.cs index 7e01474e4b..fe2380b27c 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/CSharpToVBNetConvertVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Visitors/CSharpToVBNetConvertVisitor.cs @@ -13,6 +13,7 @@ namespace ICSharpCode.NRefactory.Visitors /// /// This class converts C# constructs to their VB.NET equivalents. /// + [Obsolete("Use CSharpConstructsVisitor + ToVBNetConvertVisitor instead")] public class CSharpToVBNetConvertVisitor : CSharpConstructsVisitor { public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data) diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/VBNetToCSharpConvertVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/VBNetToCSharpConvertVisitor.cs index 8a24170fdf..3952e0d10a 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/VBNetToCSharpConvertVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Visitors/VBNetToCSharpConvertVisitor.cs @@ -15,6 +15,7 @@ namespace ICSharpCode.NRefactory.Visitors /// Applying the VBNetToCSharpConvertVisitor on a CompilationUnit has the same effect /// as applying the VBNetConstructsConvertVisitor and ToCSharpConvertVisitor. /// + [Obsolete("Use VBNetConstructsConvertVisitor + ToCSharpConvertVisitor instead")] public class VBNetToCSharpConvertVisitor : VBNetConstructsConvertVisitor { public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data) diff --git a/src/Libraries/NRefactory/Test/General/UnitTest.cs b/src/Libraries/NRefactory/Test/General/UnitTest.cs index 047ceedbe9..73f10d2b9f 100644 --- a/src/Libraries/NRefactory/Test/General/UnitTest.cs +++ b/src/Libraries/NRefactory/Test/General/UnitTest.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.NRefactory.Tests Type[] allTypes = typeof(INode).Assembly.GetTypes(); foreach (Type type in allTypes) { - if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null) { + if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null) { MethodInfo methodInfo = type.GetMethod("ToString", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); Assert.IsNotNull(methodInfo, "ToString() not found in " + type.FullName); } @@ -68,7 +68,7 @@ namespace ICSharpCode.NRefactory.Tests Type visitor = typeof(IAstVisitor); foreach (Type type in allTypes) { - if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { + if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { MethodInfo methodInfo = visitor.GetMethod("Visit" + type.Name, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.ExactBinding, null, new Type[] {type, typeof(object)}, null); Assert.IsNotNull(methodInfo, "Visit with parameter " + type.FullName + " not found"); Assert.AreEqual(2, methodInfo.GetParameters().Length); @@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.Tests Type visitor = typeof(AbstractAstVisitor); foreach (Type type in allTypes) { - if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { + if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { MethodInfo methodInfo = visitor.GetMethod("Visit" + type.Name, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.ExactBinding, null, new Type[] {type, typeof(object)}, null); Assert.IsNotNull(methodInfo, "Visit with parameter " + type.FullName + " not found"); diff --git a/src/Libraries/NRefactory/Test/NRefactoryTests.csproj b/src/Libraries/NRefactory/Test/NRefactoryTests.csproj index 369d7fe5c0..919b228af1 100644 --- a/src/Libraries/NRefactory/Test/NRefactoryTests.csproj +++ b/src/Libraries/NRefactory/Test/NRefactoryTests.csproj @@ -46,6 +46,7 @@ + diff --git a/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs b/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs index c30ed93eae..00cee6b35a 100644 --- a/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs @@ -24,7 +24,8 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(input)); parser.Parse(); Assert.AreEqual("", parser.Errors.ErrorOutput); - parser.CompilationUnit.AcceptVisitor(new VBNetToCSharpConvertVisitor(), null); + parser.CompilationUnit.AcceptVisitor(new VBNetConstructsConvertVisitor(), null); + parser.CompilationUnit.AcceptVisitor(new ToCSharpConvertVisitor(), null); CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor(); outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null); Assert.AreEqual("", outputVisitor.Errors.ErrorOutput); diff --git a/src/Libraries/NRefactory/Test/Output/SnippetConversion.cs b/src/Libraries/NRefactory/Test/Output/SnippetConversion.cs new file mode 100644 index 0000000000..68586c9050 --- /dev/null +++ b/src/Libraries/NRefactory/Test/Output/SnippetConversion.cs @@ -0,0 +1,107 @@ +// +// +// +// +// $Revision$ +// + +using System; +using NUnit.Framework; +using ICSharpCode.NRefactory.Ast; +using ICSharpCode.NRefactory.Visitors; +using ICSharpCode.NRefactory.PrettyPrinter; + +namespace ICSharpCode.NRefactory.Tests.Output +{ + [TestFixture] + public class SnippetConversion + { + void CS2VB(string input, string expectedOutput) + { + SnippetParser parser = new SnippetParser(SupportedLanguage.CSharp); + INode node = parser.Parse(input); + Assert.IsNotNull(node); + Assert.AreEqual("", parser.Errors.ErrorOutput); + PreprocessingDirective.CSharpToVB(parser.Specials); + node.AcceptVisitor(new CSharpConstructsVisitor(), null); + node.AcceptVisitor(new ToVBNetConvertVisitor(), null); + + VBNetOutputVisitor output = new VBNetOutputVisitor(); + using (SpecialNodesInserter.Install(parser.Specials, output)) { + node.AcceptVisitor(output, null); + } + Assert.AreEqual("", output.Errors.ErrorOutput); + Assert.AreEqual(expectedOutput, output.Text); + } + + [Test] + public void CompilationUnitCS2VB() + { + CS2VB( + @"using System; + +public class MyClass +{ + string abc; + + public string Abc { get { return abc; } } + + // This is a test method + static void M(params T[] args) where T : IDisposable + { + Console.WriteLine(""Hello!""); + } +}", + + @"Imports System + +Public Class [MyClass] + Private m_abc As String + + Public ReadOnly Property Abc() As String + Get + Return m_abc + End Get + End Property + + ' This is a test method + Private Shared Sub M(Of T As IDisposable)(ParamArray args As T()) + Console.WriteLine(""Hello!"") + End Sub +End Class +" + ); + } + + + + + [Test] + public void TypeMembersCS2VB() + { + CS2VB( + "void Test() {}\n" + + "void Test2() {}", + + @"Private Sub Test() +End Sub +Private Sub Test2() +End Sub +" + ); + } + + [Test] + public void StatementsCS2VB() + { + CS2VB( + "int a = 3;\n" + + "a++;", + + @"Dim a As Integer = 3 +a += 1 +" + ); + } + } +} diff --git a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs index a193e18390..8fa6f26059 100644 --- a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs @@ -24,7 +24,8 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(input)); parser.Parse(); Assert.AreEqual("", parser.Errors.ErrorOutput); - parser.CompilationUnit.AcceptVisitor(new CSharpToVBNetConvertVisitor(), null); + parser.CompilationUnit.AcceptVisitor(new CSharpConstructsVisitor(), null); + parser.CompilationUnit.AcceptVisitor(new ToVBNetConvertVisitor(), null); VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor(); outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null); Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);