diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index d0f5f933b6..5421c6400e 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -157,6 +157,9 @@ bool IsTypeNameForTypeCast(ref Token pt) } pt = Peek(); } + if (pt.kind == Tokens.Question) { + pt = Peek(); + } if (pt.kind == Tokens.Times || pt.kind == Tokens.OpenSquareBracket) { return IsPointerOrDims(ref pt); } @@ -535,14 +538,14 @@ bool WriteFullTypeName(StringBuilder b, Expression expr) void CS() { -#line 654 "cs.ATG" +#line 657 "cs.ATG" lexer.NextToken(); /* get the first token */ compilationUnit = new CompilationUnit(); while (la.kind == 120) { UsingDirective(); } while ( -#line 658 "cs.ATG" +#line 661 "cs.ATG" IsGlobalAttrTarget()) { GlobalAttributeSection(); } @@ -554,25 +557,25 @@ IsGlobalAttrTarget()) { void UsingDirective() { -#line 665 "cs.ATG" +#line 668 "cs.ATG" string qualident = null; TypeReference aliasedType = null; Expect(120); -#line 668 "cs.ATG" +#line 671 "cs.ATG" Point startPos = t.Location; Qualident( -#line 669 "cs.ATG" +#line 672 "cs.ATG" out qualident); if (la.kind == 3) { lexer.NextToken(); NonArrayType( -#line 670 "cs.ATG" +#line 673 "cs.ATG" out aliasedType); } Expect(11); -#line 672 "cs.ATG" +#line 675 "cs.ATG" if (qualident != null && qualident.Length > 0) { INode node; if (aliasedType != null) { @@ -590,11 +593,11 @@ out aliasedType); void GlobalAttributeSection() { Expect(18); -#line 688 "cs.ATG" +#line 691 "cs.ATG" Point startPos = t.Location; Expect(1); -#line 689 "cs.ATG" +#line 692 "cs.ATG" if (t.val != "assembly") Error("global attribute target specifier (\"assembly\") expected"); string attributeTarget = t.val; List attributes = new List(); @@ -602,20 +605,20 @@ out aliasedType); Expect(9); Attribute( -#line 694 "cs.ATG" +#line 697 "cs.ATG" out attribute); -#line 694 "cs.ATG" +#line 697 "cs.ATG" attributes.Add(attribute); while ( -#line 695 "cs.ATG" +#line 698 "cs.ATG" NotFinalComma()) { Expect(14); Attribute( -#line 695 "cs.ATG" +#line 698 "cs.ATG" out attribute); -#line 695 "cs.ATG" +#line 698 "cs.ATG" attributes.Add(attribute); } if (la.kind == 14) { @@ -623,7 +626,7 @@ out attribute); } Expect(19); -#line 697 "cs.ATG" +#line 700 "cs.ATG" AttributeSection section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -633,7 +636,7 @@ out attribute); void NamespaceMemberDecl() { -#line 788 "cs.ATG" +#line 791 "cs.ATG" AttributeSection section; List attributes = new List(); Modifiers m = new Modifiers(); @@ -642,13 +645,13 @@ out attribute); if (la.kind == 87) { lexer.NextToken(); -#line 794 "cs.ATG" +#line 797 "cs.ATG" Point startPos = t.Location; Qualident( -#line 795 "cs.ATG" +#line 798 "cs.ATG" out qualident); -#line 795 "cs.ATG" +#line 798 "cs.ATG" INode node = new NamespaceDeclaration(qualident); node.StartLocation = startPos; compilationUnit.AddChild(node); @@ -666,139 +669,139 @@ out qualident); lexer.NextToken(); } -#line 804 "cs.ATG" +#line 807 "cs.ATG" node.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); } else if (StartOf(2)) { while (la.kind == 18) { AttributeSection( -#line 808 "cs.ATG" +#line 811 "cs.ATG" out section); -#line 808 "cs.ATG" +#line 811 "cs.ATG" attributes.Add(section); } while (StartOf(3)) { TypeModifier( -#line 809 "cs.ATG" +#line 812 "cs.ATG" m); } TypeDecl( -#line 810 "cs.ATG" +#line 813 "cs.ATG" m, attributes); } else SynErr(126); } void Qualident( -#line 928 "cs.ATG" +#line 931 "cs.ATG" out string qualident) { Expect(1); -#line 930 "cs.ATG" +#line 933 "cs.ATG" qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); while ( -#line 931 "cs.ATG" +#line 934 "cs.ATG" DotAndIdent()) { Expect(15); Expect(1); -#line 931 "cs.ATG" +#line 934 "cs.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(t.val); } -#line 934 "cs.ATG" +#line 937 "cs.ATG" qualident = qualidentBuilder.ToString(); } void NonArrayType( -#line 1038 "cs.ATG" +#line 1041 "cs.ATG" out TypeReference type) { -#line 1040 "cs.ATG" +#line 1043 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 90 || la.kind == 107) { ClassType( -#line 1045 "cs.ATG" +#line 1048 "cs.ATG" out type, false); } else if (StartOf(4)) { SimpleType( -#line 1046 "cs.ATG" +#line 1049 "cs.ATG" out name); -#line 1046 "cs.ATG" +#line 1049 "cs.ATG" type = new TypeReference(name); } else if (la.kind == 122) { lexer.NextToken(); Expect(6); -#line 1047 "cs.ATG" +#line 1050 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(127); if (la.kind == 12) { NullableQuestionMark( -#line 1050 "cs.ATG" +#line 1053 "cs.ATG" ref type); } while ( -#line 1052 "cs.ATG" +#line 1055 "cs.ATG" IsPointer()) { Expect(6); -#line 1053 "cs.ATG" +#line 1056 "cs.ATG" ++pointer; } -#line 1055 "cs.ATG" +#line 1058 "cs.ATG" if (type != null) { type.PointerNestingLevel = pointer; } } void Attribute( -#line 704 "cs.ATG" +#line 707 "cs.ATG" out ASTAttribute attribute) { -#line 705 "cs.ATG" +#line 708 "cs.ATG" string qualident; string alias = null; if ( -#line 709 "cs.ATG" +#line 712 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 710 "cs.ATG" +#line 713 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 713 "cs.ATG" +#line 716 "cs.ATG" out qualident); -#line 714 "cs.ATG" +#line 717 "cs.ATG" List positional = new List(); List named = new List(); string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident; if (la.kind == 20) { AttributeArguments( -#line 718 "cs.ATG" +#line 721 "cs.ATG" positional, named); } -#line 718 "cs.ATG" +#line 721 "cs.ATG" attribute = new ICSharpCode.NRefactory.Parser.AST.Attribute(name, positional, named); } void AttributeArguments( -#line 721 "cs.ATG" +#line 724 "cs.ATG" List positional, List named) { -#line 723 "cs.ATG" +#line 726 "cs.ATG" bool nameFound = false; string name = ""; Expression expr; @@ -806,22 +809,22 @@ List positional, List named) { Expect(20); if (StartOf(5)) { if ( -#line 731 "cs.ATG" +#line 734 "cs.ATG" IsAssignment()) { -#line 731 "cs.ATG" +#line 734 "cs.ATG" nameFound = true; lexer.NextToken(); -#line 732 "cs.ATG" +#line 735 "cs.ATG" name = t.val; Expect(3); } Expr( -#line 734 "cs.ATG" +#line 737 "cs.ATG" out expr); -#line 734 "cs.ATG" +#line 737 "cs.ATG" if (expr != null) {if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -829,26 +832,26 @@ out expr); while (la.kind == 14) { lexer.NextToken(); if ( -#line 742 "cs.ATG" +#line 745 "cs.ATG" IsAssignment()) { -#line 742 "cs.ATG" +#line 745 "cs.ATG" nameFound = true; Expect(1); -#line 743 "cs.ATG" +#line 746 "cs.ATG" name = t.val; Expect(3); } else if (StartOf(5)) { -#line 745 "cs.ATG" +#line 748 "cs.ATG" if (nameFound) Error("no positional argument after named argument"); } else SynErr(128); Expr( -#line 746 "cs.ATG" +#line 749 "cs.ATG" out expr); -#line 746 "cs.ATG" +#line 749 "cs.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -859,70 +862,70 @@ out expr); } void Expr( -#line 2066 "cs.ATG" +#line 2069 "cs.ATG" out Expression expr) { -#line 2067 "cs.ATG" +#line 2070 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; UnaryExpr( -#line 2069 "cs.ATG" +#line 2072 "cs.ATG" out expr); if (StartOf(6)) { AssignmentOperator( -#line 2072 "cs.ATG" +#line 2075 "cs.ATG" out op); Expr( -#line 2072 "cs.ATG" +#line 2075 "cs.ATG" out expr1); -#line 2072 "cs.ATG" +#line 2075 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 2073 "cs.ATG" +#line 2076 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 2074 "cs.ATG" +#line 2077 "cs.ATG" out op); Expr( -#line 2074 "cs.ATG" +#line 2077 "cs.ATG" out expr1); -#line 2074 "cs.ATG" +#line 2077 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(7)) { ConditionalOrExpr( -#line 2076 "cs.ATG" +#line 2079 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 2077 "cs.ATG" +#line 2080 "cs.ATG" out expr1); -#line 2077 "cs.ATG" +#line 2080 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 2078 "cs.ATG" +#line 2081 "cs.ATG" out expr1); Expect(9); Expr( -#line 2078 "cs.ATG" +#line 2081 "cs.ATG" out expr2); -#line 2078 "cs.ATG" +#line 2081 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(129); } void AttributeSection( -#line 755 "cs.ATG" +#line 758 "cs.ATG" out AttributeSection section) { -#line 757 "cs.ATG" +#line 760 "cs.ATG" string attributeTarget = ""; List attributes = new List(); ASTAttribute attribute; @@ -930,25 +933,25 @@ out AttributeSection section) { Expect(18); -#line 763 "cs.ATG" +#line 766 "cs.ATG" Point startPos = t.Location; if ( -#line 764 "cs.ATG" +#line 767 "cs.ATG" IsLocalAttrTarget()) { if (la.kind == 68) { lexer.NextToken(); -#line 765 "cs.ATG" +#line 768 "cs.ATG" attributeTarget = "event"; } else if (la.kind == 100) { lexer.NextToken(); -#line 766 "cs.ATG" +#line 769 "cs.ATG" attributeTarget = "return"; } else { lexer.NextToken(); -#line 767 "cs.ATG" +#line 770 "cs.ATG" if (t.val != "field" || t.val != "method" || t.val != "module" || t.val != "param" || t.val != "property" || t.val != "type") @@ -960,20 +963,20 @@ IsLocalAttrTarget()) { Expect(9); } Attribute( -#line 777 "cs.ATG" +#line 780 "cs.ATG" out attribute); -#line 777 "cs.ATG" +#line 780 "cs.ATG" attributes.Add(attribute); while ( -#line 778 "cs.ATG" +#line 781 "cs.ATG" NotFinalComma()) { Expect(14); Attribute( -#line 778 "cs.ATG" +#line 781 "cs.ATG" out attribute); -#line 778 "cs.ATG" +#line 781 "cs.ATG" attributes.Add(attribute); } if (la.kind == 14) { @@ -981,7 +984,7 @@ out attribute); } Expect(19); -#line 780 "cs.ATG" +#line 783 "cs.ATG" section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -989,76 +992,76 @@ out attribute); } void TypeModifier( -#line 1125 "cs.ATG" +#line 1128 "cs.ATG" Modifiers m) { switch (la.kind) { case 88: { lexer.NextToken(); -#line 1127 "cs.ATG" +#line 1130 "cs.ATG" m.Add(Modifier.New, t.Location); break; } case 97: { lexer.NextToken(); -#line 1128 "cs.ATG" +#line 1131 "cs.ATG" m.Add(Modifier.Public, t.Location); break; } case 96: { lexer.NextToken(); -#line 1129 "cs.ATG" +#line 1132 "cs.ATG" m.Add(Modifier.Protected, t.Location); break; } case 83: { lexer.NextToken(); -#line 1130 "cs.ATG" +#line 1133 "cs.ATG" m.Add(Modifier.Internal, t.Location); break; } case 95: { lexer.NextToken(); -#line 1131 "cs.ATG" +#line 1134 "cs.ATG" m.Add(Modifier.Private, t.Location); break; } case 118: { lexer.NextToken(); -#line 1132 "cs.ATG" +#line 1135 "cs.ATG" m.Add(Modifier.Unsafe, t.Location); break; } case 48: { lexer.NextToken(); -#line 1133 "cs.ATG" +#line 1136 "cs.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 102: { lexer.NextToken(); -#line 1134 "cs.ATG" +#line 1137 "cs.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 106: { lexer.NextToken(); -#line 1135 "cs.ATG" +#line 1138 "cs.ATG" m.Add(Modifier.Static, t.Location); break; } case 1: { lexer.NextToken(); -#line 1136 "cs.ATG" +#line 1139 "cs.ATG" if (t.val == "partial") { m.Add(Modifier.Partial, t.Location); } break; } @@ -1067,10 +1070,10 @@ Modifiers m) { } void TypeDecl( -#line 813 "cs.ATG" +#line 816 "cs.ATG" Modifiers m, List attributes) { -#line 815 "cs.ATG" +#line 818 "cs.ATG" TypeReference type; List names; List p = new List(); @@ -1079,11 +1082,11 @@ Modifiers m, List attributes) { if (la.kind == 58) { -#line 821 "cs.ATG" +#line 824 "cs.ATG" m.Check(Modifier.Classes); lexer.NextToken(); -#line 822 "cs.ATG" +#line 825 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -1094,26 +1097,26 @@ Modifiers m, List attributes) { Expect(1); -#line 830 "cs.ATG" +#line 833 "cs.ATG" newType.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 833 "cs.ATG" +#line 836 "cs.ATG" templates); } if (la.kind == 9) { ClassBase( -#line 835 "cs.ATG" +#line 838 "cs.ATG" out names); -#line 835 "cs.ATG" +#line 838 "cs.ATG" newType.BaseTypes = names; } while ( -#line 838 "cs.ATG" +#line 841 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 838 "cs.ATG" +#line 841 "cs.ATG" templates); } ClassBody(); @@ -1121,18 +1124,18 @@ templates); lexer.NextToken(); } -#line 841 "cs.ATG" +#line 844 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (StartOf(8)) { -#line 844 "cs.ATG" +#line 847 "cs.ATG" m.Check(Modifier.StructsInterfacesEnumsDelegates); if (la.kind == 108) { lexer.NextToken(); -#line 845 "cs.ATG" +#line 848 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; newType.StartLocation = m.GetDeclarationLocation(t.Location); @@ -1142,26 +1145,26 @@ templates); Expect(1); -#line 852 "cs.ATG" +#line 855 "cs.ATG" newType.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 855 "cs.ATG" +#line 858 "cs.ATG" templates); } if (la.kind == 9) { StructInterfaces( -#line 857 "cs.ATG" +#line 860 "cs.ATG" out names); -#line 857 "cs.ATG" +#line 860 "cs.ATG" newType.BaseTypes = names; } while ( -#line 860 "cs.ATG" +#line 863 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 860 "cs.ATG" +#line 863 "cs.ATG" templates); } StructBody(); @@ -1169,14 +1172,14 @@ templates); lexer.NextToken(); } -#line 864 "cs.ATG" +#line 867 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 82) { lexer.NextToken(); -#line 868 "cs.ATG" +#line 871 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -1186,26 +1189,26 @@ templates); Expect(1); -#line 875 "cs.ATG" +#line 878 "cs.ATG" newType.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 878 "cs.ATG" +#line 881 "cs.ATG" templates); } if (la.kind == 9) { InterfaceBase( -#line 880 "cs.ATG" +#line 883 "cs.ATG" out names); -#line 880 "cs.ATG" +#line 883 "cs.ATG" newType.BaseTypes = names; } while ( -#line 883 "cs.ATG" +#line 886 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 883 "cs.ATG" +#line 886 "cs.ATG" templates); } InterfaceBody(); @@ -1213,14 +1216,14 @@ templates); lexer.NextToken(); } -#line 886 "cs.ATG" +#line 889 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 67) { lexer.NextToken(); -#line 890 "cs.ATG" +#line 893 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); @@ -1229,15 +1232,15 @@ templates); Expect(1); -#line 896 "cs.ATG" +#line 899 "cs.ATG" newType.Name = t.val; if (la.kind == 9) { lexer.NextToken(); IntegralType( -#line 897 "cs.ATG" +#line 900 "cs.ATG" out name); -#line 897 "cs.ATG" +#line 900 "cs.ATG" newType.BaseTypes.Add(new TypeReference(name)); } EnumBody(); @@ -1245,62 +1248,62 @@ out name); lexer.NextToken(); } -#line 900 "cs.ATG" +#line 903 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else { lexer.NextToken(); -#line 904 "cs.ATG" +#line 907 "cs.ATG" DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); templates = delegateDeclr.Templates; delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); if ( -#line 908 "cs.ATG" +#line 911 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 908 "cs.ATG" +#line 911 "cs.ATG" delegateDeclr.ReturnType = new TypeReference("void", 0, null); } else if (StartOf(9)) { Type( -#line 909 "cs.ATG" +#line 912 "cs.ATG" out type); -#line 909 "cs.ATG" +#line 912 "cs.ATG" delegateDeclr.ReturnType = type; } else SynErr(131); Expect(1); -#line 911 "cs.ATG" +#line 914 "cs.ATG" delegateDeclr.Name = t.val; if (la.kind == 23) { TypeParameterList( -#line 914 "cs.ATG" +#line 917 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 916 "cs.ATG" +#line 919 "cs.ATG" p); -#line 916 "cs.ATG" +#line 919 "cs.ATG" delegateDeclr.Parameters = p; } Expect(21); while ( -#line 920 "cs.ATG" +#line 923 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 920 "cs.ATG" +#line 923 "cs.ATG" templates); } Expect(11); -#line 922 "cs.ATG" +#line 925 "cs.ATG" delegateDeclr.EndLocation = t.Location; compilationUnit.AddChild(delegateDeclr); @@ -1309,90 +1312,90 @@ templates); } void TypeParameterList( -#line 2469 "cs.ATG" +#line 2472 "cs.ATG" List templates) { -#line 2471 "cs.ATG" +#line 2474 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2475 "cs.ATG" +#line 2478 "cs.ATG" out section); -#line 2475 "cs.ATG" +#line 2478 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2476 "cs.ATG" +#line 2479 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2477 "cs.ATG" +#line 2480 "cs.ATG" out section); -#line 2477 "cs.ATG" +#line 2480 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2478 "cs.ATG" +#line 2481 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); } void ClassBase( -#line 937 "cs.ATG" +#line 940 "cs.ATG" out List names) { -#line 939 "cs.ATG" +#line 942 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); ClassType( -#line 943 "cs.ATG" +#line 946 "cs.ATG" out typeRef, false); -#line 943 "cs.ATG" +#line 946 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 944 "cs.ATG" +#line 947 "cs.ATG" out typeRef, false); -#line 944 "cs.ATG" +#line 947 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } void TypeParameterConstraintsClause( -#line 2482 "cs.ATG" +#line 2485 "cs.ATG" List templates) { -#line 2483 "cs.ATG" +#line 2486 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2485 "cs.ATG" +#line 2488 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2486 "cs.ATG" +#line 2489 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2488 "cs.ATG" +#line 2491 "cs.ATG" out type); -#line 2489 "cs.ATG" +#line 2492 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1405,10 +1408,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2498 "cs.ATG" +#line 2501 "cs.ATG" out type); -#line 2499 "cs.ATG" +#line 2502 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1423,114 +1426,114 @@ out type); void ClassBody() { -#line 948 "cs.ATG" +#line 951 "cs.ATG" AttributeSection section; Expect(16); while (StartOf(11)) { -#line 951 "cs.ATG" +#line 954 "cs.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 18) { AttributeSection( -#line 954 "cs.ATG" +#line 957 "cs.ATG" out section); -#line 954 "cs.ATG" +#line 957 "cs.ATG" attributes.Add(section); } while (StartOf(12)) { MemberModifier( -#line 955 "cs.ATG" +#line 958 "cs.ATG" m); } ClassMemberDecl( -#line 956 "cs.ATG" +#line 959 "cs.ATG" m, attributes); } Expect(17); } void StructInterfaces( -#line 961 "cs.ATG" +#line 964 "cs.ATG" out List names) { -#line 963 "cs.ATG" +#line 966 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 967 "cs.ATG" +#line 970 "cs.ATG" out typeRef, false); -#line 967 "cs.ATG" +#line 970 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 968 "cs.ATG" +#line 971 "cs.ATG" out typeRef, false); -#line 968 "cs.ATG" +#line 971 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } void StructBody() { -#line 972 "cs.ATG" +#line 975 "cs.ATG" AttributeSection section; Expect(16); while (StartOf(13)) { -#line 975 "cs.ATG" +#line 978 "cs.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 18) { AttributeSection( -#line 978 "cs.ATG" +#line 981 "cs.ATG" out section); -#line 978 "cs.ATG" +#line 981 "cs.ATG" attributes.Add(section); } while (StartOf(12)) { MemberModifier( -#line 979 "cs.ATG" +#line 982 "cs.ATG" m); } StructMemberDecl( -#line 980 "cs.ATG" +#line 983 "cs.ATG" m, attributes); } Expect(17); } void InterfaceBase( -#line 985 "cs.ATG" +#line 988 "cs.ATG" out List names) { -#line 987 "cs.ATG" +#line 990 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 991 "cs.ATG" +#line 994 "cs.ATG" out typeRef, false); -#line 991 "cs.ATG" +#line 994 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 14) { lexer.NextToken(); TypeName( -#line 992 "cs.ATG" +#line 995 "cs.ATG" out typeRef, false); -#line 992 "cs.ATG" +#line 995 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } @@ -1544,72 +1547,72 @@ out typeRef, false); } void IntegralType( -#line 1147 "cs.ATG" +#line 1150 "cs.ATG" out string name) { -#line 1147 "cs.ATG" +#line 1150 "cs.ATG" name = ""; switch (la.kind) { case 101: { lexer.NextToken(); -#line 1149 "cs.ATG" +#line 1152 "cs.ATG" name = "sbyte"; break; } case 53: { lexer.NextToken(); -#line 1150 "cs.ATG" +#line 1153 "cs.ATG" name = "byte"; break; } case 103: { lexer.NextToken(); -#line 1151 "cs.ATG" +#line 1154 "cs.ATG" name = "short"; break; } case 119: { lexer.NextToken(); -#line 1152 "cs.ATG" +#line 1155 "cs.ATG" name = "ushort"; break; } case 81: { lexer.NextToken(); -#line 1153 "cs.ATG" +#line 1156 "cs.ATG" name = "int"; break; } case 115: { lexer.NextToken(); -#line 1154 "cs.ATG" +#line 1157 "cs.ATG" name = "uint"; break; } case 86: { lexer.NextToken(); -#line 1155 "cs.ATG" +#line 1158 "cs.ATG" name = "long"; break; } case 116: { lexer.NextToken(); -#line 1156 "cs.ATG" +#line 1159 "cs.ATG" name = "ulong"; break; } case 56: { lexer.NextToken(); -#line 1157 "cs.ATG" +#line 1160 "cs.ATG" name = "char"; break; } @@ -1619,25 +1622,25 @@ out string name) { void EnumBody() { -#line 998 "cs.ATG" +#line 1001 "cs.ATG" FieldDeclaration f; Expect(16); if (la.kind == 1 || la.kind == 18) { EnumMemberDecl( -#line 1000 "cs.ATG" +#line 1003 "cs.ATG" out f); -#line 1000 "cs.ATG" +#line 1003 "cs.ATG" compilationUnit.AddChild(f); while ( -#line 1001 "cs.ATG" +#line 1004 "cs.ATG" NotFinalComma()) { Expect(14); EnumMemberDecl( -#line 1001 "cs.ATG" +#line 1004 "cs.ATG" out f); -#line 1001 "cs.ATG" +#line 1004 "cs.ATG" compilationUnit.AddChild(f); } if (la.kind == 14) { @@ -1648,36 +1651,36 @@ out f); } void Type( -#line 1006 "cs.ATG" +#line 1009 "cs.ATG" out TypeReference type) { TypeWithRestriction( -#line 1008 "cs.ATG" +#line 1011 "cs.ATG" out type, true, false); } void FormalParameterList( -#line 1069 "cs.ATG" +#line 1072 "cs.ATG" List parameter) { -#line 1072 "cs.ATG" +#line 1075 "cs.ATG" ParameterDeclarationExpression p; AttributeSection section; List attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1077 "cs.ATG" +#line 1080 "cs.ATG" out section); -#line 1077 "cs.ATG" +#line 1080 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 1079 "cs.ATG" +#line 1082 "cs.ATG" out p); -#line 1079 "cs.ATG" +#line 1082 "cs.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1685,96 +1688,96 @@ out p); while (la.kind == 14) { lexer.NextToken(); -#line 1084 "cs.ATG" +#line 1087 "cs.ATG" attributes = new List(); if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 18) { AttributeSection( -#line 1085 "cs.ATG" +#line 1088 "cs.ATG" out section); -#line 1085 "cs.ATG" +#line 1088 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 1087 "cs.ATG" +#line 1090 "cs.ATG" out p); -#line 1087 "cs.ATG" +#line 1090 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else if (la.kind == 94) { ParameterArray( -#line 1088 "cs.ATG" +#line 1091 "cs.ATG" out p); -#line 1088 "cs.ATG" +#line 1091 "cs.ATG" paramsFound = true; p.Attributes = attributes; parameter.Add(p); } else SynErr(134); } } else if (la.kind == 94) { ParameterArray( -#line 1091 "cs.ATG" +#line 1094 "cs.ATG" out p); -#line 1091 "cs.ATG" +#line 1094 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else SynErr(135); } void ClassType( -#line 1139 "cs.ATG" +#line 1142 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 1140 "cs.ATG" +#line 1143 "cs.ATG" TypeReference r; typeRef = null; if (la.kind == 1) { TypeName( -#line 1142 "cs.ATG" +#line 1145 "cs.ATG" out r, canBeUnbound); -#line 1142 "cs.ATG" +#line 1145 "cs.ATG" typeRef = r; } else if (la.kind == 90) { lexer.NextToken(); -#line 1143 "cs.ATG" +#line 1146 "cs.ATG" typeRef = new TypeReference("object"); } else if (la.kind == 107) { lexer.NextToken(); -#line 1144 "cs.ATG" +#line 1147 "cs.ATG" typeRef = new TypeReference("string"); } else SynErr(136); } void TypeName( -#line 2412 "cs.ATG" +#line 2415 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2413 "cs.ATG" +#line 2416 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 2418 "cs.ATG" +#line 2421 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 2419 "cs.ATG" +#line 2422 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2422 "cs.ATG" +#line 2425 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2423 "cs.ATG" +#line 2426 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2425 "cs.ATG" +#line 2428 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1785,125 +1788,125 @@ out typeArguments, canBeUnbound); } while ( -#line 2434 "cs.ATG" +#line 2437 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2435 "cs.ATG" +#line 2438 "cs.ATG" typeArguments = null; Qualident( -#line 2436 "cs.ATG" +#line 2439 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2437 "cs.ATG" +#line 2440 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2438 "cs.ATG" +#line 2441 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } } void MemberModifier( -#line 1160 "cs.ATG" +#line 1163 "cs.ATG" Modifiers m) { switch (la.kind) { case 48: { lexer.NextToken(); -#line 1162 "cs.ATG" +#line 1165 "cs.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 70: { lexer.NextToken(); -#line 1163 "cs.ATG" +#line 1166 "cs.ATG" m.Add(Modifier.Extern, t.Location); break; } case 83: { lexer.NextToken(); -#line 1164 "cs.ATG" +#line 1167 "cs.ATG" m.Add(Modifier.Internal, t.Location); break; } case 88: { lexer.NextToken(); -#line 1165 "cs.ATG" +#line 1168 "cs.ATG" m.Add(Modifier.New, t.Location); break; } case 93: { lexer.NextToken(); -#line 1166 "cs.ATG" +#line 1169 "cs.ATG" m.Add(Modifier.Override, t.Location); break; } case 95: { lexer.NextToken(); -#line 1167 "cs.ATG" +#line 1170 "cs.ATG" m.Add(Modifier.Private, t.Location); break; } case 96: { lexer.NextToken(); -#line 1168 "cs.ATG" +#line 1171 "cs.ATG" m.Add(Modifier.Protected, t.Location); break; } case 97: { lexer.NextToken(); -#line 1169 "cs.ATG" +#line 1172 "cs.ATG" m.Add(Modifier.Public, t.Location); break; } case 98: { lexer.NextToken(); -#line 1170 "cs.ATG" +#line 1173 "cs.ATG" m.Add(Modifier.ReadOnly, t.Location); break; } case 102: { lexer.NextToken(); -#line 1171 "cs.ATG" +#line 1174 "cs.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 106: { lexer.NextToken(); -#line 1172 "cs.ATG" +#line 1175 "cs.ATG" m.Add(Modifier.Static, t.Location); break; } case 118: { lexer.NextToken(); -#line 1173 "cs.ATG" +#line 1176 "cs.ATG" m.Add(Modifier.Unsafe, t.Location); break; } case 121: { lexer.NextToken(); -#line 1174 "cs.ATG" +#line 1177 "cs.ATG" m.Add(Modifier.Virtual, t.Location); break; } case 123: { lexer.NextToken(); -#line 1175 "cs.ATG" +#line 1178 "cs.ATG" m.Add(Modifier.Volatile, t.Location); break; } @@ -1912,23 +1915,23 @@ Modifiers m) { } void ClassMemberDecl( -#line 1445 "cs.ATG" +#line 1448 "cs.ATG" Modifiers m, List attributes) { -#line 1446 "cs.ATG" +#line 1449 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 1448 "cs.ATG" +#line 1451 "cs.ATG" m, attributes); } else if (la.kind == 27) { -#line 1449 "cs.ATG" +#line 1452 "cs.ATG" m.Check(Modifier.Destructors); Point startPos = t.Location; lexer.NextToken(); Expect(1); -#line 1450 "cs.ATG" +#line 1453 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1936,17 +1939,17 @@ m, attributes); Expect(20); Expect(21); -#line 1454 "cs.ATG" +#line 1457 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 1454 "cs.ATG" +#line 1457 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(138); -#line 1455 "cs.ATG" +#line 1458 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1954,10 +1957,10 @@ out stmt); } void StructMemberDecl( -#line 1178 "cs.ATG" +#line 1181 "cs.ATG" Modifiers m, List attributes) { -#line 1180 "cs.ATG" +#line 1183 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1969,18 +1972,18 @@ Modifiers m, List attributes) { if (la.kind == 59) { -#line 1190 "cs.ATG" +#line 1193 "cs.ATG" m.Check(Modifier.Constants); lexer.NextToken(); -#line 1191 "cs.ATG" +#line 1194 "cs.ATG" Point startPos = t.Location; Type( -#line 1192 "cs.ATG" +#line 1195 "cs.ATG" out type); Expect(1); -#line 1192 "cs.ATG" +#line 1195 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); @@ -1988,72 +1991,72 @@ out type); Expect(3); Expr( -#line 1197 "cs.ATG" +#line 1200 "cs.ATG" out expr); -#line 1197 "cs.ATG" +#line 1200 "cs.ATG" f.Initializer = expr; while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1198 "cs.ATG" +#line 1201 "cs.ATG" f = new VariableDeclaration(t.val); fd.Fields.Add(f); Expect(3); Expr( -#line 1201 "cs.ATG" +#line 1204 "cs.ATG" out expr); -#line 1201 "cs.ATG" +#line 1204 "cs.ATG" f.Initializer = expr; } Expect(11); -#line 1202 "cs.ATG" +#line 1205 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( -#line 1205 "cs.ATG" +#line 1208 "cs.ATG" NotVoidPointer()) { -#line 1205 "cs.ATG" +#line 1208 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); Expect(122); -#line 1206 "cs.ATG" +#line 1209 "cs.ATG" Point startPos = t.Location; if ( -#line 1207 "cs.ATG" +#line 1210 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 1208 "cs.ATG" +#line 1211 "cs.ATG" out explicitInterface, false); -#line 1209 "cs.ATG" +#line 1212 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1212 "cs.ATG" +#line 1215 "cs.ATG" qualident = t.val; } else SynErr(140); if (la.kind == 23) { TypeParameterList( -#line 1215 "cs.ATG" +#line 1218 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1218 "cs.ATG" +#line 1221 "cs.ATG" p); } Expect(21); -#line 1219 "cs.ATG" +#line 1222 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, new TypeReference("void"), @@ -2068,31 +2071,31 @@ p); compilationUnit.BlockStart(methodDeclaration); while ( -#line 1234 "cs.ATG" +#line 1237 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1234 "cs.ATG" +#line 1237 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 1236 "cs.ATG" +#line 1239 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(141); -#line 1236 "cs.ATG" +#line 1239 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 68) { -#line 1240 "cs.ATG" +#line 1243 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); lexer.NextToken(); -#line 1241 "cs.ATG" +#line 1244 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration(null, null, m.Modifier, attributes, null); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); @@ -2101,104 +2104,104 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 1248 "cs.ATG" +#line 1251 "cs.ATG" out type); -#line 1248 "cs.ATG" +#line 1251 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 1249 "cs.ATG" +#line 1252 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 1250 "cs.ATG" +#line 1253 "cs.ATG" out explicitInterface, false); -#line 1251 "cs.ATG" +#line 1254 "cs.ATG" qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); -#line 1252 "cs.ATG" +#line 1255 "cs.ATG" eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); } else if (la.kind == 1) { lexer.NextToken(); -#line 1254 "cs.ATG" +#line 1257 "cs.ATG" qualident = t.val; } else SynErr(142); -#line 1256 "cs.ATG" +#line 1259 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; if (la.kind == 16) { lexer.NextToken(); -#line 1257 "cs.ATG" +#line 1260 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 1258 "cs.ATG" +#line 1261 "cs.ATG" out addBlock, out removeBlock); Expect(17); -#line 1259 "cs.ATG" +#line 1262 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } -#line 1262 "cs.ATG" +#line 1265 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 1268 "cs.ATG" +#line 1271 "cs.ATG" IdentAndLPar()) { -#line 1268 "cs.ATG" +#line 1271 "cs.ATG" m.Check(Modifier.Constructors | Modifier.StaticConstructors); Expect(1); -#line 1269 "cs.ATG" +#line 1272 "cs.ATG" string name = t.val; Point startPos = t.Location; Expect(20); if (StartOf(10)) { -#line 1269 "cs.ATG" +#line 1272 "cs.ATG" m.Check(Modifier.Constructors); FormalParameterList( -#line 1270 "cs.ATG" +#line 1273 "cs.ATG" p); } Expect(21); -#line 1272 "cs.ATG" +#line 1275 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 1273 "cs.ATG" +#line 1276 "cs.ATG" m.Check(Modifier.Constructors); ConstructorInitializer( -#line 1274 "cs.ATG" +#line 1277 "cs.ATG" out init); } -#line 1276 "cs.ATG" +#line 1279 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 1281 "cs.ATG" +#line 1284 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(143); -#line 1281 "cs.ATG" +#line 1284 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 69 || la.kind == 79) { -#line 1284 "cs.ATG" +#line 1287 "cs.ATG" m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -2207,45 +2210,45 @@ out stmt); if (la.kind == 79) { lexer.NextToken(); -#line 1289 "cs.ATG" +#line 1292 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); -#line 1289 "cs.ATG" +#line 1292 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(91); Type( -#line 1290 "cs.ATG" +#line 1293 "cs.ATG" out type); -#line 1290 "cs.ATG" +#line 1293 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( -#line 1291 "cs.ATG" +#line 1294 "cs.ATG" out type); Expect(1); -#line 1291 "cs.ATG" +#line 1294 "cs.ATG" string varName = t.val; Expect(21); -#line 1292 "cs.ATG" +#line 1295 "cs.ATG" Point endPos = t.Location; if (la.kind == 16) { Block( -#line 1293 "cs.ATG" +#line 1296 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 1293 "cs.ATG" +#line 1296 "cs.ATG" stmt = null; } else SynErr(144); -#line 1296 "cs.ATG" +#line 1299 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -2261,61 +2264,61 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 1311 "cs.ATG" +#line 1314 "cs.ATG" m, attributes); } else if (StartOf(9)) { Type( -#line 1312 "cs.ATG" +#line 1315 "cs.ATG" out type); -#line 1312 "cs.ATG" +#line 1315 "cs.ATG" Point startPos = t.Location; if (la.kind == 91) { -#line 1314 "cs.ATG" +#line 1317 "cs.ATG" OverloadableOperatorType op; m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 1318 "cs.ATG" +#line 1321 "cs.ATG" out op); -#line 1318 "cs.ATG" +#line 1321 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( -#line 1319 "cs.ATG" +#line 1322 "cs.ATG" out firstType); Expect(1); -#line 1319 "cs.ATG" +#line 1322 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( -#line 1320 "cs.ATG" +#line 1323 "cs.ATG" out secondType); Expect(1); -#line 1320 "cs.ATG" +#line 1323 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(145); -#line 1328 "cs.ATG" +#line 1331 "cs.ATG" Point endPos = t.Location; Expect(21); if (la.kind == 16) { Block( -#line 1329 "cs.ATG" +#line 1332 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(146); -#line 1331 "cs.ATG" +#line 1334 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -2332,43 +2335,43 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 1348 "cs.ATG" +#line 1351 "cs.ATG" IsVarDecl()) { -#line 1348 "cs.ATG" +#line 1351 "cs.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclarator( -#line 1352 "cs.ATG" +#line 1355 "cs.ATG" variableDeclarators); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 1353 "cs.ATG" +#line 1356 "cs.ATG" variableDeclarators); } Expect(11); -#line 1354 "cs.ATG" +#line 1357 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 110) { -#line 1357 "cs.ATG" +#line 1360 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( -#line 1358 "cs.ATG" +#line 1361 "cs.ATG" p); Expect(19); -#line 1358 "cs.ATG" +#line 1361 "cs.ATG" Point endLocation = t.EndLocation; Expect(16); -#line 1359 "cs.ATG" +#line 1362 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2377,58 +2380,58 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 1366 "cs.ATG" +#line 1369 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1367 "cs.ATG" +#line 1370 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( -#line 1372 "cs.ATG" +#line 1375 "cs.ATG" la.kind == Tokens.Identifier) { if ( -#line 1373 "cs.ATG" +#line 1376 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 1374 "cs.ATG" +#line 1377 "cs.ATG" out explicitInterface, false); -#line 1375 "cs.ATG" +#line 1378 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1378 "cs.ATG" +#line 1381 "cs.ATG" qualident = t.val; } else SynErr(147); -#line 1380 "cs.ATG" +#line 1383 "cs.ATG" Point qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { -#line 1384 "cs.ATG" +#line 1387 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( -#line 1386 "cs.ATG" +#line 1389 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1387 "cs.ATG" +#line 1390 "cs.ATG" p); } Expect(21); -#line 1388 "cs.ATG" +#line 1391 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, type, @@ -2442,26 +2445,26 @@ p); compilationUnit.AddChild(methodDeclaration); while ( -#line 1400 "cs.ATG" +#line 1403 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1400 "cs.ATG" +#line 1403 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 1401 "cs.ATG" +#line 1404 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(148); -#line 1401 "cs.ATG" +#line 1404 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1404 "cs.ATG" +#line 1407 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); @@ -2472,11 +2475,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1413 "cs.ATG" +#line 1416 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1415 "cs.ATG" +#line 1418 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2485,17 +2488,17 @@ out getRegion, out setRegion); } } else if (la.kind == 15) { -#line 1423 "cs.ATG" +#line 1426 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(110); Expect(18); FormalParameterList( -#line 1424 "cs.ATG" +#line 1427 "cs.ATG" p); Expect(19); -#line 1425 "cs.ATG" +#line 1428 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; @@ -2506,14 +2509,14 @@ p); Expect(16); -#line 1433 "cs.ATG" +#line 1436 "cs.ATG" Point bodyStart = t.Location; AccessorDecls( -#line 1434 "cs.ATG" +#line 1437 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 1435 "cs.ATG" +#line 1438 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2527,7 +2530,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1462 "cs.ATG" +#line 1465 "cs.ATG" TypeReference type; AttributeSection section; @@ -2542,51 +2545,51 @@ out getRegion, out setRegion); while (la.kind == 18) { AttributeSection( -#line 1475 "cs.ATG" +#line 1478 "cs.ATG" out section); -#line 1475 "cs.ATG" +#line 1478 "cs.ATG" attributes.Add(section); } if (la.kind == 88) { lexer.NextToken(); -#line 1476 "cs.ATG" +#line 1479 "cs.ATG" mod = Modifier.New; startLocation = t.Location; } if ( -#line 1479 "cs.ATG" +#line 1482 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 1479 "cs.ATG" +#line 1482 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1479 "cs.ATG" +#line 1482 "cs.ATG" name = t.val; if (la.kind == 23) { TypeParameterList( -#line 1480 "cs.ATG" +#line 1483 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1481 "cs.ATG" +#line 1484 "cs.ATG" parameters); } Expect(21); while ( -#line 1482 "cs.ATG" +#line 1485 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1482 "cs.ATG" +#line 1485 "cs.ATG" templates); } Expect(11); -#line 1484 "cs.ATG" +#line 1487 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2596,39 +2599,39 @@ templates); } else if (StartOf(18)) { if (StartOf(9)) { Type( -#line 1491 "cs.ATG" +#line 1494 "cs.ATG" out type); -#line 1491 "cs.ATG" +#line 1494 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1493 "cs.ATG" +#line 1496 "cs.ATG" name = t.val; Point qualIdentEndLocation = t.EndLocation; if (la.kind == 20 || la.kind == 23) { if (la.kind == 23) { TypeParameterList( -#line 1497 "cs.ATG" +#line 1500 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1498 "cs.ATG" +#line 1501 "cs.ATG" parameters); } Expect(21); while ( -#line 1500 "cs.ATG" +#line 1503 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1500 "cs.ATG" +#line 1503 "cs.ATG" templates); } Expect(11); -#line 1501 "cs.ATG" +#line 1504 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2637,72 +2640,72 @@ templates); } else if (la.kind == 16) { -#line 1508 "cs.ATG" +#line 1511 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1509 "cs.ATG" +#line 1512 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1509 "cs.ATG" +#line 1512 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1509 "cs.ATG" +#line 1512 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(152); } else if (la.kind == 110) { lexer.NextToken(); Expect(18); FormalParameterList( -#line 1512 "cs.ATG" +#line 1515 "cs.ATG" parameters); Expect(19); -#line 1512 "cs.ATG" +#line 1515 "cs.ATG" Point bracketEndLocation = t.EndLocation; -#line 1512 "cs.ATG" +#line 1515 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); Expect(16); -#line 1513 "cs.ATG" +#line 1516 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1513 "cs.ATG" +#line 1516 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1513 "cs.ATG" +#line 1516 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(153); } else { lexer.NextToken(); -#line 1516 "cs.ATG" +#line 1519 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1516 "cs.ATG" +#line 1519 "cs.ATG" out type); Expect(1); -#line 1516 "cs.ATG" +#line 1519 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null); compilationUnit.AddChild(ed); Expect(11); -#line 1519 "cs.ATG" +#line 1522 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(154); } void EnumMemberDecl( -#line 1524 "cs.ATG" +#line 1527 "cs.ATG" out FieldDeclaration f) { -#line 1526 "cs.ATG" +#line 1529 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2710,15 +2713,15 @@ out FieldDeclaration f) { while (la.kind == 18) { AttributeSection( -#line 1532 "cs.ATG" +#line 1535 "cs.ATG" out section); -#line 1532 "cs.ATG" +#line 1535 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1533 "cs.ATG" +#line 1536 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2727,78 +2730,78 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1538 "cs.ATG" +#line 1541 "cs.ATG" out expr); -#line 1538 "cs.ATG" +#line 1541 "cs.ATG" varDecl.Initializer = expr; } } void TypeWithRestriction( -#line 1011 "cs.ATG" +#line 1014 "cs.ATG" out TypeReference type, bool allowNullable, bool canBeUnbound) { -#line 1013 "cs.ATG" +#line 1016 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 90 || la.kind == 107) { ClassType( -#line 1018 "cs.ATG" +#line 1021 "cs.ATG" out type, canBeUnbound); } else if (StartOf(4)) { SimpleType( -#line 1019 "cs.ATG" +#line 1022 "cs.ATG" out name); -#line 1019 "cs.ATG" +#line 1022 "cs.ATG" type = new TypeReference(name); } else if (la.kind == 122) { lexer.NextToken(); Expect(6); -#line 1020 "cs.ATG" +#line 1023 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(155); -#line 1021 "cs.ATG" +#line 1024 "cs.ATG" List r = new List(); if ( -#line 1023 "cs.ATG" +#line 1026 "cs.ATG" allowNullable && la.kind == Tokens.Question) { NullableQuestionMark( -#line 1023 "cs.ATG" +#line 1026 "cs.ATG" ref type); } while ( -#line 1025 "cs.ATG" +#line 1028 "cs.ATG" IsPointerOrDims()) { -#line 1025 "cs.ATG" +#line 1028 "cs.ATG" int i = 0; if (la.kind == 6) { lexer.NextToken(); -#line 1026 "cs.ATG" +#line 1029 "cs.ATG" ++pointer; } else if (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1027 "cs.ATG" +#line 1030 "cs.ATG" ++i; } Expect(19); -#line 1027 "cs.ATG" +#line 1030 "cs.ATG" r.Add(i); } else SynErr(156); } -#line 1030 "cs.ATG" +#line 1033 "cs.ATG" if (type != null) { type.RankSpecifier = r.ToArray(); type.PointerNestingLevel = pointer; @@ -2807,57 +2810,57 @@ IsPointerOrDims()) { } void SimpleType( -#line 1058 "cs.ATG" +#line 1061 "cs.ATG" out string name) { -#line 1059 "cs.ATG" +#line 1062 "cs.ATG" name = String.Empty; if (StartOf(19)) { IntegralType( -#line 1061 "cs.ATG" +#line 1064 "cs.ATG" out name); } else if (la.kind == 74) { lexer.NextToken(); -#line 1062 "cs.ATG" +#line 1065 "cs.ATG" name = "float"; } else if (la.kind == 65) { lexer.NextToken(); -#line 1063 "cs.ATG" +#line 1066 "cs.ATG" name = "double"; } else if (la.kind == 61) { lexer.NextToken(); -#line 1064 "cs.ATG" +#line 1067 "cs.ATG" name = "decimal"; } else if (la.kind == 51) { lexer.NextToken(); -#line 1065 "cs.ATG" +#line 1068 "cs.ATG" name = "bool"; } else SynErr(157); } void NullableQuestionMark( -#line 2443 "cs.ATG" +#line 2446 "cs.ATG" ref TypeReference typeRef) { -#line 2444 "cs.ATG" +#line 2447 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2448 "cs.ATG" +#line 2451 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments); } void FixedParameter( -#line 1095 "cs.ATG" +#line 1098 "cs.ATG" out ParameterDeclarationExpression p) { -#line 1097 "cs.ATG" +#line 1100 "cs.ATG" TypeReference type; ParamModifier mod = ParamModifier.In; System.Drawing.Point start = t.Location; @@ -2866,82 +2869,82 @@ out ParameterDeclarationExpression p) { if (la.kind == 99) { lexer.NextToken(); -#line 1103 "cs.ATG" +#line 1106 "cs.ATG" mod = ParamModifier.Ref; } else { lexer.NextToken(); -#line 1104 "cs.ATG" +#line 1107 "cs.ATG" mod = ParamModifier.Out; } } Type( -#line 1106 "cs.ATG" +#line 1109 "cs.ATG" out type); Expect(1); -#line 1106 "cs.ATG" +#line 1109 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.Location; } void ParameterArray( -#line 1109 "cs.ATG" +#line 1112 "cs.ATG" out ParameterDeclarationExpression p) { -#line 1110 "cs.ATG" +#line 1113 "cs.ATG" TypeReference type; Expect(94); Type( -#line 1112 "cs.ATG" +#line 1115 "cs.ATG" out type); Expect(1); -#line 1112 "cs.ATG" +#line 1115 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, ParamModifier.Params); } void AccessorModifiers( -#line 1115 "cs.ATG" +#line 1118 "cs.ATG" out Modifiers m) { -#line 1116 "cs.ATG" +#line 1119 "cs.ATG" m = new Modifiers(); if (la.kind == 95) { lexer.NextToken(); -#line 1118 "cs.ATG" +#line 1121 "cs.ATG" m.Add(Modifier.Private, t.Location); } else if (la.kind == 96) { lexer.NextToken(); -#line 1119 "cs.ATG" +#line 1122 "cs.ATG" m.Add(Modifier.Protected, t.Location); if (la.kind == 83) { lexer.NextToken(); -#line 1120 "cs.ATG" +#line 1123 "cs.ATG" m.Add(Modifier.Internal, t.Location); } } else if (la.kind == 83) { lexer.NextToken(); -#line 1121 "cs.ATG" +#line 1124 "cs.ATG" m.Add(Modifier.Internal, t.Location); if (la.kind == 96) { lexer.NextToken(); -#line 1122 "cs.ATG" +#line 1125 "cs.ATG" m.Add(Modifier.Protected, t.Location); } } else SynErr(158); } void Block( -#line 1663 "cs.ATG" +#line 1666 "cs.ATG" out Statement stmt) { Expect(16); -#line 1665 "cs.ATG" +#line 1668 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); @@ -2952,7 +2955,7 @@ out Statement stmt) { } Expect(17); -#line 1672 "cs.ATG" +#line 1675 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2960,10 +2963,10 @@ out Statement stmt) { } void EventAccessorDecls( -#line 1598 "cs.ATG" +#line 1601 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1599 "cs.ATG" +#line 1602 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2972,102 +2975,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 18) { AttributeSection( -#line 1606 "cs.ATG" +#line 1609 "cs.ATG" out section); -#line 1606 "cs.ATG" +#line 1609 "cs.ATG" attributes.Add(section); } if ( -#line 1608 "cs.ATG" +#line 1611 "cs.ATG" IdentIsAdd()) { -#line 1608 "cs.ATG" +#line 1611 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1609 "cs.ATG" +#line 1612 "cs.ATG" out stmt); -#line 1609 "cs.ATG" +#line 1612 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 18) { AttributeSection( -#line 1610 "cs.ATG" +#line 1613 "cs.ATG" out section); -#line 1610 "cs.ATG" +#line 1613 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1611 "cs.ATG" +#line 1614 "cs.ATG" out stmt); -#line 1611 "cs.ATG" +#line 1614 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1612 "cs.ATG" +#line 1615 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1613 "cs.ATG" +#line 1616 "cs.ATG" out stmt); -#line 1613 "cs.ATG" +#line 1616 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1614 "cs.ATG" +#line 1617 "cs.ATG" out section); -#line 1614 "cs.ATG" +#line 1617 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1615 "cs.ATG" +#line 1618 "cs.ATG" out stmt); -#line 1615 "cs.ATG" +#line 1618 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1616 "cs.ATG" +#line 1619 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(159); } void ConstructorInitializer( -#line 1694 "cs.ATG" +#line 1697 "cs.ATG" out ConstructorInitializer ci) { -#line 1695 "cs.ATG" +#line 1698 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 50) { lexer.NextToken(); -#line 1699 "cs.ATG" +#line 1702 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 110) { lexer.NextToken(); -#line 1700 "cs.ATG" +#line 1703 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(160); Expect(20); if (StartOf(21)) { Argument( -#line 1703 "cs.ATG" +#line 1706 "cs.ATG" out expr); -#line 1703 "cs.ATG" +#line 1706 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1703 "cs.ATG" +#line 1706 "cs.ATG" out expr); -#line 1703 "cs.ATG" +#line 1706 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -3075,161 +3078,161 @@ out expr); } void OverloadableOperator( -#line 1717 "cs.ATG" +#line 1720 "cs.ATG" out OverloadableOperatorType op) { -#line 1718 "cs.ATG" +#line 1721 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1720 "cs.ATG" +#line 1723 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1721 "cs.ATG" +#line 1724 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 24: { lexer.NextToken(); -#line 1723 "cs.ATG" +#line 1726 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 27: { lexer.NextToken(); -#line 1724 "cs.ATG" +#line 1727 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 31: { lexer.NextToken(); -#line 1726 "cs.ATG" +#line 1729 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 32: { lexer.NextToken(); -#line 1727 "cs.ATG" +#line 1730 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 112: { lexer.NextToken(); -#line 1729 "cs.ATG" +#line 1732 "cs.ATG" op = OverloadableOperatorType.True; break; } case 71: { lexer.NextToken(); -#line 1730 "cs.ATG" +#line 1733 "cs.ATG" op = OverloadableOperatorType.False; break; } case 6: { lexer.NextToken(); -#line 1732 "cs.ATG" +#line 1735 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1733 "cs.ATG" +#line 1736 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1734 "cs.ATG" +#line 1737 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 28: { lexer.NextToken(); -#line 1736 "cs.ATG" +#line 1739 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 29: { lexer.NextToken(); -#line 1737 "cs.ATG" +#line 1740 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 30: { lexer.NextToken(); -#line 1738 "cs.ATG" +#line 1741 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 37: { lexer.NextToken(); -#line 1740 "cs.ATG" +#line 1743 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1741 "cs.ATG" +#line 1744 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 34: { lexer.NextToken(); -#line 1742 "cs.ATG" +#line 1745 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 23: { lexer.NextToken(); -#line 1743 "cs.ATG" +#line 1746 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 35: { lexer.NextToken(); -#line 1744 "cs.ATG" +#line 1747 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 36: { lexer.NextToken(); -#line 1745 "cs.ATG" +#line 1748 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 22: { lexer.NextToken(); -#line 1746 "cs.ATG" +#line 1749 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 22) { lexer.NextToken(); -#line 1746 "cs.ATG" +#line 1749 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -3239,34 +3242,34 @@ out OverloadableOperatorType op) { } void VariableDeclarator( -#line 1656 "cs.ATG" +#line 1659 "cs.ATG" List fieldDeclaration) { -#line 1657 "cs.ATG" +#line 1660 "cs.ATG" Expression expr = null; Expect(1); -#line 1659 "cs.ATG" +#line 1662 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1660 "cs.ATG" +#line 1663 "cs.ATG" out expr); -#line 1660 "cs.ATG" +#line 1663 "cs.ATG" f.Initializer = expr; } -#line 1660 "cs.ATG" +#line 1663 "cs.ATG" fieldDeclaration.Add(f); } void AccessorDecls( -#line 1542 "cs.ATG" +#line 1545 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1544 "cs.ATG" +#line 1547 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -3275,96 +3278,96 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1551 "cs.ATG" +#line 1554 "cs.ATG" out section); -#line 1551 "cs.ATG" +#line 1554 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1552 "cs.ATG" +#line 1555 "cs.ATG" out modifiers); } if ( -#line 1554 "cs.ATG" +#line 1557 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1555 "cs.ATG" +#line 1558 "cs.ATG" out getBlock, attributes); -#line 1556 "cs.ATG" +#line 1559 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1557 "cs.ATG" +#line 1560 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1558 "cs.ATG" +#line 1561 "cs.ATG" out section); -#line 1558 "cs.ATG" +#line 1561 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1559 "cs.ATG" +#line 1562 "cs.ATG" out modifiers); } SetAccessorDecl( -#line 1560 "cs.ATG" +#line 1563 "cs.ATG" out setBlock, attributes); -#line 1561 "cs.ATG" +#line 1564 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } } } else if ( -#line 1563 "cs.ATG" +#line 1566 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1564 "cs.ATG" +#line 1567 "cs.ATG" out setBlock, attributes); -#line 1565 "cs.ATG" +#line 1568 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1566 "cs.ATG" +#line 1569 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1567 "cs.ATG" +#line 1570 "cs.ATG" out section); -#line 1567 "cs.ATG" +#line 1570 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1568 "cs.ATG" +#line 1571 "cs.ATG" out modifiers); } GetAccessorDecl( -#line 1569 "cs.ATG" +#line 1572 "cs.ATG" out getBlock, attributes); -#line 1570 "cs.ATG" +#line 1573 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } } } else if (la.kind == 1) { lexer.NextToken(); -#line 1572 "cs.ATG" +#line 1575 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(162); } void InterfaceAccessors( -#line 1620 "cs.ATG" +#line 1623 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1622 "cs.ATG" +#line 1625 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; @@ -3372,284 +3375,284 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1628 "cs.ATG" +#line 1631 "cs.ATG" out section); -#line 1628 "cs.ATG" +#line 1631 "cs.ATG" attributes.Add(section); } -#line 1629 "cs.ATG" +#line 1632 "cs.ATG" Point startLocation = la.Location; if ( -#line 1631 "cs.ATG" +#line 1634 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1631 "cs.ATG" +#line 1634 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1632 "cs.ATG" +#line 1635 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1632 "cs.ATG" +#line 1635 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1633 "cs.ATG" +#line 1636 "cs.ATG" Error("set or get expected"); } else SynErr(163); Expect(11); -#line 1636 "cs.ATG" +#line 1639 "cs.ATG" if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } attributes = new List(); if (la.kind == 1 || la.kind == 18) { while (la.kind == 18) { AttributeSection( -#line 1640 "cs.ATG" +#line 1643 "cs.ATG" out section); -#line 1640 "cs.ATG" +#line 1643 "cs.ATG" attributes.Add(section); } -#line 1641 "cs.ATG" +#line 1644 "cs.ATG" startLocation = la.Location; if ( -#line 1643 "cs.ATG" +#line 1646 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1643 "cs.ATG" +#line 1646 "cs.ATG" if (getBlock != null) Error("get already declared"); else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } } else if ( -#line 1646 "cs.ATG" +#line 1649 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1646 "cs.ATG" +#line 1649 "cs.ATG" if (setBlock != null) Error("set already declared"); else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } } else if (la.kind == 1) { lexer.NextToken(); -#line 1649 "cs.ATG" +#line 1652 "cs.ATG" Error("set or get expected"); } else SynErr(164); Expect(11); -#line 1652 "cs.ATG" +#line 1655 "cs.ATG" if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } } } void GetAccessorDecl( -#line 1576 "cs.ATG" +#line 1579 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1577 "cs.ATG" +#line 1580 "cs.ATG" Statement stmt = null; Expect(1); -#line 1580 "cs.ATG" +#line 1583 "cs.ATG" if (t.val != "get") Error("get expected"); -#line 1581 "cs.ATG" +#line 1584 "cs.ATG" Point startLocation = t.Location; if (la.kind == 16) { Block( -#line 1582 "cs.ATG" +#line 1585 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); -#line 1583 "cs.ATG" +#line 1586 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); -#line 1584 "cs.ATG" +#line 1587 "cs.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } void SetAccessorDecl( -#line 1587 "cs.ATG" +#line 1590 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1588 "cs.ATG" +#line 1591 "cs.ATG" Statement stmt = null; Expect(1); -#line 1591 "cs.ATG" +#line 1594 "cs.ATG" if (t.val != "set") Error("set expected"); -#line 1592 "cs.ATG" +#line 1595 "cs.ATG" Point startLocation = t.Location; if (la.kind == 16) { Block( -#line 1593 "cs.ATG" +#line 1596 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(166); -#line 1594 "cs.ATG" +#line 1597 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); -#line 1595 "cs.ATG" +#line 1598 "cs.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } void AddAccessorDecl( -#line 1678 "cs.ATG" +#line 1681 "cs.ATG" out Statement stmt) { -#line 1679 "cs.ATG" +#line 1682 "cs.ATG" stmt = null; Expect(1); -#line 1682 "cs.ATG" +#line 1685 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1683 "cs.ATG" +#line 1686 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1686 "cs.ATG" +#line 1689 "cs.ATG" out Statement stmt) { -#line 1687 "cs.ATG" +#line 1690 "cs.ATG" stmt = null; Expect(1); -#line 1690 "cs.ATG" +#line 1693 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1691 "cs.ATG" +#line 1694 "cs.ATG" out stmt); } void VariableInitializer( -#line 1707 "cs.ATG" +#line 1710 "cs.ATG" out Expression initializerExpression) { -#line 1708 "cs.ATG" +#line 1711 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(5)) { Expr( -#line 1710 "cs.ATG" +#line 1713 "cs.ATG" out initializerExpression); } else if (la.kind == 16) { ArrayInitializer( -#line 1711 "cs.ATG" +#line 1714 "cs.ATG" out initializerExpression); } else if (la.kind == 105) { lexer.NextToken(); Type( -#line 1712 "cs.ATG" +#line 1715 "cs.ATG" out type); Expect(18); Expr( -#line 1712 "cs.ATG" +#line 1715 "cs.ATG" out expr); Expect(19); -#line 1712 "cs.ATG" +#line 1715 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(20); Type( -#line 1714 "cs.ATG" +#line 1717 "cs.ATG" out type); Expect(21); -#line 1714 "cs.ATG" +#line 1717 "cs.ATG" initializerExpression = new DefaultValueExpression(type); } else SynErr(167); } void Statement() { -#line 1826 "cs.ATG" +#line 1829 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; Point startPos = la.Location; if ( -#line 1834 "cs.ATG" +#line 1837 "cs.ATG" IsLabel()) { Expect(1); -#line 1834 "cs.ATG" +#line 1837 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 59) { lexer.NextToken(); Type( -#line 1837 "cs.ATG" +#line 1840 "cs.ATG" out type); -#line 1837 "cs.ATG" +#line 1840 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1838 "cs.ATG" +#line 1841 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1839 "cs.ATG" +#line 1842 "cs.ATG" out expr); -#line 1839 "cs.ATG" +#line 1842 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1840 "cs.ATG" +#line 1843 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1840 "cs.ATG" +#line 1843 "cs.ATG" out expr); -#line 1840 "cs.ATG" +#line 1843 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1841 "cs.ATG" +#line 1844 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1843 "cs.ATG" +#line 1846 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1843 "cs.ATG" +#line 1846 "cs.ATG" out stmt); Expect(11); -#line 1843 "cs.ATG" +#line 1846 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(23)) { EmbeddedStatement( -#line 1844 "cs.ATG" +#line 1847 "cs.ATG" out stmt); -#line 1844 "cs.ATG" +#line 1847 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(168); -#line 1850 "cs.ATG" +#line 1853 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3658,10 +3661,10 @@ out stmt); } void Argument( -#line 1749 "cs.ATG" +#line 1752 "cs.ATG" out Expression argumentexpr) { -#line 1751 "cs.ATG" +#line 1754 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3669,48 +3672,48 @@ out Expression argumentexpr) { if (la.kind == 99) { lexer.NextToken(); -#line 1756 "cs.ATG" +#line 1759 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1757 "cs.ATG" +#line 1760 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1759 "cs.ATG" +#line 1762 "cs.ATG" out expr); -#line 1759 "cs.ATG" +#line 1762 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1779 "cs.ATG" +#line 1782 "cs.ATG" out Expression outExpr) { -#line 1781 "cs.ATG" +#line 1784 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(16); if (StartOf(24)) { VariableInitializer( -#line 1786 "cs.ATG" +#line 1789 "cs.ATG" out expr); -#line 1787 "cs.ATG" +#line 1790 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1788 "cs.ATG" +#line 1791 "cs.ATG" NotFinalComma()) { Expect(14); VariableInitializer( -#line 1789 "cs.ATG" +#line 1792 "cs.ATG" out expr); -#line 1790 "cs.ATG" +#line 1793 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 14) { @@ -3719,138 +3722,138 @@ out expr); } Expect(17); -#line 1794 "cs.ATG" +#line 1797 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1762 "cs.ATG" +#line 1765 "cs.ATG" out AssignmentOperatorType op) { -#line 1763 "cs.ATG" +#line 1766 "cs.ATG" op = AssignmentOperatorType.None; if (la.kind == 3) { lexer.NextToken(); -#line 1765 "cs.ATG" +#line 1768 "cs.ATG" op = AssignmentOperatorType.Assign; } else if (la.kind == 38) { lexer.NextToken(); -#line 1766 "cs.ATG" +#line 1769 "cs.ATG" op = AssignmentOperatorType.Add; } else if (la.kind == 39) { lexer.NextToken(); -#line 1767 "cs.ATG" +#line 1770 "cs.ATG" op = AssignmentOperatorType.Subtract; } else if (la.kind == 40) { lexer.NextToken(); -#line 1768 "cs.ATG" +#line 1771 "cs.ATG" op = AssignmentOperatorType.Multiply; } else if (la.kind == 41) { lexer.NextToken(); -#line 1769 "cs.ATG" +#line 1772 "cs.ATG" op = AssignmentOperatorType.Divide; } else if (la.kind == 42) { lexer.NextToken(); -#line 1770 "cs.ATG" +#line 1773 "cs.ATG" op = AssignmentOperatorType.Modulus; } else if (la.kind == 43) { lexer.NextToken(); -#line 1771 "cs.ATG" +#line 1774 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; } else if (la.kind == 44) { lexer.NextToken(); -#line 1772 "cs.ATG" +#line 1775 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; } else if (la.kind == 45) { lexer.NextToken(); -#line 1773 "cs.ATG" +#line 1776 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; } else if (la.kind == 46) { lexer.NextToken(); -#line 1774 "cs.ATG" +#line 1777 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; } else if ( -#line 1775 "cs.ATG" +#line 1778 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { Expect(22); Expect(35); -#line 1776 "cs.ATG" +#line 1779 "cs.ATG" op = AssignmentOperatorType.ShiftRight; } else SynErr(169); } void LocalVariableDecl( -#line 1797 "cs.ATG" +#line 1800 "cs.ATG" out Statement stmt) { -#line 1799 "cs.ATG" +#line 1802 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1804 "cs.ATG" +#line 1807 "cs.ATG" out type); -#line 1804 "cs.ATG" +#line 1807 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1805 "cs.ATG" +#line 1808 "cs.ATG" out var); -#line 1805 "cs.ATG" +#line 1808 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 14) { lexer.NextToken(); LocalVariableDeclarator( -#line 1806 "cs.ATG" +#line 1809 "cs.ATG" out var); -#line 1806 "cs.ATG" +#line 1809 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1807 "cs.ATG" +#line 1810 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1810 "cs.ATG" +#line 1813 "cs.ATG" out VariableDeclaration var) { -#line 1811 "cs.ATG" +#line 1814 "cs.ATG" Expression expr = null; Expect(1); -#line 1814 "cs.ATG" +#line 1817 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1814 "cs.ATG" +#line 1817 "cs.ATG" out expr); -#line 1814 "cs.ATG" +#line 1817 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1857 "cs.ATG" +#line 1860 "cs.ATG" out Statement statement) { -#line 1859 "cs.ATG" +#line 1862 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3858,57 +3861,57 @@ out Statement statement) { if (la.kind == 16) { Block( -#line 1865 "cs.ATG" +#line 1868 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1867 "cs.ATG" +#line 1870 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1869 "cs.ATG" +#line 1872 "cs.ATG" UnCheckedAndLBrace()) { -#line 1869 "cs.ATG" +#line 1872 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 57) { lexer.NextToken(); } else if (la.kind == 117) { lexer.NextToken(); -#line 1870 "cs.ATG" +#line 1873 "cs.ATG" isChecked = false; } else SynErr(170); Block( -#line 1871 "cs.ATG" +#line 1874 "cs.ATG" out block); -#line 1871 "cs.ATG" +#line 1874 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 78) { lexer.NextToken(); -#line 1873 "cs.ATG" +#line 1876 "cs.ATG" Statement elseStatement = null; Expect(20); Expr( -#line 1874 "cs.ATG" +#line 1877 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1875 "cs.ATG" +#line 1878 "cs.ATG" out embeddedStatement); if (la.kind == 66) { lexer.NextToken(); EmbeddedStatement( -#line 1876 "cs.ATG" +#line 1879 "cs.ATG" out elseStatement); } -#line 1877 "cs.ATG" +#line 1880 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1878 "cs.ATG" +#line 1881 "cs.ATG" if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { /* else if-section (otherwise we would have a BlockStatment) */ (statement as IfElseStatement).ElseIfSections.Add( @@ -3920,104 +3923,104 @@ out elseStatement); } else if (la.kind == 109) { lexer.NextToken(); -#line 1886 "cs.ATG" +#line 1889 "cs.ATG" List switchSections = new List(); SwitchSection switchSection; Expect(20); Expr( -#line 1887 "cs.ATG" +#line 1890 "cs.ATG" out expr); Expect(21); Expect(16); while (la.kind == 54 || la.kind == 62) { SwitchSection( -#line 1888 "cs.ATG" +#line 1891 "cs.ATG" out switchSection); -#line 1888 "cs.ATG" +#line 1891 "cs.ATG" switchSections.Add(switchSection); } Expect(17); -#line 1889 "cs.ATG" +#line 1892 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 124) { lexer.NextToken(); Expect(20); Expr( -#line 1891 "cs.ATG" +#line 1894 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1893 "cs.ATG" +#line 1896 "cs.ATG" out embeddedStatement); -#line 1893 "cs.ATG" +#line 1896 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 64) { lexer.NextToken(); EmbeddedStatement( -#line 1894 "cs.ATG" +#line 1897 "cs.ATG" out embeddedStatement); Expect(124); Expect(20); Expr( -#line 1895 "cs.ATG" +#line 1898 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1895 "cs.ATG" +#line 1898 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 75) { lexer.NextToken(); -#line 1896 "cs.ATG" +#line 1899 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(5)) { ForInitializer( -#line 1897 "cs.ATG" +#line 1900 "cs.ATG" out initializer); } Expect(11); if (StartOf(5)) { Expr( -#line 1898 "cs.ATG" +#line 1901 "cs.ATG" out expr); } Expect(11); if (StartOf(5)) { ForIterator( -#line 1899 "cs.ATG" +#line 1902 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1900 "cs.ATG" +#line 1903 "cs.ATG" out embeddedStatement); -#line 1900 "cs.ATG" +#line 1903 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 76) { lexer.NextToken(); Expect(20); Type( -#line 1901 "cs.ATG" +#line 1904 "cs.ATG" out type); Expect(1); -#line 1901 "cs.ATG" +#line 1904 "cs.ATG" string varName = t.val; Point start = t.Location; Expect(80); Expr( -#line 1902 "cs.ATG" +#line 1905 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1903 "cs.ATG" +#line 1906 "cs.ATG" out embeddedStatement); -#line 1903 "cs.ATG" +#line 1906 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -4025,34 +4028,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1907 "cs.ATG" +#line 1910 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 60) { lexer.NextToken(); Expect(11); -#line 1908 "cs.ATG" +#line 1911 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 77) { GotoStatement( -#line 1909 "cs.ATG" +#line 1912 "cs.ATG" out statement); } else if ( -#line 1910 "cs.ATG" +#line 1913 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 100) { lexer.NextToken(); Expr( -#line 1910 "cs.ATG" +#line 1913 "cs.ATG" out expr); -#line 1910 "cs.ATG" +#line 1913 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 52) { lexer.NextToken(); -#line 1911 "cs.ATG" +#line 1914 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(171); Expect(11); @@ -4060,488 +4063,488 @@ out expr); lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1912 "cs.ATG" +#line 1915 "cs.ATG" out expr); } Expect(11); -#line 1912 "cs.ATG" +#line 1915 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 111) { lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1913 "cs.ATG" +#line 1916 "cs.ATG" out expr); } Expect(11); -#line 1913 "cs.ATG" +#line 1916 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(5)) { StatementExpr( -#line 1916 "cs.ATG" +#line 1919 "cs.ATG" out statement); Expect(11); } else if (la.kind == 113) { TryStatement( -#line 1918 "cs.ATG" +#line 1921 "cs.ATG" out statement); } else if (la.kind == 85) { lexer.NextToken(); Expect(20); Expr( -#line 1920 "cs.ATG" +#line 1923 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1921 "cs.ATG" +#line 1924 "cs.ATG" out embeddedStatement); -#line 1921 "cs.ATG" +#line 1924 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 120) { -#line 1923 "cs.ATG" +#line 1926 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1925 "cs.ATG" +#line 1928 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1926 "cs.ATG" +#line 1929 "cs.ATG" out embeddedStatement); -#line 1926 "cs.ATG" +#line 1929 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 118) { lexer.NextToken(); Block( -#line 1928 "cs.ATG" +#line 1931 "cs.ATG" out embeddedStatement); -#line 1928 "cs.ATG" +#line 1931 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 73) { lexer.NextToken(); Expect(20); Type( -#line 1931 "cs.ATG" +#line 1934 "cs.ATG" out type); -#line 1931 "cs.ATG" +#line 1934 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); List pointerDeclarators = new List(1); Expect(1); -#line 1934 "cs.ATG" +#line 1937 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1935 "cs.ATG" +#line 1938 "cs.ATG" out expr); -#line 1935 "cs.ATG" +#line 1938 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1937 "cs.ATG" +#line 1940 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1938 "cs.ATG" +#line 1941 "cs.ATG" out expr); -#line 1938 "cs.ATG" +#line 1941 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(21); EmbeddedStatement( -#line 1940 "cs.ATG" +#line 1943 "cs.ATG" out embeddedStatement); -#line 1940 "cs.ATG" +#line 1943 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(172); } void SwitchSection( -#line 1962 "cs.ATG" +#line 1965 "cs.ATG" out SwitchSection stmt) { -#line 1964 "cs.ATG" +#line 1967 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1968 "cs.ATG" +#line 1971 "cs.ATG" out label); -#line 1968 "cs.ATG" +#line 1971 "cs.ATG" switchSection.SwitchLabels.Add(label); while (la.kind == 54 || la.kind == 62) { SwitchLabel( -#line 1970 "cs.ATG" +#line 1973 "cs.ATG" out label); -#line 1970 "cs.ATG" +#line 1973 "cs.ATG" switchSection.SwitchLabels.Add(label); } -#line 1972 "cs.ATG" +#line 1975 "cs.ATG" compilationUnit.BlockStart(switchSection); Statement(); while (StartOf(20)) { Statement(); } -#line 1975 "cs.ATG" +#line 1978 "cs.ATG" compilationUnit.BlockEnd(); stmt = switchSection; } void ForInitializer( -#line 1943 "cs.ATG" +#line 1946 "cs.ATG" out List initializer) { -#line 1945 "cs.ATG" +#line 1948 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1949 "cs.ATG" +#line 1952 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1949 "cs.ATG" +#line 1952 "cs.ATG" out stmt); -#line 1949 "cs.ATG" +#line 1952 "cs.ATG" initializer.Add(stmt); } else if (StartOf(5)) { StatementExpr( -#line 1950 "cs.ATG" +#line 1953 "cs.ATG" out stmt); -#line 1950 "cs.ATG" +#line 1953 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1950 "cs.ATG" +#line 1953 "cs.ATG" out stmt); -#line 1950 "cs.ATG" +#line 1953 "cs.ATG" initializer.Add(stmt); } } else SynErr(173); } void ForIterator( -#line 1953 "cs.ATG" +#line 1956 "cs.ATG" out List iterator) { -#line 1955 "cs.ATG" +#line 1958 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1959 "cs.ATG" +#line 1962 "cs.ATG" out stmt); -#line 1959 "cs.ATG" +#line 1962 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1959 "cs.ATG" +#line 1962 "cs.ATG" out stmt); -#line 1959 "cs.ATG" +#line 1962 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 2030 "cs.ATG" +#line 2033 "cs.ATG" out Statement stmt) { -#line 2031 "cs.ATG" +#line 2034 "cs.ATG" Expression expr; stmt = null; Expect(77); if (la.kind == 1) { lexer.NextToken(); -#line 2035 "cs.ATG" +#line 2038 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 54) { lexer.NextToken(); Expr( -#line 2036 "cs.ATG" +#line 2039 "cs.ATG" out expr); Expect(11); -#line 2036 "cs.ATG" +#line 2039 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(11); -#line 2037 "cs.ATG" +#line 2040 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(174); } void StatementExpr( -#line 2057 "cs.ATG" +#line 2060 "cs.ATG" out Statement stmt) { -#line 2058 "cs.ATG" +#line 2061 "cs.ATG" Expression expr; Expr( -#line 2060 "cs.ATG" +#line 2063 "cs.ATG" out expr); -#line 2063 "cs.ATG" +#line 2066 "cs.ATG" stmt = new StatementExpression(expr); } void TryStatement( -#line 1987 "cs.ATG" +#line 1990 "cs.ATG" out Statement tryStatement) { -#line 1989 "cs.ATG" +#line 1992 "cs.ATG" Statement blockStmt = null, finallyStmt = null; List catchClauses = null; Expect(113); Block( -#line 1993 "cs.ATG" +#line 1996 "cs.ATG" out blockStmt); if (la.kind == 55) { CatchClauses( -#line 1995 "cs.ATG" +#line 1998 "cs.ATG" out catchClauses); if (la.kind == 72) { lexer.NextToken(); Block( -#line 1995 "cs.ATG" +#line 1998 "cs.ATG" out finallyStmt); } } else if (la.kind == 72) { lexer.NextToken(); Block( -#line 1996 "cs.ATG" +#line 1999 "cs.ATG" out finallyStmt); } else SynErr(175); -#line 1999 "cs.ATG" +#line 2002 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 2041 "cs.ATG" +#line 2044 "cs.ATG" out Statement stmt) { -#line 2043 "cs.ATG" +#line 2046 "cs.ATG" stmt = null; Expression expr; if ( -#line 2048 "cs.ATG" +#line 2051 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 2048 "cs.ATG" +#line 2051 "cs.ATG" out stmt); } else if (StartOf(5)) { Expr( -#line 2049 "cs.ATG" +#line 2052 "cs.ATG" out expr); -#line 2053 "cs.ATG" +#line 2056 "cs.ATG" stmt = new StatementExpression(expr); } else SynErr(176); } void SwitchLabel( -#line 1980 "cs.ATG" +#line 1983 "cs.ATG" out CaseLabel label) { -#line 1981 "cs.ATG" +#line 1984 "cs.ATG" Expression expr = null; label = null; if (la.kind == 54) { lexer.NextToken(); Expr( -#line 1983 "cs.ATG" +#line 1986 "cs.ATG" out expr); Expect(9); -#line 1983 "cs.ATG" +#line 1986 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(9); -#line 1984 "cs.ATG" +#line 1987 "cs.ATG" label = new CaseLabel(); } else SynErr(177); } void CatchClauses( -#line 2004 "cs.ATG" +#line 2007 "cs.ATG" out List catchClauses) { -#line 2006 "cs.ATG" +#line 2009 "cs.ATG" catchClauses = new List(); Expect(55); -#line 2009 "cs.ATG" +#line 2012 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; if (la.kind == 16) { Block( -#line 2015 "cs.ATG" +#line 2018 "cs.ATG" out stmt); -#line 2015 "cs.ATG" +#line 2018 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 2017 "cs.ATG" +#line 2020 "cs.ATG" out typeRef, false); -#line 2017 "cs.ATG" +#line 2020 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 2018 "cs.ATG" +#line 2021 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 2019 "cs.ATG" +#line 2022 "cs.ATG" out stmt); -#line 2020 "cs.ATG" +#line 2023 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); while ( -#line 2021 "cs.ATG" +#line 2024 "cs.ATG" IsTypedCatch()) { Expect(55); Expect(20); ClassType( -#line 2021 "cs.ATG" +#line 2024 "cs.ATG" out typeRef, false); -#line 2021 "cs.ATG" +#line 2024 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 2022 "cs.ATG" +#line 2025 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 2023 "cs.ATG" +#line 2026 "cs.ATG" out stmt); -#line 2024 "cs.ATG" +#line 2027 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); } if (la.kind == 55) { lexer.NextToken(); Block( -#line 2026 "cs.ATG" +#line 2029 "cs.ATG" out stmt); -#line 2026 "cs.ATG" +#line 2029 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(178); } void UnaryExpr( -#line 2084 "cs.ATG" +#line 2087 "cs.ATG" out Expression uExpr) { -#line 2086 "cs.ATG" +#line 2089 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(25) || -#line 2108 "cs.ATG" +#line 2111 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 2095 "cs.ATG" +#line 2098 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 2096 "cs.ATG" +#line 2099 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 2097 "cs.ATG" +#line 2100 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 2098 "cs.ATG" +#line 2101 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 2099 "cs.ATG" +#line 2102 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 31) { lexer.NextToken(); -#line 2100 "cs.ATG" +#line 2103 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 2101 "cs.ATG" +#line 2104 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 2102 "cs.ATG" +#line 2105 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(20); Type( -#line 2108 "cs.ATG" +#line 2111 "cs.ATG" out type); Expect(21); -#line 2108 "cs.ATG" +#line 2111 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 2112 "cs.ATG" +#line 2115 "cs.ATG" out expr); -#line 2112 "cs.ATG" +#line 2115 "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) { @@ -4559,33 +4562,33 @@ out expr); } void ConditionalOrExpr( -#line 2283 "cs.ATG" +#line 2286 "cs.ATG" ref Expression outExpr) { -#line 2284 "cs.ATG" +#line 2287 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2286 "cs.ATG" +#line 2289 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2286 "cs.ATG" +#line 2289 "cs.ATG" out expr); ConditionalAndExpr( -#line 2286 "cs.ATG" +#line 2289 "cs.ATG" ref expr); -#line 2286 "cs.ATG" +#line 2289 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 2129 "cs.ATG" +#line 2132 "cs.ATG" out Expression pexpr) { -#line 2131 "cs.ATG" +#line 2134 "cs.ATG" TypeReference type = null; List typeList = null; bool isArrayCreation = false; @@ -4595,332 +4598,332 @@ out Expression pexpr) { if (la.kind == 112) { lexer.NextToken(); -#line 2139 "cs.ATG" +#line 2142 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 71) { lexer.NextToken(); -#line 2140 "cs.ATG" +#line 2143 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 89) { lexer.NextToken(); -#line 2141 "cs.ATG" +#line 2144 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 2142 "cs.ATG" +#line 2145 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); } else if ( -#line 2143 "cs.ATG" +#line 2146 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { Expect(1); -#line 2144 "cs.ATG" +#line 2147 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 2145 "cs.ATG" +#line 2148 "cs.ATG" pexpr = new TypeReferenceExpression(type); Expect(1); -#line 2146 "cs.ATG" +#line 2149 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val; } else type.Type += "." + t.val; } else if (la.kind == 1) { lexer.NextToken(); -#line 2148 "cs.ATG" +#line 2151 "cs.ATG" pexpr = new IdentifierExpression(t.val); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 2150 "cs.ATG" +#line 2153 "cs.ATG" out expr); Expect(21); -#line 2150 "cs.ATG" +#line 2153 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(26)) { -#line 2152 "cs.ATG" +#line 2155 "cs.ATG" string val = null; switch (la.kind) { case 51: { lexer.NextToken(); -#line 2154 "cs.ATG" +#line 2157 "cs.ATG" val = "bool"; break; } case 53: { lexer.NextToken(); -#line 2155 "cs.ATG" +#line 2158 "cs.ATG" val = "byte"; break; } case 56: { lexer.NextToken(); -#line 2156 "cs.ATG" +#line 2159 "cs.ATG" val = "char"; break; } case 61: { lexer.NextToken(); -#line 2157 "cs.ATG" +#line 2160 "cs.ATG" val = "decimal"; break; } case 65: { lexer.NextToken(); -#line 2158 "cs.ATG" +#line 2161 "cs.ATG" val = "double"; break; } case 74: { lexer.NextToken(); -#line 2159 "cs.ATG" +#line 2162 "cs.ATG" val = "float"; break; } case 81: { lexer.NextToken(); -#line 2160 "cs.ATG" +#line 2163 "cs.ATG" val = "int"; break; } case 86: { lexer.NextToken(); -#line 2161 "cs.ATG" +#line 2164 "cs.ATG" val = "long"; break; } case 90: { lexer.NextToken(); -#line 2162 "cs.ATG" +#line 2165 "cs.ATG" val = "object"; break; } case 101: { lexer.NextToken(); -#line 2163 "cs.ATG" +#line 2166 "cs.ATG" val = "sbyte"; break; } case 103: { lexer.NextToken(); -#line 2164 "cs.ATG" +#line 2167 "cs.ATG" val = "short"; break; } case 107: { lexer.NextToken(); -#line 2165 "cs.ATG" +#line 2168 "cs.ATG" val = "string"; break; } case 115: { lexer.NextToken(); -#line 2166 "cs.ATG" +#line 2169 "cs.ATG" val = "uint"; break; } case 116: { lexer.NextToken(); -#line 2167 "cs.ATG" +#line 2170 "cs.ATG" val = "ulong"; break; } case 119: { lexer.NextToken(); -#line 2168 "cs.ATG" +#line 2171 "cs.ATG" val = "ushort"; break; } } -#line 2169 "cs.ATG" +#line 2172 "cs.ATG" t.val = ""; Expect(15); Expect(1); -#line 2169 "cs.ATG" +#line 2172 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); } else if (la.kind == 110) { lexer.NextToken(); -#line 2171 "cs.ATG" +#line 2174 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 50) { lexer.NextToken(); -#line 2173 "cs.ATG" +#line 2176 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 2175 "cs.ATG" +#line 2178 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 18) { lexer.NextToken(); Expr( -#line 2176 "cs.ATG" +#line 2179 "cs.ATG" out expr); -#line 2176 "cs.ATG" +#line 2179 "cs.ATG" List indices = new List(); if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 2177 "cs.ATG" +#line 2180 "cs.ATG" out expr); -#line 2177 "cs.ATG" +#line 2180 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 2178 "cs.ATG" +#line 2181 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(179); -#line 2179 "cs.ATG" +#line 2182 "cs.ATG" pexpr = retExpr; } else if (la.kind == 88) { lexer.NextToken(); NonArrayType( -#line 2180 "cs.ATG" +#line 2183 "cs.ATG" out type); -#line 2181 "cs.ATG" +#line 2184 "cs.ATG" List parameters = new List(); if (la.kind == 20) { lexer.NextToken(); -#line 2186 "cs.ATG" +#line 2189 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 2187 "cs.ATG" +#line 2190 "cs.ATG" out expr); -#line 2187 "cs.ATG" +#line 2190 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2188 "cs.ATG" +#line 2191 "cs.ATG" out expr); -#line 2188 "cs.ATG" +#line 2191 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(21); -#line 2190 "cs.ATG" +#line 2193 "cs.ATG" pexpr = oce; } else if (la.kind == 18) { lexer.NextToken(); -#line 2192 "cs.ATG" +#line 2195 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; -#line 2193 "cs.ATG" +#line 2196 "cs.ATG" int dims = 0; List ranks = new List(); if (la.kind == 14 || la.kind == 19) { while (la.kind == 14) { lexer.NextToken(); -#line 2195 "cs.ATG" +#line 2198 "cs.ATG" dims += 1; } Expect(19); -#line 2196 "cs.ATG" +#line 2199 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2197 "cs.ATG" +#line 2200 "cs.ATG" ++dims; } Expect(19); -#line 2197 "cs.ATG" +#line 2200 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2198 "cs.ATG" +#line 2201 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); ArrayInitializer( -#line 2199 "cs.ATG" +#line 2202 "cs.ATG" out expr); -#line 2199 "cs.ATG" +#line 2202 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } else if (StartOf(5)) { Expr( -#line 2200 "cs.ATG" +#line 2203 "cs.ATG" out expr); -#line 2200 "cs.ATG" +#line 2203 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2201 "cs.ATG" +#line 2204 "cs.ATG" dims += 1; Expr( -#line 2202 "cs.ATG" +#line 2205 "cs.ATG" out expr); -#line 2202 "cs.ATG" +#line 2205 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2204 "cs.ATG" +#line 2207 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2205 "cs.ATG" +#line 2208 "cs.ATG" ++dims; } Expect(19); -#line 2205 "cs.ATG" +#line 2208 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2206 "cs.ATG" +#line 2209 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { ArrayInitializer( -#line 2207 "cs.ATG" +#line 2210 "cs.ATG" out expr); -#line 2207 "cs.ATG" +#line 2210 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else SynErr(180); @@ -4929,204 +4932,204 @@ out expr); lexer.NextToken(); Expect(20); if ( -#line 2212 "cs.ATG" +#line 2215 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 2212 "cs.ATG" +#line 2215 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(9)) { TypeWithRestriction( -#line 2213 "cs.ATG" +#line 2216 "cs.ATG" out type, true, true); } else SynErr(182); Expect(21); -#line 2214 "cs.ATG" +#line 2217 "cs.ATG" pexpr = new TypeOfExpression(type); } else if ( -#line 2216 "cs.ATG" +#line 2219 "cs.ATG" la.kind == Tokens.Default && Peek(1).kind == Tokens.OpenParenthesis) { Expect(62); Expect(20); Type( -#line 2218 "cs.ATG" +#line 2221 "cs.ATG" out type); Expect(21); -#line 2218 "cs.ATG" +#line 2221 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 104) { lexer.NextToken(); Expect(20); Type( -#line 2219 "cs.ATG" +#line 2222 "cs.ATG" out type); Expect(21); -#line 2219 "cs.ATG" +#line 2222 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 57) { lexer.NextToken(); Expect(20); Expr( -#line 2220 "cs.ATG" +#line 2223 "cs.ATG" out expr); Expect(21); -#line 2220 "cs.ATG" +#line 2223 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 117) { lexer.NextToken(); Expect(20); Expr( -#line 2221 "cs.ATG" +#line 2224 "cs.ATG" out expr); Expect(21); -#line 2221 "cs.ATG" +#line 2224 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 63) { lexer.NextToken(); AnonymousMethodExpr( -#line 2222 "cs.ATG" +#line 2225 "cs.ATG" out expr); -#line 2222 "cs.ATG" +#line 2225 "cs.ATG" pexpr = expr; } else SynErr(183); while (StartOf(27) || -#line 2233 "cs.ATG" +#line 2236 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || -#line 2242 "cs.ATG" +#line 2245 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { lexer.NextToken(); -#line 2226 "cs.ATG" +#line 2229 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 2227 "cs.ATG" +#line 2230 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(184); } else if (la.kind == 47) { lexer.NextToken(); Expect(1); -#line 2230 "cs.ATG" +#line 2233 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 2231 "cs.ATG" +#line 2234 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if ( -#line 2233 "cs.ATG" +#line 2236 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) { TypeArgumentList( -#line 2234 "cs.ATG" +#line 2237 "cs.ATG" out typeList, false); Expect(15); Expect(1); -#line 2236 "cs.ATG" +#line 2239 "cs.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeList), t.val); } else if (la.kind == 20) { lexer.NextToken(); -#line 2238 "cs.ATG" +#line 2241 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 2239 "cs.ATG" +#line 2242 "cs.ATG" out expr); -#line 2239 "cs.ATG" +#line 2242 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2240 "cs.ATG" +#line 2243 "cs.ATG" out expr); -#line 2240 "cs.ATG" +#line 2243 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 2241 "cs.ATG" +#line 2244 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else if ( -#line 2242 "cs.ATG" +#line 2245 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { TypeArgumentList( -#line 2242 "cs.ATG" +#line 2245 "cs.ATG" out typeList, false); Expect(20); -#line 2243 "cs.ATG" +#line 2246 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 2244 "cs.ATG" +#line 2247 "cs.ATG" out expr); -#line 2244 "cs.ATG" +#line 2247 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2245 "cs.ATG" +#line 2248 "cs.ATG" out expr); -#line 2245 "cs.ATG" +#line 2248 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 2246 "cs.ATG" +#line 2249 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 2248 "cs.ATG" +#line 2251 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); List indices = new List(); lexer.NextToken(); Expr( -#line 2251 "cs.ATG" +#line 2254 "cs.ATG" out expr); -#line 2251 "cs.ATG" +#line 2254 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 2252 "cs.ATG" +#line 2255 "cs.ATG" out expr); -#line 2252 "cs.ATG" +#line 2255 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 2253 "cs.ATG" +#line 2256 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void AnonymousMethodExpr( -#line 2257 "cs.ATG" +#line 2260 "cs.ATG" out Expression outExpr) { -#line 2259 "cs.ATG" +#line 2262 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; Statement stmt; @@ -5137,74 +5140,74 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(10)) { FormalParameterList( -#line 2268 "cs.ATG" +#line 2271 "cs.ATG" p); -#line 2268 "cs.ATG" +#line 2271 "cs.ATG" expr.Parameters = p; } Expect(21); } -#line 2273 "cs.ATG" +#line 2276 "cs.ATG" if (compilationUnit != null) { Block( -#line 2274 "cs.ATG" +#line 2277 "cs.ATG" out stmt); -#line 2274 "cs.ATG" +#line 2277 "cs.ATG" expr.Body = (BlockStatement)stmt; -#line 2275 "cs.ATG" +#line 2278 "cs.ATG" } else { Expect(16); -#line 2277 "cs.ATG" +#line 2280 "cs.ATG" lexer.SkipCurrentBlock(); Expect(17); -#line 2279 "cs.ATG" +#line 2282 "cs.ATG" } -#line 2280 "cs.ATG" +#line 2283 "cs.ATG" expr.EndLocation = t.Location; } void TypeArgumentList( -#line 2453 "cs.ATG" +#line 2456 "cs.ATG" out List types, bool canBeUnbound) { -#line 2455 "cs.ATG" +#line 2458 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2460 "cs.ATG" +#line 2463 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2461 "cs.ATG" +#line 2464 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2462 "cs.ATG" +#line 2465 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(9)) { Type( -#line 2463 "cs.ATG" +#line 2466 "cs.ATG" out type); -#line 2463 "cs.ATG" +#line 2466 "cs.ATG" types.Add(type); while (la.kind == 14) { lexer.NextToken(); Type( -#line 2464 "cs.ATG" +#line 2467 "cs.ATG" out type); -#line 2464 "cs.ATG" +#line 2467 "cs.ATG" types.Add(type); } } else SynErr(185); @@ -5212,206 +5215,206 @@ out type); } void ConditionalAndExpr( -#line 2289 "cs.ATG" +#line 2292 "cs.ATG" ref Expression outExpr) { -#line 2290 "cs.ATG" +#line 2293 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2292 "cs.ATG" +#line 2295 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2292 "cs.ATG" +#line 2295 "cs.ATG" out expr); InclusiveOrExpr( -#line 2292 "cs.ATG" +#line 2295 "cs.ATG" ref expr); -#line 2292 "cs.ATG" +#line 2295 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2295 "cs.ATG" +#line 2298 "cs.ATG" ref Expression outExpr) { -#line 2296 "cs.ATG" +#line 2299 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2298 "cs.ATG" +#line 2301 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2298 "cs.ATG" +#line 2301 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2298 "cs.ATG" +#line 2301 "cs.ATG" ref expr); -#line 2298 "cs.ATG" +#line 2301 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2301 "cs.ATG" +#line 2304 "cs.ATG" ref Expression outExpr) { -#line 2302 "cs.ATG" +#line 2305 "cs.ATG" Expression expr; AndExpr( -#line 2304 "cs.ATG" +#line 2307 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2304 "cs.ATG" +#line 2307 "cs.ATG" out expr); AndExpr( -#line 2304 "cs.ATG" +#line 2307 "cs.ATG" ref expr); -#line 2304 "cs.ATG" +#line 2307 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2307 "cs.ATG" +#line 2310 "cs.ATG" ref Expression outExpr) { -#line 2308 "cs.ATG" +#line 2311 "cs.ATG" Expression expr; EqualityExpr( -#line 2310 "cs.ATG" +#line 2313 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2310 "cs.ATG" +#line 2313 "cs.ATG" out expr); EqualityExpr( -#line 2310 "cs.ATG" +#line 2313 "cs.ATG" ref expr); -#line 2310 "cs.ATG" +#line 2313 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2313 "cs.ATG" +#line 2316 "cs.ATG" ref Expression outExpr) { -#line 2315 "cs.ATG" +#line 2318 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2319 "cs.ATG" +#line 2322 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2322 "cs.ATG" +#line 2325 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2323 "cs.ATG" +#line 2326 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2325 "cs.ATG" +#line 2328 "cs.ATG" out expr); RelationalExpr( -#line 2325 "cs.ATG" +#line 2328 "cs.ATG" ref expr); -#line 2325 "cs.ATG" +#line 2328 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2329 "cs.ATG" +#line 2332 "cs.ATG" ref Expression outExpr) { -#line 2331 "cs.ATG" +#line 2334 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2336 "cs.ATG" +#line 2339 "cs.ATG" ref outExpr); while (StartOf(28)) { if (StartOf(29)) { if (la.kind == 23) { lexer.NextToken(); -#line 2338 "cs.ATG" +#line 2341 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2339 "cs.ATG" +#line 2342 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2340 "cs.ATG" +#line 2343 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2341 "cs.ATG" +#line 2344 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(186); UnaryExpr( -#line 2343 "cs.ATG" +#line 2346 "cs.ATG" out expr); ShiftExpr( -#line 2344 "cs.ATG" +#line 2347 "cs.ATG" ref expr); -#line 2345 "cs.ATG" +#line 2348 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 84) { lexer.NextToken(); TypeWithRestriction( -#line 2348 "cs.ATG" +#line 2351 "cs.ATG" out type, false, false); if ( -#line 2349 "cs.ATG" +#line 2352 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 2350 "cs.ATG" +#line 2353 "cs.ATG" ref type); } -#line 2351 "cs.ATG" +#line 2354 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 49) { lexer.NextToken(); TypeWithRestriction( -#line 2353 "cs.ATG" +#line 2356 "cs.ATG" out type, false, false); if ( -#line 2354 "cs.ATG" +#line 2357 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 2355 "cs.ATG" +#line 2358 "cs.ATG" ref type); } -#line 2356 "cs.ATG" +#line 2359 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(187); } @@ -5419,83 +5422,83 @@ ref type); } void ShiftExpr( -#line 2361 "cs.ATG" +#line 2364 "cs.ATG" ref Expression outExpr) { -#line 2363 "cs.ATG" +#line 2366 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2367 "cs.ATG" +#line 2370 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2370 "cs.ATG" +#line 2373 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2369 "cs.ATG" +#line 2372 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2371 "cs.ATG" +#line 2374 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2374 "cs.ATG" +#line 2377 "cs.ATG" out expr); AdditiveExpr( -#line 2374 "cs.ATG" +#line 2377 "cs.ATG" ref expr); -#line 2374 "cs.ATG" +#line 2377 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2378 "cs.ATG" +#line 2381 "cs.ATG" ref Expression outExpr) { -#line 2380 "cs.ATG" +#line 2383 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2384 "cs.ATG" +#line 2387 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2387 "cs.ATG" +#line 2390 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2388 "cs.ATG" +#line 2391 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2390 "cs.ATG" +#line 2393 "cs.ATG" out expr); MultiplicativeExpr( -#line 2390 "cs.ATG" +#line 2393 "cs.ATG" ref expr); -#line 2390 "cs.ATG" +#line 2393 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2394 "cs.ATG" +#line 2397 "cs.ATG" ref Expression outExpr) { -#line 2396 "cs.ATG" +#line 2399 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5503,57 +5506,57 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2402 "cs.ATG" +#line 2405 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2403 "cs.ATG" +#line 2406 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2404 "cs.ATG" +#line 2407 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2406 "cs.ATG" +#line 2409 "cs.ATG" out expr); -#line 2406 "cs.ATG" +#line 2409 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2510 "cs.ATG" +#line 2513 "cs.ATG" out TypeReference type) { -#line 2511 "cs.ATG" +#line 2514 "cs.ATG" TypeReference t; type = null; if (la.kind == 108) { lexer.NextToken(); -#line 2513 "cs.ATG" +#line 2516 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 58) { lexer.NextToken(); -#line 2514 "cs.ATG" +#line 2517 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 88) { lexer.NextToken(); Expect(20); Expect(21); -#line 2515 "cs.ATG" +#line 2518 "cs.ATG" type = new TypeReference("struct"); } else if (StartOf(9)) { Type( -#line 2516 "cs.ATG" +#line 2519 "cs.ATG" out t); -#line 2516 "cs.ATG" +#line 2519 "cs.ATG" type = t; } else SynErr(188); } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index cb51d5360a..766d90a8e9 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -140,6 +140,9 @@ bool IsTypeNameForTypeCast(ref Token pt) } pt = Peek(); } + if (pt.kind == Tokens.Question) { + pt = Peek(); + } if (pt.kind == Tokens.Times || pt.kind == Tokens.OpenSquareBracket) { return IsPointerOrDims(ref pt); } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs index 5d5895752b..23612fc486 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.Tests.AST } [Test] - public void NullableCastExpression() + public void NullablePrimitiveCastExpression() { CastExpression ce = ParseUtilCSharp.ParseExpression("(int?)o"); Assert.AreEqual("System.Nullable", ce.CastTo.SystemType); @@ -46,6 +46,16 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.AreEqual(CastType.Cast, ce.CastType); } + [Test] + public void NullableCastExpression() + { + CastExpression ce = ParseUtilCSharp.ParseExpression("(MyType?)o"); + Assert.AreEqual("System.Nullable", ce.CastTo.SystemType); + Assert.AreEqual("MyType", ce.CastTo.GenericTypes[0].Type); + Assert.IsTrue(ce.Expression is IdentifierExpression); + Assert.AreEqual(CastType.Cast, ce.CastType); + } + [Test] public void NullableTryCastExpression() {