From c3c5d155d39cafb1dbeb780fcecc135436e0cb87 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 21 May 2005 17:12:10 +0000 Subject: [PATCH] Fixed generic class and method declarations in C# parser. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@153 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/Libraries/NRefactory/NRefactory.sln | 4 +- .../NRefactory/Project/NRefactory.csproj | 2 +- .../General/TypeLevel/MethodDeclaration.cs | 11 + .../Project/Src/Parser/CSharp/Parser.cs | 1783 +++++++++-------- .../Project/Src/Parser/CSharp/cs.ATG | 33 +- .../GlobalScope/DelegateDeclarationTests.cs | 27 +- .../GlobalScope/TypeDeclarationTests.cs | 38 +- .../Parser/Statements/YieldStatementTests.cs | 51 + .../Parser/TypeLevel/EventDeclarationTests.cs | 4 +- .../TypeLevel/MethodDeclarationTests.cs | 42 + .../ParseableFileContentEnumerator.cs | 14 +- 11 files changed, 1089 insertions(+), 920 deletions(-) create mode 100644 src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs diff --git a/src/Libraries/NRefactory/NRefactory.sln b/src/Libraries/NRefactory/NRefactory.sln index 504ce46d46..d3cd2469c7 100644 --- a/src/Libraries/NRefactory/NRefactory.sln +++ b/src/Libraries/NRefactory/NRefactory.sln @@ -1,8 +1,8 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # SharpDevelop 2.0.0.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "Project\NRefactory.csproj", "{3a9ae6aa-bc07-4a2f-972c-581e3ae2f195}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.Tests", "Test\NRefactoryTests.csproj", "{870115dd-960a-4406-a6b9-600bcdc36a03}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "Project\NRefactory.csproj", "{3a9ae6aa-bc07-4a2f-972c-581e3ae2f195}" +EndProject Global EndGlobal diff --git a/src/Libraries/NRefactory/Project/NRefactory.csproj b/src/Libraries/NRefactory/Project/NRefactory.csproj index ff1ebca922..2c53850812 100644 --- a/src/Libraries/NRefactory/Project/NRefactory.csproj +++ b/src/Libraries/NRefactory/Project/NRefactory.csproj @@ -4,7 +4,7 @@ AnyCPU 8.0.41115 2.0 - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} + {3a9ae6aa-bc07-4a2f-972c-581e3ae2f195} ICSharpCode.NRefactory ICSharpCode.NRefactory Library diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeLevel/MethodDeclaration.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeLevel/MethodDeclaration.cs index 68f60dcc09..5ee7be0fb7 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeLevel/MethodDeclaration.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeLevel/MethodDeclaration.cs @@ -18,6 +18,7 @@ using System; using System.Diagnostics; using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; namespace ICSharpCode.NRefactory.Parser.AST @@ -29,6 +30,16 @@ namespace ICSharpCode.NRefactory.Parser.AST ArrayList handlesClause = new ArrayList(); // VB only ArrayList implementsClause = new ArrayList(); // VB only AttributeSection returnTypeAttributeSection = AttributeSection.Null; + List templates = new List(); + + public List Templates { + get { + return templates; + } + set { + templates = value; + } + } public AttributeSection ReturnTypeAttributeSection { get { diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 329c34d61e..e32291684e 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -551,25 +551,25 @@ m, attributes); } void Qualident( -#line 766 "cs.ATG" +#line 767 "cs.ATG" out string qualident) { Expect(1); -#line 768 "cs.ATG" +#line 769 "cs.ATG" qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); while ( -#line 769 "cs.ATG" +#line 770 "cs.ATG" DotAndIdent()) { Expect(14); Expect(1); -#line 769 "cs.ATG" +#line 770 "cs.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(t.val); } -#line 772 "cs.ATG" +#line 773 "cs.ATG" qualident = qualidentBuilder.ToString(); } @@ -663,43 +663,43 @@ out expr); } void Expr( -#line 1793 "cs.ATG" +#line 1800 "cs.ATG" out Expression expr) { -#line 1794 "cs.ATG" +#line 1801 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; UnaryExpr( -#line 1796 "cs.ATG" +#line 1803 "cs.ATG" out expr); if (StartOf(5)) { ConditionalOrExpr( -#line 1799 "cs.ATG" +#line 1806 "cs.ATG" ref expr); if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1799 "cs.ATG" +#line 1806 "cs.ATG" out expr1); Expect(9); Expr( -#line 1799 "cs.ATG" +#line 1806 "cs.ATG" out expr2); -#line 1799 "cs.ATG" +#line 1806 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else if (StartOf(6)) { -#line 1801 "cs.ATG" +#line 1808 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1801 "cs.ATG" +#line 1808 "cs.ATG" out op); Expr( -#line 1801 "cs.ATG" +#line 1808 "cs.ATG" out val); -#line 1801 "cs.ATG" +#line 1808 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else SynErr(127); } @@ -775,76 +775,76 @@ out attribute); } void TypeModifier( -#line 942 "cs.ATG" +#line 943 "cs.ATG" Modifiers m) { switch (la.kind) { case 87: { lexer.NextToken(); -#line 944 "cs.ATG" +#line 945 "cs.ATG" m.Add(Modifier.New); break; } case 96: { lexer.NextToken(); -#line 945 "cs.ATG" +#line 946 "cs.ATG" m.Add(Modifier.Public); break; } case 95: { lexer.NextToken(); -#line 946 "cs.ATG" +#line 947 "cs.ATG" m.Add(Modifier.Protected); break; } case 82: { lexer.NextToken(); -#line 947 "cs.ATG" +#line 948 "cs.ATG" m.Add(Modifier.Internal); break; } case 94: { lexer.NextToken(); -#line 948 "cs.ATG" +#line 949 "cs.ATG" m.Add(Modifier.Private); break; } case 117: { lexer.NextToken(); -#line 949 "cs.ATG" +#line 950 "cs.ATG" m.Add(Modifier.Unsafe); break; } case 47: { lexer.NextToken(); -#line 950 "cs.ATG" +#line 951 "cs.ATG" m.Add(Modifier.Abstract); break; } case 101: { lexer.NextToken(); -#line 951 "cs.ATG" +#line 952 "cs.ATG" m.Add(Modifier.Sealed); break; } case 105: { lexer.NextToken(); -#line 952 "cs.ATG" +#line 953 "cs.ATG" m.Add(Modifier.Static); break; } case 1: { lexer.NextToken(); -#line 953 "cs.ATG" +#line 954 "cs.ATG" if (t.val == "partial") { m.Add(Modifier.Partial); } break; } @@ -861,7 +861,7 @@ Modifiers m, ArrayList attributes) { ArrayList names; ArrayList p; string name; - List templates = new List(); + List templates; if (la.kind == 57) { @@ -871,6 +871,7 @@ Modifiers m, ArrayList attributes) { #line 672 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); @@ -878,29 +879,29 @@ Modifiers m, ArrayList attributes) { Expect(1); -#line 678 "cs.ATG" +#line 679 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 681 "cs.ATG" +#line 682 "cs.ATG" templates); } if (la.kind == 9) { ClassBase( -#line 683 "cs.ATG" +#line 684 "cs.ATG" out names); -#line 683 "cs.ATG" +#line 684 "cs.ATG" newType.BaseTypes = names; } -#line 683 "cs.ATG" +#line 684 "cs.ATG" newType.StartLocation = t.EndLocation; while ( -#line 686 "cs.ATG" +#line 687 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 686 "cs.ATG" +#line 687 "cs.ATG" templates); } ClassBody(); @@ -908,49 +909,49 @@ templates); lexer.NextToken(); } -#line 689 "cs.ATG" +#line 690 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (StartOf(7)) { -#line 692 "cs.ATG" +#line 693 "cs.ATG" m.Check(Modifier.StructsInterfacesEnumsDelegates); if (la.kind == 107) { lexer.NextToken(); -#line 693 "cs.ATG" +#line 694 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); - newType.Templates = templates; + templates = newType.Templates; compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Type = Types.Struct; Expect(1); -#line 699 "cs.ATG" +#line 700 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 702 "cs.ATG" +#line 703 "cs.ATG" templates); } if (la.kind == 9) { StructInterfaces( -#line 704 "cs.ATG" +#line 705 "cs.ATG" out names); -#line 704 "cs.ATG" +#line 705 "cs.ATG" newType.BaseTypes = names; } -#line 704 "cs.ATG" +#line 705 "cs.ATG" newType.StartLocation = t.EndLocation; while ( -#line 707 "cs.ATG" +#line 708 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 707 "cs.ATG" +#line 708 "cs.ATG" templates); } StructBody(); @@ -958,45 +959,45 @@ templates); lexer.NextToken(); } -#line 711 "cs.ATG" +#line 712 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 81) { lexer.NextToken(); -#line 715 "cs.ATG" +#line 716 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); - newType.Templates = templates; + templates = newType.Templates; compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Type = Types.Interface; Expect(1); -#line 721 "cs.ATG" +#line 722 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 724 "cs.ATG" +#line 725 "cs.ATG" templates); } if (la.kind == 9) { InterfaceBase( -#line 726 "cs.ATG" +#line 727 "cs.ATG" out names); -#line 726 "cs.ATG" +#line 727 "cs.ATG" newType.BaseTypes = names; } -#line 726 "cs.ATG" +#line 727 "cs.ATG" newType.StartLocation = t.EndLocation; while ( -#line 729 "cs.ATG" +#line 730 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 729 "cs.ATG" +#line 730 "cs.ATG" templates); } InterfaceBody(); @@ -1004,14 +1005,14 @@ templates); lexer.NextToken(); } -#line 732 "cs.ATG" +#line 733 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 66) { lexer.NextToken(); -#line 736 "cs.ATG" +#line 737 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); @@ -1019,70 +1020,70 @@ templates); Expect(1); -#line 741 "cs.ATG" +#line 742 "cs.ATG" newType.Name = t.val; if (la.kind == 9) { lexer.NextToken(); IntegralType( -#line 742 "cs.ATG" +#line 743 "cs.ATG" out name); -#line 742 "cs.ATG" +#line 743 "cs.ATG" newType.BaseTypes = new ArrayList(); newType.BaseTypes.Add(name); } -#line 745 "cs.ATG" +#line 746 "cs.ATG" newType.StartLocation = t.EndLocation; EnumBody(); if (la.kind == 11) { lexer.NextToken(); } -#line 747 "cs.ATG" +#line 748 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else { lexer.NextToken(); -#line 751 "cs.ATG" +#line 752 "cs.ATG" DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); delegateDeclr.StartLocation = t.Location; if ( -#line 754 "cs.ATG" +#line 755 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 754 "cs.ATG" +#line 755 "cs.ATG" delegateDeclr.ReturnType = new TypeReference("void", 0, null); } else if (StartOf(8)) { Type( -#line 755 "cs.ATG" +#line 756 "cs.ATG" out type); -#line 755 "cs.ATG" +#line 756 "cs.ATG" delegateDeclr.ReturnType = type; } else SynErr(129); Expect(1); -#line 757 "cs.ATG" +#line 758 "cs.ATG" delegateDeclr.Name = t.val; Expect(19); if (StartOf(9)) { FormalParameterList( -#line 758 "cs.ATG" +#line 759 "cs.ATG" out p); -#line 758 "cs.ATG" +#line 759 "cs.ATG" delegateDeclr.Parameters = p; } Expect(20); Expect(11); -#line 760 "cs.ATG" +#line 761 "cs.ATG" delegateDeclr.EndLocation = t.Location; compilationUnit.AddChild(delegateDeclr); @@ -1091,91 +1092,91 @@ out p); } void TypeParameterList( -#line 2112 "cs.ATG" +#line 2119 "cs.ATG" List templates) { -#line 2114 "cs.ATG" +#line 2121 "cs.ATG" AttributeSection section; ArrayList attributes = new ArrayList(); Expect(22); while (la.kind == 17) { AttributeSection( -#line 2118 "cs.ATG" +#line 2125 "cs.ATG" out section); -#line 2118 "cs.ATG" +#line 2125 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2119 "cs.ATG" +#line 2126 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 13) { lexer.NextToken(); while (la.kind == 17) { AttributeSection( -#line 2120 "cs.ATG" +#line 2127 "cs.ATG" out section); -#line 2120 "cs.ATG" +#line 2127 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2121 "cs.ATG" +#line 2128 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(21); } void ClassBase( -#line 775 "cs.ATG" +#line 776 "cs.ATG" out ArrayList names) { -#line 777 "cs.ATG" +#line 778 "cs.ATG" string qualident; names = new ArrayList(); List types; Expect(9); ClassType( -#line 782 "cs.ATG" +#line 783 "cs.ATG" out qualident, out types); -#line 782 "cs.ATG" +#line 783 "cs.ATG" names.Add(qualident); // TODO: enter the types while (la.kind == 13) { lexer.NextToken(); Qualident( -#line 783 "cs.ATG" +#line 784 "cs.ATG" out qualident); -#line 783 "cs.ATG" +#line 784 "cs.ATG" names.Add(qualident); } } void TypeParameterConstraintsClause( -#line 2125 "cs.ATG" +#line 2132 "cs.ATG" List templates) { -#line 2126 "cs.ATG" +#line 2133 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2128 "cs.ATG" +#line 2135 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2129 "cs.ATG" +#line 2136 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2131 "cs.ATG" +#line 2138 "cs.ATG" out type); -#line 2132 "cs.ATG" +#line 2139 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1188,10 +1189,10 @@ out type); while (la.kind == 13) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2141 "cs.ATG" +#line 2148 "cs.ATG" out type); -#line 2142 "cs.ATG" +#line 2149 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1206,114 +1207,114 @@ out type); void ClassBody() { -#line 787 "cs.ATG" +#line 788 "cs.ATG" AttributeSection section; Expect(15); while (StartOf(10)) { -#line 790 "cs.ATG" +#line 791 "cs.ATG" ArrayList attributes = new ArrayList(); Modifiers m = new Modifiers(); while (la.kind == 17) { AttributeSection( -#line 793 "cs.ATG" +#line 794 "cs.ATG" out section); -#line 793 "cs.ATG" +#line 794 "cs.ATG" attributes.Add(section); } while (StartOf(11)) { MemberModifier( -#line 794 "cs.ATG" +#line 795 "cs.ATG" m); } ClassMemberDecl( -#line 795 "cs.ATG" +#line 796 "cs.ATG" m, attributes); } Expect(16); } void StructInterfaces( -#line 800 "cs.ATG" +#line 801 "cs.ATG" out ArrayList names) { -#line 802 "cs.ATG" +#line 803 "cs.ATG" string qualident; names = new ArrayList(); Expect(9); Qualident( -#line 806 "cs.ATG" +#line 807 "cs.ATG" out qualident); -#line 806 "cs.ATG" +#line 807 "cs.ATG" names.Add(qualident); while (la.kind == 13) { lexer.NextToken(); Qualident( -#line 807 "cs.ATG" +#line 808 "cs.ATG" out qualident); -#line 807 "cs.ATG" +#line 808 "cs.ATG" names.Add(qualident); } } void StructBody() { -#line 811 "cs.ATG" +#line 812 "cs.ATG" AttributeSection section; Expect(15); while (StartOf(12)) { -#line 814 "cs.ATG" +#line 815 "cs.ATG" ArrayList attributes = new ArrayList(); Modifiers m = new Modifiers(); while (la.kind == 17) { AttributeSection( -#line 817 "cs.ATG" +#line 818 "cs.ATG" out section); -#line 817 "cs.ATG" +#line 818 "cs.ATG" attributes.Add(section); } while (StartOf(11)) { MemberModifier( -#line 818 "cs.ATG" +#line 819 "cs.ATG" m); } StructMemberDecl( -#line 819 "cs.ATG" +#line 820 "cs.ATG" m, attributes); } Expect(16); } void InterfaceBase( -#line 824 "cs.ATG" +#line 825 "cs.ATG" out ArrayList names) { -#line 826 "cs.ATG" +#line 827 "cs.ATG" string qualident; names = new ArrayList(); Expect(9); Qualident( -#line 830 "cs.ATG" +#line 831 "cs.ATG" out qualident); -#line 830 "cs.ATG" +#line 831 "cs.ATG" names.Add(qualident); while (la.kind == 13) { lexer.NextToken(); Qualident( -#line 831 "cs.ATG" +#line 832 "cs.ATG" out qualident); -#line 831 "cs.ATG" +#line 832 "cs.ATG" names.Add(qualident); } } @@ -1327,72 +1328,72 @@ out qualident); } void IntegralType( -#line 967 "cs.ATG" +#line 968 "cs.ATG" out string name) { -#line 967 "cs.ATG" +#line 968 "cs.ATG" name = ""; switch (la.kind) { case 100: { lexer.NextToken(); -#line 969 "cs.ATG" +#line 970 "cs.ATG" name = "sbyte"; break; } case 52: { lexer.NextToken(); -#line 970 "cs.ATG" +#line 971 "cs.ATG" name = "byte"; break; } case 102: { lexer.NextToken(); -#line 971 "cs.ATG" +#line 972 "cs.ATG" name = "short"; break; } case 118: { lexer.NextToken(); -#line 972 "cs.ATG" +#line 973 "cs.ATG" name = "ushort"; break; } case 80: { lexer.NextToken(); -#line 973 "cs.ATG" +#line 974 "cs.ATG" name = "int"; break; } case 114: { lexer.NextToken(); -#line 974 "cs.ATG" +#line 975 "cs.ATG" name = "uint"; break; } case 85: { lexer.NextToken(); -#line 975 "cs.ATG" +#line 976 "cs.ATG" name = "long"; break; } case 115: { lexer.NextToken(); -#line 976 "cs.ATG" +#line 977 "cs.ATG" name = "ulong"; break; } case 55: { lexer.NextToken(); -#line 977 "cs.ATG" +#line 978 "cs.ATG" name = "char"; break; } @@ -1402,25 +1403,25 @@ out string name) { void EnumBody() { -#line 837 "cs.ATG" +#line 838 "cs.ATG" FieldDeclaration f; Expect(15); if (la.kind == 1 || la.kind == 17) { EnumMemberDecl( -#line 839 "cs.ATG" +#line 840 "cs.ATG" out f); -#line 839 "cs.ATG" +#line 840 "cs.ATG" compilationUnit.AddChild(f); while ( -#line 840 "cs.ATG" +#line 841 "cs.ATG" NotFinalComma()) { Expect(13); EnumMemberDecl( -#line 840 "cs.ATG" +#line 841 "cs.ATG" out f); -#line 840 "cs.ATG" +#line 841 "cs.ATG" compilationUnit.AddChild(f); } if (la.kind == 13) { @@ -1431,10 +1432,10 @@ out f); } void Type( -#line 845 "cs.ATG" +#line 846 "cs.ATG" out TypeReference type) { -#line 847 "cs.ATG" +#line 848 "cs.ATG" string name = ""; int pointer = 0; List types = null; @@ -1442,59 +1443,59 @@ out TypeReference type) { if (la.kind == 1 || la.kind == 89 || la.kind == 106) { ClassType( -#line 853 "cs.ATG" +#line 854 "cs.ATG" out name, out types); } else if (StartOf(14)) { SimpleType( -#line 854 "cs.ATG" +#line 855 "cs.ATG" out name); } else if (la.kind == 121) { lexer.NextToken(); Expect(6); -#line 855 "cs.ATG" +#line 856 "cs.ATG" pointer = 1; name = "void"; } else SynErr(132); -#line 856 "cs.ATG" +#line 857 "cs.ATG" ArrayList r = new ArrayList(); while ( -#line 858 "cs.ATG" +#line 859 "cs.ATG" IsPointerOrDims()) { -#line 858 "cs.ATG" +#line 859 "cs.ATG" int i = 0; if (la.kind == 6) { lexer.NextToken(); -#line 859 "cs.ATG" +#line 860 "cs.ATG" ++pointer; } else if (la.kind == 17) { lexer.NextToken(); while (la.kind == 13) { lexer.NextToken(); -#line 860 "cs.ATG" +#line 861 "cs.ATG" ++i; } Expect(18); -#line 860 "cs.ATG" +#line 861 "cs.ATG" r.Add(i); } else SynErr(133); } -#line 862 "cs.ATG" +#line 863 "cs.ATG" int[] rank = new int[r.Count]; r.CopyTo(rank); type = new TypeReference(name, pointer, rank, types); } void FormalParameterList( -#line 897 "cs.ATG" +#line 898 "cs.ATG" out ArrayList parameter) { -#line 899 "cs.ATG" +#line 900 "cs.ATG" parameter = new ArrayList(); ParameterDeclarationExpression p; AttributeSection section; @@ -1502,18 +1503,18 @@ out ArrayList parameter) { while (la.kind == 17) { AttributeSection( -#line 905 "cs.ATG" +#line 906 "cs.ATG" out section); -#line 905 "cs.ATG" +#line 906 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 907 "cs.ATG" +#line 908 "cs.ATG" out p); -#line 907 "cs.ATG" +#line 908 "cs.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1521,170 +1522,170 @@ out p); while (la.kind == 13) { lexer.NextToken(); -#line 912 "cs.ATG" +#line 913 "cs.ATG" attributes = new ArrayList(); if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 17) { AttributeSection( -#line 913 "cs.ATG" +#line 914 "cs.ATG" out section); -#line 913 "cs.ATG" +#line 914 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 915 "cs.ATG" +#line 916 "cs.ATG" out p); -#line 915 "cs.ATG" +#line 916 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else if (la.kind == 93) { ParameterArray( -#line 916 "cs.ATG" +#line 917 "cs.ATG" out p); -#line 916 "cs.ATG" +#line 917 "cs.ATG" paramsFound = true; p.Attributes = attributes; parameter.Add(p); } else SynErr(134); } } else if (la.kind == 93) { ParameterArray( -#line 919 "cs.ATG" +#line 920 "cs.ATG" out p); -#line 919 "cs.ATG" +#line 920 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else SynErr(135); } void ClassType( -#line 956 "cs.ATG" +#line 957 "cs.ATG" out string name, out List types) { -#line 957 "cs.ATG" +#line 958 "cs.ATG" string qualident; name = ""; List t; types = null; if (la.kind == 1) { TypeName( -#line 962 "cs.ATG" +#line 963 "cs.ATG" out qualident, out t); -#line 962 "cs.ATG" +#line 963 "cs.ATG" name = qualident; types = t; } else if (la.kind == 89) { lexer.NextToken(); -#line 963 "cs.ATG" +#line 964 "cs.ATG" name = "object"; } else if (la.kind == 106) { lexer.NextToken(); -#line 964 "cs.ATG" +#line 965 "cs.ATG" name = "string"; } else SynErr(136); } void MemberModifier( -#line 980 "cs.ATG" +#line 981 "cs.ATG" Modifiers m) { switch (la.kind) { case 47: { lexer.NextToken(); -#line 982 "cs.ATG" +#line 983 "cs.ATG" m.Add(Modifier.Abstract); break; } case 69: { lexer.NextToken(); -#line 983 "cs.ATG" +#line 984 "cs.ATG" m.Add(Modifier.Extern); break; } case 82: { lexer.NextToken(); -#line 984 "cs.ATG" +#line 985 "cs.ATG" m.Add(Modifier.Internal); break; } case 87: { lexer.NextToken(); -#line 985 "cs.ATG" +#line 986 "cs.ATG" m.Add(Modifier.New); break; } case 92: { lexer.NextToken(); -#line 986 "cs.ATG" +#line 987 "cs.ATG" m.Add(Modifier.Override); break; } case 94: { lexer.NextToken(); -#line 987 "cs.ATG" +#line 988 "cs.ATG" m.Add(Modifier.Private); break; } case 95: { lexer.NextToken(); -#line 988 "cs.ATG" +#line 989 "cs.ATG" m.Add(Modifier.Protected); break; } case 96: { lexer.NextToken(); -#line 989 "cs.ATG" +#line 990 "cs.ATG" m.Add(Modifier.Public); break; } case 97: { lexer.NextToken(); -#line 990 "cs.ATG" +#line 991 "cs.ATG" m.Add(Modifier.Readonly); break; } case 101: { lexer.NextToken(); -#line 991 "cs.ATG" +#line 992 "cs.ATG" m.Add(Modifier.Sealed); break; } case 105: { lexer.NextToken(); -#line 992 "cs.ATG" +#line 993 "cs.ATG" m.Add(Modifier.Static); break; } case 117: { lexer.NextToken(); -#line 993 "cs.ATG" +#line 994 "cs.ATG" m.Add(Modifier.Unsafe); break; } case 120: { lexer.NextToken(); -#line 994 "cs.ATG" +#line 995 "cs.ATG" m.Add(Modifier.Virtual); break; } case 122: { lexer.NextToken(); -#line 995 "cs.ATG" +#line 996 "cs.ATG" m.Add(Modifier.Volatile); break; } @@ -1693,23 +1694,23 @@ Modifiers m) { } void ClassMemberDecl( -#line 1222 "cs.ATG" +#line 1229 "cs.ATG" Modifiers m, ArrayList attributes) { -#line 1223 "cs.ATG" +#line 1230 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 1225 "cs.ATG" +#line 1232 "cs.ATG" m, attributes); } else if (la.kind == 26) { -#line 1226 "cs.ATG" +#line 1233 "cs.ATG" m.Check(Modifier.Destructors); Point startPos = t.Location; lexer.NextToken(); Expect(1); -#line 1227 "cs.ATG" +#line 1234 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = startPos; @@ -1717,17 +1718,17 @@ m, attributes); Expect(19); Expect(20); -#line 1231 "cs.ATG" +#line 1238 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 15) { Block( -#line 1231 "cs.ATG" +#line 1238 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(138); -#line 1232 "cs.ATG" +#line 1239 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1735,10 +1736,10 @@ out stmt); } void StructMemberDecl( -#line 998 "cs.ATG" +#line 999 "cs.ATG" Modifiers m, ArrayList attributes) { -#line 1000 "cs.ATG" +#line 1001 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1749,18 +1750,18 @@ Modifiers m, ArrayList attributes) { if (la.kind == 58) { -#line 1009 "cs.ATG" +#line 1010 "cs.ATG" m.Check(Modifier.Constants); lexer.NextToken(); -#line 1010 "cs.ATG" +#line 1011 "cs.ATG" Point startPos = t.Location; Type( -#line 1011 "cs.ATG" +#line 1012 "cs.ATG" out type); Expect(1); -#line 1011 "cs.ATG" +#line 1012 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const); fd.StartLocation = startPos; VariableDeclaration f = new VariableDeclaration(t.val); @@ -1768,58 +1769,58 @@ out type); Expect(3); Expr( -#line 1016 "cs.ATG" +#line 1017 "cs.ATG" out expr); -#line 1016 "cs.ATG" +#line 1017 "cs.ATG" f.Initializer = expr; while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1017 "cs.ATG" +#line 1018 "cs.ATG" f = new VariableDeclaration(t.val); fd.Fields.Add(f); Expect(3); Expr( -#line 1020 "cs.ATG" +#line 1021 "cs.ATG" out expr); -#line 1020 "cs.ATG" +#line 1021 "cs.ATG" f.Initializer = expr; } Expect(11); -#line 1021 "cs.ATG" +#line 1022 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( -#line 1024 "cs.ATG" +#line 1025 "cs.ATG" NotVoidPointer()) { -#line 1024 "cs.ATG" +#line 1025 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); Expect(121); -#line 1025 "cs.ATG" +#line 1026 "cs.ATG" Point startPos = t.Location; Qualident( -#line 1026 "cs.ATG" +#line 1027 "cs.ATG" out qualident); if (la.kind == 22) { TypeParameterList( -#line 1028 "cs.ATG" +#line 1029 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1031 "cs.ATG" +#line 1032 "cs.ATG" out p); } Expect(20); -#line 1031 "cs.ATG" +#line 1032 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, new TypeReference("void"), @@ -1827,35 +1828,36 @@ out p); attributes); methodDeclaration.StartLocation = startPos; methodDeclaration.EndLocation = t.EndLocation; + methodDeclaration.Templates = templates; compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); while ( -#line 1043 "cs.ATG" +#line 1045 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1043 "cs.ATG" +#line 1045 "cs.ATG" templates); } if (la.kind == 15) { Block( -#line 1045 "cs.ATG" +#line 1047 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(140); -#line 1045 "cs.ATG" +#line 1047 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 67) { -#line 1049 "cs.ATG" +#line 1051 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); lexer.NextToken(); -#line 1050 "cs.ATG" +#line 1052 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); @@ -1864,103 +1866,103 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 1057 "cs.ATG" +#line 1059 "cs.ATG" out type); -#line 1057 "cs.ATG" +#line 1059 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 1059 "cs.ATG" +#line 1061 "cs.ATG" IsVarDecl()) { VariableDeclarator( -#line 1059 "cs.ATG" +#line 1061 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1060 "cs.ATG" +#line 1062 "cs.ATG" variableDeclarators); } Expect(11); -#line 1060 "cs.ATG" +#line 1062 "cs.ATG" eventDecl.VariableDeclarators = variableDeclarators; eventDecl.EndLocation = t.EndLocation; } else if (la.kind == 1) { Qualident( -#line 1061 "cs.ATG" +#line 1063 "cs.ATG" out qualident); -#line 1061 "cs.ATG" +#line 1063 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; Expect(15); -#line 1062 "cs.ATG" +#line 1064 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 1063 "cs.ATG" +#line 1065 "cs.ATG" out addBlock, out removeBlock); Expect(16); -#line 1064 "cs.ATG" +#line 1066 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } else SynErr(141); -#line 1065 "cs.ATG" +#line 1067 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 1072 "cs.ATG" +#line 1074 "cs.ATG" IdentAndLPar()) { -#line 1072 "cs.ATG" +#line 1074 "cs.ATG" m.Check(Modifier.Constructors | Modifier.StaticConstructors); Expect(1); -#line 1073 "cs.ATG" +#line 1075 "cs.ATG" string name = t.val; Point startPos = t.Location; Expect(19); if (StartOf(9)) { -#line 1073 "cs.ATG" +#line 1075 "cs.ATG" m.Check(Modifier.Constructors); FormalParameterList( -#line 1074 "cs.ATG" +#line 1076 "cs.ATG" out p); } Expect(20); -#line 1076 "cs.ATG" +#line 1078 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 1077 "cs.ATG" +#line 1079 "cs.ATG" m.Check(Modifier.Constructors); ConstructorInitializer( -#line 1078 "cs.ATG" +#line 1080 "cs.ATG" out init); } -#line 1080 "cs.ATG" +#line 1082 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 15) { Block( -#line 1085 "cs.ATG" +#line 1087 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(142); -#line 1085 "cs.ATG" +#line 1087 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 68 || la.kind == 78) { -#line 1088 "cs.ATG" +#line 1090 "cs.ATG" m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -1970,37 +1972,37 @@ out stmt); } else { lexer.NextToken(); -#line 1092 "cs.ATG" +#line 1094 "cs.ATG" isImplicit = false; } Expect(90); Type( -#line 1093 "cs.ATG" +#line 1095 "cs.ATG" out type); -#line 1093 "cs.ATG" +#line 1095 "cs.ATG" TypeReference operatorType = type; Expect(19); Type( -#line 1094 "cs.ATG" +#line 1096 "cs.ATG" out type); Expect(1); -#line 1094 "cs.ATG" +#line 1096 "cs.ATG" string varName = t.val; Expect(20); if (la.kind == 15) { Block( -#line 1094 "cs.ATG" +#line 1096 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 1094 "cs.ATG" +#line 1096 "cs.ATG" stmt = null; } else SynErr(143); -#line 1097 "cs.ATG" +#line 1099 "cs.ATG" ArrayList parameters = new ArrayList(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -2014,58 +2016,58 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 1110 "cs.ATG" +#line 1112 "cs.ATG" m, attributes); } else if (StartOf(8)) { Type( -#line 1111 "cs.ATG" +#line 1113 "cs.ATG" out type); -#line 1111 "cs.ATG" +#line 1113 "cs.ATG" Point startPos = t.Location; if (la.kind == 90) { -#line 1113 "cs.ATG" +#line 1115 "cs.ATG" OverloadableOperatorType op; m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 1117 "cs.ATG" +#line 1119 "cs.ATG" out op); -#line 1117 "cs.ATG" +#line 1119 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(19); Type( -#line 1118 "cs.ATG" +#line 1120 "cs.ATG" out firstType); Expect(1); -#line 1118 "cs.ATG" +#line 1120 "cs.ATG" string firstName = t.val; if (la.kind == 13) { lexer.NextToken(); Type( -#line 1119 "cs.ATG" +#line 1121 "cs.ATG" out secondType); Expect(1); -#line 1119 "cs.ATG" +#line 1121 "cs.ATG" secondName = t.val; } else if (la.kind == 20) { } else SynErr(144); Expect(20); if (la.kind == 15) { Block( -#line 1127 "cs.ATG" +#line 1129 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(145); -#line 1129 "cs.ATG" +#line 1131 "cs.ATG" ArrayList parameters = new ArrayList(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -2080,43 +2082,43 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 1144 "cs.ATG" +#line 1146 "cs.ATG" IsVarDecl()) { -#line 1144 "cs.ATG" +#line 1146 "cs.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = startPos; VariableDeclarator( -#line 1148 "cs.ATG" +#line 1150 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1149 "cs.ATG" +#line 1151 "cs.ATG" variableDeclarators); } Expect(11); -#line 1150 "cs.ATG" +#line 1152 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 109) { -#line 1153 "cs.ATG" +#line 1155 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(17); FormalParameterList( -#line 1154 "cs.ATG" +#line 1156 "cs.ATG" out p); Expect(18); -#line 1154 "cs.ATG" +#line 1156 "cs.ATG" Point endLocation = t.EndLocation; Expect(15); -#line 1155 "cs.ATG" +#line 1157 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2125,11 +2127,11 @@ out p); PropertySetRegion setRegion; AccessorDecls( -#line 1162 "cs.ATG" +#line 1164 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1163 "cs.ATG" +#line 1165 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; @@ -2137,48 +2139,61 @@ out getRegion, out setRegion); } else if (la.kind == 1) { Qualident( -#line 1168 "cs.ATG" +#line 1170 "cs.ATG" out qualident); -#line 1168 "cs.ATG" +#line 1170 "cs.ATG" Point qualIdentEndLocation = t.EndLocation; - if (la.kind == 15 || la.kind == 19) { - if (la.kind == 19) { + if (la.kind == 15 || la.kind == 19 || la.kind == 22) { + if (la.kind == 19 || la.kind == 22) { -#line 1171 "cs.ATG" +#line 1173 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); - lexer.NextToken(); + if (la.kind == 22) { + TypeParameterList( +#line 1175 "cs.ATG" +templates); + } + Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1172 "cs.ATG" +#line 1176 "cs.ATG" out p); } Expect(20); -#line 1172 "cs.ATG" - MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, - m.Modifier, - type, - p, - attributes); - methodDeclaration.StartLocation = startPos; - methodDeclaration.EndLocation = t.EndLocation; - compilationUnit.AddChild(methodDeclaration); - +#line 1177 "cs.ATG" + MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, + m.Modifier, + type, + p, + attributes); + methodDeclaration.StartLocation = startPos; + methodDeclaration.EndLocation = t.EndLocation; + methodDeclaration.Templates = templates; + compilationUnit.AddChild(methodDeclaration); + + while ( +#line 1187 "cs.ATG" +IdentIsWhere()) { + TypeParameterConstraintsClause( +#line 1187 "cs.ATG" +templates); + } if (la.kind == 15) { Block( -#line 1181 "cs.ATG" +#line 1188 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(146); -#line 1181 "cs.ATG" +#line 1188 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1184 "cs.ATG" +#line 1191 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); pDecl.StartLocation = startPos; pDecl.EndLocation = qualIdentEndLocation; @@ -2187,11 +2202,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1191 "cs.ATG" +#line 1198 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1193 "cs.ATG" +#line 1200 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2200,17 +2215,17 @@ out getRegion, out setRegion); } } else if (la.kind == 14) { -#line 1201 "cs.ATG" +#line 1208 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(109); Expect(17); FormalParameterList( -#line 1202 "cs.ATG" +#line 1209 "cs.ATG" out p); Expect(18); -#line 1203 "cs.ATG" +#line 1210 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = t.EndLocation; @@ -2220,14 +2235,14 @@ out p); Expect(15); -#line 1210 "cs.ATG" +#line 1217 "cs.ATG" Point bodyStart = t.Location; AccessorDecls( -#line 1211 "cs.ATG" +#line 1218 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1212 "cs.ATG" +#line 1219 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2241,7 +2256,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1239 "cs.ATG" +#line 1246 "cs.ATG" TypeReference type; ArrayList p; AttributeSection section; @@ -2256,39 +2271,39 @@ out getRegion, out setRegion); while (la.kind == 17) { AttributeSection( -#line 1252 "cs.ATG" +#line 1259 "cs.ATG" out section); -#line 1252 "cs.ATG" +#line 1259 "cs.ATG" attributes.Add(section); } if (la.kind == 87) { lexer.NextToken(); -#line 1253 "cs.ATG" +#line 1260 "cs.ATG" mod = Modifier.New; startLocation = t.Location; } if ( -#line 1256 "cs.ATG" +#line 1263 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 1256 "cs.ATG" +#line 1263 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1256 "cs.ATG" +#line 1263 "cs.ATG" name = t.val; Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1257 "cs.ATG" +#line 1264 "cs.ATG" out parameters); } Expect(20); Expect(11); -#line 1257 "cs.ATG" +#line 1264 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2297,39 +2312,39 @@ out parameters); } else if (StartOf(18)) { if (StartOf(8)) { Type( -#line 1263 "cs.ATG" +#line 1270 "cs.ATG" out type); -#line 1263 "cs.ATG" +#line 1270 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1265 "cs.ATG" +#line 1272 "cs.ATG" name = t.val; Point qualIdentEndLocation = t.EndLocation; if (la.kind == 19 || la.kind == 22) { if (la.kind == 22) { TypeParameterList( -#line 1269 "cs.ATG" +#line 1276 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1270 "cs.ATG" +#line 1277 "cs.ATG" out parameters); } Expect(20); while ( -#line 1272 "cs.ATG" +#line 1279 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1272 "cs.ATG" +#line 1279 "cs.ATG" templates); } Expect(11); -#line 1273 "cs.ATG" +#line 1280 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2337,72 +2352,72 @@ templates); } else if (la.kind == 15) { -#line 1279 "cs.ATG" +#line 1286 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1280 "cs.ATG" +#line 1287 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1280 "cs.ATG" +#line 1287 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1280 "cs.ATG" +#line 1287 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(150); } else if (la.kind == 109) { lexer.NextToken(); Expect(17); FormalParameterList( -#line 1283 "cs.ATG" +#line 1290 "cs.ATG" out p); Expect(18); -#line 1283 "cs.ATG" +#line 1290 "cs.ATG" Point bracketEndLocation = t.EndLocation; -#line 1283 "cs.ATG" +#line 1290 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, p, mod, attributes); compilationUnit.AddChild(id); Expect(15); -#line 1284 "cs.ATG" +#line 1291 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1284 "cs.ATG" +#line 1291 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1284 "cs.ATG" +#line 1291 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(151); } else { lexer.NextToken(); -#line 1287 "cs.ATG" +#line 1294 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1287 "cs.ATG" +#line 1294 "cs.ATG" out type); Expect(1); -#line 1287 "cs.ATG" +#line 1294 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes); compilationUnit.AddChild(ed); Expect(11); -#line 1290 "cs.ATG" +#line 1297 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(152); } void EnumMemberDecl( -#line 1295 "cs.ATG" +#line 1302 "cs.ATG" out FieldDeclaration f) { -#line 1297 "cs.ATG" +#line 1304 "cs.ATG" Expression expr = null; ArrayList attributes = new ArrayList(); AttributeSection section = null; @@ -2410,15 +2425,15 @@ out FieldDeclaration f) { while (la.kind == 17) { AttributeSection( -#line 1303 "cs.ATG" +#line 1310 "cs.ATG" out section); -#line 1303 "cs.ATG" +#line 1310 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1304 "cs.ATG" +#line 1311 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2427,90 +2442,90 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1309 "cs.ATG" +#line 1316 "cs.ATG" out expr); -#line 1309 "cs.ATG" +#line 1316 "cs.ATG" varDecl.Initializer = expr; } } void SimpleType( -#line 886 "cs.ATG" +#line 887 "cs.ATG" out string name) { -#line 887 "cs.ATG" +#line 888 "cs.ATG" name = String.Empty; if (StartOf(19)) { IntegralType( -#line 889 "cs.ATG" +#line 890 "cs.ATG" out name); } else if (la.kind == 73) { lexer.NextToken(); -#line 890 "cs.ATG" +#line 891 "cs.ATG" name = "float"; } else if (la.kind == 64) { lexer.NextToken(); -#line 891 "cs.ATG" +#line 892 "cs.ATG" name = "double"; } else if (la.kind == 60) { lexer.NextToken(); -#line 892 "cs.ATG" +#line 893 "cs.ATG" name = "decimal"; } else if (la.kind == 50) { lexer.NextToken(); -#line 893 "cs.ATG" +#line 894 "cs.ATG" name = "bool"; } else SynErr(153); } void NonArrayType( -#line 867 "cs.ATG" +#line 868 "cs.ATG" out TypeReference type) { -#line 869 "cs.ATG" +#line 870 "cs.ATG" string name = ""; int pointer = 0; List genericTypes = null; if (la.kind == 1 || la.kind == 89 || la.kind == 106) { ClassType( -#line 874 "cs.ATG" +#line 875 "cs.ATG" out name, out genericTypes); } else if (StartOf(14)) { SimpleType( -#line 875 "cs.ATG" +#line 876 "cs.ATG" out name); } else if (la.kind == 121) { lexer.NextToken(); Expect(6); -#line 876 "cs.ATG" +#line 877 "cs.ATG" pointer = 1; name = "void"; } else SynErr(154); while ( -#line 879 "cs.ATG" +#line 880 "cs.ATG" IsPointer()) { Expect(6); -#line 880 "cs.ATG" +#line 881 "cs.ATG" ++pointer; } -#line 882 "cs.ATG" +#line 883 "cs.ATG" type = new TypeReference(name, pointer, null, genericTypes); } void FixedParameter( -#line 923 "cs.ATG" +#line 924 "cs.ATG" out ParameterDeclarationExpression p) { -#line 925 "cs.ATG" +#line 926 "cs.ATG" TypeReference type; ParamModifier mod = ParamModifier.In; @@ -2518,65 +2533,65 @@ out ParameterDeclarationExpression p) { if (la.kind == 98) { lexer.NextToken(); -#line 930 "cs.ATG" +#line 931 "cs.ATG" mod = ParamModifier.Ref; } else { lexer.NextToken(); -#line 931 "cs.ATG" +#line 932 "cs.ATG" mod = ParamModifier.Out; } } Type( -#line 933 "cs.ATG" +#line 934 "cs.ATG" out type); Expect(1); -#line 933 "cs.ATG" +#line 934 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); } void ParameterArray( -#line 936 "cs.ATG" +#line 937 "cs.ATG" out ParameterDeclarationExpression p) { -#line 937 "cs.ATG" +#line 938 "cs.ATG" TypeReference type; Expect(93); Type( -#line 939 "cs.ATG" +#line 940 "cs.ATG" out type); Expect(1); -#line 939 "cs.ATG" +#line 940 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, ParamModifier.Params); } void TypeName( -#line 2094 "cs.ATG" +#line 2101 "cs.ATG" out string qualident, out List types) { -#line 2095 "cs.ATG" +#line 2102 "cs.ATG" List t; types = new List(); Qualident( -#line 2097 "cs.ATG" +#line 2104 "cs.ATG" out qualident); if (la.kind == 22) { TypeArgumentList( -#line 2098 "cs.ATG" +#line 2105 "cs.ATG" out t); -#line 2098 "cs.ATG" +#line 2105 "cs.ATG" types = t; } } void Block( -#line 1413 "cs.ATG" +#line 1420 "cs.ATG" out Statement stmt) { Expect(15); -#line 1415 "cs.ATG" +#line 1422 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); @@ -2587,7 +2602,7 @@ out Statement stmt) { } Expect(16); -#line 1422 "cs.ATG" +#line 1429 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2595,34 +2610,34 @@ out Statement stmt) { } void VariableDeclarator( -#line 1406 "cs.ATG" +#line 1413 "cs.ATG" ArrayList fieldDeclaration) { -#line 1407 "cs.ATG" +#line 1414 "cs.ATG" Expression expr = null; Expect(1); -#line 1409 "cs.ATG" +#line 1416 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1410 "cs.ATG" +#line 1417 "cs.ATG" out expr); -#line 1410 "cs.ATG" +#line 1417 "cs.ATG" f.Initializer = expr; } -#line 1410 "cs.ATG" +#line 1417 "cs.ATG" fieldDeclaration.Add(f); } void EventAccessorDecls( -#line 1355 "cs.ATG" +#line 1362 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1356 "cs.ATG" +#line 1363 "cs.ATG" AttributeSection section; ArrayList attributes = new ArrayList(); Statement stmt; @@ -2631,102 +2646,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 17) { AttributeSection( -#line 1363 "cs.ATG" +#line 1370 "cs.ATG" out section); -#line 1363 "cs.ATG" +#line 1370 "cs.ATG" attributes.Add(section); } if ( -#line 1365 "cs.ATG" +#line 1372 "cs.ATG" IdentIsAdd()) { -#line 1365 "cs.ATG" +#line 1372 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1366 "cs.ATG" +#line 1373 "cs.ATG" out stmt); -#line 1366 "cs.ATG" +#line 1373 "cs.ATG" attributes = new ArrayList(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 17) { AttributeSection( -#line 1367 "cs.ATG" +#line 1374 "cs.ATG" out section); -#line 1367 "cs.ATG" +#line 1374 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1368 "cs.ATG" +#line 1375 "cs.ATG" out stmt); -#line 1368 "cs.ATG" +#line 1375 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1369 "cs.ATG" +#line 1376 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1370 "cs.ATG" +#line 1377 "cs.ATG" out stmt); -#line 1370 "cs.ATG" +#line 1377 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new ArrayList(); while (la.kind == 17) { AttributeSection( -#line 1371 "cs.ATG" +#line 1378 "cs.ATG" out section); -#line 1371 "cs.ATG" +#line 1378 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1372 "cs.ATG" +#line 1379 "cs.ATG" out stmt); -#line 1372 "cs.ATG" +#line 1379 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1373 "cs.ATG" +#line 1380 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(155); } void ConstructorInitializer( -#line 1444 "cs.ATG" +#line 1451 "cs.ATG" out ConstructorInitializer ci) { -#line 1445 "cs.ATG" +#line 1452 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 49) { lexer.NextToken(); -#line 1449 "cs.ATG" +#line 1456 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 109) { lexer.NextToken(); -#line 1450 "cs.ATG" +#line 1457 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(156); Expect(19); if (StartOf(21)) { Argument( -#line 1453 "cs.ATG" +#line 1460 "cs.ATG" out expr); -#line 1453 "cs.ATG" +#line 1460 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1453 "cs.ATG" +#line 1460 "cs.ATG" out expr); -#line 1453 "cs.ATG" +#line 1460 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -2734,161 +2749,161 @@ out expr); } void OverloadableOperator( -#line 1465 "cs.ATG" +#line 1472 "cs.ATG" out OverloadableOperatorType op) { -#line 1466 "cs.ATG" +#line 1473 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1468 "cs.ATG" +#line 1475 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1469 "cs.ATG" +#line 1476 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 23: { lexer.NextToken(); -#line 1471 "cs.ATG" +#line 1478 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 26: { lexer.NextToken(); -#line 1472 "cs.ATG" +#line 1479 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 30: { lexer.NextToken(); -#line 1474 "cs.ATG" +#line 1481 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 31: { lexer.NextToken(); -#line 1475 "cs.ATG" +#line 1482 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 111: { lexer.NextToken(); -#line 1477 "cs.ATG" +#line 1484 "cs.ATG" op = OverloadableOperatorType.True; break; } case 70: { lexer.NextToken(); -#line 1478 "cs.ATG" +#line 1485 "cs.ATG" op = OverloadableOperatorType.False; break; } case 6: { lexer.NextToken(); -#line 1480 "cs.ATG" +#line 1487 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1481 "cs.ATG" +#line 1488 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1482 "cs.ATG" +#line 1489 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 27: { lexer.NextToken(); -#line 1484 "cs.ATG" +#line 1491 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 28: { lexer.NextToken(); -#line 1485 "cs.ATG" +#line 1492 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 29: { lexer.NextToken(); -#line 1486 "cs.ATG" +#line 1493 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 36: { lexer.NextToken(); -#line 1488 "cs.ATG" +#line 1495 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 32: { lexer.NextToken(); -#line 1489 "cs.ATG" +#line 1496 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 33: { lexer.NextToken(); -#line 1490 "cs.ATG" +#line 1497 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 22: { lexer.NextToken(); -#line 1491 "cs.ATG" +#line 1498 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 34: { lexer.NextToken(); -#line 1492 "cs.ATG" +#line 1499 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 35: { lexer.NextToken(); -#line 1493 "cs.ATG" +#line 1500 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 21: { lexer.NextToken(); -#line 1494 "cs.ATG" +#line 1501 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 21) { lexer.NextToken(); -#line 1494 "cs.ATG" +#line 1501 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2898,10 +2913,10 @@ out OverloadableOperatorType op) { } void AccessorDecls( -#line 1313 "cs.ATG" +#line 1320 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1315 "cs.ATG" +#line 1322 "cs.ATG" ArrayList attributes = new ArrayList(); AttributeSection section; getBlock = null; @@ -2909,136 +2924,136 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 17) { AttributeSection( -#line 1321 "cs.ATG" +#line 1328 "cs.ATG" out section); -#line 1321 "cs.ATG" +#line 1328 "cs.ATG" attributes.Add(section); } if ( -#line 1323 "cs.ATG" +#line 1330 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1324 "cs.ATG" +#line 1331 "cs.ATG" out getBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1325 "cs.ATG" +#line 1332 "cs.ATG" attributes = new ArrayList(); while (la.kind == 17) { AttributeSection( -#line 1326 "cs.ATG" +#line 1333 "cs.ATG" out section); -#line 1326 "cs.ATG" +#line 1333 "cs.ATG" attributes.Add(section); } SetAccessorDecl( -#line 1327 "cs.ATG" +#line 1334 "cs.ATG" out setBlock, attributes); } } else if ( -#line 1329 "cs.ATG" +#line 1336 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1330 "cs.ATG" +#line 1337 "cs.ATG" out setBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1331 "cs.ATG" +#line 1338 "cs.ATG" attributes = new ArrayList(); while (la.kind == 17) { AttributeSection( -#line 1332 "cs.ATG" +#line 1339 "cs.ATG" out section); -#line 1332 "cs.ATG" +#line 1339 "cs.ATG" attributes.Add(section); } GetAccessorDecl( -#line 1333 "cs.ATG" +#line 1340 "cs.ATG" out getBlock, attributes); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1335 "cs.ATG" +#line 1342 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(158); } void InterfaceAccessors( -#line 1377 "cs.ATG" +#line 1384 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1379 "cs.ATG" +#line 1386 "cs.ATG" AttributeSection section; ArrayList attributes = new ArrayList(); getBlock = null; setBlock = null; while (la.kind == 17) { AttributeSection( -#line 1384 "cs.ATG" +#line 1391 "cs.ATG" out section); -#line 1384 "cs.ATG" +#line 1391 "cs.ATG" attributes.Add(section); } if ( -#line 1386 "cs.ATG" +#line 1393 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1386 "cs.ATG" +#line 1393 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1387 "cs.ATG" +#line 1394 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1387 "cs.ATG" +#line 1394 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1388 "cs.ATG" +#line 1395 "cs.ATG" Error("set or get expected"); } else SynErr(159); Expect(11); -#line 1390 "cs.ATG" +#line 1397 "cs.ATG" attributes = new ArrayList(); if (la.kind == 1 || la.kind == 17) { while (la.kind == 17) { AttributeSection( -#line 1392 "cs.ATG" +#line 1399 "cs.ATG" out section); -#line 1392 "cs.ATG" +#line 1399 "cs.ATG" attributes.Add(section); } if ( -#line 1394 "cs.ATG" +#line 1401 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1394 "cs.ATG" +#line 1401 "cs.ATG" if (getBlock != null) Error("get already declared"); else getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1397 "cs.ATG" +#line 1404 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1397 "cs.ATG" +#line 1404 "cs.ATG" if (setBlock != null) Error("set already declared"); else setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1400 "cs.ATG" +#line 1407 "cs.ATG" Error("set or get expected"); } else SynErr(160); Expect(11); @@ -3046,187 +3061,187 @@ IdentIsSet()) { } void GetAccessorDecl( -#line 1339 "cs.ATG" +#line 1346 "cs.ATG" out PropertyGetRegion getBlock, ArrayList attributes) { -#line 1340 "cs.ATG" +#line 1347 "cs.ATG" Statement stmt = null; Expect(1); -#line 1343 "cs.ATG" +#line 1350 "cs.ATG" if (t.val != "get") Error("get expected"); if (la.kind == 15) { Block( -#line 1344 "cs.ATG" +#line 1351 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(161); -#line 1344 "cs.ATG" +#line 1351 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); } void SetAccessorDecl( -#line 1347 "cs.ATG" +#line 1354 "cs.ATG" out PropertySetRegion setBlock, ArrayList attributes) { -#line 1348 "cs.ATG" +#line 1355 "cs.ATG" Statement stmt = null; Expect(1); -#line 1351 "cs.ATG" +#line 1358 "cs.ATG" if (t.val != "set") Error("set expected"); if (la.kind == 15) { Block( -#line 1352 "cs.ATG" +#line 1359 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(162); -#line 1352 "cs.ATG" +#line 1359 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); } void AddAccessorDecl( -#line 1428 "cs.ATG" +#line 1435 "cs.ATG" out Statement stmt) { -#line 1429 "cs.ATG" +#line 1436 "cs.ATG" stmt = null; Expect(1); -#line 1432 "cs.ATG" +#line 1439 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1433 "cs.ATG" +#line 1440 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1436 "cs.ATG" +#line 1443 "cs.ATG" out Statement stmt) { -#line 1437 "cs.ATG" +#line 1444 "cs.ATG" stmt = null; Expect(1); -#line 1440 "cs.ATG" +#line 1447 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1441 "cs.ATG" +#line 1448 "cs.ATG" out stmt); } void VariableInitializer( -#line 1457 "cs.ATG" +#line 1464 "cs.ATG" out Expression initializerExpression) { -#line 1458 "cs.ATG" +#line 1465 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(4)) { Expr( -#line 1460 "cs.ATG" +#line 1467 "cs.ATG" out initializerExpression); } else if (la.kind == 15) { ArrayInitializer( -#line 1461 "cs.ATG" +#line 1468 "cs.ATG" out initializerExpression); } else if (la.kind == 104) { lexer.NextToken(); Type( -#line 1462 "cs.ATG" +#line 1469 "cs.ATG" out type); Expect(17); Expr( -#line 1462 "cs.ATG" +#line 1469 "cs.ATG" out expr); Expect(18); -#line 1462 "cs.ATG" +#line 1469 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(163); } void Statement() { -#line 1566 "cs.ATG" +#line 1573 "cs.ATG" TypeReference type; Expression expr; Statement stmt; if ( -#line 1572 "cs.ATG" +#line 1579 "cs.ATG" IsLabel()) { Expect(1); -#line 1572 "cs.ATG" +#line 1579 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 58) { lexer.NextToken(); Type( -#line 1575 "cs.ATG" +#line 1582 "cs.ATG" out type); -#line 1575 "cs.ATG" +#line 1582 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1576 "cs.ATG" +#line 1583 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1577 "cs.ATG" +#line 1584 "cs.ATG" out expr); -#line 1577 "cs.ATG" +#line 1584 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1578 "cs.ATG" +#line 1585 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1578 "cs.ATG" +#line 1585 "cs.ATG" out expr); -#line 1578 "cs.ATG" +#line 1585 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1579 "cs.ATG" +#line 1586 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1581 "cs.ATG" +#line 1588 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1581 "cs.ATG" +#line 1588 "cs.ATG" out stmt); Expect(11); -#line 1581 "cs.ATG" +#line 1588 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(22)) { EmbeddedStatement( -#line 1582 "cs.ATG" +#line 1589 "cs.ATG" out stmt); -#line 1582 "cs.ATG" +#line 1589 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(164); } void Argument( -#line 1497 "cs.ATG" +#line 1504 "cs.ATG" out Expression argumentexpr) { -#line 1499 "cs.ATG" +#line 1506 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3234,48 +3249,48 @@ out Expression argumentexpr) { if (la.kind == 98) { lexer.NextToken(); -#line 1504 "cs.ATG" +#line 1511 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1505 "cs.ATG" +#line 1512 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1507 "cs.ATG" +#line 1514 "cs.ATG" out expr); -#line 1507 "cs.ATG" +#line 1514 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1526 "cs.ATG" +#line 1533 "cs.ATG" out Expression outExpr) { -#line 1528 "cs.ATG" +#line 1535 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(15); if (StartOf(23)) { VariableInitializer( -#line 1533 "cs.ATG" +#line 1540 "cs.ATG" out expr); -#line 1533 "cs.ATG" +#line 1540 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1533 "cs.ATG" +#line 1540 "cs.ATG" NotFinalComma()) { Expect(13); VariableInitializer( -#line 1533 "cs.ATG" +#line 1540 "cs.ATG" out expr); -#line 1533 "cs.ATG" +#line 1540 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 13) { @@ -3284,84 +3299,84 @@ out expr); } Expect(16); -#line 1534 "cs.ATG" +#line 1541 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1510 "cs.ATG" +#line 1517 "cs.ATG" out AssignmentOperatorType op) { -#line 1511 "cs.ATG" +#line 1518 "cs.ATG" op = AssignmentOperatorType.None; switch (la.kind) { case 3: { lexer.NextToken(); -#line 1513 "cs.ATG" +#line 1520 "cs.ATG" op = AssignmentOperatorType.Assign; break; } case 37: { lexer.NextToken(); -#line 1514 "cs.ATG" +#line 1521 "cs.ATG" op = AssignmentOperatorType.Add; break; } case 38: { lexer.NextToken(); -#line 1515 "cs.ATG" +#line 1522 "cs.ATG" op = AssignmentOperatorType.Subtract; break; } case 39: { lexer.NextToken(); -#line 1516 "cs.ATG" +#line 1523 "cs.ATG" op = AssignmentOperatorType.Multiply; break; } case 40: { lexer.NextToken(); -#line 1517 "cs.ATG" +#line 1524 "cs.ATG" op = AssignmentOperatorType.Divide; break; } case 41: { lexer.NextToken(); -#line 1518 "cs.ATG" +#line 1525 "cs.ATG" op = AssignmentOperatorType.Modulus; break; } case 42: { lexer.NextToken(); -#line 1519 "cs.ATG" +#line 1526 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; break; } case 43: { lexer.NextToken(); -#line 1520 "cs.ATG" +#line 1527 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; break; } case 44: { lexer.NextToken(); -#line 1521 "cs.ATG" +#line 1528 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; break; } case 45: { lexer.NextToken(); -#line 1522 "cs.ATG" +#line 1529 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; break; } @@ -3369,7 +3384,7 @@ out AssignmentOperatorType op) { lexer.NextToken(); Expect(34); -#line 1523 "cs.ATG" +#line 1530 "cs.ATG" op = AssignmentOperatorType.ShiftRight; break; } @@ -3378,66 +3393,66 @@ out AssignmentOperatorType op) { } void LocalVariableDecl( -#line 1537 "cs.ATG" +#line 1544 "cs.ATG" out Statement stmt) { -#line 1539 "cs.ATG" +#line 1546 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1544 "cs.ATG" +#line 1551 "cs.ATG" out type); -#line 1544 "cs.ATG" +#line 1551 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1545 "cs.ATG" +#line 1552 "cs.ATG" out var); -#line 1545 "cs.ATG" +#line 1552 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 13) { lexer.NextToken(); LocalVariableDeclarator( -#line 1546 "cs.ATG" +#line 1553 "cs.ATG" out var); -#line 1546 "cs.ATG" +#line 1553 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1547 "cs.ATG" +#line 1554 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1550 "cs.ATG" +#line 1557 "cs.ATG" out VariableDeclaration var) { -#line 1551 "cs.ATG" +#line 1558 "cs.ATG" Expression expr = null; Expect(1); -#line 1554 "cs.ATG" +#line 1561 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1554 "cs.ATG" +#line 1561 "cs.ATG" out expr); -#line 1554 "cs.ATG" +#line 1561 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1588 "cs.ATG" +#line 1595 "cs.ATG" out Statement statement) { -#line 1590 "cs.ATG" +#line 1597 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3445,156 +3460,156 @@ out Statement statement) { if (la.kind == 15) { Block( -#line 1596 "cs.ATG" +#line 1603 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1598 "cs.ATG" +#line 1605 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1600 "cs.ATG" +#line 1607 "cs.ATG" UnCheckedAndLBrace()) { -#line 1600 "cs.ATG" +#line 1607 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 56) { lexer.NextToken(); } else if (la.kind == 116) { lexer.NextToken(); -#line 1601 "cs.ATG" +#line 1608 "cs.ATG" isChecked = false; } else SynErr(166); Block( -#line 1602 "cs.ATG" +#line 1609 "cs.ATG" out block); -#line 1602 "cs.ATG" +#line 1609 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 77) { lexer.NextToken(); -#line 1604 "cs.ATG" +#line 1611 "cs.ATG" Statement elseStatement = null; Expect(19); Expr( -#line 1605 "cs.ATG" +#line 1612 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1606 "cs.ATG" +#line 1613 "cs.ATG" out embeddedStatement); if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1607 "cs.ATG" +#line 1614 "cs.ATG" out elseStatement); } -#line 1608 "cs.ATG" +#line 1615 "cs.ATG" statement = elseStatement != null ? (Statement)new IfElseStatement(expr, embeddedStatement, elseStatement) : (Statement)new IfElseStatement(expr, embeddedStatement); } else if (la.kind == 108) { lexer.NextToken(); -#line 1609 "cs.ATG" +#line 1616 "cs.ATG" ArrayList switchSections = new ArrayList(); SwitchSection switchSection; Expect(19); Expr( -#line 1610 "cs.ATG" +#line 1617 "cs.ATG" out expr); Expect(20); Expect(15); while (la.kind == 53 || la.kind == 61) { SwitchSection( -#line 1611 "cs.ATG" +#line 1618 "cs.ATG" out switchSection); -#line 1611 "cs.ATG" +#line 1618 "cs.ATG" switchSections.Add(switchSection); } Expect(16); -#line 1612 "cs.ATG" +#line 1619 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 123) { lexer.NextToken(); Expect(19); Expr( -#line 1614 "cs.ATG" +#line 1621 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1616 "cs.ATG" +#line 1623 "cs.ATG" out embeddedStatement); -#line 1616 "cs.ATG" +#line 1623 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 63) { lexer.NextToken(); EmbeddedStatement( -#line 1617 "cs.ATG" +#line 1624 "cs.ATG" out embeddedStatement); Expect(123); Expect(19); Expr( -#line 1618 "cs.ATG" +#line 1625 "cs.ATG" out expr); Expect(20); Expect(11); -#line 1618 "cs.ATG" +#line 1625 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 74) { lexer.NextToken(); -#line 1619 "cs.ATG" +#line 1626 "cs.ATG" ArrayList initializer = null; ArrayList iterator = null; Expect(19); if (StartOf(4)) { ForInitializer( -#line 1620 "cs.ATG" +#line 1627 "cs.ATG" out initializer); } Expect(11); if (StartOf(4)) { Expr( -#line 1621 "cs.ATG" +#line 1628 "cs.ATG" out expr); } Expect(11); if (StartOf(4)) { ForIterator( -#line 1622 "cs.ATG" +#line 1629 "cs.ATG" out iterator); } Expect(20); EmbeddedStatement( -#line 1623 "cs.ATG" +#line 1630 "cs.ATG" out embeddedStatement); -#line 1623 "cs.ATG" +#line 1630 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 75) { lexer.NextToken(); Expect(19); Type( -#line 1624 "cs.ATG" +#line 1631 "cs.ATG" out type); Expect(1); -#line 1624 "cs.ATG" +#line 1631 "cs.ATG" string varName = t.val; Point start = t.Location; Expect(79); Expr( -#line 1625 "cs.ATG" +#line 1632 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1626 "cs.ATG" +#line 1633 "cs.ATG" out embeddedStatement); -#line 1626 "cs.ATG" +#line 1633 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -3602,34 +3617,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1630 "cs.ATG" +#line 1637 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 59) { lexer.NextToken(); Expect(11); -#line 1631 "cs.ATG" +#line 1638 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 76) { GotoStatement( -#line 1632 "cs.ATG" +#line 1639 "cs.ATG" out statement); } else if ( -#line 1633 "cs.ATG" +#line 1640 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 99) { lexer.NextToken(); Expr( -#line 1633 "cs.ATG" +#line 1640 "cs.ATG" out expr); -#line 1633 "cs.ATG" +#line 1640 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 51) { lexer.NextToken(); -#line 1634 "cs.ATG" +#line 1641 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(167); Expect(11); @@ -3637,375 +3652,375 @@ out expr); lexer.NextToken(); if (StartOf(4)) { Expr( -#line 1635 "cs.ATG" +#line 1642 "cs.ATG" out expr); } Expect(11); -#line 1635 "cs.ATG" +#line 1642 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 110) { lexer.NextToken(); if (StartOf(4)) { Expr( -#line 1636 "cs.ATG" +#line 1643 "cs.ATG" out expr); } Expect(11); -#line 1636 "cs.ATG" +#line 1643 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(4)) { StatementExpr( -#line 1638 "cs.ATG" +#line 1645 "cs.ATG" out statement); Expect(11); } else if (la.kind == 112) { TryStatement( -#line 1640 "cs.ATG" +#line 1647 "cs.ATG" out statement); } else if (la.kind == 84) { lexer.NextToken(); Expect(19); Expr( -#line 1642 "cs.ATG" +#line 1649 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1643 "cs.ATG" +#line 1650 "cs.ATG" out embeddedStatement); -#line 1643 "cs.ATG" +#line 1650 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 119) { -#line 1645 "cs.ATG" +#line 1652 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(19); ResourceAcquisition( -#line 1647 "cs.ATG" +#line 1654 "cs.ATG" out resourceAcquisitionStmt); Expect(20); EmbeddedStatement( -#line 1648 "cs.ATG" +#line 1655 "cs.ATG" out embeddedStatement); -#line 1648 "cs.ATG" +#line 1655 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 117) { lexer.NextToken(); Block( -#line 1650 "cs.ATG" +#line 1657 "cs.ATG" out embeddedStatement); -#line 1650 "cs.ATG" +#line 1657 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 72) { lexer.NextToken(); Expect(19); Type( -#line 1653 "cs.ATG" +#line 1660 "cs.ATG" out type); -#line 1653 "cs.ATG" +#line 1660 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); ArrayList pointerDeclarators = new ArrayList(1); Expect(1); -#line 1656 "cs.ATG" +#line 1663 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1657 "cs.ATG" +#line 1664 "cs.ATG" out expr); -#line 1657 "cs.ATG" +#line 1664 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1659 "cs.ATG" +#line 1666 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1660 "cs.ATG" +#line 1667 "cs.ATG" out expr); -#line 1660 "cs.ATG" +#line 1667 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(20); EmbeddedStatement( -#line 1662 "cs.ATG" +#line 1669 "cs.ATG" out embeddedStatement); -#line 1662 "cs.ATG" +#line 1669 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(168); } void SwitchSection( -#line 1684 "cs.ATG" +#line 1691 "cs.ATG" out SwitchSection stmt) { -#line 1686 "cs.ATG" +#line 1693 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1690 "cs.ATG" +#line 1697 "cs.ATG" out label); -#line 1690 "cs.ATG" +#line 1697 "cs.ATG" switchSection.SwitchLabels.Add(label); while (la.kind == 53 || la.kind == 61) { SwitchLabel( -#line 1692 "cs.ATG" +#line 1699 "cs.ATG" out label); -#line 1692 "cs.ATG" +#line 1699 "cs.ATG" switchSection.SwitchLabels.Add(label); } -#line 1694 "cs.ATG" +#line 1701 "cs.ATG" compilationUnit.BlockStart(switchSection); Statement(); while (StartOf(20)) { Statement(); } -#line 1697 "cs.ATG" +#line 1704 "cs.ATG" compilationUnit.BlockEnd(); stmt = switchSection; } void ForInitializer( -#line 1665 "cs.ATG" +#line 1672 "cs.ATG" out ArrayList initializer) { -#line 1667 "cs.ATG" +#line 1674 "cs.ATG" Statement stmt; initializer = new ArrayList(); if ( -#line 1671 "cs.ATG" +#line 1678 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1671 "cs.ATG" +#line 1678 "cs.ATG" out stmt); -#line 1671 "cs.ATG" +#line 1678 "cs.ATG" initializer.Add(stmt); } else if (StartOf(4)) { StatementExpr( -#line 1672 "cs.ATG" +#line 1679 "cs.ATG" out stmt); -#line 1672 "cs.ATG" +#line 1679 "cs.ATG" initializer.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1672 "cs.ATG" +#line 1679 "cs.ATG" out stmt); -#line 1672 "cs.ATG" +#line 1679 "cs.ATG" initializer.Add(stmt); } -#line 1672 "cs.ATG" +#line 1679 "cs.ATG" initializer.Add(stmt); } else SynErr(169); } void ForIterator( -#line 1675 "cs.ATG" +#line 1682 "cs.ATG" out ArrayList iterator) { -#line 1677 "cs.ATG" +#line 1684 "cs.ATG" Statement stmt; iterator = new ArrayList(); StatementExpr( -#line 1681 "cs.ATG" +#line 1688 "cs.ATG" out stmt); -#line 1681 "cs.ATG" +#line 1688 "cs.ATG" iterator.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1681 "cs.ATG" +#line 1688 "cs.ATG" out stmt); -#line 1681 "cs.ATG" +#line 1688 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1747 "cs.ATG" +#line 1754 "cs.ATG" out Statement stmt) { -#line 1748 "cs.ATG" +#line 1755 "cs.ATG" Expression expr; stmt = null; Expect(76); if (la.kind == 1) { lexer.NextToken(); -#line 1752 "cs.ATG" +#line 1759 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1753 "cs.ATG" +#line 1760 "cs.ATG" out expr); Expect(11); -#line 1753 "cs.ATG" +#line 1760 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1754 "cs.ATG" +#line 1761 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(170); } void StatementExpr( -#line 1774 "cs.ATG" +#line 1781 "cs.ATG" out Statement stmt) { -#line 1779 "cs.ATG" +#line 1786 "cs.ATG" bool mustBeAssignment = la.kind == Tokens.Plus || la.kind == Tokens.Minus || la.kind == Tokens.Not || la.kind == Tokens.BitwiseComplement || la.kind == Tokens.Times || la.kind == Tokens.BitwiseAnd || IsTypeCast(); Expression expr = null; UnaryExpr( -#line 1785 "cs.ATG" +#line 1792 "cs.ATG" out expr); if (StartOf(6)) { -#line 1788 "cs.ATG" +#line 1795 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1788 "cs.ATG" +#line 1795 "cs.ATG" out op); Expr( -#line 1788 "cs.ATG" +#line 1795 "cs.ATG" out val); -#line 1788 "cs.ATG" +#line 1795 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else if (la.kind == 11 || la.kind == 13 || la.kind == 20) { -#line 1789 "cs.ATG" +#line 1796 "cs.ATG" if (mustBeAssignment) Error("error in assignment."); } else SynErr(171); -#line 1790 "cs.ATG" +#line 1797 "cs.ATG" stmt = new StatementExpression(expr); } void TryStatement( -#line 1709 "cs.ATG" +#line 1716 "cs.ATG" out Statement tryStatement) { -#line 1711 "cs.ATG" +#line 1718 "cs.ATG" Statement blockStmt = null, finallyStmt = null; ArrayList catchClauses = null; Expect(112); Block( -#line 1715 "cs.ATG" +#line 1722 "cs.ATG" out blockStmt); if (la.kind == 54) { CatchClauses( -#line 1717 "cs.ATG" +#line 1724 "cs.ATG" out catchClauses); if (la.kind == 71) { lexer.NextToken(); Block( -#line 1717 "cs.ATG" +#line 1724 "cs.ATG" out finallyStmt); } } else if (la.kind == 71) { lexer.NextToken(); Block( -#line 1718 "cs.ATG" +#line 1725 "cs.ATG" out finallyStmt); } else SynErr(172); -#line 1721 "cs.ATG" +#line 1728 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 1758 "cs.ATG" +#line 1765 "cs.ATG" out Statement stmt) { -#line 1760 "cs.ATG" +#line 1767 "cs.ATG" stmt = null; Expression expr; if ( -#line 1765 "cs.ATG" +#line 1772 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1765 "cs.ATG" +#line 1772 "cs.ATG" out stmt); } else if (StartOf(4)) { Expr( -#line 1766 "cs.ATG" +#line 1773 "cs.ATG" out expr); -#line 1770 "cs.ATG" +#line 1777 "cs.ATG" stmt = new StatementExpression(expr); } else SynErr(173); } void SwitchLabel( -#line 1702 "cs.ATG" +#line 1709 "cs.ATG" out CaseLabel label) { -#line 1703 "cs.ATG" +#line 1710 "cs.ATG" Expression expr = null; label = null; if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1705 "cs.ATG" +#line 1712 "cs.ATG" out expr); Expect(9); -#line 1705 "cs.ATG" +#line 1712 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(9); -#line 1706 "cs.ATG" +#line 1713 "cs.ATG" label = new CaseLabel(); } else SynErr(174); } void CatchClauses( -#line 1726 "cs.ATG" +#line 1733 "cs.ATG" out ArrayList catchClauses) { -#line 1728 "cs.ATG" +#line 1735 "cs.ATG" catchClauses = new ArrayList(); Expect(54); -#line 1731 "cs.ATG" +#line 1738 "cs.ATG" string name; string identifier; Statement stmt; @@ -4013,138 +4028,138 @@ out ArrayList catchClauses) { if (la.kind == 15) { Block( -#line 1738 "cs.ATG" +#line 1745 "cs.ATG" out stmt); -#line 1738 "cs.ATG" +#line 1745 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 19) { lexer.NextToken(); ClassType( -#line 1740 "cs.ATG" +#line 1747 "cs.ATG" out name, out types); -#line 1740 "cs.ATG" +#line 1747 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1740 "cs.ATG" +#line 1747 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1740 "cs.ATG" +#line 1747 "cs.ATG" out stmt); -#line 1740 "cs.ATG" +#line 1747 "cs.ATG" catchClauses.Add(new CatchClause(new TypeReference(name, 0, null, types), identifier, stmt)); while ( -#line 1741 "cs.ATG" +#line 1748 "cs.ATG" IsTypedCatch()) { Expect(54); Expect(19); ClassType( -#line 1741 "cs.ATG" +#line 1748 "cs.ATG" out name, out types); -#line 1741 "cs.ATG" +#line 1748 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1741 "cs.ATG" +#line 1748 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1741 "cs.ATG" +#line 1748 "cs.ATG" out stmt); -#line 1741 "cs.ATG" +#line 1748 "cs.ATG" catchClauses.Add(new CatchClause(new TypeReference(name, 0, null, types), identifier, stmt)); } if (la.kind == 54) { lexer.NextToken(); Block( -#line 1743 "cs.ATG" +#line 1750 "cs.ATG" out stmt); -#line 1743 "cs.ATG" +#line 1750 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(175); } void UnaryExpr( -#line 1806 "cs.ATG" +#line 1813 "cs.ATG" out Expression uExpr) { -#line 1808 "cs.ATG" +#line 1815 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(24) || -#line 1832 "cs.ATG" +#line 1839 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1817 "cs.ATG" +#line 1824 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1818 "cs.ATG" +#line 1825 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 23) { lexer.NextToken(); -#line 1819 "cs.ATG" +#line 1826 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 26) { lexer.NextToken(); -#line 1820 "cs.ATG" +#line 1827 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1821 "cs.ATG" +#line 1828 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 30) { lexer.NextToken(); -#line 1822 "cs.ATG" +#line 1829 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1823 "cs.ATG" +#line 1830 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1824 "cs.ATG" +#line 1831 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(19); Type( -#line 1832 "cs.ATG" +#line 1839 "cs.ATG" out type); Expect(20); -#line 1832 "cs.ATG" +#line 1839 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 1836 "cs.ATG" +#line 1843 "cs.ATG" out expr); -#line 1836 "cs.ATG" +#line 1843 "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) { @@ -4162,33 +4177,33 @@ out expr); } void ConditionalOrExpr( -#line 1972 "cs.ATG" +#line 1979 "cs.ATG" ref Expression outExpr) { -#line 1973 "cs.ATG" +#line 1980 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 1975 "cs.ATG" +#line 1982 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 1975 "cs.ATG" +#line 1982 "cs.ATG" out expr); ConditionalAndExpr( -#line 1975 "cs.ATG" +#line 1982 "cs.ATG" ref expr); -#line 1975 "cs.ATG" +#line 1982 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1853 "cs.ATG" +#line 1860 "cs.ATG" out Expression pexpr) { -#line 1855 "cs.ATG" +#line 1862 "cs.ATG" TypeReference type = null; bool isArrayCreation = false; Expression expr; @@ -4198,349 +4213,349 @@ out Expression pexpr) { case 111: { lexer.NextToken(); -#line 1862 "cs.ATG" +#line 1869 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); break; } case 70: { lexer.NextToken(); -#line 1863 "cs.ATG" +#line 1870 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); break; } case 88: { lexer.NextToken(); -#line 1864 "cs.ATG" +#line 1871 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); break; } case 2: { lexer.NextToken(); -#line 1865 "cs.ATG" +#line 1872 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 1: { lexer.NextToken(); -#line 1867 "cs.ATG" +#line 1874 "cs.ATG" pexpr = new IdentifierExpression(t.val); break; } case 19: { lexer.NextToken(); Expr( -#line 1869 "cs.ATG" +#line 1876 "cs.ATG" out expr); Expect(20); -#line 1869 "cs.ATG" +#line 1876 "cs.ATG" pexpr = new ParenthesizedExpression(expr); break; } case 50: case 52: case 55: case 60: case 64: case 73: case 80: case 85: case 89: case 100: case 102: case 106: case 114: case 115: case 118: { -#line 1871 "cs.ATG" +#line 1878 "cs.ATG" string val = null; switch (la.kind) { case 50: { lexer.NextToken(); -#line 1873 "cs.ATG" +#line 1880 "cs.ATG" val = "bool"; break; } case 52: { lexer.NextToken(); -#line 1874 "cs.ATG" +#line 1881 "cs.ATG" val = "byte"; break; } case 55: { lexer.NextToken(); -#line 1875 "cs.ATG" +#line 1882 "cs.ATG" val = "char"; break; } case 60: { lexer.NextToken(); -#line 1876 "cs.ATG" +#line 1883 "cs.ATG" val = "decimal"; break; } case 64: { lexer.NextToken(); -#line 1877 "cs.ATG" +#line 1884 "cs.ATG" val = "double"; break; } case 73: { lexer.NextToken(); -#line 1878 "cs.ATG" +#line 1885 "cs.ATG" val = "float"; break; } case 80: { lexer.NextToken(); -#line 1879 "cs.ATG" +#line 1886 "cs.ATG" val = "int"; break; } case 85: { lexer.NextToken(); -#line 1880 "cs.ATG" +#line 1887 "cs.ATG" val = "long"; break; } case 89: { lexer.NextToken(); -#line 1881 "cs.ATG" +#line 1888 "cs.ATG" val = "object"; break; } case 100: { lexer.NextToken(); -#line 1882 "cs.ATG" +#line 1889 "cs.ATG" val = "sbyte"; break; } case 102: { lexer.NextToken(); -#line 1883 "cs.ATG" +#line 1890 "cs.ATG" val = "short"; break; } case 106: { lexer.NextToken(); -#line 1884 "cs.ATG" +#line 1891 "cs.ATG" val = "string"; break; } case 114: { lexer.NextToken(); -#line 1885 "cs.ATG" +#line 1892 "cs.ATG" val = "uint"; break; } case 115: { lexer.NextToken(); -#line 1886 "cs.ATG" +#line 1893 "cs.ATG" val = "ulong"; break; } case 118: { lexer.NextToken(); -#line 1887 "cs.ATG" +#line 1894 "cs.ATG" val = "ushort"; break; } } -#line 1888 "cs.ATG" +#line 1895 "cs.ATG" t.val = ""; Expect(14); Expect(1); -#line 1888 "cs.ATG" +#line 1895 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); break; } case 109: { lexer.NextToken(); -#line 1890 "cs.ATG" +#line 1897 "cs.ATG" pexpr = new ThisReferenceExpression(); break; } case 49: { lexer.NextToken(); -#line 1892 "cs.ATG" +#line 1899 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1894 "cs.ATG" +#line 1901 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 17) { lexer.NextToken(); Expr( -#line 1895 "cs.ATG" +#line 1902 "cs.ATG" out expr); -#line 1895 "cs.ATG" +#line 1902 "cs.ATG" ArrayList indices = new ArrayList(); if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1896 "cs.ATG" +#line 1903 "cs.ATG" out expr); -#line 1896 "cs.ATG" +#line 1903 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 1897 "cs.ATG" +#line 1904 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(176); -#line 1898 "cs.ATG" +#line 1905 "cs.ATG" pexpr = retExpr; break; } case 87: { lexer.NextToken(); NonArrayType( -#line 1899 "cs.ATG" +#line 1906 "cs.ATG" out type); -#line 1899 "cs.ATG" +#line 1906 "cs.ATG" ArrayList parameters = new ArrayList(); if (la.kind == 19) { lexer.NextToken(); -#line 1904 "cs.ATG" +#line 1911 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 1905 "cs.ATG" +#line 1912 "cs.ATG" out expr); -#line 1905 "cs.ATG" +#line 1912 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1906 "cs.ATG" +#line 1913 "cs.ATG" out expr); -#line 1906 "cs.ATG" +#line 1913 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(20); -#line 1908 "cs.ATG" +#line 1915 "cs.ATG" pexpr = oce; } else if (la.kind == 17) { -#line 1910 "cs.ATG" +#line 1917 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; lexer.NextToken(); -#line 1911 "cs.ATG" +#line 1918 "cs.ATG" int dims = 0; ArrayList rank = new ArrayList(); ArrayList parameterExpression = new ArrayList(); if (StartOf(4)) { Expr( -#line 1915 "cs.ATG" +#line 1922 "cs.ATG" out expr); -#line 1915 "cs.ATG" +#line 1922 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1917 "cs.ATG" +#line 1924 "cs.ATG" out expr); -#line 1917 "cs.ATG" +#line 1924 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } } Expect(18); -#line 1919 "cs.ATG" +#line 1926 "cs.ATG" parameters.Add(new ArrayCreationParameter(parameterExpression)); ace.Parameters = parameters; while ( -#line 1922 "cs.ATG" +#line 1929 "cs.ATG" IsDims()) { Expect(17); -#line 1922 "cs.ATG" +#line 1929 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 1923 "cs.ATG" +#line 1930 "cs.ATG" dims++; } -#line 1923 "cs.ATG" +#line 1930 "cs.ATG" rank.Add(dims); parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } -#line 1927 "cs.ATG" +#line 1934 "cs.ATG" if (rank.Count > 0) { ace.Rank = (int[])rank.ToArray(typeof (int)); } if (la.kind == 15) { ArrayInitializer( -#line 1931 "cs.ATG" +#line 1938 "cs.ATG" out expr); -#line 1931 "cs.ATG" +#line 1938 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else if (la.kind == 13 || la.kind == 18) { while (la.kind == 13) { lexer.NextToken(); -#line 1933 "cs.ATG" +#line 1940 "cs.ATG" dims++; } -#line 1934 "cs.ATG" +#line 1941 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); while ( -#line 1936 "cs.ATG" +#line 1943 "cs.ATG" IsDims()) { Expect(17); -#line 1936 "cs.ATG" +#line 1943 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 1936 "cs.ATG" +#line 1943 "cs.ATG" dims++; } -#line 1936 "cs.ATG" +#line 1943 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } ArrayInitializer( -#line 1936 "cs.ATG" +#line 1943 "cs.ATG" out expr); -#line 1936 "cs.ATG" +#line 1943 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters; } else SynErr(177); } else SynErr(178); @@ -4550,20 +4565,20 @@ out expr); lexer.NextToken(); Expect(19); if ( -#line 1942 "cs.ATG" +#line 1949 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 1942 "cs.ATG" +#line 1949 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(8)) { Type( -#line 1943 "cs.ATG" +#line 1950 "cs.ATG" out type); } else SynErr(179); Expect(20); -#line 1944 "cs.ATG" +#line 1951 "cs.ATG" pexpr = new TypeOfExpression(type); break; } @@ -4571,11 +4586,11 @@ out type); lexer.NextToken(); Expect(19); Type( -#line 1945 "cs.ATG" +#line 1952 "cs.ATG" out type); Expect(20); -#line 1945 "cs.ATG" +#line 1952 "cs.ATG" pexpr = new SizeOfExpression(type); break; } @@ -4583,11 +4598,11 @@ out type); lexer.NextToken(); Expect(19); Expr( -#line 1946 "cs.ATG" +#line 1953 "cs.ATG" out expr); Expect(20); -#line 1946 "cs.ATG" +#line 1953 "cs.ATG" pexpr = new CheckedExpression(expr); break; } @@ -4595,11 +4610,11 @@ out expr); lexer.NextToken(); Expect(19); Expr( -#line 1947 "cs.ATG" +#line 1954 "cs.ATG" out expr); Expect(20); -#line 1947 "cs.ATG" +#line 1954 "cs.ATG" pexpr = new UncheckedExpression(expr); break; } @@ -4610,353 +4625,353 @@ out expr); if (la.kind == 30) { lexer.NextToken(); -#line 1951 "cs.ATG" +#line 1958 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 31) { lexer.NextToken(); -#line 1952 "cs.ATG" +#line 1959 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(181); } else if (la.kind == 46) { lexer.NextToken(); Expect(1); -#line 1955 "cs.ATG" +#line 1962 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1956 "cs.ATG" +#line 1963 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if (la.kind == 19) { lexer.NextToken(); -#line 1958 "cs.ATG" +#line 1965 "cs.ATG" ArrayList parameters = new ArrayList(); if (StartOf(21)) { Argument( -#line 1959 "cs.ATG" +#line 1966 "cs.ATG" out expr); -#line 1959 "cs.ATG" +#line 1966 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1960 "cs.ATG" +#line 1967 "cs.ATG" out expr); -#line 1960 "cs.ATG" +#line 1967 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(20); -#line 1961 "cs.ATG" +#line 1968 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else { -#line 1963 "cs.ATG" +#line 1970 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); ArrayList indices = new ArrayList(); lexer.NextToken(); Expr( -#line 1966 "cs.ATG" +#line 1973 "cs.ATG" out expr); -#line 1966 "cs.ATG" +#line 1973 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1967 "cs.ATG" +#line 1974 "cs.ATG" out expr); -#line 1967 "cs.ATG" +#line 1974 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 1968 "cs.ATG" +#line 1975 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void ConditionalAndExpr( -#line 1978 "cs.ATG" +#line 1985 "cs.ATG" ref Expression outExpr) { -#line 1979 "cs.ATG" +#line 1986 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 1981 "cs.ATG" +#line 1988 "cs.ATG" ref outExpr); while (la.kind == 24) { lexer.NextToken(); UnaryExpr( -#line 1981 "cs.ATG" +#line 1988 "cs.ATG" out expr); InclusiveOrExpr( -#line 1981 "cs.ATG" +#line 1988 "cs.ATG" ref expr); -#line 1981 "cs.ATG" +#line 1988 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 1984 "cs.ATG" +#line 1991 "cs.ATG" ref Expression outExpr) { -#line 1985 "cs.ATG" +#line 1992 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 1987 "cs.ATG" +#line 1994 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 1987 "cs.ATG" +#line 1994 "cs.ATG" out expr); ExclusiveOrExpr( -#line 1987 "cs.ATG" +#line 1994 "cs.ATG" ref expr); -#line 1987 "cs.ATG" +#line 1994 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 1990 "cs.ATG" +#line 1997 "cs.ATG" ref Expression outExpr) { -#line 1991 "cs.ATG" +#line 1998 "cs.ATG" Expression expr; AndExpr( -#line 1993 "cs.ATG" +#line 2000 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 1993 "cs.ATG" +#line 2000 "cs.ATG" out expr); AndExpr( -#line 1993 "cs.ATG" +#line 2000 "cs.ATG" ref expr); -#line 1993 "cs.ATG" +#line 2000 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 1996 "cs.ATG" +#line 2003 "cs.ATG" ref Expression outExpr) { -#line 1997 "cs.ATG" +#line 2004 "cs.ATG" Expression expr; EqualityExpr( -#line 1999 "cs.ATG" +#line 2006 "cs.ATG" ref outExpr); while (la.kind == 27) { lexer.NextToken(); UnaryExpr( -#line 1999 "cs.ATG" +#line 2006 "cs.ATG" out expr); EqualityExpr( -#line 1999 "cs.ATG" +#line 2006 "cs.ATG" ref expr); -#line 1999 "cs.ATG" +#line 2006 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2002 "cs.ATG" +#line 2009 "cs.ATG" ref Expression outExpr) { -#line 2004 "cs.ATG" +#line 2011 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2008 "cs.ATG" +#line 2015 "cs.ATG" ref outExpr); while (la.kind == 32 || la.kind == 33) { if (la.kind == 33) { lexer.NextToken(); -#line 2011 "cs.ATG" +#line 2018 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2012 "cs.ATG" +#line 2019 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2014 "cs.ATG" +#line 2021 "cs.ATG" out expr); RelationalExpr( -#line 2014 "cs.ATG" +#line 2021 "cs.ATG" ref expr); -#line 2014 "cs.ATG" +#line 2021 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2018 "cs.ATG" +#line 2025 "cs.ATG" ref Expression outExpr) { -#line 2020 "cs.ATG" +#line 2027 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2025 "cs.ATG" +#line 2032 "cs.ATG" ref outExpr); while (StartOf(26)) { if (StartOf(27)) { if (la.kind == 22) { lexer.NextToken(); -#line 2028 "cs.ATG" +#line 2035 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 21) { lexer.NextToken(); -#line 2029 "cs.ATG" +#line 2036 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 35) { lexer.NextToken(); -#line 2030 "cs.ATG" +#line 2037 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 34) { lexer.NextToken(); -#line 2031 "cs.ATG" +#line 2038 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(182); UnaryExpr( -#line 2033 "cs.ATG" +#line 2040 "cs.ATG" out expr); ShiftExpr( -#line 2033 "cs.ATG" +#line 2040 "cs.ATG" ref expr); -#line 2033 "cs.ATG" +#line 2040 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 83) { lexer.NextToken(); -#line 2036 "cs.ATG" +#line 2043 "cs.ATG" op = BinaryOperatorType.IS; } else if (la.kind == 48) { lexer.NextToken(); -#line 2037 "cs.ATG" +#line 2044 "cs.ATG" op = BinaryOperatorType.AS; } else SynErr(183); Type( -#line 2039 "cs.ATG" +#line 2046 "cs.ATG" out type); -#line 2039 "cs.ATG" +#line 2046 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, new TypeReferenceExpression(type)); } } } void ShiftExpr( -#line 2043 "cs.ATG" +#line 2050 "cs.ATG" ref Expression outExpr) { -#line 2045 "cs.ATG" +#line 2052 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2049 "cs.ATG" +#line 2056 "cs.ATG" ref outExpr); while (la.kind == 36 || -#line 2052 "cs.ATG" +#line 2059 "cs.ATG" IsShiftRight()) { if (la.kind == 36) { lexer.NextToken(); -#line 2051 "cs.ATG" +#line 2058 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(21); Expect(21); -#line 2053 "cs.ATG" +#line 2060 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2056 "cs.ATG" +#line 2063 "cs.ATG" out expr); AdditiveExpr( -#line 2056 "cs.ATG" +#line 2063 "cs.ATG" ref expr); -#line 2056 "cs.ATG" +#line 2063 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2060 "cs.ATG" +#line 2067 "cs.ATG" ref Expression outExpr) { -#line 2062 "cs.ATG" +#line 2069 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2066 "cs.ATG" +#line 2073 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2069 "cs.ATG" +#line 2076 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2070 "cs.ATG" +#line 2077 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2072 "cs.ATG" +#line 2079 "cs.ATG" out expr); MultiplicativeExpr( -#line 2072 "cs.ATG" +#line 2079 "cs.ATG" ref expr); -#line 2072 "cs.ATG" +#line 2079 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2076 "cs.ATG" +#line 2083 "cs.ATG" ref Expression outExpr) { -#line 2078 "cs.ATG" +#line 2085 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -4964,84 +4979,84 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2084 "cs.ATG" +#line 2091 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2085 "cs.ATG" +#line 2092 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2086 "cs.ATG" +#line 2093 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2088 "cs.ATG" +#line 2095 "cs.ATG" out expr); -#line 2088 "cs.ATG" +#line 2095 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeArgumentList( -#line 2101 "cs.ATG" +#line 2108 "cs.ATG" out List types) { -#line 2103 "cs.ATG" +#line 2110 "cs.ATG" types = new List(); TypeReference type = null; Expect(22); Type( -#line 2107 "cs.ATG" +#line 2114 "cs.ATG" out type); -#line 2107 "cs.ATG" +#line 2114 "cs.ATG" types.Add(type); while (la.kind == 13) { lexer.NextToken(); Type( -#line 2108 "cs.ATG" +#line 2115 "cs.ATG" out type); -#line 2108 "cs.ATG" +#line 2115 "cs.ATG" types.Add(type); } Expect(21); } void TypeParameterConstraintsClauseBase( -#line 2153 "cs.ATG" +#line 2160 "cs.ATG" out TypeReference type) { -#line 2154 "cs.ATG" +#line 2161 "cs.ATG" TypeReference t; type = null; if (la.kind == 107) { lexer.NextToken(); -#line 2156 "cs.ATG" +#line 2163 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 57) { lexer.NextToken(); -#line 2157 "cs.ATG" +#line 2164 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 87) { lexer.NextToken(); Expect(19); Expect(20); -#line 2158 "cs.ATG" +#line 2165 "cs.ATG" type = new TypeReference("struct"); } else if (StartOf(8)) { Type( -#line 2159 "cs.ATG" +#line 2166 "cs.ATG" out t); -#line 2159 "cs.ATG" +#line 2166 "cs.ATG" type = t; } else SynErr(184); } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 2f17701f37..695a28ee5c 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -666,10 +666,11 @@ TypeDecl ArrayList names; ArrayList p; string name; - List templates = new List(); + List templates; .) = /*--- class declaration: */ (. m.Check(Modifier.Classes); .) "class" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); + templates = newType.Templates; compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); @@ -691,7 +692,7 @@ TypeDecl .) | /*--- struct declaration: */ (. m.Check(Modifier.StructsInterfacesEnumsDelegates); .) ( "struct" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); - newType.Templates = templates; + templates = newType.Templates; compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Type = Types.Struct; @@ -713,7 +714,7 @@ TypeDecl .) | /*--- interface declaration: */ "interface" (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); - newType.Templates = templates; + templates = newType.Templates; compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); newType.Type = Types.Interface; @@ -1035,6 +1036,7 @@ StructMemberDecl attributes); methodDeclaration.StartLocation = startPos; methodDeclaration.EndLocation = t.EndLocation; + methodDeclaration.Templates = templates; compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); .) @@ -1169,16 +1171,21 @@ StructMemberDecl ( /*--- "not void" method (function) declaration: */ ( (. m.Check(Modifier.PropertysEventsMethods); .) - "(" [ FormalParameterList ] ")" (. MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, - m.Modifier, - type, - p, - attributes); - methodDeclaration.StartLocation = startPos; - methodDeclaration.EndLocation = t.EndLocation; - compilationUnit.AddChild(methodDeclaration); - .) - ( Block | ";" ) (. methodDeclaration.Body = (BlockStatement)stmt; .) + /* .NET 2.0 */ + [ TypeParameterList ] + "(" [ FormalParameterList ] ")" (. + MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, + m.Modifier, + type, + p, + attributes); + methodDeclaration.StartLocation = startPos; + methodDeclaration.EndLocation = t.EndLocation; + methodDeclaration.Templates = templates; + compilationUnit.AddChild(methodDeclaration); + .) + { IF (IdentIsWhere()) TypeParameterConstraintsClause } + ( Block | ";" ) (. methodDeclaration.Body = (BlockStatement)stmt; .) /*--- property declaration: */ | "{" (. PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); diff --git a/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs index 04849ee07a..08d50fdc90 100644 --- a/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs @@ -3,7 +3,7 @@ * User: Omnibrain * Date: 13.09.2004 * Time: 19:54 - * + * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; @@ -24,6 +24,10 @@ namespace ICSharpCode.NRefactory.Tests.AST { Assert.AreEqual("System.Void", dd.ReturnType.SystemType); Assert.AreEqual("MyDelegate", dd.Name); + } + + void TestParameters(DelegateDeclaration dd) + { Assert.AreEqual(3, dd.Parameters.Count); Assert.AreEqual("a", ((ParameterDeclarationExpression)dd.Parameters[0]).ParameterName); @@ -43,6 +47,27 @@ namespace ICSharpCode.NRefactory.Tests.AST string program = "public delegate void MyDelegate(int a, int secondParam, MyObj lastParam);\n"; TestDelegateDeclaration((DelegateDeclaration)ParseUtilCSharp.ParseGlobal(program, typeof(DelegateDeclaration))); } + + [Test] + public void CSharpDelegateWithoutNameDeclarationTest() + { + string program = "public delegate void(int a, int secondParam, MyObj lastParam);\n"; + DelegateDeclaration dd = (DelegateDeclaration)ParseUtilCSharp.ParseGlobal(program, typeof(DelegateDeclaration), true); + Assert.AreEqual("System.Void", dd.ReturnType.SystemType); + Assert.AreEqual("?", dd.Name); + TestParameters(dd); + } + + [Test] + public void CSharpGenericDelegateDeclarationTest() + { + string program = "public delegate T CreateObject(int a, int secondParam, MyObj lastParam);\n"; + DelegateDeclaration dd = (DelegateDeclaration)ParseUtilCSharp.ParseGlobal(program, typeof(DelegateDeclaration)); + Assert.AreEqual("CreateObject", dd.Name); + Assert.AreEqual("T", dd.ReturnType.Type); + TestParameters(dd); + Assert.Fail("Getting type parameters not implemented."); + } #endregion #region VB.NET diff --git a/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs index f460d3d353..d454a1ae8e 100644 --- a/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs @@ -3,7 +3,7 @@ * User: Omnibrain * Date: 13.09.2004 * Time: 19:54 - * + * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; @@ -61,7 +61,8 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.AreEqual("G", td.Name); Assert.AreEqual(Modifier.Public, td.Modifier); Assert.AreEqual(0, td.BaseTypes.Count); - // TODO: test the generic stuff + Assert.AreEqual(1, td.Templates.Count); + Assert.AreEqual("T", td.Templates[0].Name); } @@ -69,7 +70,7 @@ namespace ICSharpCode.NRefactory.Tests.AST public void CSharpGenericClassWithWhere() { string declr = @" -public class Test where T : IMyInterface +public class Test where T : IMyInterface { } "; @@ -77,14 +78,17 @@ public class Test where T : IMyInterface Assert.AreEqual(Types.Class, td.Type); Assert.AreEqual("Test", td.Name); - // TODO: test the generic stuff + + Assert.AreEqual(1, td.Templates.Count); + Assert.AreEqual("T", td.Templates[0].Name); + Assert.AreEqual("IMyInterface", td.Templates[0].Bases[0].Type); } [Test] public void CSharpComplexGenericClassTypeDeclarationTest() { string declr = @" -public class Generic : System.IComparable where S : G where T : MyNamespace.IMyInterface +public class Generic : System.IComparable where S : G where T : MyNamespace.IMyInterface { } "; @@ -95,7 +99,17 @@ public class Generic : System.IComparable where S : G where T : MyNa Assert.AreEqual(Modifier.Public, td.Modifier); Assert.AreEqual(1, td.BaseTypes.Count); Assert.AreEqual("System.IComparable", td.BaseTypes[0]); - // TODO: test the generic stuff + + Assert.AreEqual(2, td.Templates.Count); + Assert.AreEqual("T", td.Templates[0].Name); + Assert.AreEqual("MyNamespace.IMyInterface", td.Templates[0].Bases[0].Type); + + Assert.AreEqual("S", td.Templates[1].Name); + Assert.AreEqual("G", td.Templates[1].Bases[0].Type); + Assert.AreEqual(1, td.Templates[1].Bases[0].GenericTypes.Count); + Assert.IsTrue(td.Templates[1].Bases[0].GenericTypes[0].IsArrayType); + Assert.AreEqual("T", td.Templates[1].Bases[0].GenericTypes[0].Type); + Assert.AreEqual(new int[] {0}, td.Templates[1].Bases[0].GenericTypes[0].RankSpecifier); } [Test] @@ -103,7 +117,7 @@ public class Generic : System.IComparable where S : G where T : MyNa { string declr = @" [MyAttr()] -public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 +public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 { } "; @@ -152,40 +166,38 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 public void VBNetSimpleClassTypeDeclarationTest() { string program = "Class TestClass\n" + - "End Class\n"; + "End Class\n"; TypeDeclaration td = (TypeDeclaration)ParseUtilVBNet.ParseGlobal(program, typeof(TypeDeclaration)); Assert.AreEqual("TestClass", td.Name); Assert.AreEqual(Types.Class, td.Type); Assert.AreEqual(1, td.StartLocation.Y, "start line"); Assert.AreEqual(2, td.EndLocation.Y, "end line"); -// Assert.IsFalse(td.IsPartialType); } [Test] public void VBNetSimpleClassTypeDeclarationWithoutLastNewLineTest() { string program = "Class TestClass\n" + - "End Class"; + "End Class"; TypeDeclaration td = (TypeDeclaration)ParseUtilVBNet.ParseGlobal(program, typeof(TypeDeclaration)); Assert.AreEqual("TestClass", td.Name); Assert.AreEqual(Types.Class, td.Type); Assert.AreEqual(1, td.StartLocation.Y, "start line"); Assert.AreEqual(2, td.EndLocation.Y, "end line"); -// Assert.IsFalse(td.IsPartialType); } [Test] public void VBNetSimplePartialClassTypeDeclarationTest() { string program = "Partial Class TestClass\n" + - "End Class\n"; + "End Class\n"; TypeDeclaration td = (TypeDeclaration)ParseUtilVBNet.ParseGlobal(program, typeof(TypeDeclaration)); Assert.AreEqual("TestClass", td.Name); Assert.AreEqual(Types.Class, td.Type); -// Assert.IsTrue(td.IsPartialType); + Assert.AreEqual(Modifier.Partial, td.Modifier); } #endregion } diff --git a/src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs b/src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs new file mode 100644 index 0000000000..72b02b4722 --- /dev/null +++ b/src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs @@ -0,0 +1,51 @@ +/* + * Created by SharpDevelop. + * User: Daniel Grunwald + * Date: 21.05.2005 + * Time: 17:54 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.IO; +using NUnit.Framework; +using ICSharpCode.NRefactory.Parser; +using ICSharpCode.NRefactory.Parser.AST; + +namespace ICSharpCode.NRefactory.Tests.AST +{ + [TestFixture] + public class YieldStatementTests + { + [Test] + public void YieldReturnStatementTest() + { + YieldStatement yieldStmt = (YieldStatement)ParseUtilCSharp.ParseStatment("yield return \"Foo\";", typeof(YieldStatement)); + Assert.IsTrue(yieldStmt.IsYieldReturn()); + ReturnStatement retStmt = (ReturnStatement)yieldStmt.Statement; + PrimitiveExpression expr = (PrimitiveExpression)retStmt.Expression; + Assert.AreEqual("Foo", expr.Value); + } + + [Test] + public void YieldBreakStatementTest() + { + YieldStatement yieldStmt = (YieldStatement)ParseUtilCSharp.ParseStatment("yield break;", typeof(YieldStatement)); + Assert.IsTrue(yieldStmt.IsYieldBreak()); + } + + [Test] + public void YieldAsVariableTest() + { + StatementExpression se = (StatementExpression)ParseUtilCSharp.ParseStatment("yield = 3;", typeof(StatementExpression)); + AssignmentExpression ae = se.Expression as AssignmentExpression; + + Assert.AreEqual(AssignmentOperatorType.Assign, ae.Op); + + Assert.IsTrue(ae.Left is IdentifierExpression); + Assert.AreEqual("yield", ((IdentifierExpression)ae.Left).Identifier); + Assert.IsTrue(ae.Right is PrimitiveExpression); + } + } +} diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs index 86eb6eec69..09f5299630 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs @@ -29,8 +29,8 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.AreEqual("MyEvent", ((VariableDeclaration)ed.VariableDeclarators[0]).Name); Assert.AreEqual("System.EventHandler", ed.TypeReference.Type); - Assert.IsTrue(!ed.HasAddRegion); - Assert.IsTrue(!ed.HasRemoveRegion); + Assert.IsFalse(ed.HasAddRegion); + Assert.IsFalse(ed.HasRemoveRegion); } [Test] diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs index 30ed1d89fe..0c19bfc0e2 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs @@ -37,6 +37,48 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.AreEqual(1, md.Parameters.Count); Assert.AreEqual("?", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); } + + [Test] + public void CSharpGenericVoidMethodDeclarationTest() + { + MethodDeclaration md = (MethodDeclaration)ParseUtilCSharp.ParseTypeMember("void MyMethod(T a) {} ", typeof(MethodDeclaration)); + Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual(1, md.Parameters.Count); + Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); + Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); + + Assert.AreEqual(1, md.Templates.Count); + Assert.AreEqual("T", md.Templates[0].Name); + } + + [Test] + public void CSharpGenericMethodDeclarationTest() + { + MethodDeclaration md = (MethodDeclaration)ParseUtilCSharp.ParseTypeMember("T MyMethod(T a) {} ", typeof(MethodDeclaration)); + Assert.AreEqual("T", md.TypeReference.Type); + Assert.AreEqual(1, md.Parameters.Count); + Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); + Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); + + Assert.AreEqual(1, md.Templates.Count); + Assert.AreEqual("T", md.Templates[0].Name); + } + + [Test] + public void CSharpGenericMethodDeclarationWithConstraintTest() + { + string program = "T MyMethod(T a) where T : ISomeInterface {} "; + MethodDeclaration md = (MethodDeclaration)ParseUtilCSharp.ParseTypeMember(program, typeof(MethodDeclaration)); + Assert.AreEqual("T", md.TypeReference.Type); + Assert.AreEqual(1, md.Parameters.Count); + Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); + Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); + + Assert.AreEqual(1, md.Templates.Count); + Assert.AreEqual("T", md.Templates[0].Name); + Assert.AreEqual(1, md.Templates[0].Bases.Count); + Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type); + } #endregion #region VB.NET diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs b/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs index 698d237670..ffc28051b0 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/ParseableFileContentEnumerator.cs @@ -115,10 +115,16 @@ namespace ICSharpCode.SharpDevelop.Project if (item.ItemType != ItemType.Compile) return MoveNext(); string fileContent; - if (res != null) { - fileContent = pcd.EndInvoke(res); - } else { - fileContent = GetFileContent(item); + try { + if (res != null) { + fileContent = pcd.EndInvoke(res); + } else { + fileContent = GetFileContent(item); + } + } catch (IOException ex) { + res = null; + Console.WriteLine(ex); + return MoveNext(); // skip invalid files } if (nextItem != null && nextItem.ItemType == ItemType.Compile && CanReadAsync(nextItem)) res = pcd.BeginInvoke(nextItem.Project, nextItem.FileName, null, null);