From 79e5c60dcf6960c781190e19c360f3928b8d09fd Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 22 May 2005 14:13:35 +0000 Subject: [PATCH] Added invocation of generic methods to c# parser. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@156 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Expressions/InvocationExpression.cs | 18 + .../Project/Src/Parser/CSharp/Parser.cs | 1983 +++++++++-------- .../Project/Src/Parser/CSharp/cs.ATG | 15 + .../FieldReferenceExpressionTests.cs | 12 + .../Expressions/InvocationExpressionTests.cs | 11 + 5 files changed, 1069 insertions(+), 970 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Expressions/InvocationExpression.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Expressions/InvocationExpression.cs index d820de363b..c3a57f0c57 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Expressions/InvocationExpression.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Expressions/InvocationExpression.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.Collections; +using System.Collections.Generic; namespace ICSharpCode.NRefactory.Parser.AST { @@ -9,6 +10,7 @@ namespace ICSharpCode.NRefactory.Parser.AST { Expression targetObject; // List parameters; ArrayList parameters; + List typeParameters; public Expression TargetObject { get { @@ -28,12 +30,28 @@ namespace ICSharpCode.NRefactory.Parser.AST { } } + public List TypeParameters { + get { + return typeParameters; + } + set { + typeParameters = value == null ? new List(1) : value; + } + } + public InvocationExpression(Expression targetObject, ArrayList parameters) { this.TargetObject = targetObject; this.Parameters = parameters; } + public InvocationExpression(Expression targetObject, ArrayList parameters, List typeParameters) + { + this.TargetObject = targetObject; + this.Parameters = parameters; + this.TypeParameters = typeParameters; + } + public InvocationExpression(Expression targetObject) { this.TargetObject = targetObject; diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 5f29d636c1..046d436186 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -325,6 +325,15 @@ bool IsLocalVarDecl () { pt.kind == Tokens.Identifier; } +/* True if lookahead is type parameters (<...>) followed by the specified token */ +bool IsGenericFollowedBy(int token) +{ + Token t = la; + if (t.kind != Tokens.LessThan) return false; + StartPeek(); + return SkipGeneric(ref t) && t.kind == token; +} + /* True, if lookahead ident is "where" */ bool IdentIsWhere () { return la.kind == Tokens.Identifier && la.val == "where"; @@ -393,13 +402,13 @@ bool IsShiftRight() void CS() { -#line 512 "cs.ATG" +#line 521 "cs.ATG" compilationUnit = new CompilationUnit(); while (la.kind == 119) { UsingDirective(); } while ( -#line 515 "cs.ATG" +#line 524 "cs.ATG" IsGlobalAttrTarget()) { GlobalAttributeSection(); } @@ -411,28 +420,28 @@ IsGlobalAttrTarget()) { void UsingDirective() { -#line 522 "cs.ATG" +#line 531 "cs.ATG" string qualident = null, aliasident = null; Expect(119); -#line 525 "cs.ATG" +#line 534 "cs.ATG" Point startPos = t.Location; if ( -#line 526 "cs.ATG" +#line 535 "cs.ATG" IsAssignment()) { lexer.NextToken(); -#line 526 "cs.ATG" +#line 535 "cs.ATG" aliasident = t.val; Expect(3); } Qualident( -#line 527 "cs.ATG" +#line 536 "cs.ATG" out qualident); Expect(11); -#line 529 "cs.ATG" +#line 538 "cs.ATG" if (qualident != null && qualident.Length > 0) { INode node; if (aliasident != null) { @@ -450,11 +459,11 @@ out qualident); void GlobalAttributeSection() { Expect(17); -#line 546 "cs.ATG" +#line 555 "cs.ATG" Point startPos = t.Location; Expect(1); -#line 546 "cs.ATG" +#line 555 "cs.ATG" if (t.val != "assembly") Error("global attribute target specifier (\"assembly\") expected"); string attributeTarget = t.val; ArrayList attributes = new ArrayList(); @@ -462,20 +471,20 @@ out qualident); Expect(9); Attribute( -#line 551 "cs.ATG" +#line 560 "cs.ATG" out attribute); -#line 551 "cs.ATG" +#line 560 "cs.ATG" attributes.Add(attribute); while ( -#line 552 "cs.ATG" +#line 561 "cs.ATG" NotFinalComma()) { Expect(13); Attribute( -#line 552 "cs.ATG" +#line 561 "cs.ATG" out attribute); -#line 552 "cs.ATG" +#line 561 "cs.ATG" attributes.Add(attribute); } if (la.kind == 13) { @@ -483,7 +492,7 @@ out attribute); } Expect(18); -#line 554 "cs.ATG" +#line 563 "cs.ATG" AttributeSection section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -493,7 +502,7 @@ out attribute); void NamespaceMemberDecl() { -#line 638 "cs.ATG" +#line 647 "cs.ATG" AttributeSection section; ArrayList attributes = new ArrayList(); Modifiers m = new Modifiers(); @@ -502,13 +511,13 @@ out attribute); if (la.kind == 86) { lexer.NextToken(); -#line 644 "cs.ATG" +#line 653 "cs.ATG" Point startPos = t.Location; Qualident( -#line 645 "cs.ATG" +#line 654 "cs.ATG" out qualident); -#line 645 "cs.ATG" +#line 654 "cs.ATG" INode node = new NamespaceDeclaration(qualident); node.StartLocation = startPos; compilationUnit.AddChild(node); @@ -526,83 +535,83 @@ out qualident); lexer.NextToken(); } -#line 654 "cs.ATG" +#line 663 "cs.ATG" node.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); } else if (StartOf(2)) { while (la.kind == 17) { AttributeSection( -#line 658 "cs.ATG" +#line 667 "cs.ATG" out section); -#line 658 "cs.ATG" +#line 667 "cs.ATG" attributes.Add(section); } while (StartOf(3)) { TypeModifier( -#line 659 "cs.ATG" +#line 668 "cs.ATG" m); } TypeDecl( -#line 660 "cs.ATG" +#line 669 "cs.ATG" m, attributes); } else SynErr(125); } void Qualident( -#line 776 "cs.ATG" +#line 785 "cs.ATG" out string qualident) { Expect(1); -#line 778 "cs.ATG" +#line 787 "cs.ATG" qualidentBuilder.Length = 0; qualidentBuilder.Append(t.val); while ( -#line 779 "cs.ATG" +#line 788 "cs.ATG" DotAndIdent()) { Expect(14); Expect(1); -#line 779 "cs.ATG" +#line 788 "cs.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(t.val); } -#line 782 "cs.ATG" +#line 791 "cs.ATG" qualident = qualidentBuilder.ToString(); } void Attribute( -#line 561 "cs.ATG" +#line 570 "cs.ATG" out ICSharpCode.NRefactory.Parser.AST.Attribute attribute) { -#line 562 "cs.ATG" +#line 571 "cs.ATG" string qualident; Qualident( -#line 564 "cs.ATG" +#line 573 "cs.ATG" out qualident); -#line 564 "cs.ATG" +#line 573 "cs.ATG" ArrayList positional = new ArrayList(); ArrayList named = new ArrayList(); string name = qualident; if (la.kind == 19) { AttributeArguments( -#line 568 "cs.ATG" +#line 577 "cs.ATG" ref positional, ref named); } -#line 568 "cs.ATG" +#line 577 "cs.ATG" attribute = new ICSharpCode.NRefactory.Parser.AST.Attribute(name, positional, named); } void AttributeArguments( -#line 571 "cs.ATG" +#line 580 "cs.ATG" ref ArrayList positional, ref ArrayList named) { -#line 573 "cs.ATG" +#line 582 "cs.ATG" bool nameFound = false; string name = ""; Expression expr; @@ -610,22 +619,22 @@ ref ArrayList positional, ref ArrayList named) { Expect(19); if (StartOf(4)) { if ( -#line 581 "cs.ATG" +#line 590 "cs.ATG" IsAssignment()) { -#line 581 "cs.ATG" +#line 590 "cs.ATG" nameFound = true; lexer.NextToken(); -#line 582 "cs.ATG" +#line 591 "cs.ATG" name = t.val; Expect(3); } Expr( -#line 584 "cs.ATG" +#line 593 "cs.ATG" out expr); -#line 584 "cs.ATG" +#line 593 "cs.ATG" if (expr != null) {if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -633,26 +642,26 @@ out expr); while (la.kind == 13) { lexer.NextToken(); if ( -#line 592 "cs.ATG" +#line 601 "cs.ATG" IsAssignment()) { -#line 592 "cs.ATG" +#line 601 "cs.ATG" nameFound = true; Expect(1); -#line 593 "cs.ATG" +#line 602 "cs.ATG" name = t.val; Expect(3); } else if (StartOf(4)) { -#line 595 "cs.ATG" +#line 604 "cs.ATG" if (nameFound) Error("no positional argument after named argument"); } else SynErr(126); Expr( -#line 596 "cs.ATG" +#line 605 "cs.ATG" out expr); -#line 596 "cs.ATG" +#line 605 "cs.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -663,52 +672,52 @@ out expr); } void Expr( -#line 1809 "cs.ATG" +#line 1818 "cs.ATG" out Expression expr) { -#line 1810 "cs.ATG" +#line 1819 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; UnaryExpr( -#line 1812 "cs.ATG" +#line 1821 "cs.ATG" out expr); if (StartOf(5)) { ConditionalOrExpr( -#line 1815 "cs.ATG" +#line 1824 "cs.ATG" ref expr); if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1815 "cs.ATG" +#line 1824 "cs.ATG" out expr1); Expect(9); Expr( -#line 1815 "cs.ATG" +#line 1824 "cs.ATG" out expr2); -#line 1815 "cs.ATG" +#line 1824 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else if (StartOf(6)) { -#line 1817 "cs.ATG" +#line 1826 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1817 "cs.ATG" +#line 1826 "cs.ATG" out op); Expr( -#line 1817 "cs.ATG" +#line 1826 "cs.ATG" out val); -#line 1817 "cs.ATG" +#line 1826 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else SynErr(127); } void AttributeSection( -#line 605 "cs.ATG" +#line 614 "cs.ATG" out AttributeSection section) { -#line 607 "cs.ATG" +#line 616 "cs.ATG" string attributeTarget = ""; ArrayList attributes = new ArrayList(); ICSharpCode.NRefactory.Parser.AST.Attribute attribute; @@ -716,25 +725,25 @@ out AttributeSection section) { Expect(17); -#line 613 "cs.ATG" +#line 622 "cs.ATG" Point startPos = t.Location; if ( -#line 614 "cs.ATG" +#line 623 "cs.ATG" IsLocalAttrTarget()) { if (la.kind == 67) { lexer.NextToken(); -#line 615 "cs.ATG" +#line 624 "cs.ATG" attributeTarget = "event"; } else if (la.kind == 99) { lexer.NextToken(); -#line 616 "cs.ATG" +#line 625 "cs.ATG" attributeTarget = "return"; } else { lexer.NextToken(); -#line 617 "cs.ATG" +#line 626 "cs.ATG" if (t.val != "field" || t.val != "method" || t.val != "module" || t.val != "param" || t.val != "property" || t.val != "type") @@ -746,20 +755,20 @@ IsLocalAttrTarget()) { Expect(9); } Attribute( -#line 627 "cs.ATG" +#line 636 "cs.ATG" out attribute); -#line 627 "cs.ATG" +#line 636 "cs.ATG" attributes.Add(attribute); while ( -#line 628 "cs.ATG" +#line 637 "cs.ATG" NotFinalComma()) { Expect(13); Attribute( -#line 628 "cs.ATG" +#line 637 "cs.ATG" out attribute); -#line 628 "cs.ATG" +#line 637 "cs.ATG" attributes.Add(attribute); } if (la.kind == 13) { @@ -767,7 +776,7 @@ out attribute); } Expect(18); -#line 630 "cs.ATG" +#line 639 "cs.ATG" section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -775,76 +784,76 @@ out attribute); } void TypeModifier( -#line 952 "cs.ATG" +#line 961 "cs.ATG" Modifiers m) { switch (la.kind) { case 87: { lexer.NextToken(); -#line 954 "cs.ATG" +#line 963 "cs.ATG" m.Add(Modifier.New); break; } case 96: { lexer.NextToken(); -#line 955 "cs.ATG" +#line 964 "cs.ATG" m.Add(Modifier.Public); break; } case 95: { lexer.NextToken(); -#line 956 "cs.ATG" +#line 965 "cs.ATG" m.Add(Modifier.Protected); break; } case 82: { lexer.NextToken(); -#line 957 "cs.ATG" +#line 966 "cs.ATG" m.Add(Modifier.Internal); break; } case 94: { lexer.NextToken(); -#line 958 "cs.ATG" +#line 967 "cs.ATG" m.Add(Modifier.Private); break; } case 117: { lexer.NextToken(); -#line 959 "cs.ATG" +#line 968 "cs.ATG" m.Add(Modifier.Unsafe); break; } case 47: { lexer.NextToken(); -#line 960 "cs.ATG" +#line 969 "cs.ATG" m.Add(Modifier.Abstract); break; } case 101: { lexer.NextToken(); -#line 961 "cs.ATG" +#line 970 "cs.ATG" m.Add(Modifier.Sealed); break; } case 105: { lexer.NextToken(); -#line 962 "cs.ATG" +#line 971 "cs.ATG" m.Add(Modifier.Static); break; } case 1: { lexer.NextToken(); -#line 963 "cs.ATG" +#line 972 "cs.ATG" if (t.val == "partial") { m.Add(Modifier.Partial); } break; } @@ -853,10 +862,10 @@ Modifiers m) { } void TypeDecl( -#line 663 "cs.ATG" +#line 672 "cs.ATG" Modifiers m, ArrayList attributes) { -#line 665 "cs.ATG" +#line 674 "cs.ATG" TypeReference type; ArrayList names; ArrayList p; @@ -865,11 +874,11 @@ Modifiers m, ArrayList attributes) { if (la.kind == 57) { -#line 671 "cs.ATG" +#line 680 "cs.ATG" m.Check(Modifier.Classes); lexer.NextToken(); -#line 672 "cs.ATG" +#line 681 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -879,29 +888,29 @@ Modifiers m, ArrayList attributes) { Expect(1); -#line 679 "cs.ATG" +#line 688 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 682 "cs.ATG" +#line 691 "cs.ATG" templates); } if (la.kind == 9) { ClassBase( -#line 684 "cs.ATG" +#line 693 "cs.ATG" out names); -#line 684 "cs.ATG" +#line 693 "cs.ATG" newType.BaseTypes = names; } -#line 684 "cs.ATG" +#line 693 "cs.ATG" newType.StartLocation = t.EndLocation; while ( -#line 687 "cs.ATG" +#line 696 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 687 "cs.ATG" +#line 696 "cs.ATG" templates); } ClassBody(); @@ -909,18 +918,18 @@ templates); lexer.NextToken(); } -#line 690 "cs.ATG" +#line 699 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (StartOf(7)) { -#line 693 "cs.ATG" +#line 702 "cs.ATG" m.Check(Modifier.StructsInterfacesEnumsDelegates); if (la.kind == 107) { lexer.NextToken(); -#line 694 "cs.ATG" +#line 703 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -929,29 +938,29 @@ templates); Expect(1); -#line 700 "cs.ATG" +#line 709 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 703 "cs.ATG" +#line 712 "cs.ATG" templates); } if (la.kind == 9) { StructInterfaces( -#line 705 "cs.ATG" +#line 714 "cs.ATG" out names); -#line 705 "cs.ATG" +#line 714 "cs.ATG" newType.BaseTypes = names; } -#line 705 "cs.ATG" +#line 714 "cs.ATG" newType.StartLocation = t.EndLocation; while ( -#line 708 "cs.ATG" +#line 717 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 708 "cs.ATG" +#line 717 "cs.ATG" templates); } StructBody(); @@ -959,14 +968,14 @@ templates); lexer.NextToken(); } -#line 712 "cs.ATG" +#line 721 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 81) { lexer.NextToken(); -#line 716 "cs.ATG" +#line 725 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); templates = newType.Templates; compilationUnit.AddChild(newType); @@ -975,29 +984,29 @@ templates); Expect(1); -#line 722 "cs.ATG" +#line 731 "cs.ATG" newType.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 725 "cs.ATG" +#line 734 "cs.ATG" templates); } if (la.kind == 9) { InterfaceBase( -#line 727 "cs.ATG" +#line 736 "cs.ATG" out names); -#line 727 "cs.ATG" +#line 736 "cs.ATG" newType.BaseTypes = names; } -#line 727 "cs.ATG" +#line 736 "cs.ATG" newType.StartLocation = t.EndLocation; while ( -#line 730 "cs.ATG" +#line 739 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 730 "cs.ATG" +#line 739 "cs.ATG" templates); } InterfaceBody(); @@ -1005,14 +1014,14 @@ templates); lexer.NextToken(); } -#line 733 "cs.ATG" +#line 742 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else if (la.kind == 66) { lexer.NextToken(); -#line 737 "cs.ATG" +#line 746 "cs.ATG" TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes); compilationUnit.AddChild(newType); compilationUnit.BlockStart(newType); @@ -1020,83 +1029,83 @@ templates); Expect(1); -#line 742 "cs.ATG" +#line 751 "cs.ATG" newType.Name = t.val; if (la.kind == 9) { lexer.NextToken(); IntegralType( -#line 743 "cs.ATG" +#line 752 "cs.ATG" out name); -#line 743 "cs.ATG" +#line 752 "cs.ATG" newType.BaseTypes = new ArrayList(); newType.BaseTypes.Add(name); } -#line 746 "cs.ATG" +#line 755 "cs.ATG" newType.StartLocation = t.EndLocation; EnumBody(); if (la.kind == 11) { lexer.NextToken(); } -#line 748 "cs.ATG" +#line 757 "cs.ATG" newType.EndLocation = t.Location; compilationUnit.BlockEnd(); } else { lexer.NextToken(); -#line 752 "cs.ATG" +#line 761 "cs.ATG" DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); templates = delegateDeclr.Templates; delegateDeclr.StartLocation = t.Location; if ( -#line 756 "cs.ATG" +#line 765 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 756 "cs.ATG" +#line 765 "cs.ATG" delegateDeclr.ReturnType = new TypeReference("void", 0, null); } else if (StartOf(8)) { Type( -#line 757 "cs.ATG" +#line 766 "cs.ATG" out type); -#line 757 "cs.ATG" +#line 766 "cs.ATG" delegateDeclr.ReturnType = type; } else SynErr(129); Expect(1); -#line 759 "cs.ATG" +#line 768 "cs.ATG" delegateDeclr.Name = t.val; if (la.kind == 22) { TypeParameterList( -#line 762 "cs.ATG" +#line 771 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 764 "cs.ATG" +#line 773 "cs.ATG" out p); -#line 764 "cs.ATG" +#line 773 "cs.ATG" delegateDeclr.Parameters = p; } Expect(20); while ( -#line 768 "cs.ATG" +#line 777 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 768 "cs.ATG" +#line 777 "cs.ATG" templates); } Expect(11); -#line 770 "cs.ATG" +#line 779 "cs.ATG" delegateDeclr.EndLocation = t.Location; compilationUnit.AddChild(delegateDeclr); @@ -1105,91 +1114,91 @@ templates); } void TypeParameterList( -#line 2151 "cs.ATG" +#line 2166 "cs.ATG" List templates) { -#line 2153 "cs.ATG" +#line 2168 "cs.ATG" AttributeSection section; ArrayList attributes = new ArrayList(); Expect(22); while (la.kind == 17) { AttributeSection( -#line 2157 "cs.ATG" +#line 2172 "cs.ATG" out section); -#line 2157 "cs.ATG" +#line 2172 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2158 "cs.ATG" +#line 2173 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 13) { lexer.NextToken(); while (la.kind == 17) { AttributeSection( -#line 2159 "cs.ATG" +#line 2174 "cs.ATG" out section); -#line 2159 "cs.ATG" +#line 2174 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2160 "cs.ATG" +#line 2175 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(21); } void ClassBase( -#line 785 "cs.ATG" +#line 794 "cs.ATG" out ArrayList names) { -#line 787 "cs.ATG" +#line 796 "cs.ATG" string qualident; names = new ArrayList(); List types; Expect(9); ClassType( -#line 792 "cs.ATG" +#line 801 "cs.ATG" out qualident, out types); -#line 792 "cs.ATG" +#line 801 "cs.ATG" names.Add(qualident); // TODO: enter the types while (la.kind == 13) { lexer.NextToken(); Qualident( -#line 793 "cs.ATG" +#line 802 "cs.ATG" out qualident); -#line 793 "cs.ATG" +#line 802 "cs.ATG" names.Add(qualident); } } void TypeParameterConstraintsClause( -#line 2164 "cs.ATG" +#line 2179 "cs.ATG" List templates) { -#line 2165 "cs.ATG" +#line 2180 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2167 "cs.ATG" +#line 2182 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2168 "cs.ATG" +#line 2183 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2170 "cs.ATG" +#line 2185 "cs.ATG" out type); -#line 2171 "cs.ATG" +#line 2186 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1202,10 +1211,10 @@ out type); while (la.kind == 13) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2180 "cs.ATG" +#line 2195 "cs.ATG" out type); -#line 2181 "cs.ATG" +#line 2196 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1220,114 +1229,114 @@ out type); void ClassBody() { -#line 797 "cs.ATG" +#line 806 "cs.ATG" AttributeSection section; Expect(15); while (StartOf(10)) { -#line 800 "cs.ATG" +#line 809 "cs.ATG" ArrayList attributes = new ArrayList(); Modifiers m = new Modifiers(); while (la.kind == 17) { AttributeSection( -#line 803 "cs.ATG" +#line 812 "cs.ATG" out section); -#line 803 "cs.ATG" +#line 812 "cs.ATG" attributes.Add(section); } while (StartOf(11)) { MemberModifier( -#line 804 "cs.ATG" +#line 813 "cs.ATG" m); } ClassMemberDecl( -#line 805 "cs.ATG" +#line 814 "cs.ATG" m, attributes); } Expect(16); } void StructInterfaces( -#line 810 "cs.ATG" +#line 819 "cs.ATG" out ArrayList names) { -#line 812 "cs.ATG" +#line 821 "cs.ATG" string qualident; names = new ArrayList(); Expect(9); Qualident( -#line 816 "cs.ATG" +#line 825 "cs.ATG" out qualident); -#line 816 "cs.ATG" +#line 825 "cs.ATG" names.Add(qualident); while (la.kind == 13) { lexer.NextToken(); Qualident( -#line 817 "cs.ATG" +#line 826 "cs.ATG" out qualident); -#line 817 "cs.ATG" +#line 826 "cs.ATG" names.Add(qualident); } } void StructBody() { -#line 821 "cs.ATG" +#line 830 "cs.ATG" AttributeSection section; Expect(15); while (StartOf(12)) { -#line 824 "cs.ATG" +#line 833 "cs.ATG" ArrayList attributes = new ArrayList(); Modifiers m = new Modifiers(); while (la.kind == 17) { AttributeSection( -#line 827 "cs.ATG" +#line 836 "cs.ATG" out section); -#line 827 "cs.ATG" +#line 836 "cs.ATG" attributes.Add(section); } while (StartOf(11)) { MemberModifier( -#line 828 "cs.ATG" +#line 837 "cs.ATG" m); } StructMemberDecl( -#line 829 "cs.ATG" +#line 838 "cs.ATG" m, attributes); } Expect(16); } void InterfaceBase( -#line 834 "cs.ATG" +#line 843 "cs.ATG" out ArrayList names) { -#line 836 "cs.ATG" +#line 845 "cs.ATG" string qualident; names = new ArrayList(); Expect(9); Qualident( -#line 840 "cs.ATG" +#line 849 "cs.ATG" out qualident); -#line 840 "cs.ATG" +#line 849 "cs.ATG" names.Add(qualident); while (la.kind == 13) { lexer.NextToken(); Qualident( -#line 841 "cs.ATG" +#line 850 "cs.ATG" out qualident); -#line 841 "cs.ATG" +#line 850 "cs.ATG" names.Add(qualident); } } @@ -1341,72 +1350,72 @@ out qualident); } void IntegralType( -#line 977 "cs.ATG" +#line 986 "cs.ATG" out string name) { -#line 977 "cs.ATG" +#line 986 "cs.ATG" name = ""; switch (la.kind) { case 100: { lexer.NextToken(); -#line 979 "cs.ATG" +#line 988 "cs.ATG" name = "sbyte"; break; } case 52: { lexer.NextToken(); -#line 980 "cs.ATG" +#line 989 "cs.ATG" name = "byte"; break; } case 102: { lexer.NextToken(); -#line 981 "cs.ATG" +#line 990 "cs.ATG" name = "short"; break; } case 118: { lexer.NextToken(); -#line 982 "cs.ATG" +#line 991 "cs.ATG" name = "ushort"; break; } case 80: { lexer.NextToken(); -#line 983 "cs.ATG" +#line 992 "cs.ATG" name = "int"; break; } case 114: { lexer.NextToken(); -#line 984 "cs.ATG" +#line 993 "cs.ATG" name = "uint"; break; } case 85: { lexer.NextToken(); -#line 985 "cs.ATG" +#line 994 "cs.ATG" name = "long"; break; } case 115: { lexer.NextToken(); -#line 986 "cs.ATG" +#line 995 "cs.ATG" name = "ulong"; break; } case 55: { lexer.NextToken(); -#line 987 "cs.ATG" +#line 996 "cs.ATG" name = "char"; break; } @@ -1416,25 +1425,25 @@ out string name) { void EnumBody() { -#line 847 "cs.ATG" +#line 856 "cs.ATG" FieldDeclaration f; Expect(15); if (la.kind == 1 || la.kind == 17) { EnumMemberDecl( -#line 849 "cs.ATG" +#line 858 "cs.ATG" out f); -#line 849 "cs.ATG" +#line 858 "cs.ATG" compilationUnit.AddChild(f); while ( -#line 850 "cs.ATG" +#line 859 "cs.ATG" NotFinalComma()) { Expect(13); EnumMemberDecl( -#line 850 "cs.ATG" +#line 859 "cs.ATG" out f); -#line 850 "cs.ATG" +#line 859 "cs.ATG" compilationUnit.AddChild(f); } if (la.kind == 13) { @@ -1445,10 +1454,10 @@ out f); } void Type( -#line 855 "cs.ATG" +#line 864 "cs.ATG" out TypeReference type) { -#line 857 "cs.ATG" +#line 866 "cs.ATG" string name = ""; int pointer = 0; List types = null; @@ -1456,59 +1465,59 @@ out TypeReference type) { if (la.kind == 1 || la.kind == 89 || la.kind == 106) { ClassType( -#line 863 "cs.ATG" +#line 872 "cs.ATG" out name, out types); } else if (StartOf(14)) { SimpleType( -#line 864 "cs.ATG" +#line 873 "cs.ATG" out name); } else if (la.kind == 121) { lexer.NextToken(); Expect(6); -#line 865 "cs.ATG" +#line 874 "cs.ATG" pointer = 1; name = "void"; } else SynErr(132); -#line 866 "cs.ATG" +#line 875 "cs.ATG" ArrayList r = new ArrayList(); while ( -#line 868 "cs.ATG" +#line 877 "cs.ATG" IsPointerOrDims()) { -#line 868 "cs.ATG" +#line 877 "cs.ATG" int i = 0; if (la.kind == 6) { lexer.NextToken(); -#line 869 "cs.ATG" +#line 878 "cs.ATG" ++pointer; } else if (la.kind == 17) { lexer.NextToken(); while (la.kind == 13) { lexer.NextToken(); -#line 870 "cs.ATG" +#line 879 "cs.ATG" ++i; } Expect(18); -#line 870 "cs.ATG" +#line 879 "cs.ATG" r.Add(i); } else SynErr(133); } -#line 872 "cs.ATG" +#line 881 "cs.ATG" int[] rank = new int[r.Count]; r.CopyTo(rank); type = new TypeReference(name, pointer, rank, types); } void FormalParameterList( -#line 907 "cs.ATG" +#line 916 "cs.ATG" out ArrayList parameter) { -#line 909 "cs.ATG" +#line 918 "cs.ATG" parameter = new ArrayList(); ParameterDeclarationExpression p; AttributeSection section; @@ -1516,18 +1525,18 @@ out ArrayList parameter) { while (la.kind == 17) { AttributeSection( -#line 915 "cs.ATG" +#line 924 "cs.ATG" out section); -#line 915 "cs.ATG" +#line 924 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 917 "cs.ATG" +#line 926 "cs.ATG" out p); -#line 917 "cs.ATG" +#line 926 "cs.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1535,170 +1544,170 @@ out p); while (la.kind == 13) { lexer.NextToken(); -#line 922 "cs.ATG" +#line 931 "cs.ATG" attributes = new ArrayList(); if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 17) { AttributeSection( -#line 923 "cs.ATG" +#line 932 "cs.ATG" out section); -#line 923 "cs.ATG" +#line 932 "cs.ATG" attributes.Add(section); } if (StartOf(15)) { FixedParameter( -#line 925 "cs.ATG" +#line 934 "cs.ATG" out p); -#line 925 "cs.ATG" +#line 934 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else if (la.kind == 93) { ParameterArray( -#line 926 "cs.ATG" +#line 935 "cs.ATG" out p); -#line 926 "cs.ATG" +#line 935 "cs.ATG" paramsFound = true; p.Attributes = attributes; parameter.Add(p); } else SynErr(134); } } else if (la.kind == 93) { ParameterArray( -#line 929 "cs.ATG" +#line 938 "cs.ATG" out p); -#line 929 "cs.ATG" +#line 938 "cs.ATG" p.Attributes = attributes; parameter.Add(p); } else SynErr(135); } void ClassType( -#line 966 "cs.ATG" +#line 975 "cs.ATG" out string name, out List types) { -#line 967 "cs.ATG" +#line 976 "cs.ATG" string qualident; name = ""; List t; types = null; if (la.kind == 1) { TypeName( -#line 972 "cs.ATG" +#line 981 "cs.ATG" out qualident, out t); -#line 972 "cs.ATG" +#line 981 "cs.ATG" name = qualident; types = t; } else if (la.kind == 89) { lexer.NextToken(); -#line 973 "cs.ATG" +#line 982 "cs.ATG" name = "object"; } else if (la.kind == 106) { lexer.NextToken(); -#line 974 "cs.ATG" +#line 983 "cs.ATG" name = "string"; } else SynErr(136); } void MemberModifier( -#line 990 "cs.ATG" +#line 999 "cs.ATG" Modifiers m) { switch (la.kind) { case 47: { lexer.NextToken(); -#line 992 "cs.ATG" +#line 1001 "cs.ATG" m.Add(Modifier.Abstract); break; } case 69: { lexer.NextToken(); -#line 993 "cs.ATG" +#line 1002 "cs.ATG" m.Add(Modifier.Extern); break; } case 82: { lexer.NextToken(); -#line 994 "cs.ATG" +#line 1003 "cs.ATG" m.Add(Modifier.Internal); break; } case 87: { lexer.NextToken(); -#line 995 "cs.ATG" +#line 1004 "cs.ATG" m.Add(Modifier.New); break; } case 92: { lexer.NextToken(); -#line 996 "cs.ATG" +#line 1005 "cs.ATG" m.Add(Modifier.Override); break; } case 94: { lexer.NextToken(); -#line 997 "cs.ATG" +#line 1006 "cs.ATG" m.Add(Modifier.Private); break; } case 95: { lexer.NextToken(); -#line 998 "cs.ATG" +#line 1007 "cs.ATG" m.Add(Modifier.Protected); break; } case 96: { lexer.NextToken(); -#line 999 "cs.ATG" +#line 1008 "cs.ATG" m.Add(Modifier.Public); break; } case 97: { lexer.NextToken(); -#line 1000 "cs.ATG" +#line 1009 "cs.ATG" m.Add(Modifier.Readonly); break; } case 101: { lexer.NextToken(); -#line 1001 "cs.ATG" +#line 1010 "cs.ATG" m.Add(Modifier.Sealed); break; } case 105: { lexer.NextToken(); -#line 1002 "cs.ATG" +#line 1011 "cs.ATG" m.Add(Modifier.Static); break; } case 117: { lexer.NextToken(); -#line 1003 "cs.ATG" +#line 1012 "cs.ATG" m.Add(Modifier.Unsafe); break; } case 120: { lexer.NextToken(); -#line 1004 "cs.ATG" +#line 1013 "cs.ATG" m.Add(Modifier.Virtual); break; } case 122: { lexer.NextToken(); -#line 1005 "cs.ATG" +#line 1014 "cs.ATG" m.Add(Modifier.Volatile); break; } @@ -1707,23 +1716,23 @@ Modifiers m) { } void ClassMemberDecl( -#line 1238 "cs.ATG" +#line 1247 "cs.ATG" Modifiers m, ArrayList attributes) { -#line 1239 "cs.ATG" +#line 1248 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 1241 "cs.ATG" +#line 1250 "cs.ATG" m, attributes); } else if (la.kind == 26) { -#line 1242 "cs.ATG" +#line 1251 "cs.ATG" m.Check(Modifier.Destructors); Point startPos = t.Location; lexer.NextToken(); Expect(1); -#line 1243 "cs.ATG" +#line 1252 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = startPos; @@ -1731,17 +1740,17 @@ m, attributes); Expect(19); Expect(20); -#line 1247 "cs.ATG" +#line 1256 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 15) { Block( -#line 1247 "cs.ATG" +#line 1256 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(138); -#line 1248 "cs.ATG" +#line 1257 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1749,10 +1758,10 @@ out stmt); } void StructMemberDecl( -#line 1008 "cs.ATG" +#line 1017 "cs.ATG" Modifiers m, ArrayList attributes) { -#line 1010 "cs.ATG" +#line 1019 "cs.ATG" string qualident = null; TypeReference type; Expression expr; @@ -1763,18 +1772,18 @@ Modifiers m, ArrayList attributes) { if (la.kind == 58) { -#line 1019 "cs.ATG" +#line 1028 "cs.ATG" m.Check(Modifier.Constants); lexer.NextToken(); -#line 1020 "cs.ATG" +#line 1029 "cs.ATG" Point startPos = t.Location; Type( -#line 1021 "cs.ATG" +#line 1030 "cs.ATG" out type); Expect(1); -#line 1021 "cs.ATG" +#line 1030 "cs.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const); fd.StartLocation = startPos; VariableDeclaration f = new VariableDeclaration(t.val); @@ -1782,58 +1791,58 @@ out type); Expect(3); Expr( -#line 1026 "cs.ATG" +#line 1035 "cs.ATG" out expr); -#line 1026 "cs.ATG" +#line 1035 "cs.ATG" f.Initializer = expr; while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1027 "cs.ATG" +#line 1036 "cs.ATG" f = new VariableDeclaration(t.val); fd.Fields.Add(f); Expect(3); Expr( -#line 1030 "cs.ATG" +#line 1039 "cs.ATG" out expr); -#line 1030 "cs.ATG" +#line 1039 "cs.ATG" f.Initializer = expr; } Expect(11); -#line 1031 "cs.ATG" +#line 1040 "cs.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); } else if ( -#line 1034 "cs.ATG" +#line 1043 "cs.ATG" NotVoidPointer()) { -#line 1034 "cs.ATG" +#line 1043 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); Expect(121); -#line 1035 "cs.ATG" +#line 1044 "cs.ATG" Point startPos = t.Location; Qualident( -#line 1036 "cs.ATG" +#line 1045 "cs.ATG" out qualident); if (la.kind == 22) { TypeParameterList( -#line 1038 "cs.ATG" +#line 1047 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1041 "cs.ATG" +#line 1050 "cs.ATG" out p); } Expect(20); -#line 1041 "cs.ATG" +#line 1050 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, new TypeReference("void"), @@ -1846,31 +1855,31 @@ out p); compilationUnit.BlockStart(methodDeclaration); while ( -#line 1054 "cs.ATG" +#line 1063 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1054 "cs.ATG" +#line 1063 "cs.ATG" templates); } if (la.kind == 15) { Block( -#line 1056 "cs.ATG" +#line 1065 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(140); -#line 1056 "cs.ATG" +#line 1065 "cs.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; } else if (la.kind == 67) { -#line 1060 "cs.ATG" +#line 1069 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); lexer.NextToken(); -#line 1061 "cs.ATG" +#line 1070 "cs.ATG" EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); @@ -1879,103 +1888,103 @@ out stmt); EventRemoveRegion removeBlock = null; Type( -#line 1068 "cs.ATG" +#line 1077 "cs.ATG" out type); -#line 1068 "cs.ATG" +#line 1077 "cs.ATG" eventDecl.TypeReference = type; if ( -#line 1070 "cs.ATG" +#line 1079 "cs.ATG" IsVarDecl()) { VariableDeclarator( -#line 1070 "cs.ATG" +#line 1079 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1071 "cs.ATG" +#line 1080 "cs.ATG" variableDeclarators); } Expect(11); -#line 1071 "cs.ATG" +#line 1080 "cs.ATG" eventDecl.VariableDeclarators = variableDeclarators; eventDecl.EndLocation = t.EndLocation; } else if (la.kind == 1) { Qualident( -#line 1072 "cs.ATG" +#line 1081 "cs.ATG" out qualident); -#line 1072 "cs.ATG" +#line 1081 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; Expect(15); -#line 1073 "cs.ATG" +#line 1082 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 1074 "cs.ATG" +#line 1083 "cs.ATG" out addBlock, out removeBlock); Expect(16); -#line 1075 "cs.ATG" +#line 1084 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } else SynErr(141); -#line 1076 "cs.ATG" +#line 1085 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 1083 "cs.ATG" +#line 1092 "cs.ATG" IdentAndLPar()) { -#line 1083 "cs.ATG" +#line 1092 "cs.ATG" m.Check(Modifier.Constructors | Modifier.StaticConstructors); Expect(1); -#line 1084 "cs.ATG" +#line 1093 "cs.ATG" string name = t.val; Point startPos = t.Location; Expect(19); if (StartOf(9)) { -#line 1084 "cs.ATG" +#line 1093 "cs.ATG" m.Check(Modifier.Constructors); FormalParameterList( -#line 1085 "cs.ATG" +#line 1094 "cs.ATG" out p); } Expect(20); -#line 1087 "cs.ATG" +#line 1096 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 1088 "cs.ATG" +#line 1097 "cs.ATG" m.Check(Modifier.Constructors); ConstructorInitializer( -#line 1089 "cs.ATG" +#line 1098 "cs.ATG" out init); } -#line 1091 "cs.ATG" +#line 1100 "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 1096 "cs.ATG" +#line 1105 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(142); -#line 1096 "cs.ATG" +#line 1105 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 68 || la.kind == 78) { -#line 1099 "cs.ATG" +#line 1108 "cs.ATG" m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -1985,37 +1994,37 @@ out stmt); } else { lexer.NextToken(); -#line 1103 "cs.ATG" +#line 1112 "cs.ATG" isImplicit = false; } Expect(90); Type( -#line 1104 "cs.ATG" +#line 1113 "cs.ATG" out type); -#line 1104 "cs.ATG" +#line 1113 "cs.ATG" TypeReference operatorType = type; Expect(19); Type( -#line 1105 "cs.ATG" +#line 1114 "cs.ATG" out type); Expect(1); -#line 1105 "cs.ATG" +#line 1114 "cs.ATG" string varName = t.val; Expect(20); if (la.kind == 15) { Block( -#line 1105 "cs.ATG" +#line 1114 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 1105 "cs.ATG" +#line 1114 "cs.ATG" stmt = null; } else SynErr(143); -#line 1108 "cs.ATG" +#line 1117 "cs.ATG" ArrayList parameters = new ArrayList(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -2029,58 +2038,58 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 1121 "cs.ATG" +#line 1130 "cs.ATG" m, attributes); } else if (StartOf(8)) { Type( -#line 1122 "cs.ATG" +#line 1131 "cs.ATG" out type); -#line 1122 "cs.ATG" +#line 1131 "cs.ATG" Point startPos = t.Location; if (la.kind == 90) { -#line 1124 "cs.ATG" +#line 1133 "cs.ATG" OverloadableOperatorType op; m.Check(Modifier.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 1128 "cs.ATG" +#line 1137 "cs.ATG" out op); -#line 1128 "cs.ATG" +#line 1137 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(19); Type( -#line 1129 "cs.ATG" +#line 1138 "cs.ATG" out firstType); Expect(1); -#line 1129 "cs.ATG" +#line 1138 "cs.ATG" string firstName = t.val; if (la.kind == 13) { lexer.NextToken(); Type( -#line 1130 "cs.ATG" +#line 1139 "cs.ATG" out secondType); Expect(1); -#line 1130 "cs.ATG" +#line 1139 "cs.ATG" secondName = t.val; } else if (la.kind == 20) { } else SynErr(144); Expect(20); if (la.kind == 15) { Block( -#line 1138 "cs.ATG" +#line 1147 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(145); -#line 1140 "cs.ATG" +#line 1149 "cs.ATG" ArrayList parameters = new ArrayList(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -2095,43 +2104,43 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 1155 "cs.ATG" +#line 1164 "cs.ATG" IsVarDecl()) { -#line 1155 "cs.ATG" +#line 1164 "cs.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = startPos; VariableDeclarator( -#line 1159 "cs.ATG" +#line 1168 "cs.ATG" variableDeclarators); while (la.kind == 13) { lexer.NextToken(); VariableDeclarator( -#line 1160 "cs.ATG" +#line 1169 "cs.ATG" variableDeclarators); } Expect(11); -#line 1161 "cs.ATG" +#line 1170 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 109) { -#line 1164 "cs.ATG" +#line 1173 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(17); FormalParameterList( -#line 1165 "cs.ATG" +#line 1174 "cs.ATG" out p); Expect(18); -#line 1165 "cs.ATG" +#line 1174 "cs.ATG" Point endLocation = t.EndLocation; Expect(15); -#line 1166 "cs.ATG" +#line 1175 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -2140,11 +2149,11 @@ out p); PropertySetRegion setRegion; AccessorDecls( -#line 1173 "cs.ATG" +#line 1182 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1174 "cs.ATG" +#line 1183 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; @@ -2152,30 +2161,30 @@ out getRegion, out setRegion); } else if (la.kind == 1) { Qualident( -#line 1179 "cs.ATG" +#line 1188 "cs.ATG" out qualident); -#line 1179 "cs.ATG" +#line 1188 "cs.ATG" Point qualIdentEndLocation = t.EndLocation; if (la.kind == 15 || la.kind == 19 || la.kind == 22) { if (la.kind == 19 || la.kind == 22) { -#line 1182 "cs.ATG" +#line 1191 "cs.ATG" m.Check(Modifier.PropertysEventsMethods); if (la.kind == 22) { TypeParameterList( -#line 1184 "cs.ATG" +#line 1193 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1185 "cs.ATG" +#line 1194 "cs.ATG" out p); } Expect(20); -#line 1186 "cs.ATG" +#line 1195 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, type, @@ -2187,26 +2196,26 @@ out p); compilationUnit.AddChild(methodDeclaration); while ( -#line 1196 "cs.ATG" +#line 1205 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1196 "cs.ATG" +#line 1205 "cs.ATG" templates); } if (la.kind == 15) { Block( -#line 1197 "cs.ATG" +#line 1206 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(146); -#line 1197 "cs.ATG" +#line 1206 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 1200 "cs.ATG" +#line 1209 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); pDecl.StartLocation = startPos; pDecl.EndLocation = qualIdentEndLocation; @@ -2215,11 +2224,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 1207 "cs.ATG" +#line 1216 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1209 "cs.ATG" +#line 1218 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2228,17 +2237,17 @@ out getRegion, out setRegion); } } else if (la.kind == 14) { -#line 1217 "cs.ATG" +#line 1226 "cs.ATG" m.Check(Modifier.Indexers); lexer.NextToken(); Expect(109); Expect(17); FormalParameterList( -#line 1218 "cs.ATG" +#line 1227 "cs.ATG" out p); Expect(18); -#line 1219 "cs.ATG" +#line 1228 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = t.EndLocation; @@ -2248,14 +2257,14 @@ out p); Expect(15); -#line 1226 "cs.ATG" +#line 1235 "cs.ATG" Point bodyStart = t.Location; AccessorDecls( -#line 1227 "cs.ATG" +#line 1236 "cs.ATG" out getRegion, out setRegion); Expect(16); -#line 1228 "cs.ATG" +#line 1237 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2269,7 +2278,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1255 "cs.ATG" +#line 1264 "cs.ATG" TypeReference type; ArrayList p; AttributeSection section; @@ -2284,39 +2293,39 @@ out getRegion, out setRegion); while (la.kind == 17) { AttributeSection( -#line 1268 "cs.ATG" +#line 1277 "cs.ATG" out section); -#line 1268 "cs.ATG" +#line 1277 "cs.ATG" attributes.Add(section); } if (la.kind == 87) { lexer.NextToken(); -#line 1269 "cs.ATG" +#line 1278 "cs.ATG" mod = Modifier.New; startLocation = t.Location; } if ( -#line 1272 "cs.ATG" +#line 1281 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 1272 "cs.ATG" +#line 1281 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1272 "cs.ATG" +#line 1281 "cs.ATG" name = t.val; Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1273 "cs.ATG" +#line 1282 "cs.ATG" out parameters); } Expect(20); Expect(11); -#line 1273 "cs.ATG" +#line 1282 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2325,39 +2334,39 @@ out parameters); } else if (StartOf(18)) { if (StartOf(8)) { Type( -#line 1279 "cs.ATG" +#line 1288 "cs.ATG" out type); -#line 1279 "cs.ATG" +#line 1288 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1281 "cs.ATG" +#line 1290 "cs.ATG" name = t.val; Point qualIdentEndLocation = t.EndLocation; if (la.kind == 19 || la.kind == 22) { if (la.kind == 22) { TypeParameterList( -#line 1285 "cs.ATG" +#line 1294 "cs.ATG" templates); } Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1286 "cs.ATG" +#line 1295 "cs.ATG" out parameters); } Expect(20); while ( -#line 1288 "cs.ATG" +#line 1297 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1288 "cs.ATG" +#line 1297 "cs.ATG" templates); } Expect(11); -#line 1289 "cs.ATG" +#line 1298 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2365,72 +2374,72 @@ templates); } else if (la.kind == 15) { -#line 1295 "cs.ATG" +#line 1304 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1296 "cs.ATG" +#line 1305 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1296 "cs.ATG" +#line 1305 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1296 "cs.ATG" +#line 1305 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(150); } else if (la.kind == 109) { lexer.NextToken(); Expect(17); FormalParameterList( -#line 1299 "cs.ATG" +#line 1308 "cs.ATG" out p); Expect(18); -#line 1299 "cs.ATG" +#line 1308 "cs.ATG" Point bracketEndLocation = t.EndLocation; -#line 1299 "cs.ATG" +#line 1308 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, p, mod, attributes); compilationUnit.AddChild(id); Expect(15); -#line 1300 "cs.ATG" +#line 1309 "cs.ATG" Point bodyStart = t.Location; InterfaceAccessors( -#line 1300 "cs.ATG" +#line 1309 "cs.ATG" out getBlock, out setBlock); Expect(16); -#line 1300 "cs.ATG" +#line 1309 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(151); } else { lexer.NextToken(); -#line 1303 "cs.ATG" +#line 1312 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1303 "cs.ATG" +#line 1312 "cs.ATG" out type); Expect(1); -#line 1303 "cs.ATG" +#line 1312 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes); compilationUnit.AddChild(ed); Expect(11); -#line 1306 "cs.ATG" +#line 1315 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(152); } void EnumMemberDecl( -#line 1311 "cs.ATG" +#line 1320 "cs.ATG" out FieldDeclaration f) { -#line 1313 "cs.ATG" +#line 1322 "cs.ATG" Expression expr = null; ArrayList attributes = new ArrayList(); AttributeSection section = null; @@ -2438,15 +2447,15 @@ out FieldDeclaration f) { while (la.kind == 17) { AttributeSection( -#line 1319 "cs.ATG" +#line 1328 "cs.ATG" out section); -#line 1319 "cs.ATG" +#line 1328 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1320 "cs.ATG" +#line 1329 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2455,90 +2464,90 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1325 "cs.ATG" +#line 1334 "cs.ATG" out expr); -#line 1325 "cs.ATG" +#line 1334 "cs.ATG" varDecl.Initializer = expr; } } void SimpleType( -#line 896 "cs.ATG" +#line 905 "cs.ATG" out string name) { -#line 897 "cs.ATG" +#line 906 "cs.ATG" name = String.Empty; if (StartOf(19)) { IntegralType( -#line 899 "cs.ATG" +#line 908 "cs.ATG" out name); } else if (la.kind == 73) { lexer.NextToken(); -#line 900 "cs.ATG" +#line 909 "cs.ATG" name = "float"; } else if (la.kind == 64) { lexer.NextToken(); -#line 901 "cs.ATG" +#line 910 "cs.ATG" name = "double"; } else if (la.kind == 60) { lexer.NextToken(); -#line 902 "cs.ATG" +#line 911 "cs.ATG" name = "decimal"; } else if (la.kind == 50) { lexer.NextToken(); -#line 903 "cs.ATG" +#line 912 "cs.ATG" name = "bool"; } else SynErr(153); } void NonArrayType( -#line 877 "cs.ATG" +#line 886 "cs.ATG" out TypeReference type) { -#line 879 "cs.ATG" +#line 888 "cs.ATG" string name = ""; int pointer = 0; List genericTypes = null; if (la.kind == 1 || la.kind == 89 || la.kind == 106) { ClassType( -#line 884 "cs.ATG" +#line 893 "cs.ATG" out name, out genericTypes); } else if (StartOf(14)) { SimpleType( -#line 885 "cs.ATG" +#line 894 "cs.ATG" out name); } else if (la.kind == 121) { lexer.NextToken(); Expect(6); -#line 886 "cs.ATG" +#line 895 "cs.ATG" pointer = 1; name = "void"; } else SynErr(154); while ( -#line 889 "cs.ATG" +#line 898 "cs.ATG" IsPointer()) { Expect(6); -#line 890 "cs.ATG" +#line 899 "cs.ATG" ++pointer; } -#line 892 "cs.ATG" +#line 901 "cs.ATG" type = new TypeReference(name, pointer, null, genericTypes); } void FixedParameter( -#line 933 "cs.ATG" +#line 942 "cs.ATG" out ParameterDeclarationExpression p) { -#line 935 "cs.ATG" +#line 944 "cs.ATG" TypeReference type; ParamModifier mod = ParamModifier.In; @@ -2546,65 +2555,65 @@ out ParameterDeclarationExpression p) { if (la.kind == 98) { lexer.NextToken(); -#line 940 "cs.ATG" +#line 949 "cs.ATG" mod = ParamModifier.Ref; } else { lexer.NextToken(); -#line 941 "cs.ATG" +#line 950 "cs.ATG" mod = ParamModifier.Out; } } Type( -#line 943 "cs.ATG" +#line 952 "cs.ATG" out type); Expect(1); -#line 943 "cs.ATG" +#line 952 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); } void ParameterArray( -#line 946 "cs.ATG" +#line 955 "cs.ATG" out ParameterDeclarationExpression p) { -#line 947 "cs.ATG" +#line 956 "cs.ATG" TypeReference type; Expect(93); Type( -#line 949 "cs.ATG" +#line 958 "cs.ATG" out type); Expect(1); -#line 949 "cs.ATG" +#line 958 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, ParamModifier.Params); } void TypeName( -#line 2133 "cs.ATG" +#line 2148 "cs.ATG" out string qualident, out List types) { -#line 2134 "cs.ATG" +#line 2149 "cs.ATG" List t; types = new List(); Qualident( -#line 2136 "cs.ATG" +#line 2151 "cs.ATG" out qualident); if (la.kind == 22) { TypeArgumentList( -#line 2137 "cs.ATG" +#line 2152 "cs.ATG" out t); -#line 2137 "cs.ATG" +#line 2152 "cs.ATG" types = t; } } void Block( -#line 1429 "cs.ATG" +#line 1438 "cs.ATG" out Statement stmt) { Expect(15); -#line 1431 "cs.ATG" +#line 1440 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); @@ -2615,7 +2624,7 @@ out Statement stmt) { } Expect(16); -#line 1438 "cs.ATG" +#line 1447 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2623,34 +2632,34 @@ out Statement stmt) { } void VariableDeclarator( -#line 1422 "cs.ATG" +#line 1431 "cs.ATG" ArrayList fieldDeclaration) { -#line 1423 "cs.ATG" +#line 1432 "cs.ATG" Expression expr = null; Expect(1); -#line 1425 "cs.ATG" +#line 1434 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1426 "cs.ATG" +#line 1435 "cs.ATG" out expr); -#line 1426 "cs.ATG" +#line 1435 "cs.ATG" f.Initializer = expr; } -#line 1426 "cs.ATG" +#line 1435 "cs.ATG" fieldDeclaration.Add(f); } void EventAccessorDecls( -#line 1371 "cs.ATG" +#line 1380 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1372 "cs.ATG" +#line 1381 "cs.ATG" AttributeSection section; ArrayList attributes = new ArrayList(); Statement stmt; @@ -2659,102 +2668,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 17) { AttributeSection( -#line 1379 "cs.ATG" +#line 1388 "cs.ATG" out section); -#line 1379 "cs.ATG" +#line 1388 "cs.ATG" attributes.Add(section); } if ( -#line 1381 "cs.ATG" +#line 1390 "cs.ATG" IdentIsAdd()) { -#line 1381 "cs.ATG" +#line 1390 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1382 "cs.ATG" +#line 1391 "cs.ATG" out stmt); -#line 1382 "cs.ATG" +#line 1391 "cs.ATG" attributes = new ArrayList(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 17) { AttributeSection( -#line 1383 "cs.ATG" +#line 1392 "cs.ATG" out section); -#line 1383 "cs.ATG" +#line 1392 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1384 "cs.ATG" +#line 1393 "cs.ATG" out stmt); -#line 1384 "cs.ATG" +#line 1393 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1385 "cs.ATG" +#line 1394 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1386 "cs.ATG" +#line 1395 "cs.ATG" out stmt); -#line 1386 "cs.ATG" +#line 1395 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new ArrayList(); while (la.kind == 17) { AttributeSection( -#line 1387 "cs.ATG" +#line 1396 "cs.ATG" out section); -#line 1387 "cs.ATG" +#line 1396 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1388 "cs.ATG" +#line 1397 "cs.ATG" out stmt); -#line 1388 "cs.ATG" +#line 1397 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1389 "cs.ATG" +#line 1398 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(155); } void ConstructorInitializer( -#line 1460 "cs.ATG" +#line 1469 "cs.ATG" out ConstructorInitializer ci) { -#line 1461 "cs.ATG" +#line 1470 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 49) { lexer.NextToken(); -#line 1465 "cs.ATG" +#line 1474 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 109) { lexer.NextToken(); -#line 1466 "cs.ATG" +#line 1475 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(156); Expect(19); if (StartOf(21)) { Argument( -#line 1469 "cs.ATG" +#line 1478 "cs.ATG" out expr); -#line 1469 "cs.ATG" +#line 1478 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1469 "cs.ATG" +#line 1478 "cs.ATG" out expr); -#line 1469 "cs.ATG" +#line 1478 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -2762,161 +2771,161 @@ out expr); } void OverloadableOperator( -#line 1481 "cs.ATG" +#line 1490 "cs.ATG" out OverloadableOperatorType op) { -#line 1482 "cs.ATG" +#line 1491 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1484 "cs.ATG" +#line 1493 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1485 "cs.ATG" +#line 1494 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 23: { lexer.NextToken(); -#line 1487 "cs.ATG" +#line 1496 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 26: { lexer.NextToken(); -#line 1488 "cs.ATG" +#line 1497 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 30: { lexer.NextToken(); -#line 1490 "cs.ATG" +#line 1499 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 31: { lexer.NextToken(); -#line 1491 "cs.ATG" +#line 1500 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 111: { lexer.NextToken(); -#line 1493 "cs.ATG" +#line 1502 "cs.ATG" op = OverloadableOperatorType.True; break; } case 70: { lexer.NextToken(); -#line 1494 "cs.ATG" +#line 1503 "cs.ATG" op = OverloadableOperatorType.False; break; } case 6: { lexer.NextToken(); -#line 1496 "cs.ATG" +#line 1505 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1497 "cs.ATG" +#line 1506 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1498 "cs.ATG" +#line 1507 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 27: { lexer.NextToken(); -#line 1500 "cs.ATG" +#line 1509 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 28: { lexer.NextToken(); -#line 1501 "cs.ATG" +#line 1510 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 29: { lexer.NextToken(); -#line 1502 "cs.ATG" +#line 1511 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 36: { lexer.NextToken(); -#line 1504 "cs.ATG" +#line 1513 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 32: { lexer.NextToken(); -#line 1505 "cs.ATG" +#line 1514 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 33: { lexer.NextToken(); -#line 1506 "cs.ATG" +#line 1515 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 22: { lexer.NextToken(); -#line 1507 "cs.ATG" +#line 1516 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 34: { lexer.NextToken(); -#line 1508 "cs.ATG" +#line 1517 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 35: { lexer.NextToken(); -#line 1509 "cs.ATG" +#line 1518 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 21: { lexer.NextToken(); -#line 1510 "cs.ATG" +#line 1519 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 21) { lexer.NextToken(); -#line 1510 "cs.ATG" +#line 1519 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2926,10 +2935,10 @@ out OverloadableOperatorType op) { } void AccessorDecls( -#line 1329 "cs.ATG" +#line 1338 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1331 "cs.ATG" +#line 1340 "cs.ATG" ArrayList attributes = new ArrayList(); AttributeSection section; getBlock = null; @@ -2937,136 +2946,136 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 17) { AttributeSection( -#line 1337 "cs.ATG" +#line 1346 "cs.ATG" out section); -#line 1337 "cs.ATG" +#line 1346 "cs.ATG" attributes.Add(section); } if ( -#line 1339 "cs.ATG" +#line 1348 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1340 "cs.ATG" +#line 1349 "cs.ATG" out getBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1341 "cs.ATG" +#line 1350 "cs.ATG" attributes = new ArrayList(); while (la.kind == 17) { AttributeSection( -#line 1342 "cs.ATG" +#line 1351 "cs.ATG" out section); -#line 1342 "cs.ATG" +#line 1351 "cs.ATG" attributes.Add(section); } SetAccessorDecl( -#line 1343 "cs.ATG" +#line 1352 "cs.ATG" out setBlock, attributes); } } else if ( -#line 1345 "cs.ATG" +#line 1354 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1346 "cs.ATG" +#line 1355 "cs.ATG" out setBlock, attributes); if (la.kind == 1 || la.kind == 17) { -#line 1347 "cs.ATG" +#line 1356 "cs.ATG" attributes = new ArrayList(); while (la.kind == 17) { AttributeSection( -#line 1348 "cs.ATG" +#line 1357 "cs.ATG" out section); -#line 1348 "cs.ATG" +#line 1357 "cs.ATG" attributes.Add(section); } GetAccessorDecl( -#line 1349 "cs.ATG" +#line 1358 "cs.ATG" out getBlock, attributes); } } else if (la.kind == 1) { lexer.NextToken(); -#line 1351 "cs.ATG" +#line 1360 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(158); } void InterfaceAccessors( -#line 1393 "cs.ATG" +#line 1402 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1395 "cs.ATG" +#line 1404 "cs.ATG" AttributeSection section; ArrayList attributes = new ArrayList(); getBlock = null; setBlock = null; while (la.kind == 17) { AttributeSection( -#line 1400 "cs.ATG" +#line 1409 "cs.ATG" out section); -#line 1400 "cs.ATG" +#line 1409 "cs.ATG" attributes.Add(section); } if ( -#line 1402 "cs.ATG" +#line 1411 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1402 "cs.ATG" +#line 1411 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1403 "cs.ATG" +#line 1412 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1403 "cs.ATG" +#line 1412 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1404 "cs.ATG" +#line 1413 "cs.ATG" Error("set or get expected"); } else SynErr(159); Expect(11); -#line 1406 "cs.ATG" +#line 1415 "cs.ATG" attributes = new ArrayList(); if (la.kind == 1 || la.kind == 17) { while (la.kind == 17) { AttributeSection( -#line 1408 "cs.ATG" +#line 1417 "cs.ATG" out section); -#line 1408 "cs.ATG" +#line 1417 "cs.ATG" attributes.Add(section); } if ( -#line 1410 "cs.ATG" +#line 1419 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1410 "cs.ATG" +#line 1419 "cs.ATG" if (getBlock != null) Error("get already declared"); else getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1413 "cs.ATG" +#line 1422 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1413 "cs.ATG" +#line 1422 "cs.ATG" if (setBlock != null) Error("set already declared"); else setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1416 "cs.ATG" +#line 1425 "cs.ATG" Error("set or get expected"); } else SynErr(160); Expect(11); @@ -3074,187 +3083,187 @@ IdentIsSet()) { } void GetAccessorDecl( -#line 1355 "cs.ATG" +#line 1364 "cs.ATG" out PropertyGetRegion getBlock, ArrayList attributes) { -#line 1356 "cs.ATG" +#line 1365 "cs.ATG" Statement stmt = null; Expect(1); -#line 1359 "cs.ATG" +#line 1368 "cs.ATG" if (t.val != "get") Error("get expected"); if (la.kind == 15) { Block( -#line 1360 "cs.ATG" +#line 1369 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(161); -#line 1360 "cs.ATG" +#line 1369 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); } void SetAccessorDecl( -#line 1363 "cs.ATG" +#line 1372 "cs.ATG" out PropertySetRegion setBlock, ArrayList attributes) { -#line 1364 "cs.ATG" +#line 1373 "cs.ATG" Statement stmt = null; Expect(1); -#line 1367 "cs.ATG" +#line 1376 "cs.ATG" if (t.val != "set") Error("set expected"); if (la.kind == 15) { Block( -#line 1368 "cs.ATG" +#line 1377 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(162); -#line 1368 "cs.ATG" +#line 1377 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); } void AddAccessorDecl( -#line 1444 "cs.ATG" +#line 1453 "cs.ATG" out Statement stmt) { -#line 1445 "cs.ATG" +#line 1454 "cs.ATG" stmt = null; Expect(1); -#line 1448 "cs.ATG" +#line 1457 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1449 "cs.ATG" +#line 1458 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1452 "cs.ATG" +#line 1461 "cs.ATG" out Statement stmt) { -#line 1453 "cs.ATG" +#line 1462 "cs.ATG" stmt = null; Expect(1); -#line 1456 "cs.ATG" +#line 1465 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1457 "cs.ATG" +#line 1466 "cs.ATG" out stmt); } void VariableInitializer( -#line 1473 "cs.ATG" +#line 1482 "cs.ATG" out Expression initializerExpression) { -#line 1474 "cs.ATG" +#line 1483 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(4)) { Expr( -#line 1476 "cs.ATG" +#line 1485 "cs.ATG" out initializerExpression); } else if (la.kind == 15) { ArrayInitializer( -#line 1477 "cs.ATG" +#line 1486 "cs.ATG" out initializerExpression); } else if (la.kind == 104) { lexer.NextToken(); Type( -#line 1478 "cs.ATG" +#line 1487 "cs.ATG" out type); Expect(17); Expr( -#line 1478 "cs.ATG" +#line 1487 "cs.ATG" out expr); Expect(18); -#line 1478 "cs.ATG" +#line 1487 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(163); } void Statement() { -#line 1582 "cs.ATG" +#line 1591 "cs.ATG" TypeReference type; Expression expr; Statement stmt; if ( -#line 1588 "cs.ATG" +#line 1597 "cs.ATG" IsLabel()) { Expect(1); -#line 1588 "cs.ATG" +#line 1597 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 58) { lexer.NextToken(); Type( -#line 1591 "cs.ATG" +#line 1600 "cs.ATG" out type); -#line 1591 "cs.ATG" +#line 1600 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1592 "cs.ATG" +#line 1601 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1593 "cs.ATG" +#line 1602 "cs.ATG" out expr); -#line 1593 "cs.ATG" +#line 1602 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1594 "cs.ATG" +#line 1603 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1594 "cs.ATG" +#line 1603 "cs.ATG" out expr); -#line 1594 "cs.ATG" +#line 1603 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1595 "cs.ATG" +#line 1604 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1597 "cs.ATG" +#line 1606 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1597 "cs.ATG" +#line 1606 "cs.ATG" out stmt); Expect(11); -#line 1597 "cs.ATG" +#line 1606 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(22)) { EmbeddedStatement( -#line 1598 "cs.ATG" +#line 1607 "cs.ATG" out stmt); -#line 1598 "cs.ATG" +#line 1607 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(164); } void Argument( -#line 1513 "cs.ATG" +#line 1522 "cs.ATG" out Expression argumentexpr) { -#line 1515 "cs.ATG" +#line 1524 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3262,48 +3271,48 @@ out Expression argumentexpr) { if (la.kind == 98) { lexer.NextToken(); -#line 1520 "cs.ATG" +#line 1529 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1521 "cs.ATG" +#line 1530 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1523 "cs.ATG" +#line 1532 "cs.ATG" out expr); -#line 1523 "cs.ATG" +#line 1532 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1542 "cs.ATG" +#line 1551 "cs.ATG" out Expression outExpr) { -#line 1544 "cs.ATG" +#line 1553 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(15); if (StartOf(23)) { VariableInitializer( -#line 1549 "cs.ATG" +#line 1558 "cs.ATG" out expr); -#line 1549 "cs.ATG" +#line 1558 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1549 "cs.ATG" +#line 1558 "cs.ATG" NotFinalComma()) { Expect(13); VariableInitializer( -#line 1549 "cs.ATG" +#line 1558 "cs.ATG" out expr); -#line 1549 "cs.ATG" +#line 1558 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 13) { @@ -3312,84 +3321,84 @@ out expr); } Expect(16); -#line 1550 "cs.ATG" +#line 1559 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1526 "cs.ATG" +#line 1535 "cs.ATG" out AssignmentOperatorType op) { -#line 1527 "cs.ATG" +#line 1536 "cs.ATG" op = AssignmentOperatorType.None; switch (la.kind) { case 3: { lexer.NextToken(); -#line 1529 "cs.ATG" +#line 1538 "cs.ATG" op = AssignmentOperatorType.Assign; break; } case 37: { lexer.NextToken(); -#line 1530 "cs.ATG" +#line 1539 "cs.ATG" op = AssignmentOperatorType.Add; break; } case 38: { lexer.NextToken(); -#line 1531 "cs.ATG" +#line 1540 "cs.ATG" op = AssignmentOperatorType.Subtract; break; } case 39: { lexer.NextToken(); -#line 1532 "cs.ATG" +#line 1541 "cs.ATG" op = AssignmentOperatorType.Multiply; break; } case 40: { lexer.NextToken(); -#line 1533 "cs.ATG" +#line 1542 "cs.ATG" op = AssignmentOperatorType.Divide; break; } case 41: { lexer.NextToken(); -#line 1534 "cs.ATG" +#line 1543 "cs.ATG" op = AssignmentOperatorType.Modulus; break; } case 42: { lexer.NextToken(); -#line 1535 "cs.ATG" +#line 1544 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; break; } case 43: { lexer.NextToken(); -#line 1536 "cs.ATG" +#line 1545 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; break; } case 44: { lexer.NextToken(); -#line 1537 "cs.ATG" +#line 1546 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; break; } case 45: { lexer.NextToken(); -#line 1538 "cs.ATG" +#line 1547 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; break; } @@ -3397,7 +3406,7 @@ out AssignmentOperatorType op) { lexer.NextToken(); Expect(34); -#line 1539 "cs.ATG" +#line 1548 "cs.ATG" op = AssignmentOperatorType.ShiftRight; break; } @@ -3406,66 +3415,66 @@ out AssignmentOperatorType op) { } void LocalVariableDecl( -#line 1553 "cs.ATG" +#line 1562 "cs.ATG" out Statement stmt) { -#line 1555 "cs.ATG" +#line 1564 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1560 "cs.ATG" +#line 1569 "cs.ATG" out type); -#line 1560 "cs.ATG" +#line 1569 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1561 "cs.ATG" +#line 1570 "cs.ATG" out var); -#line 1561 "cs.ATG" +#line 1570 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 13) { lexer.NextToken(); LocalVariableDeclarator( -#line 1562 "cs.ATG" +#line 1571 "cs.ATG" out var); -#line 1562 "cs.ATG" +#line 1571 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1563 "cs.ATG" +#line 1572 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1566 "cs.ATG" +#line 1575 "cs.ATG" out VariableDeclaration var) { -#line 1567 "cs.ATG" +#line 1576 "cs.ATG" Expression expr = null; Expect(1); -#line 1570 "cs.ATG" +#line 1579 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1570 "cs.ATG" +#line 1579 "cs.ATG" out expr); -#line 1570 "cs.ATG" +#line 1579 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1604 "cs.ATG" +#line 1613 "cs.ATG" out Statement statement) { -#line 1606 "cs.ATG" +#line 1615 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3473,156 +3482,156 @@ out Statement statement) { if (la.kind == 15) { Block( -#line 1612 "cs.ATG" +#line 1621 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1614 "cs.ATG" +#line 1623 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1616 "cs.ATG" +#line 1625 "cs.ATG" UnCheckedAndLBrace()) { -#line 1616 "cs.ATG" +#line 1625 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 56) { lexer.NextToken(); } else if (la.kind == 116) { lexer.NextToken(); -#line 1617 "cs.ATG" +#line 1626 "cs.ATG" isChecked = false; } else SynErr(166); Block( -#line 1618 "cs.ATG" +#line 1627 "cs.ATG" out block); -#line 1618 "cs.ATG" +#line 1627 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 77) { lexer.NextToken(); -#line 1620 "cs.ATG" +#line 1629 "cs.ATG" Statement elseStatement = null; Expect(19); Expr( -#line 1621 "cs.ATG" +#line 1630 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1622 "cs.ATG" +#line 1631 "cs.ATG" out embeddedStatement); if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1623 "cs.ATG" +#line 1632 "cs.ATG" out elseStatement); } -#line 1624 "cs.ATG" +#line 1633 "cs.ATG" statement = elseStatement != null ? (Statement)new IfElseStatement(expr, embeddedStatement, elseStatement) : (Statement)new IfElseStatement(expr, embeddedStatement); } else if (la.kind == 108) { lexer.NextToken(); -#line 1625 "cs.ATG" +#line 1634 "cs.ATG" ArrayList switchSections = new ArrayList(); SwitchSection switchSection; Expect(19); Expr( -#line 1626 "cs.ATG" +#line 1635 "cs.ATG" out expr); Expect(20); Expect(15); while (la.kind == 53 || la.kind == 61) { SwitchSection( -#line 1627 "cs.ATG" +#line 1636 "cs.ATG" out switchSection); -#line 1627 "cs.ATG" +#line 1636 "cs.ATG" switchSections.Add(switchSection); } Expect(16); -#line 1628 "cs.ATG" +#line 1637 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 123) { lexer.NextToken(); Expect(19); Expr( -#line 1630 "cs.ATG" +#line 1639 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1632 "cs.ATG" +#line 1641 "cs.ATG" out embeddedStatement); -#line 1632 "cs.ATG" +#line 1641 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 63) { lexer.NextToken(); EmbeddedStatement( -#line 1633 "cs.ATG" +#line 1642 "cs.ATG" out embeddedStatement); Expect(123); Expect(19); Expr( -#line 1634 "cs.ATG" +#line 1643 "cs.ATG" out expr); Expect(20); Expect(11); -#line 1634 "cs.ATG" +#line 1643 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 74) { lexer.NextToken(); -#line 1635 "cs.ATG" +#line 1644 "cs.ATG" ArrayList initializer = null; ArrayList iterator = null; Expect(19); if (StartOf(4)) { ForInitializer( -#line 1636 "cs.ATG" +#line 1645 "cs.ATG" out initializer); } Expect(11); if (StartOf(4)) { Expr( -#line 1637 "cs.ATG" +#line 1646 "cs.ATG" out expr); } Expect(11); if (StartOf(4)) { ForIterator( -#line 1638 "cs.ATG" +#line 1647 "cs.ATG" out iterator); } Expect(20); EmbeddedStatement( -#line 1639 "cs.ATG" +#line 1648 "cs.ATG" out embeddedStatement); -#line 1639 "cs.ATG" +#line 1648 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 75) { lexer.NextToken(); Expect(19); Type( -#line 1640 "cs.ATG" +#line 1649 "cs.ATG" out type); Expect(1); -#line 1640 "cs.ATG" +#line 1649 "cs.ATG" string varName = t.val; Point start = t.Location; Expect(79); Expr( -#line 1641 "cs.ATG" +#line 1650 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1642 "cs.ATG" +#line 1651 "cs.ATG" out embeddedStatement); -#line 1642 "cs.ATG" +#line 1651 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -3630,34 +3639,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1646 "cs.ATG" +#line 1655 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 59) { lexer.NextToken(); Expect(11); -#line 1647 "cs.ATG" +#line 1656 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 76) { GotoStatement( -#line 1648 "cs.ATG" +#line 1657 "cs.ATG" out statement); } else if ( -#line 1649 "cs.ATG" +#line 1658 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 99) { lexer.NextToken(); Expr( -#line 1649 "cs.ATG" +#line 1658 "cs.ATG" out expr); -#line 1649 "cs.ATG" +#line 1658 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 51) { lexer.NextToken(); -#line 1650 "cs.ATG" +#line 1659 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(167); Expect(11); @@ -3665,375 +3674,375 @@ out expr); lexer.NextToken(); if (StartOf(4)) { Expr( -#line 1651 "cs.ATG" +#line 1660 "cs.ATG" out expr); } Expect(11); -#line 1651 "cs.ATG" +#line 1660 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 110) { lexer.NextToken(); if (StartOf(4)) { Expr( -#line 1652 "cs.ATG" +#line 1661 "cs.ATG" out expr); } Expect(11); -#line 1652 "cs.ATG" +#line 1661 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(4)) { StatementExpr( -#line 1654 "cs.ATG" +#line 1663 "cs.ATG" out statement); Expect(11); } else if (la.kind == 112) { TryStatement( -#line 1656 "cs.ATG" +#line 1665 "cs.ATG" out statement); } else if (la.kind == 84) { lexer.NextToken(); Expect(19); Expr( -#line 1658 "cs.ATG" +#line 1667 "cs.ATG" out expr); Expect(20); EmbeddedStatement( -#line 1659 "cs.ATG" +#line 1668 "cs.ATG" out embeddedStatement); -#line 1659 "cs.ATG" +#line 1668 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 119) { -#line 1661 "cs.ATG" +#line 1670 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(19); ResourceAcquisition( -#line 1663 "cs.ATG" +#line 1672 "cs.ATG" out resourceAcquisitionStmt); Expect(20); EmbeddedStatement( -#line 1664 "cs.ATG" +#line 1673 "cs.ATG" out embeddedStatement); -#line 1664 "cs.ATG" +#line 1673 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 117) { lexer.NextToken(); Block( -#line 1666 "cs.ATG" +#line 1675 "cs.ATG" out embeddedStatement); -#line 1666 "cs.ATG" +#line 1675 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 72) { lexer.NextToken(); Expect(19); Type( -#line 1669 "cs.ATG" +#line 1678 "cs.ATG" out type); -#line 1669 "cs.ATG" +#line 1678 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); ArrayList pointerDeclarators = new ArrayList(1); Expect(1); -#line 1672 "cs.ATG" +#line 1681 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1673 "cs.ATG" +#line 1682 "cs.ATG" out expr); -#line 1673 "cs.ATG" +#line 1682 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 13) { lexer.NextToken(); Expect(1); -#line 1675 "cs.ATG" +#line 1684 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1676 "cs.ATG" +#line 1685 "cs.ATG" out expr); -#line 1676 "cs.ATG" +#line 1685 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(20); EmbeddedStatement( -#line 1678 "cs.ATG" +#line 1687 "cs.ATG" out embeddedStatement); -#line 1678 "cs.ATG" +#line 1687 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(168); } void SwitchSection( -#line 1700 "cs.ATG" +#line 1709 "cs.ATG" out SwitchSection stmt) { -#line 1702 "cs.ATG" +#line 1711 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1706 "cs.ATG" +#line 1715 "cs.ATG" out label); -#line 1706 "cs.ATG" +#line 1715 "cs.ATG" switchSection.SwitchLabels.Add(label); while (la.kind == 53 || la.kind == 61) { SwitchLabel( -#line 1708 "cs.ATG" +#line 1717 "cs.ATG" out label); -#line 1708 "cs.ATG" +#line 1717 "cs.ATG" switchSection.SwitchLabels.Add(label); } -#line 1710 "cs.ATG" +#line 1719 "cs.ATG" compilationUnit.BlockStart(switchSection); Statement(); while (StartOf(20)) { Statement(); } -#line 1713 "cs.ATG" +#line 1722 "cs.ATG" compilationUnit.BlockEnd(); stmt = switchSection; } void ForInitializer( -#line 1681 "cs.ATG" +#line 1690 "cs.ATG" out ArrayList initializer) { -#line 1683 "cs.ATG" +#line 1692 "cs.ATG" Statement stmt; initializer = new ArrayList(); if ( -#line 1687 "cs.ATG" +#line 1696 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1687 "cs.ATG" +#line 1696 "cs.ATG" out stmt); -#line 1687 "cs.ATG" +#line 1696 "cs.ATG" initializer.Add(stmt); } else if (StartOf(4)) { StatementExpr( -#line 1688 "cs.ATG" +#line 1697 "cs.ATG" out stmt); -#line 1688 "cs.ATG" +#line 1697 "cs.ATG" initializer.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1688 "cs.ATG" +#line 1697 "cs.ATG" out stmt); -#line 1688 "cs.ATG" +#line 1697 "cs.ATG" initializer.Add(stmt); } -#line 1688 "cs.ATG" +#line 1697 "cs.ATG" initializer.Add(stmt); } else SynErr(169); } void ForIterator( -#line 1691 "cs.ATG" +#line 1700 "cs.ATG" out ArrayList iterator) { -#line 1693 "cs.ATG" +#line 1702 "cs.ATG" Statement stmt; iterator = new ArrayList(); StatementExpr( -#line 1697 "cs.ATG" +#line 1706 "cs.ATG" out stmt); -#line 1697 "cs.ATG" +#line 1706 "cs.ATG" iterator.Add(stmt); while (la.kind == 13) { lexer.NextToken(); StatementExpr( -#line 1697 "cs.ATG" +#line 1706 "cs.ATG" out stmt); -#line 1697 "cs.ATG" +#line 1706 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1763 "cs.ATG" +#line 1772 "cs.ATG" out Statement stmt) { -#line 1764 "cs.ATG" +#line 1773 "cs.ATG" Expression expr; stmt = null; Expect(76); if (la.kind == 1) { lexer.NextToken(); -#line 1768 "cs.ATG" +#line 1777 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1769 "cs.ATG" +#line 1778 "cs.ATG" out expr); Expect(11); -#line 1769 "cs.ATG" +#line 1778 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1770 "cs.ATG" +#line 1779 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(170); } void StatementExpr( -#line 1790 "cs.ATG" +#line 1799 "cs.ATG" out Statement stmt) { -#line 1795 "cs.ATG" +#line 1804 "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 1801 "cs.ATG" +#line 1810 "cs.ATG" out expr); if (StartOf(6)) { -#line 1804 "cs.ATG" +#line 1813 "cs.ATG" AssignmentOperatorType op; Expression val; AssignmentOperator( -#line 1804 "cs.ATG" +#line 1813 "cs.ATG" out op); Expr( -#line 1804 "cs.ATG" +#line 1813 "cs.ATG" out val); -#line 1804 "cs.ATG" +#line 1813 "cs.ATG" expr = new AssignmentExpression(expr, op, val); } else if (la.kind == 11 || la.kind == 13 || la.kind == 20) { -#line 1805 "cs.ATG" +#line 1814 "cs.ATG" if (mustBeAssignment) Error("error in assignment."); } else SynErr(171); -#line 1806 "cs.ATG" +#line 1815 "cs.ATG" stmt = new StatementExpression(expr); } void TryStatement( -#line 1725 "cs.ATG" +#line 1734 "cs.ATG" out Statement tryStatement) { -#line 1727 "cs.ATG" +#line 1736 "cs.ATG" Statement blockStmt = null, finallyStmt = null; ArrayList catchClauses = null; Expect(112); Block( -#line 1731 "cs.ATG" +#line 1740 "cs.ATG" out blockStmt); if (la.kind == 54) { CatchClauses( -#line 1733 "cs.ATG" +#line 1742 "cs.ATG" out catchClauses); if (la.kind == 71) { lexer.NextToken(); Block( -#line 1733 "cs.ATG" +#line 1742 "cs.ATG" out finallyStmt); } } else if (la.kind == 71) { lexer.NextToken(); Block( -#line 1734 "cs.ATG" +#line 1743 "cs.ATG" out finallyStmt); } else SynErr(172); -#line 1737 "cs.ATG" +#line 1746 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 1774 "cs.ATG" +#line 1783 "cs.ATG" out Statement stmt) { -#line 1776 "cs.ATG" +#line 1785 "cs.ATG" stmt = null; Expression expr; if ( -#line 1781 "cs.ATG" +#line 1790 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1781 "cs.ATG" +#line 1790 "cs.ATG" out stmt); } else if (StartOf(4)) { Expr( -#line 1782 "cs.ATG" +#line 1791 "cs.ATG" out expr); -#line 1786 "cs.ATG" +#line 1795 "cs.ATG" stmt = new StatementExpression(expr); } else SynErr(173); } void SwitchLabel( -#line 1718 "cs.ATG" +#line 1727 "cs.ATG" out CaseLabel label) { -#line 1719 "cs.ATG" +#line 1728 "cs.ATG" Expression expr = null; label = null; if (la.kind == 53) { lexer.NextToken(); Expr( -#line 1721 "cs.ATG" +#line 1730 "cs.ATG" out expr); Expect(9); -#line 1721 "cs.ATG" +#line 1730 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 61) { lexer.NextToken(); Expect(9); -#line 1722 "cs.ATG" +#line 1731 "cs.ATG" label = new CaseLabel(); } else SynErr(174); } void CatchClauses( -#line 1742 "cs.ATG" +#line 1751 "cs.ATG" out ArrayList catchClauses) { -#line 1744 "cs.ATG" +#line 1753 "cs.ATG" catchClauses = new ArrayList(); Expect(54); -#line 1747 "cs.ATG" +#line 1756 "cs.ATG" string name; string identifier; Statement stmt; @@ -4041,138 +4050,138 @@ out ArrayList catchClauses) { if (la.kind == 15) { Block( -#line 1754 "cs.ATG" +#line 1763 "cs.ATG" out stmt); -#line 1754 "cs.ATG" +#line 1763 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 19) { lexer.NextToken(); ClassType( -#line 1756 "cs.ATG" +#line 1765 "cs.ATG" out name, out types); -#line 1756 "cs.ATG" +#line 1765 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1756 "cs.ATG" +#line 1765 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1756 "cs.ATG" +#line 1765 "cs.ATG" out stmt); -#line 1756 "cs.ATG" +#line 1765 "cs.ATG" catchClauses.Add(new CatchClause(new TypeReference(name, 0, null, types), identifier, stmt)); while ( -#line 1757 "cs.ATG" +#line 1766 "cs.ATG" IsTypedCatch()) { Expect(54); Expect(19); ClassType( -#line 1757 "cs.ATG" +#line 1766 "cs.ATG" out name, out types); -#line 1757 "cs.ATG" +#line 1766 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1757 "cs.ATG" +#line 1766 "cs.ATG" identifier = t.val; } Expect(20); Block( -#line 1757 "cs.ATG" +#line 1766 "cs.ATG" out stmt); -#line 1757 "cs.ATG" +#line 1766 "cs.ATG" catchClauses.Add(new CatchClause(new TypeReference(name, 0, null, types), identifier, stmt)); } if (la.kind == 54) { lexer.NextToken(); Block( -#line 1759 "cs.ATG" +#line 1768 "cs.ATG" out stmt); -#line 1759 "cs.ATG" +#line 1768 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(175); } void UnaryExpr( -#line 1822 "cs.ATG" +#line 1831 "cs.ATG" out Expression uExpr) { -#line 1824 "cs.ATG" +#line 1833 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(24) || -#line 1848 "cs.ATG" +#line 1857 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1833 "cs.ATG" +#line 1842 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1834 "cs.ATG" +#line 1843 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 23) { lexer.NextToken(); -#line 1835 "cs.ATG" +#line 1844 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 26) { lexer.NextToken(); -#line 1836 "cs.ATG" +#line 1845 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1837 "cs.ATG" +#line 1846 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 30) { lexer.NextToken(); -#line 1838 "cs.ATG" +#line 1847 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1839 "cs.ATG" +#line 1848 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1840 "cs.ATG" +#line 1849 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(19); Type( -#line 1848 "cs.ATG" +#line 1857 "cs.ATG" out type); Expect(20); -#line 1848 "cs.ATG" +#line 1857 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 1852 "cs.ATG" +#line 1861 "cs.ATG" out expr); -#line 1852 "cs.ATG" +#line 1861 "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) { @@ -4190,34 +4199,35 @@ out expr); } void ConditionalOrExpr( -#line 2011 "cs.ATG" +#line 2026 "cs.ATG" ref Expression outExpr) { -#line 2012 "cs.ATG" +#line 2027 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2014 "cs.ATG" +#line 2029 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2014 "cs.ATG" +#line 2029 "cs.ATG" out expr); ConditionalAndExpr( -#line 2014 "cs.ATG" +#line 2029 "cs.ATG" ref expr); -#line 2014 "cs.ATG" +#line 2029 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1869 "cs.ATG" +#line 1878 "cs.ATG" out Expression pexpr) { -#line 1871 "cs.ATG" +#line 1880 "cs.ATG" TypeReference type = null; + List typeList = null; bool isArrayCreation = false; Expression expr; pexpr = null; @@ -4226,349 +4236,349 @@ out Expression pexpr) { case 111: { lexer.NextToken(); -#line 1878 "cs.ATG" +#line 1888 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); break; } case 70: { lexer.NextToken(); -#line 1879 "cs.ATG" +#line 1889 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); break; } case 88: { lexer.NextToken(); -#line 1880 "cs.ATG" +#line 1890 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); break; } case 2: { lexer.NextToken(); -#line 1881 "cs.ATG" +#line 1891 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 1: { lexer.NextToken(); -#line 1883 "cs.ATG" +#line 1893 "cs.ATG" pexpr = new IdentifierExpression(t.val); break; } case 19: { lexer.NextToken(); Expr( -#line 1885 "cs.ATG" +#line 1895 "cs.ATG" out expr); Expect(20); -#line 1885 "cs.ATG" +#line 1895 "cs.ATG" pexpr = new ParenthesizedExpression(expr); break; } case 50: case 52: case 55: case 60: case 64: case 73: case 80: case 85: case 89: case 100: case 102: case 106: case 114: case 115: case 118: { -#line 1887 "cs.ATG" +#line 1897 "cs.ATG" string val = null; switch (la.kind) { case 50: { lexer.NextToken(); -#line 1889 "cs.ATG" +#line 1899 "cs.ATG" val = "bool"; break; } case 52: { lexer.NextToken(); -#line 1890 "cs.ATG" +#line 1900 "cs.ATG" val = "byte"; break; } case 55: { lexer.NextToken(); -#line 1891 "cs.ATG" +#line 1901 "cs.ATG" val = "char"; break; } case 60: { lexer.NextToken(); -#line 1892 "cs.ATG" +#line 1902 "cs.ATG" val = "decimal"; break; } case 64: { lexer.NextToken(); -#line 1893 "cs.ATG" +#line 1903 "cs.ATG" val = "double"; break; } case 73: { lexer.NextToken(); -#line 1894 "cs.ATG" +#line 1904 "cs.ATG" val = "float"; break; } case 80: { lexer.NextToken(); -#line 1895 "cs.ATG" +#line 1905 "cs.ATG" val = "int"; break; } case 85: { lexer.NextToken(); -#line 1896 "cs.ATG" +#line 1906 "cs.ATG" val = "long"; break; } case 89: { lexer.NextToken(); -#line 1897 "cs.ATG" +#line 1907 "cs.ATG" val = "object"; break; } case 100: { lexer.NextToken(); -#line 1898 "cs.ATG" +#line 1908 "cs.ATG" val = "sbyte"; break; } case 102: { lexer.NextToken(); -#line 1899 "cs.ATG" +#line 1909 "cs.ATG" val = "short"; break; } case 106: { lexer.NextToken(); -#line 1900 "cs.ATG" +#line 1910 "cs.ATG" val = "string"; break; } case 114: { lexer.NextToken(); -#line 1901 "cs.ATG" +#line 1911 "cs.ATG" val = "uint"; break; } case 115: { lexer.NextToken(); -#line 1902 "cs.ATG" +#line 1912 "cs.ATG" val = "ulong"; break; } case 118: { lexer.NextToken(); -#line 1903 "cs.ATG" +#line 1913 "cs.ATG" val = "ushort"; break; } } -#line 1904 "cs.ATG" +#line 1914 "cs.ATG" t.val = ""; Expect(14); Expect(1); -#line 1904 "cs.ATG" +#line 1914 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); break; } case 109: { lexer.NextToken(); -#line 1906 "cs.ATG" +#line 1916 "cs.ATG" pexpr = new ThisReferenceExpression(); break; } case 49: { lexer.NextToken(); -#line 1908 "cs.ATG" +#line 1918 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1910 "cs.ATG" +#line 1920 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 17) { lexer.NextToken(); Expr( -#line 1911 "cs.ATG" +#line 1921 "cs.ATG" out expr); -#line 1911 "cs.ATG" +#line 1921 "cs.ATG" ArrayList indices = new ArrayList(); if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1912 "cs.ATG" +#line 1922 "cs.ATG" out expr); -#line 1912 "cs.ATG" +#line 1922 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 1913 "cs.ATG" +#line 1923 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(176); -#line 1914 "cs.ATG" +#line 1924 "cs.ATG" pexpr = retExpr; break; } case 87: { lexer.NextToken(); NonArrayType( -#line 1915 "cs.ATG" +#line 1925 "cs.ATG" out type); -#line 1915 "cs.ATG" +#line 1925 "cs.ATG" ArrayList parameters = new ArrayList(); if (la.kind == 19) { lexer.NextToken(); -#line 1920 "cs.ATG" +#line 1930 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 1921 "cs.ATG" +#line 1931 "cs.ATG" out expr); -#line 1921 "cs.ATG" +#line 1931 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1922 "cs.ATG" +#line 1932 "cs.ATG" out expr); -#line 1922 "cs.ATG" +#line 1932 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(20); -#line 1924 "cs.ATG" +#line 1934 "cs.ATG" pexpr = oce; } else if (la.kind == 17) { -#line 1926 "cs.ATG" +#line 1936 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; lexer.NextToken(); -#line 1927 "cs.ATG" +#line 1937 "cs.ATG" int dims = 0; ArrayList rank = new ArrayList(); ArrayList parameterExpression = new ArrayList(); if (StartOf(4)) { Expr( -#line 1931 "cs.ATG" +#line 1941 "cs.ATG" out expr); -#line 1931 "cs.ATG" +#line 1941 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1933 "cs.ATG" +#line 1943 "cs.ATG" out expr); -#line 1933 "cs.ATG" +#line 1943 "cs.ATG" if (expr != null) { parameterExpression.Add(expr); } } Expect(18); -#line 1935 "cs.ATG" +#line 1945 "cs.ATG" parameters.Add(new ArrayCreationParameter(parameterExpression)); ace.Parameters = parameters; while ( -#line 1938 "cs.ATG" +#line 1948 "cs.ATG" IsDims()) { Expect(17); -#line 1938 "cs.ATG" +#line 1948 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 1939 "cs.ATG" +#line 1949 "cs.ATG" dims++; } -#line 1939 "cs.ATG" +#line 1949 "cs.ATG" rank.Add(dims); parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } -#line 1943 "cs.ATG" +#line 1953 "cs.ATG" if (rank.Count > 0) { ace.Rank = (int[])rank.ToArray(typeof (int)); } if (la.kind == 15) { ArrayInitializer( -#line 1947 "cs.ATG" +#line 1957 "cs.ATG" out expr); -#line 1947 "cs.ATG" +#line 1957 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else if (la.kind == 13 || la.kind == 18) { while (la.kind == 13) { lexer.NextToken(); -#line 1949 "cs.ATG" +#line 1959 "cs.ATG" dims++; } -#line 1950 "cs.ATG" +#line 1960 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); while ( -#line 1952 "cs.ATG" +#line 1962 "cs.ATG" IsDims()) { Expect(17); -#line 1952 "cs.ATG" +#line 1962 "cs.ATG" dims =0; while (la.kind == 13) { lexer.NextToken(); -#line 1952 "cs.ATG" +#line 1962 "cs.ATG" dims++; } -#line 1952 "cs.ATG" +#line 1962 "cs.ATG" parameters.Add(new ArrayCreationParameter(dims)); Expect(18); } ArrayInitializer( -#line 1952 "cs.ATG" +#line 1962 "cs.ATG" out expr); -#line 1952 "cs.ATG" +#line 1962 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters; } else SynErr(177); } else SynErr(178); @@ -4578,20 +4588,20 @@ out expr); lexer.NextToken(); Expect(19); if ( -#line 1958 "cs.ATG" +#line 1968 "cs.ATG" NotVoidPointer()) { Expect(121); -#line 1958 "cs.ATG" +#line 1968 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(8)) { Type( -#line 1959 "cs.ATG" +#line 1969 "cs.ATG" out type); } else SynErr(179); Expect(20); -#line 1960 "cs.ATG" +#line 1970 "cs.ATG" pexpr = new TypeOfExpression(type); break; } @@ -4599,11 +4609,11 @@ out type); lexer.NextToken(); Expect(19); Type( -#line 1961 "cs.ATG" +#line 1971 "cs.ATG" out type); Expect(20); -#line 1961 "cs.ATG" +#line 1971 "cs.ATG" pexpr = new SizeOfExpression(type); break; } @@ -4611,11 +4621,11 @@ out type); lexer.NextToken(); Expect(19); Expr( -#line 1962 "cs.ATG" +#line 1972 "cs.ATG" out expr); Expect(20); -#line 1962 "cs.ATG" +#line 1972 "cs.ATG" pexpr = new CheckedExpression(expr); break; } @@ -4623,112 +4633,145 @@ out expr); lexer.NextToken(); Expect(19); Expr( -#line 1963 "cs.ATG" +#line 1973 "cs.ATG" out expr); Expect(20); -#line 1963 "cs.ATG" +#line 1973 "cs.ATG" pexpr = new UncheckedExpression(expr); break; } case 62: { lexer.NextToken(); AnonymousMethodExpr( -#line 1964 "cs.ATG" +#line 1974 "cs.ATG" out expr); -#line 1964 "cs.ATG" +#line 1974 "cs.ATG" pexpr = expr; break; } default: SynErr(180); break; } - while (StartOf(25)) { + while (StartOf(25) || +#line 1989 "cs.ATG" +IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 30 || la.kind == 31) { if (la.kind == 30) { lexer.NextToken(); -#line 1968 "cs.ATG" +#line 1978 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 31) { lexer.NextToken(); -#line 1969 "cs.ATG" +#line 1979 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(181); } else if (la.kind == 46) { lexer.NextToken(); Expect(1); -#line 1972 "cs.ATG" +#line 1982 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1973 "cs.ATG" +#line 1983 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if (la.kind == 19) { lexer.NextToken(); -#line 1975 "cs.ATG" +#line 1985 "cs.ATG" ArrayList parameters = new ArrayList(); if (StartOf(21)) { Argument( -#line 1976 "cs.ATG" +#line 1986 "cs.ATG" out expr); -#line 1976 "cs.ATG" +#line 1986 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 13) { lexer.NextToken(); Argument( -#line 1977 "cs.ATG" +#line 1987 "cs.ATG" out expr); -#line 1977 "cs.ATG" +#line 1987 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(20); -#line 1978 "cs.ATG" +#line 1988 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); + } else if ( +#line 1989 "cs.ATG" +IsGenericFollowedBy(Tokens.OpenParenthesis)) { + TypeArgumentList( +#line 1989 "cs.ATG" +out typeList); + Expect(19); + +#line 1990 "cs.ATG" + ArrayList parameters = new ArrayList(); + if (StartOf(21)) { + Argument( +#line 1991 "cs.ATG" +out expr); + +#line 1991 "cs.ATG" + if (expr != null) {parameters.Add(expr);} + while (la.kind == 13) { + lexer.NextToken(); + Argument( +#line 1992 "cs.ATG" +out expr); + +#line 1992 "cs.ATG" + if (expr != null) {parameters.Add(expr);} + } + } + Expect(20); + +#line 1993 "cs.ATG" + pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 1980 "cs.ATG" +#line 1995 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); ArrayList indices = new ArrayList(); lexer.NextToken(); Expr( -#line 1983 "cs.ATG" +#line 1998 "cs.ATG" out expr); -#line 1983 "cs.ATG" +#line 1998 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 13) { lexer.NextToken(); Expr( -#line 1984 "cs.ATG" +#line 1999 "cs.ATG" out expr); -#line 1984 "cs.ATG" +#line 1999 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(18); -#line 1985 "cs.ATG" +#line 2000 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void AnonymousMethodExpr( -#line 1989 "cs.ATG" +#line 2004 "cs.ATG" out Expression outExpr) { -#line 1991 "cs.ATG" +#line 2006 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); Statement stmt; ArrayList p; @@ -4737,306 +4780,333 @@ out Expression outExpr) { Expect(19); if (StartOf(9)) { FormalParameterList( -#line 1998 "cs.ATG" +#line 2013 "cs.ATG" out p); -#line 1998 "cs.ATG" +#line 2013 "cs.ATG" expr.Parameters = p; } Expect(20); -#line 2002 "cs.ATG" +#line 2017 "cs.ATG" if (compilationUnit != null) { Block( -#line 2003 "cs.ATG" +#line 2018 "cs.ATG" out stmt); -#line 2003 "cs.ATG" +#line 2018 "cs.ATG" expr.Body = (BlockStatement)stmt; -#line 2004 "cs.ATG" +#line 2019 "cs.ATG" } else { Expect(15); -#line 2006 "cs.ATG" +#line 2021 "cs.ATG" lexer.SkipCurrentBlock(); Expect(16); -#line 2008 "cs.ATG" +#line 2023 "cs.ATG" } } + void TypeArgumentList( +#line 2155 "cs.ATG" +out List types) { + +#line 2157 "cs.ATG" + types = new List(); + TypeReference type = null; + + Expect(22); + Type( +#line 2161 "cs.ATG" +out type); + +#line 2161 "cs.ATG" + types.Add(type); + while (la.kind == 13) { + lexer.NextToken(); + Type( +#line 2162 "cs.ATG" +out type); + +#line 2162 "cs.ATG" + types.Add(type); + } + Expect(21); + } + void ConditionalAndExpr( -#line 2017 "cs.ATG" +#line 2032 "cs.ATG" ref Expression outExpr) { -#line 2018 "cs.ATG" +#line 2033 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2020 "cs.ATG" +#line 2035 "cs.ATG" ref outExpr); while (la.kind == 24) { lexer.NextToken(); UnaryExpr( -#line 2020 "cs.ATG" +#line 2035 "cs.ATG" out expr); InclusiveOrExpr( -#line 2020 "cs.ATG" +#line 2035 "cs.ATG" ref expr); -#line 2020 "cs.ATG" +#line 2035 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2023 "cs.ATG" +#line 2038 "cs.ATG" ref Expression outExpr) { -#line 2024 "cs.ATG" +#line 2039 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2026 "cs.ATG" +#line 2041 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2026 "cs.ATG" +#line 2041 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2026 "cs.ATG" +#line 2041 "cs.ATG" ref expr); -#line 2026 "cs.ATG" +#line 2041 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2029 "cs.ATG" +#line 2044 "cs.ATG" ref Expression outExpr) { -#line 2030 "cs.ATG" +#line 2045 "cs.ATG" Expression expr; AndExpr( -#line 2032 "cs.ATG" +#line 2047 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2032 "cs.ATG" +#line 2047 "cs.ATG" out expr); AndExpr( -#line 2032 "cs.ATG" +#line 2047 "cs.ATG" ref expr); -#line 2032 "cs.ATG" +#line 2047 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2035 "cs.ATG" +#line 2050 "cs.ATG" ref Expression outExpr) { -#line 2036 "cs.ATG" +#line 2051 "cs.ATG" Expression expr; EqualityExpr( -#line 2038 "cs.ATG" +#line 2053 "cs.ATG" ref outExpr); while (la.kind == 27) { lexer.NextToken(); UnaryExpr( -#line 2038 "cs.ATG" +#line 2053 "cs.ATG" out expr); EqualityExpr( -#line 2038 "cs.ATG" +#line 2053 "cs.ATG" ref expr); -#line 2038 "cs.ATG" +#line 2053 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2041 "cs.ATG" +#line 2056 "cs.ATG" ref Expression outExpr) { -#line 2043 "cs.ATG" +#line 2058 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2047 "cs.ATG" +#line 2062 "cs.ATG" ref outExpr); while (la.kind == 32 || la.kind == 33) { if (la.kind == 33) { lexer.NextToken(); -#line 2050 "cs.ATG" +#line 2065 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2051 "cs.ATG" +#line 2066 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2053 "cs.ATG" +#line 2068 "cs.ATG" out expr); RelationalExpr( -#line 2053 "cs.ATG" +#line 2068 "cs.ATG" ref expr); -#line 2053 "cs.ATG" +#line 2068 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2057 "cs.ATG" +#line 2072 "cs.ATG" ref Expression outExpr) { -#line 2059 "cs.ATG" +#line 2074 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2064 "cs.ATG" +#line 2079 "cs.ATG" ref outExpr); while (StartOf(26)) { if (StartOf(27)) { if (la.kind == 22) { lexer.NextToken(); -#line 2067 "cs.ATG" +#line 2082 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 21) { lexer.NextToken(); -#line 2068 "cs.ATG" +#line 2083 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 35) { lexer.NextToken(); -#line 2069 "cs.ATG" +#line 2084 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 34) { lexer.NextToken(); -#line 2070 "cs.ATG" +#line 2085 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(182); UnaryExpr( -#line 2072 "cs.ATG" +#line 2087 "cs.ATG" out expr); ShiftExpr( -#line 2072 "cs.ATG" +#line 2087 "cs.ATG" ref expr); -#line 2072 "cs.ATG" +#line 2087 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 83) { lexer.NextToken(); -#line 2075 "cs.ATG" +#line 2090 "cs.ATG" op = BinaryOperatorType.IS; } else if (la.kind == 48) { lexer.NextToken(); -#line 2076 "cs.ATG" +#line 2091 "cs.ATG" op = BinaryOperatorType.AS; } else SynErr(183); Type( -#line 2078 "cs.ATG" +#line 2093 "cs.ATG" out type); -#line 2078 "cs.ATG" +#line 2093 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, new TypeReferenceExpression(type)); } } } void ShiftExpr( -#line 2082 "cs.ATG" +#line 2097 "cs.ATG" ref Expression outExpr) { -#line 2084 "cs.ATG" +#line 2099 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2088 "cs.ATG" +#line 2103 "cs.ATG" ref outExpr); while (la.kind == 36 || -#line 2091 "cs.ATG" +#line 2106 "cs.ATG" IsShiftRight()) { if (la.kind == 36) { lexer.NextToken(); -#line 2090 "cs.ATG" +#line 2105 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(21); Expect(21); -#line 2092 "cs.ATG" +#line 2107 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2095 "cs.ATG" +#line 2110 "cs.ATG" out expr); AdditiveExpr( -#line 2095 "cs.ATG" +#line 2110 "cs.ATG" ref expr); -#line 2095 "cs.ATG" +#line 2110 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2099 "cs.ATG" +#line 2114 "cs.ATG" ref Expression outExpr) { -#line 2101 "cs.ATG" +#line 2116 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2105 "cs.ATG" +#line 2120 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2108 "cs.ATG" +#line 2123 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2109 "cs.ATG" +#line 2124 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2111 "cs.ATG" +#line 2126 "cs.ATG" out expr); MultiplicativeExpr( -#line 2111 "cs.ATG" +#line 2126 "cs.ATG" ref expr); -#line 2111 "cs.ATG" +#line 2126 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2115 "cs.ATG" +#line 2130 "cs.ATG" ref Expression outExpr) { -#line 2117 "cs.ATG" +#line 2132 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5044,84 +5114,57 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2123 "cs.ATG" +#line 2138 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2124 "cs.ATG" +#line 2139 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2125 "cs.ATG" +#line 2140 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2127 "cs.ATG" +#line 2142 "cs.ATG" out expr); -#line 2127 "cs.ATG" - outExpr = new BinaryOperatorExpression(outExpr, op, expr); - } - } - - void TypeArgumentList( -#line 2140 "cs.ATG" -out List types) { - #line 2142 "cs.ATG" - types = new List(); - TypeReference type = null; - - Expect(22); - Type( -#line 2146 "cs.ATG" -out type); - -#line 2146 "cs.ATG" - types.Add(type); - while (la.kind == 13) { - lexer.NextToken(); - Type( -#line 2147 "cs.ATG" -out type); - -#line 2147 "cs.ATG" - types.Add(type); + outExpr = new BinaryOperatorExpression(outExpr, op, expr); } - Expect(21); } void TypeParameterConstraintsClauseBase( -#line 2192 "cs.ATG" +#line 2207 "cs.ATG" out TypeReference type) { -#line 2193 "cs.ATG" +#line 2208 "cs.ATG" TypeReference t; type = null; if (la.kind == 107) { lexer.NextToken(); -#line 2195 "cs.ATG" +#line 2210 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 57) { lexer.NextToken(); -#line 2196 "cs.ATG" +#line 2211 "cs.ATG" type = new TypeReference("struct"); } else if (la.kind == 87) { lexer.NextToken(); Expect(19); Expect(20); -#line 2197 "cs.ATG" +#line 2212 "cs.ATG" type = new TypeReference("struct"); } else if (StartOf(8)) { Type( -#line 2198 "cs.ATG" +#line 2213 "cs.ATG" out t); -#line 2198 "cs.ATG" +#line 2213 "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 dd18a03582..63082ac13f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -309,6 +309,15 @@ bool IsLocalVarDecl () { pt.kind == Tokens.Identifier; } +/* True if lookahead is type parameters (<...>) followed by the specified token */ +bool IsGenericFollowedBy(int token) +{ + Token t = la; + if (t.kind != Tokens.LessThan) return false; + StartPeek(); + return SkipGeneric(ref t) && t.kind == token; +} + /* True, if lookahead ident is "where" */ bool IdentIsWhere () { return la.kind == Tokens.Identifier && la.val == "where"; @@ -1869,6 +1878,7 @@ UnaryExpr PrimaryExpr (. TypeReference type = null; + List typeList = null; bool isArrayCreation = false; Expression expr; pexpr = null; @@ -1976,6 +1986,11 @@ PrimaryExpr [ Argument (. if (expr != null) {parameters.Add(expr);} .) { "," Argument (. if (expr != null) {parameters.Add(expr);} .) } ] ")" (. pexpr = new InvocationExpression(pexpr, parameters); .) + | ( IF (IsGenericFollowedBy(Tokens.OpenParenthesis)) TypeArgumentList ) + "(" (. ArrayList parameters = new ArrayList(); .) + [ Argument (. if (expr != null) {parameters.Add(expr);} .) + { "," Argument (. if (expr != null) {parameters.Add(expr);} .) + } ] ")" (. pexpr = new InvocationExpression(pexpr, parameters, typeList); .) /*--- element access */ | (. if (isArrayCreation) Error("element access not allow on array creation"); ArrayList indices = new ArrayList(); diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/FieldReferenceExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/FieldReferenceExpressionTests.cs index a2d2ea5b55..2ff5d29815 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/FieldReferenceExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/FieldReferenceExpressionTests.cs @@ -27,6 +27,18 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.IsTrue(fre.TargetObject is IdentifierExpression); Assert.AreEqual("myTargetObject", ((IdentifierExpression)fre.TargetObject).Identifier); } + + [Test] + public void CSharpGenericFieldReferenceExpressionTest() + { + FieldReferenceExpression fre = (FieldReferenceExpression)ParseUtilCSharp.ParseExpression("SomeClass.myField", typeof(FieldReferenceExpression)); + Assert.AreEqual("myField", fre.FieldName); + Assert.IsTrue(fre.TargetObject is TypeReferenceExpression); + TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference; + Assert.AreEqual("SomeClass", tr.Type); + Assert.AreEqual(1, tr.GenericTypes.Count); + Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType); + } #endregion #region VB.NET diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs index 2466fbadeb..888d70172c 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs @@ -32,6 +32,17 @@ namespace ICSharpCode.NRefactory.Tests.AST CheckSimpleInvoke((InvocationExpression)ParseUtilCSharp.ParseExpression("myMethod()", typeof(InvocationExpression))); } + [Test] + public void CSharpGenericInvocationExpressionTest() + { + InvocationExpression expr = (InvocationExpression)ParseUtilCSharp.ParseExpression("myMethod('a')", typeof(InvocationExpression)); + Assert.AreEqual(1, expr.Parameters.Count); + Assert.IsTrue(expr.TargetObject is IdentifierExpression); + Assert.AreEqual("myMethod", ((IdentifierExpression)expr.TargetObject).Identifier); + Assert.AreEqual(1, expr.TypeParameters.Count); + Assert.AreEqual("System.Char", expr.TypeParameters[0].SystemType); + } + [Test] public void CSharpInvalidNestedInvocationExpressionTest() {