diff --git a/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs index 9fbf414ee1..3efdd4d6b9 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs @@ -128,17 +128,22 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } if (typeReference.Type == null || typeReference.Type.Length ==0) { outputFormatter.PrintText("void"); + } else if (typeReference.SystemType == "System.Nullable" && typeReference.GenericTypes != null + && typeReference.GenericTypes.Count == 1) + { + nodeTracker.TrackedVisit(typeReference.GenericTypes[0], data); + outputFormatter.PrintText("?"); } else { if (typeReference.SystemType.Length > 0) { outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType)); } else { outputFormatter.PrintText(typeReference.Type); } - } - if (typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) { - outputFormatter.PrintToken(Tokens.LessThan); - AppendCommaSeparatedList(typeReference.GenericTypes); - outputFormatter.PrintToken(Tokens.GreaterThan); + if (typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) { + outputFormatter.PrintToken(Tokens.LessThan); + AppendCommaSeparatedList(typeReference.GenericTypes); + outputFormatter.PrintToken(Tokens.GreaterThan); + } } for (int i = 0; i < typeReference.PointerNestingLevel; ++i) { outputFormatter.PrintToken(Tokens.Times); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index f419f787bb..d329b3456d 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -280,8 +280,8 @@ bool LBrackAndCommaOrRBrack () { bool IsDims () { return LBrackAndCommaOrRBrack(); } -/* True, if "[" is followed by "," or "]" * - * or if the current token is "*" */ +/* True, if "[" is followed by "," or "]" */ +/* or if the current token is "*" */ bool TimesOrLBrackAndCommaOrRBrack () { return la.kind == Tokens.Times || LBrackAndCommaOrRBrack(); } @@ -304,12 +304,19 @@ bool SkipGeneric(ref Token pt) } } pt = Peek(); - return true; } return true; } -/* True, if lookahead is a primitive type keyword, or * - * if it is a type declaration followed by an ident */ +bool SkipQuestionMark(ref Token pt) +{ + if (pt.kind == Tokens.Question) { + pt = Peek(); + } + return true; +} + +/* True, if lookahead is a primitive type keyword, or */ +/* if it is a type declaration followed by an ident */ bool IsLocalVarDecl () { if (IsYieldStatement()) { return false; @@ -322,7 +329,7 @@ bool IsLocalVarDecl () { Token pt = la ; string ignore; - return IsQualident(ref pt, out ignore) && SkipGeneric(ref pt) && IsPointerOrDims(ref pt) && + return IsQualident(ref pt, out ignore) && SkipGeneric(ref pt) && SkipQuestionMark(ref pt) && IsPointerOrDims(ref pt) && pt.kind == Tokens.Identifier; } @@ -434,13 +441,13 @@ void WriteFullTypeName(StringBuilder b, Expression expr) void CS() { -#line 552 "cs.ATG" +#line 559 "cs.ATG" compilationUnit = new CompilationUnit(); while (la.kind == 119) { UsingDirective(); } while ( -#line 555 "cs.ATG" +#line 562 "cs.ATG" IsGlobalAttrTarget()) { GlobalAttributeSection(); } @@ -452,25 +459,25 @@ IsGlobalAttrTarget()) { void UsingDirective() { -#line 562 "cs.ATG" +#line 569 "cs.ATG" string qualident = null; TypeReference aliasedType = null; Expect(119); -#line 565 "cs.ATG" +#line 572 "cs.ATG" Point startPos = t.Location; Qualident( -#line 566 "cs.ATG" +#line 573 "cs.ATG" out qualident); if (la.kind == 3) { lexer.NextToken(); NonArrayType( -#line 567 "cs.ATG" +#line 574 "cs.ATG" out aliasedType); } Expect(11); -#line 569 "cs.ATG" +#line 576 "cs.ATG" if (qualident != null && qualident.Length > 0) { INode node; if (aliasedType != null) { @@ -488,11 +495,11 @@ out aliasedType); void GlobalAttributeSection() { Expect(17); -#line 585 "cs.ATG" +#line 592 "cs.ATG" Point startPos = t.Location; Expect(1); -#line 586 "cs.ATG" +#line 593 "cs.ATG" if (t.val != "assembly") Error("global attribute target specifier (\"assembly\") expected"); string attributeTarget = t.val; List attributes = new List(); @@ -500,20 +507,20 @@ out aliasedType); Expect(9); Attribute( -#line 591 "cs.ATG" +#line 598 "cs.ATG" out attribute); -#line 591 "cs.ATG" +#line 598 "cs.ATG" attributes.Add(attribute); while ( -#line 592 "cs.ATG" +#line 599 "cs.ATG" NotFinalComma()) { Expect(13); Attribute( -#line 592 "cs.ATG" +#line 599 "cs.ATG" out attribute); -#line 592 "cs.ATG" +#line 599 "cs.ATG" attributes.Add(attribute); } if (la.kind == 13) { @@ -521,7 +528,7 @@ out attribute); } Expect(18); -#line 594 "cs.ATG" +#line 601 "cs.ATG" AttributeSection section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -531,7 +538,7 @@ out attribute); void NamespaceMemberDecl() { -#line 678 "cs.ATG" +#line 685 "cs.ATG" AttributeSection section; List attributes = new List(); Modifiers m = new Modifiers(); @@ -540,13 +547,13 @@ out attribute); if (la.kind == 86) { lexer.NextToken(); -#line 684 "cs.ATG" +#line 691 "cs.ATG" Point startPos = t.Location; Qualident( -#line 685 "cs.ATG" +#line 692 "cs.ATG" out qualident); -#line 685 "cs.ATG" +#line 692 "cs.ATG" INode node = new NamespaceDeclaration(qualident); node.StartLocation = startPos; compilationUnit.AddChild(node); @@ -564,123 +571,128 @@ out qualident); lexer.NextToken(); } -#line 694 "cs.ATG" +#line 701 "cs.ATG" node.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); } else if (StartOf(2)) { while (la.kind == 17) { AttributeSection( -#line 698 "cs.ATG" +#line 705 "cs.ATG" out section); -#line 698 "cs.ATG" +#line 705 "cs.ATG" attributes.Add(section); } while (StartOf(3)) { TypeModifier( -#line 699 "cs.ATG" +#line 706 "cs.ATG" m); } TypeDecl( -#line 700 "cs.ATG" +#line 707 "cs.ATG" m, attributes); } else SynErr(125); } void Qualident( -#line 818 "cs.ATG" +#line 825 "cs.ATG" out string qualident) { Expect(1); -#line 820 "cs.ATG" +#line 827 "cs.ATG" qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); while ( -#line 821 "cs.ATG" +#line 828 "cs.ATG" DotAndIdent()) { Expect(14); Expect(1); -#line 821 "cs.ATG" +#line 828 "cs.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(t.val); } -#line 824 "cs.ATG" +#line 831 "cs.ATG" qualident = qualidentBuilder.ToString(); } void NonArrayType( -#line 920 "cs.ATG" +#line 928 "cs.ATG" out TypeReference type) { -#line 922 "cs.ATG" +#line 930 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 89 || la.kind == 106) { ClassType( -#line 927 "cs.ATG" +#line 935 "cs.ATG" out type); } else if (StartOf(4)) { SimpleType( -#line 928 "cs.ATG" +#line 936 "cs.ATG" out name); -#line 928 "cs.ATG" +#line 936 "cs.ATG" type = new TypeReference(name); + if (la.kind == 12) { + NullableQuestionMark( +#line 937 "cs.ATG" +ref type); + } } else if (la.kind == 121) { lexer.NextToken(); Expect(6); -#line 929 "cs.ATG" +#line 938 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(126); while ( -#line 932 "cs.ATG" +#line 941 "cs.ATG" IsPointer()) { Expect(6); -#line 933 "cs.ATG" +#line 942 "cs.ATG" ++pointer; } -#line 935 "cs.ATG" +#line 944 "cs.ATG" if (type != null) { type.PointerNestingLevel = pointer; } } void Attribute( -#line 601 "cs.ATG" +#line 608 "cs.ATG" out ASTAttribute attribute) { -#line 602 "cs.ATG" +#line 609 "cs.ATG" string qualident; Qualident( -#line 604 "cs.ATG" +#line 611 "cs.ATG" out qualident); -#line 604 "cs.ATG" +#line 611 "cs.ATG" List positional = new List(); List named = new List(); string name = qualident; if (la.kind == 19) { AttributeArguments( -#line 608 "cs.ATG" +#line 615 "cs.ATG" positional, named); } -#line 608 "cs.ATG" +#line 615 "cs.ATG" attribute = new ICSharpCode.NRefactory.Parser.AST.Attribute(name, positional, named); } void AttributeArguments( -#line 611 "cs.ATG" +#line 618 "cs.ATG" List positional, List named) { -#line 613 "cs.ATG" +#line 620 "cs.ATG" bool nameFound = false; string name = ""; Expression expr; @@ -688,22 +700,22 @@ List positional, List named) { Expect(19); if (StartOf(5)) { if ( -#line 621 "cs.ATG" +#line 628 "cs.ATG" IsAssignment()) { -#line 621 "cs.ATG" +#line 628 "cs.ATG" nameFound = true; lexer.NextToken(); -#line 622 "cs.ATG" +#line 629 "cs.ATG" name = t.val; Expect(3); } Expr( -#line 624 "cs.ATG" +#line 631 "cs.ATG" out expr); -#line 624 "cs.ATG" +#line 631 "cs.ATG" if (expr != null) {if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -711,26 +723,26 @@ out expr); while (la.kind == 13) { lexer.NextToken(); if ( -#line 632 "cs.ATG" +#line 639 "cs.ATG" IsAssignment()) { -#line 632 "cs.ATG" +#line 639 "cs.ATG" nameFound = true; Expect(1); -#line 633 "cs.ATG" +#line 640 "cs.ATG" name = t.val; Expect(3); } else if (StartOf(5)) { -#line 635 "cs.ATG" +#line 642 "cs.ATG" if (nameFound) Error("no positional argument after named argument"); } else SynErr(127); Expr( -#line 636 "cs.ATG" +#line 643 "cs.ATG" out expr); -#line 636 "cs.ATG" +#line 643 "cs.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -741,52 +753,52 @@ out expr); } void Expr( -#line 1877 "cs.ATG" +#line 1886 "cs.ATG" out Expression expr) { -#line 1878 "cs.ATG" +#line 1887 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; UnaryExpr( -#line 1880 "cs.ATG" +#line 1889 "cs.ATG" out expr); if (StartOf(6)) { ConditionalOrExpr( -#line 1883 "cs.ATG" +#line 1892 "cs.ATG" ref expr); if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1883 "cs.ATG" +#line 1892 "cs.ATG" out expr1); Expect(9); Expr( -#line 1883 "cs.ATG" +#line 1892 "cs.ATG" out expr2); -#line 1883 "cs.ATG" +#line 1892 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else if (StartOf(7)) { -#line 1885 "cs.ATG" +#line 1894 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1885 "cs.ATG" +#line 1894 "cs.ATG" out op); Expr( -#line 1885 "cs.ATG" +#line 1894 "cs.ATG" out val); -#line 1885 "cs.ATG" +#line 1894 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else SynErr(128); } void AttributeSection( -#line 645 "cs.ATG" +#line 652 "cs.ATG" out AttributeSection section) { -#line 647 "cs.ATG" +#line 654 "cs.ATG" string attributeTarget = ""; List attributes = new List(); ASTAttribute attribute; @@ -794,25 +806,25 @@ out AttributeSection section) { Expect(17); -#line 653 "cs.ATG" +#line 660 "cs.ATG" Point startPos = t.Location; if ( -#line 654 "cs.ATG" +#line 661 "cs.ATG" IsLocalAttrTarget()) { if (la.kind == 67) { lexer.NextToken(); -#line 655 "cs.ATG" +#line 662 "cs.ATG" attributeTarget = "event"; } else if (la.kind == 99) { lexer.NextToken(); -#line 656 "cs.ATG" +#line 663 "cs.ATG" attributeTarget = "return"; } else { lexer.NextToken(); -#line 657 "cs.ATG" +#line 664 "cs.ATG" if (t.val != "field" || t.val != "method" || t.val != "module" || t.val != "param" || t.val != "property" || t.val != "type") @@ -824,20 +836,20 @@ IsLocalAttrTarget()) { Expect(9); } Attribute( -#line 667 "cs.ATG" +#line 674 "cs.ATG" out attribute); -#line 667 "cs.ATG" +#line 674 "cs.ATG" attributes.Add(attribute); while ( -#line 668 "cs.ATG" +#line 675 "cs.ATG" NotFinalComma()) { Expect(13); Attribute( -#line 668 "cs.ATG" +#line 675 "cs.ATG" out attribute); -#line 668 "cs.ATG" +#line 675 "cs.ATG" attributes.Add(attribute); } if (la.kind == 13) { @@ -845,7 +857,7 @@ out attribute); } Expect(18); -#line 670 "cs.ATG" +#line 677 "cs.ATG" section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -853,76 +865,76 @@ out attribute); } void TypeModifier( -#line 995 "cs.ATG" +#line 1004 "cs.ATG" Modifiers m) { switch (la.kind) { case 87: { lexer.NextToken(); -#line 997 "cs.ATG" +#line 1006 "cs.ATG" m.Add(Modifier.New, t.Location); break; } case 96: { lexer.NextToken(); -#line 998 "cs.ATG" +#line 1007 "cs.ATG" m.Add(Modifier.Public, t.Location); break; } case 95: { lexer.NextToken(); -#line 999 "cs.ATG" +#line 1008 "cs.ATG" m.Add(Modifier.Protected, t.Location); break; } case 82: { lexer.NextToken(); -#line 1000 "cs.ATG" +#line 1009 "cs.ATG" m.Add(Modifier.Internal, t.Location); break; } case 94: { lexer.NextToken(); -#line 1001 "cs.ATG" +#line 1010 "cs.ATG" m.Add(Modifier.Private, t.Location); break; } case 117: { lexer.NextToken(); -#line 1002 "cs.ATG" +#line 1011 "cs.ATG" m.Add(Modifier.Unsafe, t.Location); break; } case 47: { lexer.NextToken(); -#line 1003 "cs.ATG" +#line 1012 "cs.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 101: { lexer.NextToken(); -#line 1004 "cs.ATG" +#line 1013 "cs.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 105: { lexer.NextToken(); -#line 1005 "cs.ATG" +#line 1014 "cs.ATG" m.Add(Modifier.Static, t.Location); break; } case 1: { lexer.NextToken(); -#line 1006 "cs.ATG" +#line 1015 "cs.ATG" if (t.val == "partial") { m.Add(Modifier.Partial, t.Location); } break; } @@ -931,10 +943,10 @@ Modifiers m) { } void TypeDecl( -#line 703 "cs.ATG" +#line 710 "cs.ATG" Modifiers m, List attributes) { -#line 705 "cs.ATG" +#line 712 "cs.ATG" TypeReference type; List names; List p = new List(); @@ -943,11 +955,11 @@ Modifiers m, List attributes) { if (la.kind == 57) { -#line 711 "cs.ATG" +#line 718 "cs.ATG" m.Check(Modifier.Classes); lexer.NextToken(); -#line 712 "cs.ATG" +#line 719 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -958,26 +970,26 @@ Modifiers m, List attributes) { Expect(1); -#line 720 "cs.ATG" +#line 727 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 723 "cs.ATG" +#line 730 "cs.ATG" templates); } if (la.kind == 9) { ClassBase( -#line 725 "cs.ATG" +#line 732 "cs.ATG" out names); -#line 725 "cs.ATG" +#line 732 "cs.ATG" newType.BaseTypes = names; } while ( -#line 728 "cs.ATG" +#line 735 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 728 "cs.ATG" +#line 735 "cs.ATG" templates); } ClassBody(); @@ -985,18 +997,18 @@ templates); lexer.NextToken(); } -#line 731 "cs.ATG" +#line 738 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (StartOf(8)) { -#line 734 "cs.ATG" +#line 741 "cs.ATG" m.Check(Modifier.StructsInterfacesEnumsDelegates); if (la.kind == 107) { lexer.NextToken(); -#line 735 "cs.ATG" +#line 742 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; newType.StartLocation = m.GetDeclarationLocation(t.Location); @@ -1006,26 +1018,26 @@ templates); Expect(1); -#line 742 "cs.ATG" +#line 749 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 745 "cs.ATG" +#line 752 "cs.ATG" templates); } if (la.kind == 9) { StructInterfaces( -#line 747 "cs.ATG" +#line 754 "cs.ATG" out names); -#line 747 "cs.ATG" +#line 754 "cs.ATG" newType.BaseTypes = names; } while ( -#line 750 "cs.ATG" +#line 757 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 750 "cs.ATG" +#line 757 "cs.ATG" templates); } StructBody(); @@ -1033,14 +1045,14 @@ templates); lexer.NextToken(); } -#line 754 "cs.ATG" +#line 761 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 81) { lexer.NextToken(); -#line 758 "cs.ATG" +#line 765 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -1050,26 +1062,26 @@ templates); Expect(1); -#line 765 "cs.ATG" +#line 772 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 768 "cs.ATG" +#line 775 "cs.ATG" templates); } if (la.kind == 9) { InterfaceBase( -#line 770 "cs.ATG" +#line 777 "cs.ATG" out names); -#line 770 "cs.ATG" +#line 777 "cs.ATG" newType.BaseTypes = names; } while ( -#line 773 "cs.ATG" +#line 780 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 773 "cs.ATG" +#line 780 "cs.ATG" templates); } InterfaceBody(); @@ -1077,14 +1089,14 @@ templates); lexer.NextToken(); } -#line 776 "cs.ATG" +#line 783 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 66) { lexer.NextToken(); -#line 780 "cs.ATG" +#line 787 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); @@ -1093,15 +1105,15 @@ templates); Expect(1); -#line 786 "cs.ATG" +#line 793 "cs.ATG" newType.Name = t.val; if (la.kind == 9) { lexer.NextToken(); IntegralType( -#line 787 "cs.ATG" +#line 794 "cs.ATG" out name); -#line 787 "cs.ATG" +#line 794 "cs.ATG" newType.BaseTypes.Add(new TypeReference(name)); } EnumBody(); @@ -1109,62 +1121,62 @@ out name); lexer.NextToken(); } -#line 790 "cs.ATG" +#line 797 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else { lexer.NextToken(); -#line 794 "cs.ATG" +#line 801 "cs.ATG" DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); templates = delegateDeclr.Templates; delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); if ( -#line 798 "cs.ATG" +#line 805 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 798 "cs.ATG" +#line 805 "cs.ATG" delegateDeclr.ReturnType = new TypeReference("void", 0, null); } else if (StartOf(9)) { Type( -#line 799 "cs.ATG" +#line 806 "cs.ATG" out type); -#line 799 "cs.ATG" +#line 806 "cs.ATG" delegateDeclr.ReturnType = type; } else SynErr(130); Expect(1); -#line 801 "cs.ATG" +#line 808 "cs.ATG" delegateDeclr.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 804 "cs.ATG" +#line 811 "cs.ATG" templates); } Expect(19); if (StartOf(10)) { FormalParameterList( -#line 806 "cs.ATG" +#line 813 "cs.ATG" p); -#line 806 "cs.ATG" +#line 813 "cs.ATG" delegateDeclr.Parameters = p; } Expect(20); while ( -#line 810 "cs.ATG" +#line 817 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 810 "cs.ATG" +#line 817 "cs.ATG" templates); } Expect(11); -#line 812 "cs.ATG" +#line 819 "cs.ATG" delegateDeclr.EndLocation = t.Location; compilationUnit.AddChild(delegateDeclr); @@ -1173,90 +1185,90 @@ templates); } void TypeParameterList( -#line 2260 "cs.ATG" +#line 2280 "cs.ATG" List templates) { -#line 2262 "cs.ATG" +#line 2282 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(22); while (la.kind == 17) { AttributeSection( -#line 2266 "cs.ATG" +#line 2286 "cs.ATG" out section); -#line 2266 "cs.ATG" +#line 2286 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2267 "cs.ATG" +#line 2287 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 13) { lexer.NextToken(); while (la.kind == 17) { AttributeSection( -#line 2268 "cs.ATG" +#line 2288 "cs.ATG" out section); -#line 2268 "cs.ATG" +#line 2288 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2269 "cs.ATG" +#line 2289 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(21); } void ClassBase( -#line 827 "cs.ATG" +#line 834 "cs.ATG" out List names) { -#line 829 "cs.ATG" +#line 836 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); ClassType( -#line 833 "cs.ATG" +#line 840 "cs.ATG" out typeRef); -#line 833 "cs.ATG" +#line 840 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 13) { lexer.NextToken(); TypeName( -#line 834 "cs.ATG" +#line 841 "cs.ATG" out typeRef); -#line 834 "cs.ATG" +#line 841 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } void TypeParameterConstraintsClause( -#line 2273 "cs.ATG" +#line 2293 "cs.ATG" List templates) { -#line 2274 "cs.ATG" +#line 2294 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2276 "cs.ATG" +#line 2296 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2277 "cs.ATG" +#line 2297 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2279 "cs.ATG" +#line 2299 "cs.ATG" out type); -#line 2280 "cs.ATG" +#line 2300 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1269,10 +1281,10 @@ out type); while (la.kind == 13) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2289 "cs.ATG" +#line 2309 "cs.ATG" out type); -#line 2290 "cs.ATG" +#line 2310 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1287,114 +1299,114 @@ out type); void ClassBody() { -#line 838 "cs.ATG" +#line 845 "cs.ATG" AttributeSection section; Expect(15); while (StartOf(11)) { -#line 841 "cs.ATG" +#line 848 "cs.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 17) { AttributeSection( -#line 844 "cs.ATG" +#line 851 "cs.ATG" out section); -#line 844 "cs.ATG" +#line 851 "cs.ATG" attributes.Add(section); } while (StartOf(12)) { MemberModifier( -#line 845 "cs.ATG" +#line 852 "cs.ATG" m); } ClassMemberDecl( -#line 846 "cs.ATG" +#line 853 "cs.ATG" m, attributes); } Expect(16); } void StructInterfaces( -#line 851 "cs.ATG" +#line 858 "cs.ATG" out List names) { -#line 853 "cs.ATG" +#line 860 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 857 "cs.ATG" +#line 864 "cs.ATG" out typeRef); -#line 857 "cs.ATG" +#line 864 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 13) { lexer.NextToken(); TypeName( -#line 858 "cs.ATG" +#line 865 "cs.ATG" out typeRef); -#line 858 "cs.ATG" +#line 865 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } void StructBody() { -#line 862 "cs.ATG" +#line 869 "cs.ATG" AttributeSection section; Expect(15); while (StartOf(13)) { -#line 865 "cs.ATG" +#line 872 "cs.ATG" List attributes = new List(); Modifiers m = new Modifiers(); while (la.kind == 17) { AttributeSection( -#line 868 "cs.ATG" +#line 875 "cs.ATG" out section); -#line 868 "cs.ATG" +#line 875 "cs.ATG" attributes.Add(section); } while (StartOf(12)) { MemberModifier( -#line 869 "cs.ATG" +#line 876 "cs.ATG" m); } StructMemberDecl( -#line 870 "cs.ATG" +#line 877 "cs.ATG" m, attributes); } Expect(16); } void InterfaceBase( -#line 875 "cs.ATG" +#line 882 "cs.ATG" out List names) { -#line 877 "cs.ATG" +#line 884 "cs.ATG" TypeReference typeRef; names = new List(); Expect(9); TypeName( -#line 881 "cs.ATG" +#line 888 "cs.ATG" out typeRef); -#line 881 "cs.ATG" +#line 888 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } while (la.kind == 13) { lexer.NextToken(); TypeName( -#line 882 "cs.ATG" +#line 889 "cs.ATG" out typeRef); -#line 882 "cs.ATG" +#line 889 "cs.ATG" if (typeRef != null) { names.Add(typeRef); } } } @@ -1408,72 +1420,72 @@ out typeRef); } void IntegralType( -#line 1017 "cs.ATG" +#line 1026 "cs.ATG" out string name) { -#line 1017 "cs.ATG" +#line 1026 "cs.ATG" name = ""; switch (la.kind) { case 100: { lexer.NextToken(); -#line 1019 "cs.ATG" +#line 1028 "cs.ATG" name = "sbyte"; break; } case 52: { lexer.NextToken(); -#line 1020 "cs.ATG" +#line 1029 "cs.ATG" name = "byte"; break; } case 102: { lexer.NextToken(); -#line 1021 "cs.ATG" +#line 1030 "cs.ATG" name = "short"; break; } case 118: { lexer.NextToken(); -#line 1022 "cs.ATG" +#line 1031 "cs.ATG" name = "ushort"; break; } case 80: { lexer.NextToken(); -#line 1023 "cs.ATG" +#line 1032 "cs.ATG" name = "int"; break; } case 114: { lexer.NextToken(); -#line 1024 "cs.ATG" +#line 1033 "cs.ATG" name = "uint"; break; } case 85: { lexer.NextToken(); -#line 1025 "cs.ATG" +#line 1034 "cs.ATG" name = "long"; break; } case 115: { lexer.NextToken(); -#line 1026 "cs.ATG" +#line 1035 "cs.ATG" name = "ulong"; break; } case 55: { lexer.NextToken(); -#line 1027 "cs.ATG" +#line 1036 "cs.ATG" name = "char"; break; } @@ -1483,25 +1495,25 @@ out string name) { void EnumBody() { -#line 888 "cs.ATG" +#line 895 "cs.ATG" FieldDeclaration f; Expect(15); if (la.kind == 1 || la.kind == 17) { EnumMemberDecl( -#line 890 "cs.ATG" +#line 897 "cs.ATG" out f); -#line 890 "cs.ATG" +#line 897 "cs.ATG" compilationUnit.AddChild(f); while ( -#line 891 "cs.ATG" +#line 898 "cs.ATG" NotFinalComma()) { Expect(13); EnumMemberDecl( -#line 891 "cs.ATG" +#line 898 "cs.ATG" out f); -#line 891 "cs.ATG" +#line 898 "cs.ATG" compilationUnit.AddChild(f); } if (la.kind == 13) { @@ -1512,62 +1524,67 @@ out f); } void Type( -#line 896 "cs.ATG" +#line 903 "cs.ATG" out TypeReference type) { -#line 898 "cs.ATG" +#line 905 "cs.ATG" string name; int pointer = 0; type = null; if (la.kind == 1 || la.kind == 89 || la.kind == 106) { ClassType( -#line 903 "cs.ATG" +#line 910 "cs.ATG" out type); } else if (StartOf(4)) { SimpleType( -#line 904 "cs.ATG" +#line 911 "cs.ATG" out name); -#line 904 "cs.ATG" +#line 911 "cs.ATG" type = new TypeReference(name); + if (la.kind == 12) { + NullableQuestionMark( +#line 912 "cs.ATG" +ref type); + } } else if (la.kind == 121) { lexer.NextToken(); Expect(6); -#line 905 "cs.ATG" +#line 913 "cs.ATG" pointer = 1; type = new TypeReference("void"); } else SynErr(133); -#line 906 "cs.ATG" +#line 914 "cs.ATG" List r = new List(); while ( -#line 908 "cs.ATG" +#line 916 "cs.ATG" IsPointerOrDims()) { -#line 908 "cs.ATG" +#line 916 "cs.ATG" int i = 0; if (la.kind == 6) { lexer.NextToken(); -#line 909 "cs.ATG" +#line 917 "cs.ATG" ++pointer; } else if (la.kind == 17) { lexer.NextToken(); while (la.kind == 13) { lexer.NextToken(); -#line 910 "cs.ATG" +#line 918 "cs.ATG" ++i; } Expect(18); -#line 910 "cs.ATG" +#line 918 "cs.ATG" r.Add(i); } else SynErr(134); } -#line 913 "cs.ATG" +#line 921 "cs.ATG" if (type != null) { type.RankSpecifier = r.ToArray(); type.PointerNestingLevel = pointer; @@ -1576,28 +1593,28 @@ IsPointerOrDims()) { } void FormalParameterList( -#line 949 "cs.ATG" +#line 958 "cs.ATG" List parameter) { -#line 952 "cs.ATG" +#line 961 "cs.ATG" ParameterDeclarationExpression p; AttributeSection section; List attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 957 "cs.ATG" +#line 966 "cs.ATG" out section); -#line 957 "cs.ATG" +#line 966 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 959 "cs.ATG" +#line 968 "cs.ATG" out p); -#line 959 "cs.ATG" +#line 968 "cs.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1605,96 +1622,96 @@ out p); while (la.kind == 13) { lexer.NextToken(); -#line 964 "cs.ATG" +#line 973 "cs.ATG" attributes = new List(); if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 17) { AttributeSection( -#line 965 "cs.ATG" +#line 974 "cs.ATG" out section); -#line 965 "cs.ATG" +#line 974 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 967 "cs.ATG" +#line 976 "cs.ATG" out p); -#line 967 "cs.ATG" +#line 976 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else if (la.kind == 93) { ParameterArray( -#line 968 "cs.ATG" +#line 977 "cs.ATG" out p); -#line 968 "cs.ATG" +#line 977 "cs.ATG" paramsFound = true; p.Attributes = attributes; parameter.Add(p); } else SynErr(135); } } else if (la.kind == 93) { ParameterArray( -#line 971 "cs.ATG" +#line 980 "cs.ATG" out p); -#line 971 "cs.ATG" +#line 980 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else SynErr(136); } void ClassType( -#line 1009 "cs.ATG" +#line 1018 "cs.ATG" out TypeReference typeRef) { -#line 1010 "cs.ATG" +#line 1019 "cs.ATG" TypeReference r; typeRef = null; if (la.kind == 1) { TypeName( -#line 1012 "cs.ATG" +#line 1021 "cs.ATG" out r); -#line 1012 "cs.ATG" +#line 1021 "cs.ATG" typeRef = r; } else if (la.kind == 89) { lexer.NextToken(); -#line 1013 "cs.ATG" +#line 1022 "cs.ATG" typeRef = new TypeReference("object"); } else if (la.kind == 106) { lexer.NextToken(); -#line 1014 "cs.ATG" +#line 1023 "cs.ATG" typeRef = new TypeReference("string"); } else SynErr(137); } void TypeName( -#line 2225 "cs.ATG" +#line 2234 "cs.ATG" out TypeReference typeRef) { -#line 2226 "cs.ATG" +#line 2235 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 2231 "cs.ATG" +#line 2240 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 2232 "cs.ATG" +#line 2241 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2235 "cs.ATG" +#line 2244 "cs.ATG" out qualident); if (la.kind == 22) { TypeArgumentList( -#line 2236 "cs.ATG" +#line 2245 "cs.ATG" out typeArguments); } -#line 2238 "cs.ATG" +#line 2247 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1704,107 +1721,112 @@ out typeArguments); typeRef = new TypeReference(alias + "." + qualident, typeArguments); } + if (la.kind == 12) { + NullableQuestionMark( +#line 2256 "cs.ATG" +ref typeRef); + } } void MemberModifier( -#line 1030 "cs.ATG" +#line 1039 "cs.ATG" Modifiers m) { switch (la.kind) { case 47: { lexer.NextToken(); -#line 1032 "cs.ATG" +#line 1041 "cs.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 69: { lexer.NextToken(); -#line 1033 "cs.ATG" +#line 1042 "cs.ATG" m.Add(Modifier.Extern, t.Location); break; } case 82: { lexer.NextToken(); -#line 1034 "cs.ATG" +#line 1043 "cs.ATG" m.Add(Modifier.Internal, t.Location); break; } case 87: { lexer.NextToken(); -#line 1035 "cs.ATG" +#line 1044 "cs.ATG" m.Add(Modifier.New, t.Location); break; } case 92: { lexer.NextToken(); -#line 1036 "cs.ATG" +#line 1045 "cs.ATG" m.Add(Modifier.Override, t.Location); break; } case 94: { lexer.NextToken(); -#line 1037 "cs.ATG" +#line 1046 "cs.ATG" m.Add(Modifier.Private, t.Location); break; } case 95: { lexer.NextToken(); -#line 1038 "cs.ATG" +#line 1047 "cs.ATG" m.Add(Modifier.Protected, t.Location); break; } case 96: { lexer.NextToken(); -#line 1039 "cs.ATG" +#line 1048 "cs.ATG" m.Add(Modifier.Public, t.Location); break; } case 97: { lexer.NextToken(); -#line 1040 "cs.ATG" +#line 1049 "cs.ATG" m.Add(Modifier.Readonly, t.Location); break; } case 101: { lexer.NextToken(); -#line 1041 "cs.ATG" +#line 1050 "cs.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 105: { lexer.NextToken(); -#line 1042 "cs.ATG" +#line 1051 "cs.ATG" m.Add(Modifier.Static, t.Location); break; } case 117: { lexer.NextToken(); -#line 1043 "cs.ATG" +#line 1052 "cs.ATG" m.Add(Modifier.Unsafe, t.Location); break; } case 120: { lexer.NextToken(); -#line 1044 "cs.ATG" +#line 1053 "cs.ATG" m.Add(Modifier.Virtual, t.Location); break; } case 122: { lexer.NextToken(); -#line 1045 "cs.ATG" +#line 1054 "cs.ATG" m.Add(Modifier.Volatile, t.Location); break; } @@ -1813,23 +1835,23 @@ Modifiers m) { } void ClassMemberDecl( -#line 1286 "cs.ATG" +#line 1295 "cs.ATG" Modifiers m, List attributes) { -#line 1287 "cs.ATG" +#line 1296 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 1289 "cs.ATG" +#line 1298 "cs.ATG" m, attributes); } else if (la.kind == 26) { -#line 1290 "cs.ATG" +#line 1299 "cs.ATG" m.Check(Modifier.Destructors); Point startPos = t.Location; lexer.NextToken(); Expect(1); -#line 1291 "cs.ATG" +#line 1300 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1837,17 +1859,17 @@ m, attributes); Expect(19); Expect(20); -#line 1295 "cs.ATG" +#line 1304 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 15) { Block( -#line 1295 "cs.ATG" +#line 1304 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(139); -#line 1296 "cs.ATG" +#line 1305 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1855,10 +1877,10 @@ out stmt); } void StructMemberDecl( -#line 1048 "cs.ATG" +#line 1057 "cs.ATG" Modifiers m, List attributes) { -#line 1050 "cs.ATG" +#line 1059 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1869,18 +1891,18 @@ Modifiers m, List attributes) { if (la.kind == 58) { -#line 1059 "cs.ATG" +#line 1068 "cs.ATG" m.Check(Modifier.Constants); lexer.NextToken(); -#line 1060 "cs.ATG" +#line 1069 "cs.ATG" Point startPos = t.Location; Type( -#line 1061 "cs.ATG" +#line 1070 "cs.ATG" out type); Expect(1); -#line 1061 "cs.ATG" +#line 1070 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclaration f = new VariableDeclaration(t.val); @@ -1888,58 +1910,58 @@ out type); Expect(3); Expr( -#line 1066 "cs.ATG" +#line 1075 "cs.ATG" out expr); -#line 1066 "cs.ATG" +#line 1075 "cs.ATG" f.Initializer = expr; while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1067 "cs.ATG" +#line 1076 "cs.ATG" f = new VariableDeclaration(t.val); fd.Fields.Add(f); Expect(3); Expr( -#line 1070 "cs.ATG" +#line 1079 "cs.ATG" out expr); -#line 1070 "cs.ATG" +#line 1079 "cs.ATG" f.Initializer = expr; } Expect(11); -#line 1071 "cs.ATG" +#line 1080 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( -#line 1074 "cs.ATG" +#line 1083 "cs.ATG" NotVoidPointer()) { -#line 1074 "cs.ATG" +#line 1083 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); Expect(121); -#line 1075 "cs.ATG" +#line 1084 "cs.ATG" Point startPos = t.Location; Qualident( -#line 1076 "cs.ATG" +#line 1085 "cs.ATG" out qualident); if (la.kind == 22) { TypeParameterList( -#line 1078 "cs.ATG" +#line 1087 "cs.ATG" templates); } Expect(19); if (StartOf(10)) { FormalParameterList( -#line 1081 "cs.ATG" +#line 1090 "cs.ATG" p); } Expect(20); -#line 1081 "cs.ATG" +#line 1090 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, new TypeReference("void"), @@ -1952,31 +1974,31 @@ p); compilationUnit.BlockStart(methodDeclaration); while ( -#line 1094 "cs.ATG" +#line 1103 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1094 "cs.ATG" +#line 1103 "cs.ATG" templates); } if (la.kind == 15) { Block( -#line 1096 "cs.ATG" +#line 1105 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(141); -#line 1096 "cs.ATG" +#line 1105 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 67) { -#line 1100 "cs.ATG" +#line 1109 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); lexer.NextToken(); -#line 1101 "cs.ATG" +#line 1110 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); @@ -1985,103 +2007,103 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 1108 "cs.ATG" +#line 1117 "cs.ATG" out type); -#line 1108 "cs.ATG" +#line 1117 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 1110 "cs.ATG" +#line 1119 "cs.ATG" IsVarDecl()) { VariableDeclarator( -#line 1110 "cs.ATG" +#line 1119 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1111 "cs.ATG" +#line 1120 "cs.ATG" variableDeclarators); } Expect(11); -#line 1111 "cs.ATG" +#line 1120 "cs.ATG" eventDecl.VariableDeclarators = variableDeclarators; eventDecl.EndLocation = t.EndLocation; } else if (la.kind == 1) { Qualident( -#line 1112 "cs.ATG" +#line 1121 "cs.ATG" out qualident); -#line 1112 "cs.ATG" +#line 1121 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; Expect(15); -#line 1113 "cs.ATG" +#line 1122 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 1114 "cs.ATG" +#line 1123 "cs.ATG" out addBlock, out removeBlock); Expect(16); -#line 1115 "cs.ATG" +#line 1124 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } else SynErr(142); -#line 1116 "cs.ATG" +#line 1125 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 1123 "cs.ATG" +#line 1132 "cs.ATG" IdentAndLPar()) { -#line 1123 "cs.ATG" +#line 1132 "cs.ATG" m.Check(Modifier.Constructors | Modifier.StaticConstructors); Expect(1); -#line 1124 "cs.ATG" +#line 1133 "cs.ATG" string name = t.val; Point startPos = t.Location; Expect(19); if (StartOf(10)) { -#line 1124 "cs.ATG" +#line 1133 "cs.ATG" m.Check(Modifier.Constructors); FormalParameterList( -#line 1125 "cs.ATG" +#line 1134 "cs.ATG" p); } Expect(20); -#line 1127 "cs.ATG" +#line 1136 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 1128 "cs.ATG" +#line 1137 "cs.ATG" m.Check(Modifier.Constructors); ConstructorInitializer( -#line 1129 "cs.ATG" +#line 1138 "cs.ATG" out init); } -#line 1131 "cs.ATG" +#line 1140 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 15) { Block( -#line 1136 "cs.ATG" +#line 1145 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(143); -#line 1136 "cs.ATG" +#line 1145 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 68 || la.kind == 78) { -#line 1139 "cs.ATG" +#line 1148 "cs.ATG" m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -2090,45 +2112,45 @@ out stmt); if (la.kind == 78) { lexer.NextToken(); -#line 1144 "cs.ATG" +#line 1153 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); -#line 1144 "cs.ATG" +#line 1153 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(90); Type( -#line 1145 "cs.ATG" +#line 1154 "cs.ATG" out type); -#line 1145 "cs.ATG" +#line 1154 "cs.ATG" TypeReference operatorType = type; Expect(19); Type( -#line 1146 "cs.ATG" +#line 1155 "cs.ATG" out type); Expect(1); -#line 1146 "cs.ATG" +#line 1155 "cs.ATG" string varName = t.val; Expect(20); -#line 1147 "cs.ATG" +#line 1156 "cs.ATG" Point endPos = t.Location; if (la.kind == 15) { Block( -#line 1148 "cs.ATG" +#line 1157 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 1148 "cs.ATG" +#line 1157 "cs.ATG" stmt = null; } else SynErr(144); -#line 1151 "cs.ATG" +#line 1160 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -2144,61 +2166,61 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 1166 "cs.ATG" +#line 1175 "cs.ATG" m, attributes); } else if (StartOf(9)) { Type( -#line 1167 "cs.ATG" +#line 1176 "cs.ATG" out type); -#line 1167 "cs.ATG" +#line 1176 "cs.ATG" Point startPos = t.Location; if (la.kind == 90) { -#line 1169 "cs.ATG" +#line 1178 "cs.ATG" OverloadableOperatorType op; m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 1173 "cs.ATG" +#line 1182 "cs.ATG" out op); -#line 1173 "cs.ATG" +#line 1182 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(19); Type( -#line 1174 "cs.ATG" +#line 1183 "cs.ATG" out firstType); Expect(1); -#line 1174 "cs.ATG" +#line 1183 "cs.ATG" string firstName = t.val; if (la.kind == 13) { lexer.NextToken(); Type( -#line 1175 "cs.ATG" +#line 1184 "cs.ATG" out secondType); Expect(1); -#line 1175 "cs.ATG" +#line 1184 "cs.ATG" secondName = t.val; } else if (la.kind == 20) { } else SynErr(145); -#line 1183 "cs.ATG" +#line 1192 "cs.ATG" Point endPos = t.Location; Expect(20); if (la.kind == 15) { Block( -#line 1184 "cs.ATG" +#line 1193 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(146); -#line 1186 "cs.ATG" +#line 1195 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -2215,43 +2237,43 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 1203 "cs.ATG" +#line 1212 "cs.ATG" IsVarDecl()) { -#line 1203 "cs.ATG" +#line 1212 "cs.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclarator( -#line 1207 "cs.ATG" +#line 1216 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1208 "cs.ATG" +#line 1217 "cs.ATG" variableDeclarators); } Expect(11); -#line 1209 "cs.ATG" +#line 1218 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 109) { -#line 1212 "cs.ATG" +#line 1221 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(17); FormalParameterList( -#line 1213 "cs.ATG" +#line 1222 "cs.ATG" p); Expect(18); -#line 1213 "cs.ATG" +#line 1222 "cs.ATG" Point endLocation = t.EndLocation; Expect(15); -#line 1214 "cs.ATG" +#line 1223 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2260,11 +2282,11 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 1221 "cs.ATG" +#line 1230 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1222 "cs.ATG" +#line 1231 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; @@ -2272,30 +2294,30 @@ out getRegion, out setRegion); } else if (la.kind == 1) { Qualident( -#line 1227 "cs.ATG" +#line 1236 "cs.ATG" out qualident); -#line 1227 "cs.ATG" +#line 1236 "cs.ATG" Point qualIdentEndLocation = t.EndLocation; if (la.kind == 15 || la.kind == 19 || la.kind == 22) { if (la.kind == 19 || la.kind == 22) { -#line 1230 "cs.ATG" +#line 1239 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); if (la.kind == 22) { TypeParameterList( -#line 1232 "cs.ATG" +#line 1241 "cs.ATG" templates); } Expect(19); if (StartOf(10)) { FormalParameterList( -#line 1233 "cs.ATG" +#line 1242 "cs.ATG" p); } Expect(20); -#line 1234 "cs.ATG" +#line 1243 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, type, @@ -2307,26 +2329,26 @@ p); compilationUnit.AddChild(methodDeclaration); while ( -#line 1244 "cs.ATG" +#line 1253 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1244 "cs.ATG" +#line 1253 "cs.ATG" templates); } if (la.kind == 15) { Block( -#line 1245 "cs.ATG" +#line 1254 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(147); -#line 1245 "cs.ATG" +#line 1254 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1248 "cs.ATG" +#line 1257 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = qualIdentEndLocation; @@ -2335,11 +2357,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1255 "cs.ATG" +#line 1264 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1257 "cs.ATG" +#line 1266 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2348,17 +2370,17 @@ out getRegion, out setRegion); } } else if (la.kind == 14) { -#line 1265 "cs.ATG" +#line 1274 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(109); Expect(17); FormalParameterList( -#line 1266 "cs.ATG" +#line 1275 "cs.ATG" p); Expect(18); -#line 1267 "cs.ATG" +#line 1276 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; @@ -2368,14 +2390,14 @@ p); Expect(15); -#line 1274 "cs.ATG" +#line 1283 "cs.ATG" Point bodyStart = t.Location; AccessorDecls( -#line 1275 "cs.ATG" +#line 1284 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1276 "cs.ATG" +#line 1285 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2389,7 +2411,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1303 "cs.ATG" +#line 1312 "cs.ATG" TypeReference type; AttributeSection section; @@ -2404,51 +2426,51 @@ out getRegion, out setRegion); while (la.kind == 17) { AttributeSection( -#line 1316 "cs.ATG" +#line 1325 "cs.ATG" out section); -#line 1316 "cs.ATG" +#line 1325 "cs.ATG" attributes.Add(section); } if (la.kind == 87) { lexer.NextToken(); -#line 1317 "cs.ATG" +#line 1326 "cs.ATG" mod = Modifier.New; startLocation = t.Location; } if ( -#line 1320 "cs.ATG" +#line 1329 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 1320 "cs.ATG" +#line 1329 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1320 "cs.ATG" +#line 1329 "cs.ATG" name = t.val; if (la.kind == 22) { TypeParameterList( -#line 1321 "cs.ATG" +#line 1330 "cs.ATG" templates); } Expect(19); if (StartOf(10)) { FormalParameterList( -#line 1322 "cs.ATG" +#line 1331 "cs.ATG" parameters); } Expect(20); while ( -#line 1323 "cs.ATG" +#line 1332 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1323 "cs.ATG" +#line 1332 "cs.ATG" templates); } Expect(11); -#line 1325 "cs.ATG" +#line 1334 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2458,39 +2480,39 @@ templates); } else if (StartOf(18)) { if (StartOf(9)) { Type( -#line 1332 "cs.ATG" +#line 1341 "cs.ATG" out type); -#line 1332 "cs.ATG" +#line 1341 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1334 "cs.ATG" +#line 1343 "cs.ATG" name = t.val; Point qualIdentEndLocation = t.EndLocation; if (la.kind == 19 || la.kind == 22) { if (la.kind == 22) { TypeParameterList( -#line 1338 "cs.ATG" +#line 1347 "cs.ATG" templates); } Expect(19); if (StartOf(10)) { FormalParameterList( -#line 1339 "cs.ATG" +#line 1348 "cs.ATG" parameters); } Expect(20); while ( -#line 1341 "cs.ATG" +#line 1350 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1341 "cs.ATG" +#line 1350 "cs.ATG" templates); } Expect(11); -#line 1342 "cs.ATG" +#line 1351 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2499,72 +2521,72 @@ templates); } else if (la.kind == 15) { -#line 1349 "cs.ATG" +#line 1358 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1350 "cs.ATG" +#line 1359 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1350 "cs.ATG" +#line 1359 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1350 "cs.ATG" +#line 1359 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(151); } else if (la.kind == 109) { lexer.NextToken(); Expect(17); FormalParameterList( -#line 1353 "cs.ATG" +#line 1362 "cs.ATG" parameters); Expect(18); -#line 1353 "cs.ATG" +#line 1362 "cs.ATG" Point bracketEndLocation = t.EndLocation; -#line 1353 "cs.ATG" +#line 1362 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); Expect(15); -#line 1354 "cs.ATG" +#line 1363 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1354 "cs.ATG" +#line 1363 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1354 "cs.ATG" +#line 1363 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(152); } else { lexer.NextToken(); -#line 1357 "cs.ATG" +#line 1366 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1357 "cs.ATG" +#line 1366 "cs.ATG" out type); Expect(1); -#line 1357 "cs.ATG" +#line 1366 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes); compilationUnit.AddChild(ed); Expect(11); -#line 1360 "cs.ATG" +#line 1369 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(153); } void EnumMemberDecl( -#line 1365 "cs.ATG" +#line 1374 "cs.ATG" out FieldDeclaration f) { -#line 1367 "cs.ATG" +#line 1376 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2572,15 +2594,15 @@ out FieldDeclaration f) { while (la.kind == 17) { AttributeSection( -#line 1373 "cs.ATG" +#line 1382 "cs.ATG" out section); -#line 1373 "cs.ATG" +#line 1382 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1374 "cs.ATG" +#line 1383 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2589,52 +2611,66 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1379 "cs.ATG" +#line 1388 "cs.ATG" out expr); -#line 1379 "cs.ATG" +#line 1388 "cs.ATG" varDecl.Initializer = expr; } } void SimpleType( -#line 938 "cs.ATG" +#line 947 "cs.ATG" out string name) { -#line 939 "cs.ATG" +#line 948 "cs.ATG" name = String.Empty; if (StartOf(19)) { IntegralType( -#line 941 "cs.ATG" +#line 950 "cs.ATG" out name); } else if (la.kind == 73) { lexer.NextToken(); -#line 942 "cs.ATG" +#line 951 "cs.ATG" name = "float"; } else if (la.kind == 64) { lexer.NextToken(); -#line 943 "cs.ATG" +#line 952 "cs.ATG" name = "double"; } else if (la.kind == 60) { lexer.NextToken(); -#line 944 "cs.ATG" +#line 953 "cs.ATG" name = "decimal"; } else if (la.kind == 50) { lexer.NextToken(); -#line 945 "cs.ATG" +#line 954 "cs.ATG" name = "bool"; } else SynErr(154); } + void NullableQuestionMark( +#line 2259 "cs.ATG" +ref TypeReference typeRef) { + +#line 2260 "cs.ATG" + List typeArguments = new List(1); + Expect(12); + +#line 2264 "cs.ATG" + if (typeRef != null) typeArguments.Add(typeRef); + typeRef = new TypeReference("System.Nullable", typeArguments); + + } + void FixedParameter( -#line 975 "cs.ATG" +#line 984 "cs.ATG" out ParameterDeclarationExpression p) { -#line 977 "cs.ATG" +#line 986 "cs.ATG" TypeReference type; ParamModifier mod = ParamModifier.In; System.Drawing.Point start = t.Location; @@ -2643,46 +2679,46 @@ out ParameterDeclarationExpression p) { if (la.kind == 98) { lexer.NextToken(); -#line 983 "cs.ATG" +#line 992 "cs.ATG" mod = ParamModifier.Ref; } else { lexer.NextToken(); -#line 984 "cs.ATG" +#line 993 "cs.ATG" mod = ParamModifier.Out; } } Type( -#line 986 "cs.ATG" +#line 995 "cs.ATG" out type); Expect(1); -#line 986 "cs.ATG" +#line 995 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.Location; } void ParameterArray( -#line 989 "cs.ATG" +#line 998 "cs.ATG" out ParameterDeclarationExpression p) { -#line 990 "cs.ATG" +#line 999 "cs.ATG" TypeReference type; Expect(93); Type( -#line 992 "cs.ATG" +#line 1001 "cs.ATG" out type); Expect(1); -#line 992 "cs.ATG" +#line 1001 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, ParamModifier.Params); } void Block( -#line 1483 "cs.ATG" +#line 1492 "cs.ATG" out Statement stmt) { Expect(15); -#line 1485 "cs.ATG" +#line 1494 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); @@ -2693,7 +2729,7 @@ out Statement stmt) { } Expect(16); -#line 1492 "cs.ATG" +#line 1501 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2701,34 +2737,34 @@ out Statement stmt) { } void VariableDeclarator( -#line 1476 "cs.ATG" +#line 1485 "cs.ATG" List fieldDeclaration) { -#line 1477 "cs.ATG" +#line 1486 "cs.ATG" Expression expr = null; Expect(1); -#line 1479 "cs.ATG" +#line 1488 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1480 "cs.ATG" +#line 1489 "cs.ATG" out expr); -#line 1480 "cs.ATG" +#line 1489 "cs.ATG" f.Initializer = expr; } -#line 1480 "cs.ATG" +#line 1489 "cs.ATG" fieldDeclaration.Add(f); } void EventAccessorDecls( -#line 1425 "cs.ATG" +#line 1434 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1426 "cs.ATG" +#line 1435 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2737,102 +2773,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 17) { AttributeSection( -#line 1433 "cs.ATG" +#line 1442 "cs.ATG" out section); -#line 1433 "cs.ATG" +#line 1442 "cs.ATG" attributes.Add(section); } if ( -#line 1435 "cs.ATG" +#line 1444 "cs.ATG" IdentIsAdd()) { -#line 1435 "cs.ATG" +#line 1444 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1436 "cs.ATG" +#line 1445 "cs.ATG" out stmt); -#line 1436 "cs.ATG" +#line 1445 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 17) { AttributeSection( -#line 1437 "cs.ATG" +#line 1446 "cs.ATG" out section); -#line 1437 "cs.ATG" +#line 1446 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1438 "cs.ATG" +#line 1447 "cs.ATG" out stmt); -#line 1438 "cs.ATG" +#line 1447 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1439 "cs.ATG" +#line 1448 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1440 "cs.ATG" +#line 1449 "cs.ATG" out stmt); -#line 1440 "cs.ATG" +#line 1449 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 1441 "cs.ATG" +#line 1450 "cs.ATG" out section); -#line 1441 "cs.ATG" +#line 1450 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1442 "cs.ATG" +#line 1451 "cs.ATG" out stmt); -#line 1442 "cs.ATG" +#line 1451 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1443 "cs.ATG" +#line 1452 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(155); } void ConstructorInitializer( -#line 1514 "cs.ATG" +#line 1523 "cs.ATG" out ConstructorInitializer ci) { -#line 1515 "cs.ATG" +#line 1524 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 49) { lexer.NextToken(); -#line 1519 "cs.ATG" +#line 1528 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 109) { lexer.NextToken(); -#line 1520 "cs.ATG" +#line 1529 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(156); Expect(19); if (StartOf(21)) { Argument( -#line 1523 "cs.ATG" +#line 1532 "cs.ATG" out expr); -#line 1523 "cs.ATG" +#line 1532 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1523 "cs.ATG" +#line 1532 "cs.ATG" out expr); -#line 1523 "cs.ATG" +#line 1532 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -2840,161 +2876,161 @@ out expr); } void OverloadableOperator( -#line 1535 "cs.ATG" +#line 1544 "cs.ATG" out OverloadableOperatorType op) { -#line 1536 "cs.ATG" +#line 1545 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1538 "cs.ATG" +#line 1547 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1539 "cs.ATG" +#line 1548 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 23: { lexer.NextToken(); -#line 1541 "cs.ATG" +#line 1550 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 26: { lexer.NextToken(); -#line 1542 "cs.ATG" +#line 1551 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 30: { lexer.NextToken(); -#line 1544 "cs.ATG" +#line 1553 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 31: { lexer.NextToken(); -#line 1545 "cs.ATG" +#line 1554 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 111: { lexer.NextToken(); -#line 1547 "cs.ATG" +#line 1556 "cs.ATG" op = OverloadableOperatorType.True; break; } case 70: { lexer.NextToken(); -#line 1548 "cs.ATG" +#line 1557 "cs.ATG" op = OverloadableOperatorType.False; break; } case 6: { lexer.NextToken(); -#line 1550 "cs.ATG" +#line 1559 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1551 "cs.ATG" +#line 1560 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1552 "cs.ATG" +#line 1561 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 27: { lexer.NextToken(); -#line 1554 "cs.ATG" +#line 1563 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 28: { lexer.NextToken(); -#line 1555 "cs.ATG" +#line 1564 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 29: { lexer.NextToken(); -#line 1556 "cs.ATG" +#line 1565 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 36: { lexer.NextToken(); -#line 1558 "cs.ATG" +#line 1567 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 32: { lexer.NextToken(); -#line 1559 "cs.ATG" +#line 1568 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 33: { lexer.NextToken(); -#line 1560 "cs.ATG" +#line 1569 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 22: { lexer.NextToken(); -#line 1561 "cs.ATG" +#line 1570 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 34: { lexer.NextToken(); -#line 1562 "cs.ATG" +#line 1571 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 35: { lexer.NextToken(); -#line 1563 "cs.ATG" +#line 1572 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 21: { lexer.NextToken(); -#line 1564 "cs.ATG" +#line 1573 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 21) { lexer.NextToken(); -#line 1564 "cs.ATG" +#line 1573 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -3004,10 +3040,10 @@ out OverloadableOperatorType op) { } void AccessorDecls( -#line 1383 "cs.ATG" +#line 1392 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1385 "cs.ATG" +#line 1394 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -3015,136 +3051,136 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 17) { AttributeSection( -#line 1391 "cs.ATG" +#line 1400 "cs.ATG" out section); -#line 1391 "cs.ATG" +#line 1400 "cs.ATG" attributes.Add(section); } if ( -#line 1393 "cs.ATG" +#line 1402 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1394 "cs.ATG" +#line 1403 "cs.ATG" out getBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1395 "cs.ATG" +#line 1404 "cs.ATG" attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 1396 "cs.ATG" +#line 1405 "cs.ATG" out section); -#line 1396 "cs.ATG" +#line 1405 "cs.ATG" attributes.Add(section); } SetAccessorDecl( -#line 1397 "cs.ATG" +#line 1406 "cs.ATG" out setBlock, attributes); } } else if ( -#line 1399 "cs.ATG" +#line 1408 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1400 "cs.ATG" +#line 1409 "cs.ATG" out setBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1401 "cs.ATG" +#line 1410 "cs.ATG" attributes = new List(); while (la.kind == 17) { AttributeSection( -#line 1402 "cs.ATG" +#line 1411 "cs.ATG" out section); -#line 1402 "cs.ATG" +#line 1411 "cs.ATG" attributes.Add(section); } GetAccessorDecl( -#line 1403 "cs.ATG" +#line 1412 "cs.ATG" out getBlock, attributes); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1405 "cs.ATG" +#line 1414 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(158); } void InterfaceAccessors( -#line 1447 "cs.ATG" +#line 1456 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1449 "cs.ATG" +#line 1458 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; while (la.kind == 17) { AttributeSection( -#line 1454 "cs.ATG" +#line 1463 "cs.ATG" out section); -#line 1454 "cs.ATG" +#line 1463 "cs.ATG" attributes.Add(section); } if ( -#line 1456 "cs.ATG" +#line 1465 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1456 "cs.ATG" +#line 1465 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1457 "cs.ATG" +#line 1466 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1457 "cs.ATG" +#line 1466 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1458 "cs.ATG" +#line 1467 "cs.ATG" Error("set or get expected"); } else SynErr(159); Expect(11); -#line 1460 "cs.ATG" +#line 1469 "cs.ATG" attributes = new List(); if (la.kind == 1 || la.kind == 17) { while (la.kind == 17) { AttributeSection( -#line 1462 "cs.ATG" +#line 1471 "cs.ATG" out section); -#line 1462 "cs.ATG" +#line 1471 "cs.ATG" attributes.Add(section); } if ( -#line 1464 "cs.ATG" +#line 1473 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1464 "cs.ATG" +#line 1473 "cs.ATG" if (getBlock != null) Error("get already declared"); else getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1467 "cs.ATG" +#line 1476 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1467 "cs.ATG" +#line 1476 "cs.ATG" if (setBlock != null) Error("set already declared"); else setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1470 "cs.ATG" +#line 1479 "cs.ATG" Error("set or get expected"); } else SynErr(160); Expect(11); @@ -3152,183 +3188,183 @@ IdentIsSet()) { } void GetAccessorDecl( -#line 1409 "cs.ATG" +#line 1418 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1410 "cs.ATG" +#line 1419 "cs.ATG" Statement stmt = null; Expect(1); -#line 1413 "cs.ATG" +#line 1422 "cs.ATG" if (t.val != "get") Error("get expected"); if (la.kind == 15) { Block( -#line 1414 "cs.ATG" +#line 1423 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(161); -#line 1414 "cs.ATG" +#line 1423 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); } void SetAccessorDecl( -#line 1417 "cs.ATG" +#line 1426 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1418 "cs.ATG" +#line 1427 "cs.ATG" Statement stmt = null; Expect(1); -#line 1421 "cs.ATG" +#line 1430 "cs.ATG" if (t.val != "set") Error("set expected"); if (la.kind == 15) { Block( -#line 1422 "cs.ATG" +#line 1431 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(162); -#line 1422 "cs.ATG" +#line 1431 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); } void AddAccessorDecl( -#line 1498 "cs.ATG" +#line 1507 "cs.ATG" out Statement stmt) { -#line 1499 "cs.ATG" +#line 1508 "cs.ATG" stmt = null; Expect(1); -#line 1502 "cs.ATG" +#line 1511 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1503 "cs.ATG" +#line 1512 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1506 "cs.ATG" +#line 1515 "cs.ATG" out Statement stmt) { -#line 1507 "cs.ATG" +#line 1516 "cs.ATG" stmt = null; Expect(1); -#line 1510 "cs.ATG" +#line 1519 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1511 "cs.ATG" +#line 1520 "cs.ATG" out stmt); } void VariableInitializer( -#line 1527 "cs.ATG" +#line 1536 "cs.ATG" out Expression initializerExpression) { -#line 1528 "cs.ATG" +#line 1537 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(5)) { Expr( -#line 1530 "cs.ATG" +#line 1539 "cs.ATG" out initializerExpression); } else if (la.kind == 15) { ArrayInitializer( -#line 1531 "cs.ATG" +#line 1540 "cs.ATG" out initializerExpression); } else if (la.kind == 104) { lexer.NextToken(); Type( -#line 1532 "cs.ATG" +#line 1541 "cs.ATG" out type); Expect(17); Expr( -#line 1532 "cs.ATG" +#line 1541 "cs.ATG" out expr); Expect(18); -#line 1532 "cs.ATG" +#line 1541 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(163); } void Statement() { -#line 1636 "cs.ATG" +#line 1645 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; Point startPos = la.Location; if ( -#line 1644 "cs.ATG" +#line 1653 "cs.ATG" IsLabel()) { Expect(1); -#line 1644 "cs.ATG" +#line 1653 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 58) { lexer.NextToken(); Type( -#line 1647 "cs.ATG" +#line 1656 "cs.ATG" out type); -#line 1647 "cs.ATG" +#line 1656 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1648 "cs.ATG" +#line 1657 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1649 "cs.ATG" +#line 1658 "cs.ATG" out expr); -#line 1649 "cs.ATG" +#line 1658 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1650 "cs.ATG" +#line 1659 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1650 "cs.ATG" +#line 1659 "cs.ATG" out expr); -#line 1650 "cs.ATG" +#line 1659 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1651 "cs.ATG" +#line 1660 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1653 "cs.ATG" +#line 1662 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1653 "cs.ATG" +#line 1662 "cs.ATG" out stmt); Expect(11); -#line 1653 "cs.ATG" +#line 1662 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(22)) { EmbeddedStatement( -#line 1654 "cs.ATG" +#line 1663 "cs.ATG" out stmt); -#line 1654 "cs.ATG" +#line 1663 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(164); -#line 1660 "cs.ATG" +#line 1669 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3337,10 +3373,10 @@ out stmt); } void Argument( -#line 1567 "cs.ATG" +#line 1576 "cs.ATG" out Expression argumentexpr) { -#line 1569 "cs.ATG" +#line 1578 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3348,48 +3384,48 @@ out Expression argumentexpr) { if (la.kind == 98) { lexer.NextToken(); -#line 1574 "cs.ATG" +#line 1583 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1575 "cs.ATG" +#line 1584 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1577 "cs.ATG" +#line 1586 "cs.ATG" out expr); -#line 1577 "cs.ATG" +#line 1586 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1596 "cs.ATG" +#line 1605 "cs.ATG" out Expression outExpr) { -#line 1598 "cs.ATG" +#line 1607 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(15); if (StartOf(23)) { VariableInitializer( -#line 1603 "cs.ATG" +#line 1612 "cs.ATG" out expr); -#line 1603 "cs.ATG" +#line 1612 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1603 "cs.ATG" +#line 1612 "cs.ATG" NotFinalComma()) { Expect(13); VariableInitializer( -#line 1603 "cs.ATG" +#line 1612 "cs.ATG" out expr); -#line 1603 "cs.ATG" +#line 1612 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 13) { @@ -3398,84 +3434,84 @@ out expr); } Expect(16); -#line 1604 "cs.ATG" +#line 1613 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1580 "cs.ATG" +#line 1589 "cs.ATG" out AssignmentOperatorType op) { -#line 1581 "cs.ATG" +#line 1590 "cs.ATG" op = AssignmentOperatorType.None; switch (la.kind) { case 3: { lexer.NextToken(); -#line 1583 "cs.ATG" +#line 1592 "cs.ATG" op = AssignmentOperatorType.Assign; break; } case 37: { lexer.NextToken(); -#line 1584 "cs.ATG" +#line 1593 "cs.ATG" op = AssignmentOperatorType.Add; break; } case 38: { lexer.NextToken(); -#line 1585 "cs.ATG" +#line 1594 "cs.ATG" op = AssignmentOperatorType.Subtract; break; } case 39: { lexer.NextToken(); -#line 1586 "cs.ATG" +#line 1595 "cs.ATG" op = AssignmentOperatorType.Multiply; break; } case 40: { lexer.NextToken(); -#line 1587 "cs.ATG" +#line 1596 "cs.ATG" op = AssignmentOperatorType.Divide; break; } case 41: { lexer.NextToken(); -#line 1588 "cs.ATG" +#line 1597 "cs.ATG" op = AssignmentOperatorType.Modulus; break; } case 42: { lexer.NextToken(); -#line 1589 "cs.ATG" +#line 1598 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; break; } case 43: { lexer.NextToken(); -#line 1590 "cs.ATG" +#line 1599 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; break; } case 44: { lexer.NextToken(); -#line 1591 "cs.ATG" +#line 1600 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; break; } case 45: { lexer.NextToken(); -#line 1592 "cs.ATG" +#line 1601 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; break; } @@ -3483,7 +3519,7 @@ out AssignmentOperatorType op) { lexer.NextToken(); Expect(34); -#line 1593 "cs.ATG" +#line 1602 "cs.ATG" op = AssignmentOperatorType.ShiftRight; break; } @@ -3492,66 +3528,66 @@ out AssignmentOperatorType op) { } void LocalVariableDecl( -#line 1607 "cs.ATG" +#line 1616 "cs.ATG" out Statement stmt) { -#line 1609 "cs.ATG" +#line 1618 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1614 "cs.ATG" +#line 1623 "cs.ATG" out type); -#line 1614 "cs.ATG" +#line 1623 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1615 "cs.ATG" +#line 1624 "cs.ATG" out var); -#line 1615 "cs.ATG" +#line 1624 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 13) { lexer.NextToken(); LocalVariableDeclarator( -#line 1616 "cs.ATG" +#line 1625 "cs.ATG" out var); -#line 1616 "cs.ATG" +#line 1625 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1617 "cs.ATG" +#line 1626 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1620 "cs.ATG" +#line 1629 "cs.ATG" out VariableDeclaration var) { -#line 1621 "cs.ATG" +#line 1630 "cs.ATG" Expression expr = null; Expect(1); -#line 1624 "cs.ATG" +#line 1633 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1624 "cs.ATG" +#line 1633 "cs.ATG" out expr); -#line 1624 "cs.ATG" +#line 1633 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1667 "cs.ATG" +#line 1676 "cs.ATG" out Statement statement) { -#line 1669 "cs.ATG" +#line 1678 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3559,156 +3595,156 @@ out Statement statement) { if (la.kind == 15) { Block( -#line 1675 "cs.ATG" +#line 1684 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1677 "cs.ATG" +#line 1686 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1679 "cs.ATG" +#line 1688 "cs.ATG" UnCheckedAndLBrace()) { -#line 1679 "cs.ATG" +#line 1688 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 56) { lexer.NextToken(); } else if (la.kind == 116) { lexer.NextToken(); -#line 1680 "cs.ATG" +#line 1689 "cs.ATG" isChecked = false; } else SynErr(166); Block( -#line 1681 "cs.ATG" +#line 1690 "cs.ATG" out block); -#line 1681 "cs.ATG" +#line 1690 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 77) { lexer.NextToken(); -#line 1683 "cs.ATG" +#line 1692 "cs.ATG" Statement elseStatement = null; Expect(19); Expr( -#line 1684 "cs.ATG" +#line 1693 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1685 "cs.ATG" +#line 1694 "cs.ATG" out embeddedStatement); if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1686 "cs.ATG" +#line 1695 "cs.ATG" out elseStatement); } -#line 1687 "cs.ATG" +#line 1696 "cs.ATG" statement = elseStatement != null ? (Statement)new IfElseStatement(expr, embeddedStatement, elseStatement) : (Statement)new IfElseStatement(expr, embeddedStatement); } else if (la.kind == 108) { lexer.NextToken(); -#line 1688 "cs.ATG" +#line 1697 "cs.ATG" ArrayList switchSections = new ArrayList(); SwitchSection switchSection; Expect(19); Expr( -#line 1689 "cs.ATG" +#line 1698 "cs.ATG" out expr); Expect(20); Expect(15); while (la.kind == 53 || la.kind == 61) { SwitchSection( -#line 1690 "cs.ATG" +#line 1699 "cs.ATG" out switchSection); -#line 1690 "cs.ATG" +#line 1699 "cs.ATG" switchSections.Add(switchSection); } Expect(16); -#line 1691 "cs.ATG" +#line 1700 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 123) { lexer.NextToken(); Expect(19); Expr( -#line 1693 "cs.ATG" +#line 1702 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1695 "cs.ATG" +#line 1704 "cs.ATG" out embeddedStatement); -#line 1695 "cs.ATG" +#line 1704 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 63) { lexer.NextToken(); EmbeddedStatement( -#line 1696 "cs.ATG" +#line 1705 "cs.ATG" out embeddedStatement); Expect(123); Expect(19); Expr( -#line 1697 "cs.ATG" +#line 1706 "cs.ATG" out expr); Expect(20); Expect(11); -#line 1697 "cs.ATG" +#line 1706 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 74) { lexer.NextToken(); -#line 1698 "cs.ATG" +#line 1707 "cs.ATG" ArrayList initializer = null; ArrayList iterator = null; Expect(19); if (StartOf(5)) { ForInitializer( -#line 1699 "cs.ATG" +#line 1708 "cs.ATG" out initializer); } Expect(11); if (StartOf(5)) { Expr( -#line 1700 "cs.ATG" +#line 1709 "cs.ATG" out expr); } Expect(11); if (StartOf(5)) { ForIterator( -#line 1701 "cs.ATG" +#line 1710 "cs.ATG" out iterator); } Expect(20); EmbeddedStatement( -#line 1702 "cs.ATG" +#line 1711 "cs.ATG" out embeddedStatement); -#line 1702 "cs.ATG" +#line 1711 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 75) { lexer.NextToken(); Expect(19); Type( -#line 1703 "cs.ATG" +#line 1712 "cs.ATG" out type); Expect(1); -#line 1703 "cs.ATG" +#line 1712 "cs.ATG" string varName = t.val; Point start = t.Location; Expect(79); Expr( -#line 1704 "cs.ATG" +#line 1713 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1705 "cs.ATG" +#line 1714 "cs.ATG" out embeddedStatement); -#line 1705 "cs.ATG" +#line 1714 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -3716,34 +3752,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1709 "cs.ATG" +#line 1718 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 59) { lexer.NextToken(); Expect(11); -#line 1710 "cs.ATG" +#line 1719 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 76) { GotoStatement( -#line 1711 "cs.ATG" +#line 1720 "cs.ATG" out statement); } else if ( -#line 1712 "cs.ATG" +#line 1721 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 99) { lexer.NextToken(); Expr( -#line 1712 "cs.ATG" +#line 1721 "cs.ATG" out expr); -#line 1712 "cs.ATG" +#line 1721 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 51) { lexer.NextToken(); -#line 1713 "cs.ATG" +#line 1722 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(167); Expect(11); @@ -3751,513 +3787,513 @@ out expr); lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1714 "cs.ATG" +#line 1723 "cs.ATG" out expr); } Expect(11); -#line 1714 "cs.ATG" +#line 1723 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 110) { lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1715 "cs.ATG" +#line 1724 "cs.ATG" out expr); } Expect(11); -#line 1715 "cs.ATG" +#line 1724 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(5)) { StatementExpr( -#line 1717 "cs.ATG" +#line 1726 "cs.ATG" out statement); Expect(11); } else if (la.kind == 112) { TryStatement( -#line 1719 "cs.ATG" +#line 1728 "cs.ATG" out statement); } else if (la.kind == 84) { lexer.NextToken(); Expect(19); Expr( -#line 1721 "cs.ATG" +#line 1730 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1722 "cs.ATG" +#line 1731 "cs.ATG" out embeddedStatement); -#line 1722 "cs.ATG" +#line 1731 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 119) { -#line 1724 "cs.ATG" +#line 1733 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(19); ResourceAcquisition( -#line 1726 "cs.ATG" +#line 1735 "cs.ATG" out resourceAcquisitionStmt); Expect(20); EmbeddedStatement( -#line 1727 "cs.ATG" +#line 1736 "cs.ATG" out embeddedStatement); -#line 1727 "cs.ATG" +#line 1736 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 117) { lexer.NextToken(); Block( -#line 1729 "cs.ATG" +#line 1738 "cs.ATG" out embeddedStatement); -#line 1729 "cs.ATG" +#line 1738 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 72) { lexer.NextToken(); Expect(19); Type( -#line 1732 "cs.ATG" +#line 1741 "cs.ATG" out type); -#line 1732 "cs.ATG" +#line 1741 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); ArrayList pointerDeclarators = new ArrayList(1); Expect(1); -#line 1735 "cs.ATG" +#line 1744 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1736 "cs.ATG" +#line 1745 "cs.ATG" out expr); -#line 1736 "cs.ATG" +#line 1745 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1738 "cs.ATG" +#line 1747 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1739 "cs.ATG" +#line 1748 "cs.ATG" out expr); -#line 1739 "cs.ATG" +#line 1748 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(20); EmbeddedStatement( -#line 1741 "cs.ATG" +#line 1750 "cs.ATG" out embeddedStatement); -#line 1741 "cs.ATG" +#line 1750 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(168); } void SwitchSection( -#line 1763 "cs.ATG" +#line 1772 "cs.ATG" out SwitchSection stmt) { -#line 1765 "cs.ATG" +#line 1774 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1769 "cs.ATG" +#line 1778 "cs.ATG" out label); -#line 1769 "cs.ATG" +#line 1778 "cs.ATG" switchSection.SwitchLabels.Add(label); while (la.kind == 53 || la.kind == 61) { SwitchLabel( -#line 1771 "cs.ATG" +#line 1780 "cs.ATG" out label); -#line 1771 "cs.ATG" +#line 1780 "cs.ATG" switchSection.SwitchLabels.Add(label); } -#line 1773 "cs.ATG" +#line 1782 "cs.ATG" compilationUnit.BlockStart(switchSection); Statement(); while (StartOf(20)) { Statement(); } -#line 1776 "cs.ATG" +#line 1785 "cs.ATG" compilationUnit.BlockEnd(); stmt = switchSection; } void ForInitializer( -#line 1744 "cs.ATG" +#line 1753 "cs.ATG" out ArrayList initializer) { -#line 1746 "cs.ATG" +#line 1755 "cs.ATG" Statement stmt; initializer = new ArrayList(); if ( -#line 1750 "cs.ATG" +#line 1759 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1750 "cs.ATG" +#line 1759 "cs.ATG" out stmt); -#line 1750 "cs.ATG" +#line 1759 "cs.ATG" initializer.Add(stmt); } else if (StartOf(5)) { StatementExpr( -#line 1751 "cs.ATG" +#line 1760 "cs.ATG" out stmt); -#line 1751 "cs.ATG" +#line 1760 "cs.ATG" initializer.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1751 "cs.ATG" +#line 1760 "cs.ATG" out stmt); -#line 1751 "cs.ATG" +#line 1760 "cs.ATG" initializer.Add(stmt); } -#line 1751 "cs.ATG" +#line 1760 "cs.ATG" initializer.Add(stmt); } else SynErr(169); } void ForIterator( -#line 1754 "cs.ATG" +#line 1763 "cs.ATG" out ArrayList iterator) { -#line 1756 "cs.ATG" +#line 1765 "cs.ATG" Statement stmt; iterator = new ArrayList(); StatementExpr( -#line 1760 "cs.ATG" +#line 1769 "cs.ATG" out stmt); -#line 1760 "cs.ATG" +#line 1769 "cs.ATG" iterator.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1760 "cs.ATG" +#line 1769 "cs.ATG" out stmt); -#line 1760 "cs.ATG" +#line 1769 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1831 "cs.ATG" +#line 1840 "cs.ATG" out Statement stmt) { -#line 1832 "cs.ATG" +#line 1841 "cs.ATG" Expression expr; stmt = null; Expect(76); if (la.kind == 1) { lexer.NextToken(); -#line 1836 "cs.ATG" +#line 1845 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1837 "cs.ATG" +#line 1846 "cs.ATG" out expr); Expect(11); -#line 1837 "cs.ATG" +#line 1846 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1838 "cs.ATG" +#line 1847 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(170); } void StatementExpr( -#line 1858 "cs.ATG" +#line 1867 "cs.ATG" out Statement stmt) { -#line 1863 "cs.ATG" +#line 1872 "cs.ATG" bool mustBeAssignment = la.kind == Tokens.Plus || la.kind == Tokens.Minus || la.kind == Tokens.Not || la.kind == Tokens.BitwiseComplement || la.kind == Tokens.Times || la.kind == Tokens.BitwiseAnd || IsTypeCast(); Expression expr = null; UnaryExpr( -#line 1869 "cs.ATG" +#line 1878 "cs.ATG" out expr); if (StartOf(7)) { -#line 1872 "cs.ATG" +#line 1881 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1872 "cs.ATG" +#line 1881 "cs.ATG" out op); Expr( -#line 1872 "cs.ATG" +#line 1881 "cs.ATG" out val); -#line 1872 "cs.ATG" +#line 1881 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else if (la.kind == 11 || la.kind == 13 || la.kind == 20) { -#line 1873 "cs.ATG" +#line 1882 "cs.ATG" if (mustBeAssignment) Error("error in assignment."); } else SynErr(171); -#line 1874 "cs.ATG" +#line 1883 "cs.ATG" stmt = new StatementExpression(expr); } void TryStatement( -#line 1788 "cs.ATG" +#line 1797 "cs.ATG" out Statement tryStatement) { -#line 1790 "cs.ATG" +#line 1799 "cs.ATG" Statement blockStmt = null, finallyStmt = null; ArrayList catchClauses = null; Expect(112); Block( -#line 1794 "cs.ATG" +#line 1803 "cs.ATG" out blockStmt); if (la.kind == 54) { CatchClauses( -#line 1796 "cs.ATG" +#line 1805 "cs.ATG" out catchClauses); if (la.kind == 71) { lexer.NextToken(); Block( -#line 1796 "cs.ATG" +#line 1805 "cs.ATG" out finallyStmt); } } else if (la.kind == 71) { lexer.NextToken(); Block( -#line 1797 "cs.ATG" +#line 1806 "cs.ATG" out finallyStmt); } else SynErr(172); -#line 1800 "cs.ATG" +#line 1809 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 1842 "cs.ATG" +#line 1851 "cs.ATG" out Statement stmt) { -#line 1844 "cs.ATG" +#line 1853 "cs.ATG" stmt = null; Expression expr; if ( -#line 1849 "cs.ATG" +#line 1858 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1849 "cs.ATG" +#line 1858 "cs.ATG" out stmt); } else if (StartOf(5)) { Expr( -#line 1850 "cs.ATG" +#line 1859 "cs.ATG" out expr); -#line 1854 "cs.ATG" +#line 1863 "cs.ATG" stmt = new StatementExpression(expr); } else SynErr(173); } void SwitchLabel( -#line 1781 "cs.ATG" +#line 1790 "cs.ATG" out CaseLabel label) { -#line 1782 "cs.ATG" +#line 1791 "cs.ATG" Expression expr = null; label = null; if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1784 "cs.ATG" +#line 1793 "cs.ATG" out expr); Expect(9); -#line 1784 "cs.ATG" +#line 1793 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(9); -#line 1785 "cs.ATG" +#line 1794 "cs.ATG" label = new CaseLabel(); } else SynErr(174); } void CatchClauses( -#line 1805 "cs.ATG" +#line 1814 "cs.ATG" out ArrayList catchClauses) { -#line 1807 "cs.ATG" +#line 1816 "cs.ATG" catchClauses = new ArrayList(); Expect(54); -#line 1810 "cs.ATG" +#line 1819 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; if (la.kind == 15) { Block( -#line 1816 "cs.ATG" +#line 1825 "cs.ATG" out stmt); -#line 1816 "cs.ATG" +#line 1825 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 19) { lexer.NextToken(); ClassType( -#line 1818 "cs.ATG" +#line 1827 "cs.ATG" out typeRef); -#line 1818 "cs.ATG" +#line 1827 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1819 "cs.ATG" +#line 1828 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1820 "cs.ATG" +#line 1829 "cs.ATG" out stmt); -#line 1821 "cs.ATG" +#line 1830 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); while ( -#line 1822 "cs.ATG" +#line 1831 "cs.ATG" IsTypedCatch()) { Expect(54); Expect(19); ClassType( -#line 1822 "cs.ATG" +#line 1831 "cs.ATG" out typeRef); -#line 1822 "cs.ATG" +#line 1831 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1823 "cs.ATG" +#line 1832 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1824 "cs.ATG" +#line 1833 "cs.ATG" out stmt); -#line 1825 "cs.ATG" +#line 1834 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); } if (la.kind == 54) { lexer.NextToken(); Block( -#line 1827 "cs.ATG" +#line 1836 "cs.ATG" out stmt); -#line 1827 "cs.ATG" +#line 1836 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(175); } void UnaryExpr( -#line 1890 "cs.ATG" +#line 1899 "cs.ATG" out Expression uExpr) { -#line 1892 "cs.ATG" +#line 1901 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(24) || -#line 1916 "cs.ATG" +#line 1925 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1901 "cs.ATG" +#line 1910 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1902 "cs.ATG" +#line 1911 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 23) { lexer.NextToken(); -#line 1903 "cs.ATG" +#line 1912 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 26) { lexer.NextToken(); -#line 1904 "cs.ATG" +#line 1913 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1905 "cs.ATG" +#line 1914 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 30) { lexer.NextToken(); -#line 1906 "cs.ATG" +#line 1915 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1907 "cs.ATG" +#line 1916 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1908 "cs.ATG" +#line 1917 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(19); Type( -#line 1916 "cs.ATG" +#line 1925 "cs.ATG" out type); Expect(20); -#line 1916 "cs.ATG" +#line 1925 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 1920 "cs.ATG" +#line 1929 "cs.ATG" out expr); -#line 1920 "cs.ATG" +#line 1929 "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) { @@ -4275,33 +4311,33 @@ out expr); } void ConditionalOrExpr( -#line 2103 "cs.ATG" +#line 2112 "cs.ATG" ref Expression outExpr) { -#line 2104 "cs.ATG" +#line 2113 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2106 "cs.ATG" +#line 2115 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2106 "cs.ATG" +#line 2115 "cs.ATG" out expr); ConditionalAndExpr( -#line 2106 "cs.ATG" +#line 2115 "cs.ATG" ref expr); -#line 2106 "cs.ATG" +#line 2115 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1937 "cs.ATG" +#line 1946 "cs.ATG" out Expression pexpr) { -#line 1939 "cs.ATG" +#line 1948 "cs.ATG" TypeReference type = null; List typeList = null; bool isArrayCreation = false; @@ -4311,340 +4347,340 @@ out Expression pexpr) { if (la.kind == 111) { lexer.NextToken(); -#line 1947 "cs.ATG" +#line 1956 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 70) { lexer.NextToken(); -#line 1948 "cs.ATG" +#line 1957 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 88) { lexer.NextToken(); -#line 1949 "cs.ATG" +#line 1958 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1950 "cs.ATG" +#line 1959 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); } else if ( -#line 1951 "cs.ATG" +#line 1960 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { TypeName( -#line 1952 "cs.ATG" +#line 1961 "cs.ATG" out type); -#line 1952 "cs.ATG" +#line 1961 "cs.ATG" pexpr = new TypeReferenceExpression(type); } else if (la.kind == 1) { lexer.NextToken(); -#line 1954 "cs.ATG" +#line 1963 "cs.ATG" pexpr = new IdentifierExpression(t.val); } else if (la.kind == 19) { lexer.NextToken(); Expr( -#line 1956 "cs.ATG" +#line 1965 "cs.ATG" out expr); Expect(20); -#line 1956 "cs.ATG" +#line 1965 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(25)) { -#line 1958 "cs.ATG" +#line 1967 "cs.ATG" string val = null; switch (la.kind) { case 50: { lexer.NextToken(); -#line 1960 "cs.ATG" +#line 1969 "cs.ATG" val = "bool"; break; } case 52: { lexer.NextToken(); -#line 1961 "cs.ATG" +#line 1970 "cs.ATG" val = "byte"; break; } case 55: { lexer.NextToken(); -#line 1962 "cs.ATG" +#line 1971 "cs.ATG" val = "char"; break; } case 60: { lexer.NextToken(); -#line 1963 "cs.ATG" +#line 1972 "cs.ATG" val = "decimal"; break; } case 64: { lexer.NextToken(); -#line 1964 "cs.ATG" +#line 1973 "cs.ATG" val = "double"; break; } case 73: { lexer.NextToken(); -#line 1965 "cs.ATG" +#line 1974 "cs.ATG" val = "float"; break; } case 80: { lexer.NextToken(); -#line 1966 "cs.ATG" +#line 1975 "cs.ATG" val = "int"; break; } case 85: { lexer.NextToken(); -#line 1967 "cs.ATG" +#line 1976 "cs.ATG" val = "long"; break; } case 89: { lexer.NextToken(); -#line 1968 "cs.ATG" +#line 1977 "cs.ATG" val = "object"; break; } case 100: { lexer.NextToken(); -#line 1969 "cs.ATG" +#line 1978 "cs.ATG" val = "sbyte"; break; } case 102: { lexer.NextToken(); -#line 1970 "cs.ATG" +#line 1979 "cs.ATG" val = "short"; break; } case 106: { lexer.NextToken(); -#line 1971 "cs.ATG" +#line 1980 "cs.ATG" val = "string"; break; } case 114: { lexer.NextToken(); -#line 1972 "cs.ATG" +#line 1981 "cs.ATG" val = "uint"; break; } case 115: { lexer.NextToken(); -#line 1973 "cs.ATG" +#line 1982 "cs.ATG" val = "ulong"; break; } case 118: { lexer.NextToken(); -#line 1974 "cs.ATG" +#line 1983 "cs.ATG" val = "ushort"; break; } } -#line 1975 "cs.ATG" +#line 1984 "cs.ATG" t.val = ""; Expect(14); Expect(1); -#line 1975 "cs.ATG" +#line 1984 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); } else if (la.kind == 109) { lexer.NextToken(); -#line 1977 "cs.ATG" +#line 1986 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 49) { lexer.NextToken(); -#line 1979 "cs.ATG" +#line 1988 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1981 "cs.ATG" +#line 1990 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 17) { lexer.NextToken(); Expr( -#line 1982 "cs.ATG" +#line 1991 "cs.ATG" out expr); -#line 1982 "cs.ATG" +#line 1991 "cs.ATG" ArrayList indices = new ArrayList(); if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1983 "cs.ATG" +#line 1992 "cs.ATG" out expr); -#line 1983 "cs.ATG" +#line 1992 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 1984 "cs.ATG" +#line 1993 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(176); -#line 1985 "cs.ATG" +#line 1994 "cs.ATG" pexpr = retExpr; } else if (la.kind == 87) { lexer.NextToken(); NonArrayType( -#line 1986 "cs.ATG" +#line 1995 "cs.ATG" out type); -#line 1986 "cs.ATG" +#line 1995 "cs.ATG" ArrayList parameters = new ArrayList(); if (la.kind == 19) { lexer.NextToken(); -#line 1991 "cs.ATG" +#line 2000 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 1992 "cs.ATG" +#line 2001 "cs.ATG" out expr); -#line 1992 "cs.ATG" +#line 2001 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1993 "cs.ATG" +#line 2002 "cs.ATG" out expr); -#line 1993 "cs.ATG" +#line 2002 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(20); -#line 1995 "cs.ATG" +#line 2004 "cs.ATG" pexpr = oce; } else if (la.kind == 17) { -#line 1997 "cs.ATG" +#line 2006 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; lexer.NextToken(); -#line 1998 "cs.ATG" +#line 2007 "cs.ATG" int dims = 0; ArrayList rank = new ArrayList(); ArrayList parameterExpression = new ArrayList(); if (StartOf(5)) { Expr( -#line 2002 "cs.ATG" +#line 2011 "cs.ATG" out expr); -#line 2002 "cs.ATG" +#line 2011 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 2004 "cs.ATG" +#line 2013 "cs.ATG" out expr); -#line 2004 "cs.ATG" +#line 2013 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } } Expect(18); -#line 2006 "cs.ATG" +#line 2015 "cs.ATG" parameters.Add(new ArrayCreationParameter(parameterExpression)); ace.Parameters = parameters; while ( -#line 2009 "cs.ATG" +#line 2018 "cs.ATG" IsDims()) { Expect(17); -#line 2009 "cs.ATG" +#line 2018 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 2010 "cs.ATG" +#line 2019 "cs.ATG" dims++; } -#line 2010 "cs.ATG" +#line 2019 "cs.ATG" rank.Add(dims); parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } -#line 2014 "cs.ATG" +#line 2023 "cs.ATG" if (rank.Count > 0) { ace.Rank = (int[])rank.ToArray(typeof (int)); } if (la.kind == 15) { ArrayInitializer( -#line 2018 "cs.ATG" +#line 2027 "cs.ATG" out expr); -#line 2018 "cs.ATG" +#line 2027 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else if (la.kind == 13 || la.kind == 18) { while (la.kind == 13) { lexer.NextToken(); -#line 2020 "cs.ATG" +#line 2029 "cs.ATG" dims++; } -#line 2021 "cs.ATG" +#line 2030 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); while ( -#line 2023 "cs.ATG" +#line 2032 "cs.ATG" IsDims()) { Expect(17); -#line 2023 "cs.ATG" +#line 2032 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 2023 "cs.ATG" +#line 2032 "cs.ATG" dims++; } -#line 2023 "cs.ATG" +#line 2032 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } ArrayInitializer( -#line 2023 "cs.ATG" +#line 2032 "cs.ATG" out expr); -#line 2023 "cs.ATG" +#line 2032 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters; } else SynErr(177); } else SynErr(178); @@ -4652,192 +4688,192 @@ out expr); lexer.NextToken(); Expect(19); if ( -#line 2029 "cs.ATG" +#line 2038 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 2029 "cs.ATG" +#line 2038 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(9)) { Type( -#line 2030 "cs.ATG" +#line 2039 "cs.ATG" out type); } else SynErr(179); Expect(20); -#line 2031 "cs.ATG" +#line 2040 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 103) { lexer.NextToken(); Expect(19); Type( -#line 2032 "cs.ATG" +#line 2041 "cs.ATG" out type); Expect(20); -#line 2032 "cs.ATG" +#line 2041 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 56) { lexer.NextToken(); Expect(19); Expr( -#line 2033 "cs.ATG" +#line 2042 "cs.ATG" out expr); Expect(20); -#line 2033 "cs.ATG" +#line 2042 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 116) { lexer.NextToken(); Expect(19); Expr( -#line 2034 "cs.ATG" +#line 2043 "cs.ATG" out expr); Expect(20); -#line 2034 "cs.ATG" +#line 2043 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 62) { lexer.NextToken(); AnonymousMethodExpr( -#line 2035 "cs.ATG" +#line 2044 "cs.ATG" out expr); -#line 2035 "cs.ATG" +#line 2044 "cs.ATG" pexpr = expr; } else SynErr(180); while (StartOf(26) || -#line 2056 "cs.ATG" +#line 2065 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || -#line 2064 "cs.ATG" +#line 2073 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 30 || la.kind == 31) { if (la.kind == 30) { lexer.NextToken(); -#line 2039 "cs.ATG" +#line 2048 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 31) { lexer.NextToken(); -#line 2040 "cs.ATG" +#line 2049 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(181); } else if (la.kind == 46) { lexer.NextToken(); Expect(1); -#line 2043 "cs.ATG" +#line 2052 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 2044 "cs.ATG" +#line 2053 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if ( -#line 2056 "cs.ATG" +#line 2065 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) { TypeArgumentList( -#line 2057 "cs.ATG" +#line 2066 "cs.ATG" out typeList); Expect(14); Expect(1); -#line 2058 "cs.ATG" +#line 2067 "cs.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeList), t.val); } else if (la.kind == 19) { lexer.NextToken(); -#line 2060 "cs.ATG" +#line 2069 "cs.ATG" ArrayList parameters = new ArrayList(); if (StartOf(21)) { Argument( -#line 2061 "cs.ATG" +#line 2070 "cs.ATG" out expr); -#line 2061 "cs.ATG" +#line 2070 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 13) { lexer.NextToken(); Argument( -#line 2062 "cs.ATG" +#line 2071 "cs.ATG" out expr); -#line 2062 "cs.ATG" +#line 2071 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(20); -#line 2063 "cs.ATG" +#line 2072 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else if ( -#line 2064 "cs.ATG" +#line 2073 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { TypeArgumentList( -#line 2064 "cs.ATG" +#line 2073 "cs.ATG" out typeList); Expect(19); -#line 2065 "cs.ATG" +#line 2074 "cs.ATG" ArrayList parameters = new ArrayList(); if (StartOf(21)) { Argument( -#line 2066 "cs.ATG" +#line 2075 "cs.ATG" out expr); -#line 2066 "cs.ATG" +#line 2075 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 13) { lexer.NextToken(); Argument( -#line 2067 "cs.ATG" +#line 2076 "cs.ATG" out expr); -#line 2067 "cs.ATG" +#line 2076 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(20); -#line 2068 "cs.ATG" +#line 2077 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 2070 "cs.ATG" +#line 2079 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); ArrayList indices = new ArrayList(); lexer.NextToken(); Expr( -#line 2073 "cs.ATG" +#line 2082 "cs.ATG" out expr); -#line 2073 "cs.ATG" +#line 2082 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 2074 "cs.ATG" +#line 2083 "cs.ATG" out expr); -#line 2074 "cs.ATG" +#line 2083 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 2075 "cs.ATG" +#line 2084 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void AnonymousMethodExpr( -#line 2079 "cs.ATG" +#line 2088 "cs.ATG" out Expression outExpr) { -#line 2081 "cs.ATG" +#line 2090 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; Statement stmt; @@ -4847,336 +4883,336 @@ out Expression outExpr) { Expect(19); if (StartOf(10)) { FormalParameterList( -#line 2089 "cs.ATG" +#line 2098 "cs.ATG" p); -#line 2089 "cs.ATG" +#line 2098 "cs.ATG" expr.Parameters = p; } Expect(20); -#line 2093 "cs.ATG" +#line 2102 "cs.ATG" if (compilationUnit != null) { Block( -#line 2094 "cs.ATG" +#line 2103 "cs.ATG" out stmt); -#line 2094 "cs.ATG" +#line 2103 "cs.ATG" expr.Body = (BlockStatement)stmt; -#line 2095 "cs.ATG" +#line 2104 "cs.ATG" } else { Expect(15); -#line 2097 "cs.ATG" +#line 2106 "cs.ATG" lexer.SkipCurrentBlock(); Expect(16); -#line 2099 "cs.ATG" +#line 2108 "cs.ATG" } -#line 2100 "cs.ATG" +#line 2109 "cs.ATG" expr.EndLocation = t.Location; } void TypeArgumentList( -#line 2249 "cs.ATG" +#line 2269 "cs.ATG" out List types) { -#line 2251 "cs.ATG" +#line 2271 "cs.ATG" types = new List(); TypeReference type = null; Expect(22); Type( -#line 2255 "cs.ATG" +#line 2275 "cs.ATG" out type); -#line 2255 "cs.ATG" +#line 2275 "cs.ATG" types.Add(type); while (la.kind == 13) { lexer.NextToken(); Type( -#line 2256 "cs.ATG" +#line 2276 "cs.ATG" out type); -#line 2256 "cs.ATG" +#line 2276 "cs.ATG" types.Add(type); } Expect(21); } void ConditionalAndExpr( -#line 2109 "cs.ATG" +#line 2118 "cs.ATG" ref Expression outExpr) { -#line 2110 "cs.ATG" +#line 2119 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2112 "cs.ATG" +#line 2121 "cs.ATG" ref outExpr); while (la.kind == 24) { lexer.NextToken(); UnaryExpr( -#line 2112 "cs.ATG" +#line 2121 "cs.ATG" out expr); InclusiveOrExpr( -#line 2112 "cs.ATG" +#line 2121 "cs.ATG" ref expr); -#line 2112 "cs.ATG" +#line 2121 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2115 "cs.ATG" +#line 2124 "cs.ATG" ref Expression outExpr) { -#line 2116 "cs.ATG" +#line 2125 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2118 "cs.ATG" +#line 2127 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2118 "cs.ATG" +#line 2127 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2118 "cs.ATG" +#line 2127 "cs.ATG" ref expr); -#line 2118 "cs.ATG" +#line 2127 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2121 "cs.ATG" +#line 2130 "cs.ATG" ref Expression outExpr) { -#line 2122 "cs.ATG" +#line 2131 "cs.ATG" Expression expr; AndExpr( -#line 2124 "cs.ATG" +#line 2133 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2124 "cs.ATG" +#line 2133 "cs.ATG" out expr); AndExpr( -#line 2124 "cs.ATG" +#line 2133 "cs.ATG" ref expr); -#line 2124 "cs.ATG" +#line 2133 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2127 "cs.ATG" +#line 2136 "cs.ATG" ref Expression outExpr) { -#line 2128 "cs.ATG" +#line 2137 "cs.ATG" Expression expr; EqualityExpr( -#line 2130 "cs.ATG" +#line 2139 "cs.ATG" ref outExpr); while (la.kind == 27) { lexer.NextToken(); UnaryExpr( -#line 2130 "cs.ATG" +#line 2139 "cs.ATG" out expr); EqualityExpr( -#line 2130 "cs.ATG" +#line 2139 "cs.ATG" ref expr); -#line 2130 "cs.ATG" +#line 2139 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2133 "cs.ATG" +#line 2142 "cs.ATG" ref Expression outExpr) { -#line 2135 "cs.ATG" +#line 2144 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2139 "cs.ATG" +#line 2148 "cs.ATG" ref outExpr); while (la.kind == 32 || la.kind == 33) { if (la.kind == 33) { lexer.NextToken(); -#line 2142 "cs.ATG" +#line 2151 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2143 "cs.ATG" +#line 2152 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2145 "cs.ATG" +#line 2154 "cs.ATG" out expr); RelationalExpr( -#line 2145 "cs.ATG" +#line 2154 "cs.ATG" ref expr); -#line 2145 "cs.ATG" +#line 2154 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2149 "cs.ATG" +#line 2158 "cs.ATG" ref Expression outExpr) { -#line 2151 "cs.ATG" +#line 2160 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2156 "cs.ATG" +#line 2165 "cs.ATG" ref outExpr); while (StartOf(27)) { if (StartOf(28)) { if (la.kind == 22) { lexer.NextToken(); -#line 2159 "cs.ATG" +#line 2168 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 21) { lexer.NextToken(); -#line 2160 "cs.ATG" +#line 2169 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 35) { lexer.NextToken(); -#line 2161 "cs.ATG" +#line 2170 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 34) { lexer.NextToken(); -#line 2162 "cs.ATG" +#line 2171 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(182); UnaryExpr( -#line 2164 "cs.ATG" +#line 2173 "cs.ATG" out expr); ShiftExpr( -#line 2164 "cs.ATG" +#line 2173 "cs.ATG" ref expr); -#line 2164 "cs.ATG" +#line 2173 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 83) { lexer.NextToken(); -#line 2167 "cs.ATG" +#line 2176 "cs.ATG" op = BinaryOperatorType.TypeCheck; } else if (la.kind == 48) { lexer.NextToken(); -#line 2168 "cs.ATG" +#line 2177 "cs.ATG" op = BinaryOperatorType.AsCast; } else SynErr(183); Type( -#line 2170 "cs.ATG" +#line 2179 "cs.ATG" out type); -#line 2170 "cs.ATG" +#line 2179 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, new TypeReferenceExpression(type)); } } } void ShiftExpr( -#line 2174 "cs.ATG" +#line 2183 "cs.ATG" ref Expression outExpr) { -#line 2176 "cs.ATG" +#line 2185 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2180 "cs.ATG" +#line 2189 "cs.ATG" ref outExpr); while (la.kind == 36 || -#line 2183 "cs.ATG" +#line 2192 "cs.ATG" IsShiftRight()) { if (la.kind == 36) { lexer.NextToken(); -#line 2182 "cs.ATG" +#line 2191 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(21); Expect(21); -#line 2184 "cs.ATG" +#line 2193 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2187 "cs.ATG" +#line 2196 "cs.ATG" out expr); AdditiveExpr( -#line 2187 "cs.ATG" +#line 2196 "cs.ATG" ref expr); -#line 2187 "cs.ATG" +#line 2196 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2191 "cs.ATG" +#line 2200 "cs.ATG" ref Expression outExpr) { -#line 2193 "cs.ATG" +#line 2202 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2197 "cs.ATG" +#line 2206 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2200 "cs.ATG" +#line 2209 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2201 "cs.ATG" +#line 2210 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2203 "cs.ATG" +#line 2212 "cs.ATG" out expr); MultiplicativeExpr( -#line 2203 "cs.ATG" +#line 2212 "cs.ATG" ref expr); -#line 2203 "cs.ATG" +#line 2212 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2207 "cs.ATG" +#line 2216 "cs.ATG" ref Expression outExpr) { -#line 2209 "cs.ATG" +#line 2218 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5184,57 +5220,57 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2215 "cs.ATG" +#line 2224 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2216 "cs.ATG" +#line 2225 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2217 "cs.ATG" +#line 2226 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2219 "cs.ATG" +#line 2228 "cs.ATG" out expr); -#line 2219 "cs.ATG" +#line 2228 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2301 "cs.ATG" +#line 2321 "cs.ATG" out TypeReference type) { -#line 2302 "cs.ATG" +#line 2322 "cs.ATG" TypeReference t; type = null; if (la.kind == 107) { lexer.NextToken(); -#line 2304 "cs.ATG" +#line 2324 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 57) { lexer.NextToken(); -#line 2305 "cs.ATG" +#line 2325 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 87) { lexer.NextToken(); Expect(19); Expect(20); -#line 2306 "cs.ATG" +#line 2326 "cs.ATG" type = new TypeReference("struct"); } else if (StartOf(9)) { Type( -#line 2307 "cs.ATG" +#line 2327 "cs.ATG" out t); -#line 2307 "cs.ATG" +#line 2327 "cs.ATG" type = t; } else SynErr(184); } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index c523fc00d9..459da48134 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -263,8 +263,8 @@ bool LBrackAndCommaOrRBrack () { bool IsDims () { return LBrackAndCommaOrRBrack(); } -/* True, if "[" is followed by "," or "]" * - * or if the current token is "*" */ +/* True, if "[" is followed by "," or "]" */ +/* or if the current token is "*" */ bool TimesOrLBrackAndCommaOrRBrack () { return la.kind == Tokens.Times || LBrackAndCommaOrRBrack(); } @@ -287,12 +287,19 @@ bool SkipGeneric(ref Token pt) } } pt = Peek(); - return true; } return true; } -/* True, if lookahead is a primitive type keyword, or * - * if it is a type declaration followed by an ident */ +bool SkipQuestionMark(ref Token pt) +{ + if (pt.kind == Tokens.Question) { + pt = Peek(); + } + return true; +} + +/* True, if lookahead is a primitive type keyword, or */ +/* if it is a type declaration followed by an ident */ bool IsLocalVarDecl () { if (IsYieldStatement()) { return false; @@ -305,7 +312,7 @@ bool IsLocalVarDecl () { Token pt = la ; string ignore; - return IsQualident(ref pt, out ignore) && SkipGeneric(ref pt) && IsPointerOrDims(ref pt) && + return IsQualident(ref pt, out ignore) && SkipGeneric(ref pt) && SkipQuestionMark(ref pt) && IsPointerOrDims(ref pt) && pt.kind == Tokens.Identifier; } @@ -902,6 +909,7 @@ Type = ( ClassType | SimpleType (. type = new TypeReference(name); .) + [ NullableQuestionMark ] | "void" "*" (. pointer = 1; type = new TypeReference("void"); .) ) (. List r = new List(); .) @@ -926,6 +934,7 @@ NonArrayType = ( ClassType | SimpleType (. type = new TypeReference(name); .) + [ NullableQuestionMark ] | "void" "*" (. pointer = 1; type = new TypeReference("void"); .) ) @@ -2244,6 +2253,17 @@ TypeName typeRef = new TypeReference(alias + "." + qualident, typeArguments); } .) + [ NullableQuestionMark ] +. + +NullableQuestionMark +(. List typeArguments = new List(1); .) += + "?" + (. + if (typeRef != null) typeArguments.Add(typeRef); + typeRef = new TypeReference("System.Nullable", typeArguments); + .) . TypeArgumentList types> diff --git a/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs index adb2e2bf37..caf8cd575f 100644 --- a/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs @@ -113,6 +113,7 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual("int", type.GenericTypes[0].Type); } + [Test] public void CSharpSimpleLocalVariableDeclarationTest() { @@ -123,6 +124,7 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.AreEqual("MyVar", type.Type); // TODO: Check initializer } + [Test] public void CSharpSimpleLocalVariableDeclarationTest1() { @@ -134,6 +136,52 @@ namespace ICSharpCode.NRefactory.Tests.AST // TODO: Check initializer } + [Test] + public void CSharpNullableLocalVariableDeclarationTest1() + { + LocalVariableDeclaration lvd = (LocalVariableDeclaration)ParseUtilCSharp.ParseStatment("int? a;", typeof(LocalVariableDeclaration)); + Assert.AreEqual(1, lvd.Variables.Count); + Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); + TypeReference type = lvd.GetTypeForVariable(0); + Assert.AreEqual("System.Nullable", type.SystemType); + Assert.AreEqual("System.Int32", type.GenericTypes[0].SystemType); + } + + [Test] + public void CSharpNullableLocalVariableDeclarationTest2() + { + LocalVariableDeclaration lvd = (LocalVariableDeclaration)ParseUtilCSharp.ParseStatment("DateTime? a;", typeof(LocalVariableDeclaration)); + Assert.AreEqual(1, lvd.Variables.Count); + Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); + TypeReference type = lvd.GetTypeForVariable(0); + Assert.AreEqual("System.Nullable", type.SystemType); + Assert.AreEqual("DateTime", type.GenericTypes[0].Type); + } + + [Test] + public void CSharpNullableLocalVariableDeclarationTest3() + { + LocalVariableDeclaration lvd = (LocalVariableDeclaration)ParseUtilCSharp.ParseStatment("DateTime?[] a;", typeof(LocalVariableDeclaration)); + Assert.AreEqual(1, lvd.Variables.Count); + Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); + TypeReference type = lvd.GetTypeForVariable(0); + Assert.IsTrue(type.IsArrayType); + Assert.AreEqual("System.Nullable", type.SystemType); + Assert.AreEqual("DateTime", type.GenericTypes[0].Type); + } + + [Test] + public void CSharpNullableLocalVariableDeclarationTest4() + { + LocalVariableDeclaration lvd = (LocalVariableDeclaration)ParseUtilCSharp.ParseStatment("SomeStruct? a;", typeof(LocalVariableDeclaration)); + Assert.AreEqual(1, lvd.Variables.Count); + Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); + TypeReference type = lvd.GetTypeForVariable(0); + Assert.AreEqual("System.Nullable", type.SystemType); + Assert.AreEqual("SomeStruct", type.GenericTypes[0].Type); + Assert.AreEqual("System.Nullable", type.GenericTypes[0].GenericTypes[0].SystemType); + Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].GenericTypes[0].SystemType); + } #endregion #region VB.NET