From d9dd2ffd907137096f3aa5c51ea08f0de1fb51d2 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 10 Oct 2006 17:07:34 +0000 Subject: [PATCH] Fixed SD2-1166: C# parser: Initializer in event declaration causes parser error git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1899 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../NRefactoryASTGenerator/AST/Expressions.cs | 1 + .../NRefactoryASTGenerator/AST/TypeLevel.cs | 3 +- .../NRefactory/Project/Src/Ast/Generated.cs | 31 +- .../NRefactory/Project/Src/IAstVisitor.cs | 2 +- .../Project/Src/Parser/CSharp/Parser.cs | 1494 +++++++++-------- .../Project/Src/Parser/CSharp/cs.ATG | 2 + .../CSharp/CSharpOutputVisitor.cs | 67 +- .../PrettyPrinter/VBNet/VBNetOutputVisitor.cs | 8 + .../Src/Visitors/AbstractASTVisitor.cs | 6 +- .../Src/Visitors/AbstractAstTransformer.cs | 6 +- .../Test/Output/CSharp/CSharpOutputTest.cs | 13 + .../Output/CSharp/VBToCSharpConverterTest.cs | 2 +- .../Expressions/AnonymousMethodTests.cs | 2 + 13 files changed, 878 insertions(+), 759 deletions(-) diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs index 77ddf2eb21..6a8b0a2479 100644 --- a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs @@ -156,6 +156,7 @@ namespace NRefactoryASTGenerator.Ast class AnonymousMethodExpression : Expression { List parameters; BlockStatement body; + bool hasParameterList; } class CheckedExpression : Expression { diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs index c41956b4f9..3acff12011 100644 --- a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs @@ -91,13 +91,14 @@ namespace NRefactoryASTGenerator.Ast [IncludeBoolProperty("HasRaiseRegion", "return !raiseRegion.IsNull;")] class EventDeclaration : ParametrizedNode { - TypeReference typeReference; + TypeReference typeReference; List interfaceImplementations; EventAddRegion addRegion; EventRemoveRegion removeRegion; EventRaiseRegion raiseRegion; Location bodyStart; Location bodyEnd; + Expression initializer; public EventDeclaration(TypeReference typeReference, string name, Modifiers modifier, List attributes, List parameters) : base(modifier, attributes, name, parameters) diff --git a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs index 28beb0eff5..eddb819902 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs @@ -87,6 +87,8 @@ namespace ICSharpCode.NRefactory.Ast { BlockStatement body; + bool hasParameterList; + public List Parameters { get { return parameters; @@ -106,6 +108,15 @@ namespace ICSharpCode.NRefactory.Ast { } } + public bool HasParameterList { + get { + return hasParameterList; + } + set { + hasParameterList = value; + } + } + public AnonymousMethodExpression() { parameters = new List(); body = BlockStatement.Null; @@ -116,7 +127,7 @@ namespace ICSharpCode.NRefactory.Ast { } public override string ToString() { - return string.Format("[AnonymousMethodExpression Parameters={0} Body={1}]", GetCollectionString(Parameters), Body); + return string.Format("[AnonymousMethodExpression Parameters={0} Body={1} HasParameterList={2}]", GetCollectionString(Parameters), Body, HasParameterList); } } @@ -1488,6 +1499,8 @@ namespace ICSharpCode.NRefactory.Ast { Location bodyEnd; + Expression initializer; + public TypeReference TypeReference { get { return typeReference; @@ -1551,6 +1564,16 @@ namespace ICSharpCode.NRefactory.Ast { } } + public Expression Initializer { + get { + return initializer; + } + set { + initializer = value ?? Expression.Null; + if (!initializer.IsNull) initializer.Parent = this; + } + } + public EventDeclaration(TypeReference typeReference, string name, Modifiers modifier, List attributes, List parameters) : base(modifier, attributes, name, parameters) { TypeReference = typeReference; @@ -1560,6 +1583,7 @@ namespace ICSharpCode.NRefactory.Ast { raiseRegion = EventRaiseRegion.Null; bodyStart = Location.Empty; bodyEnd = Location.Empty; + initializer = Expression.Null; } public EventDeclaration(TypeReference typeReference, Modifiers modifier, List parameters, List attributes, string name, List interfaceImplementations) : @@ -1571,6 +1595,7 @@ namespace ICSharpCode.NRefactory.Ast { raiseRegion = EventRaiseRegion.Null; bodyStart = Location.Empty; bodyEnd = Location.Empty; + initializer = Expression.Null; } public bool HasAddRegion { @@ -1597,8 +1622,8 @@ namespace ICSharpCode.NRefactory.Ast { public override string ToString() { return string.Format("[EventDeclaration TypeReference={0} InterfaceImplementations={1} AddRegion={2} Re" + - "moveRegion={3} RaiseRegion={4} BodyStart={5} BodyEnd={6} Name={7} Parameters={8}" + - " Attributes={9} Modifier={10}]", TypeReference, GetCollectionString(InterfaceImplementations), AddRegion, RemoveRegion, RaiseRegion, BodyStart, BodyEnd, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + "moveRegion={3} RaiseRegion={4} BodyStart={5} BodyEnd={6} Initializer={7} Name={8" + + "} Parameters={9} Attributes={10} Modifier={11}]", TypeReference, GetCollectionString(InterfaceImplementations), AddRegion, RemoveRegion, RaiseRegion, BodyStart, BodyEnd, Initializer, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); } } diff --git a/src/Libraries/NRefactory/Project/Src/IAstVisitor.cs b/src/Libraries/NRefactory/Project/Src/IAstVisitor.cs index 37a52affe5..f3bbb2c091 100644 --- a/src/Libraries/NRefactory/Project/Src/IAstVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/IAstVisitor.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.88 +// Runtime Version:2.0.50727.42 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 56e89a9ec3..310e3a4a94 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -359,60 +359,60 @@ out expr); } void Expr( -#line 1610 "cs.ATG" +#line 1611 "cs.ATG" out Expression expr) { -#line 1611 "cs.ATG" +#line 1612 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; UnaryExpr( -#line 1613 "cs.ATG" +#line 1614 "cs.ATG" out expr); if (StartOf(6)) { AssignmentOperator( -#line 1616 "cs.ATG" +#line 1617 "cs.ATG" out op); Expr( -#line 1616 "cs.ATG" +#line 1617 "cs.ATG" out expr1); -#line 1616 "cs.ATG" +#line 1617 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1617 "cs.ATG" +#line 1618 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1618 "cs.ATG" +#line 1619 "cs.ATG" out op); Expr( -#line 1618 "cs.ATG" +#line 1619 "cs.ATG" out expr1); -#line 1618 "cs.ATG" +#line 1619 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(7)) { ConditionalOrExpr( -#line 1620 "cs.ATG" +#line 1621 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1621 "cs.ATG" +#line 1622 "cs.ATG" out expr1); -#line 1621 "cs.ATG" +#line 1622 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1622 "cs.ATG" +#line 1623 "cs.ATG" out expr1); Expect(9); Expr( -#line 1622 "cs.ATG" +#line 1623 "cs.ATG" out expr2); -#line 1622 "cs.ATG" +#line 1623 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(129); @@ -821,39 +821,39 @@ templates); } void TypeParameterList( -#line 2011 "cs.ATG" +#line 2013 "cs.ATG" List templates) { -#line 2013 "cs.ATG" +#line 2015 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2017 "cs.ATG" +#line 2019 "cs.ATG" out section); -#line 2017 "cs.ATG" +#line 2019 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2018 "cs.ATG" +#line 2020 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2019 "cs.ATG" +#line 2021 "cs.ATG" out section); -#line 2019 "cs.ATG" +#line 2021 "cs.ATG" attributes.Add(section); } Expect(1); -#line 2020 "cs.ATG" +#line 2022 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -886,25 +886,25 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2024 "cs.ATG" +#line 2026 "cs.ATG" List templates) { -#line 2025 "cs.ATG" +#line 2027 "cs.ATG" string name = ""; TypeReference type; Expect(1); -#line 2027 "cs.ATG" +#line 2029 "cs.ATG" if (t.val != "where") Error("where expected"); Expect(1); -#line 2028 "cs.ATG" +#line 2030 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2030 "cs.ATG" +#line 2032 "cs.ATG" out type); -#line 2031 "cs.ATG" +#line 2033 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -917,10 +917,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2040 "cs.ATG" +#line 2042 "cs.ATG" out type); -#line 2041 "cs.ATG" +#line 2043 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1256,33 +1256,33 @@ out r, canBeUnbound); } void TypeName( -#line 1954 "cs.ATG" +#line 1956 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 1955 "cs.ATG" +#line 1957 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 1960 "cs.ATG" +#line 1962 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { lexer.NextToken(); -#line 1961 "cs.ATG" +#line 1963 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 1964 "cs.ATG" +#line 1966 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 1965 "cs.ATG" +#line 1967 "cs.ATG" out typeArguments, canBeUnbound); } -#line 1967 "cs.ATG" +#line 1969 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1293,22 +1293,22 @@ out typeArguments, canBeUnbound); } while ( -#line 1976 "cs.ATG" +#line 1978 "cs.ATG" DotAndIdent()) { Expect(15); -#line 1977 "cs.ATG" +#line 1979 "cs.ATG" typeArguments = null; Qualident( -#line 1978 "cs.ATG" +#line 1980 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 1979 "cs.ATG" +#line 1981 "cs.ATG" out typeArguments, canBeUnbound); } -#line 1980 "cs.ATG" +#line 1982 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } } @@ -1404,23 +1404,23 @@ la.kind == Tokens.Identifier && la.val == "partial") { } void ClassMemberDecl( -#line 984 "cs.ATG" +#line 985 "cs.ATG" ModifierList m, List attributes) { -#line 985 "cs.ATG" +#line 986 "cs.ATG" Statement stmt = null; if (StartOf(16)) { StructMemberDecl( -#line 987 "cs.ATG" +#line 988 "cs.ATG" m, attributes); } else if (la.kind == 27) { -#line 988 "cs.ATG" +#line 989 "cs.ATG" m.Check(Modifiers.Destructors); Location startPos = t.Location; lexer.NextToken(); Expect(1); -#line 989 "cs.ATG" +#line 990 "cs.ATG" DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); d.Modifier = m.Modifier; d.StartLocation = m.GetDeclarationLocation(startPos); @@ -1428,17 +1428,17 @@ m, attributes); Expect(20); Expect(21); -#line 993 "cs.ATG" +#line 994 "cs.ATG" d.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 993 "cs.ATG" +#line 994 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(137); -#line 994 "cs.ATG" +#line 995 "cs.ATG" d.Body = (BlockStatement)stmt; compilationUnit.AddChild(d); @@ -1619,78 +1619,87 @@ out explicitInterface, false); #line 777 "cs.ATG" eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; - if (la.kind == 16) { + if (la.kind == 3) { lexer.NextToken(); + Expr( +#line 778 "cs.ATG" +out expr); #line 778 "cs.ATG" + eventDecl.Initializer = expr; + } + if (la.kind == 16) { + lexer.NextToken(); + +#line 779 "cs.ATG" eventDecl.BodyStart = t.Location; EventAccessorDecls( -#line 779 "cs.ATG" +#line 780 "cs.ATG" out addBlock, out removeBlock); Expect(17); -#line 780 "cs.ATG" +#line 781 "cs.ATG" eventDecl.BodyEnd = t.EndLocation; } if (la.kind == 11) { lexer.NextToken(); } -#line 783 "cs.ATG" +#line 784 "cs.ATG" compilationUnit.BlockEnd(); eventDecl.AddRegion = addBlock; eventDecl.RemoveRegion = removeBlock; } else if ( -#line 789 "cs.ATG" +#line 790 "cs.ATG" IdentAndLPar()) { -#line 789 "cs.ATG" +#line 790 "cs.ATG" m.Check(Modifiers.Constructors | Modifiers.StaticConstructors); Expect(1); -#line 790 "cs.ATG" +#line 791 "cs.ATG" string name = t.val; Location startPos = t.Location; Expect(20); if (StartOf(10)) { -#line 790 "cs.ATG" +#line 791 "cs.ATG" m.Check(Modifiers.Constructors); FormalParameterList( -#line 791 "cs.ATG" +#line 792 "cs.ATG" p); } Expect(21); -#line 793 "cs.ATG" +#line 794 "cs.ATG" ConstructorInitializer init = null; if (la.kind == 9) { -#line 794 "cs.ATG" +#line 795 "cs.ATG" m.Check(Modifiers.Constructors); ConstructorInitializer( -#line 795 "cs.ATG" +#line 796 "cs.ATG" out init); } -#line 797 "cs.ATG" +#line 798 "cs.ATG" ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); cd.StartLocation = startPos; cd.EndLocation = t.EndLocation; if (la.kind == 16) { Block( -#line 802 "cs.ATG" +#line 803 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(142); -#line 802 "cs.ATG" +#line 803 "cs.ATG" cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); } else if (la.kind == 69 || la.kind == 79) { -#line 805 "cs.ATG" +#line 806 "cs.ATG" m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); bool isImplicit = true; @@ -1699,45 +1708,45 @@ out stmt); if (la.kind == 79) { lexer.NextToken(); -#line 810 "cs.ATG" +#line 811 "cs.ATG" startPos = t.Location; } else { lexer.NextToken(); -#line 810 "cs.ATG" +#line 811 "cs.ATG" isImplicit = false; startPos = t.Location; } Expect(91); Type( -#line 811 "cs.ATG" +#line 812 "cs.ATG" out type); -#line 811 "cs.ATG" +#line 812 "cs.ATG" TypeReference operatorType = type; Expect(20); Type( -#line 812 "cs.ATG" +#line 813 "cs.ATG" out type); Expect(1); -#line 812 "cs.ATG" +#line 813 "cs.ATG" string varName = t.val; Expect(21); -#line 813 "cs.ATG" +#line 814 "cs.ATG" Location endPos = t.Location; if (la.kind == 16) { Block( -#line 814 "cs.ATG" +#line 815 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); -#line 814 "cs.ATG" +#line 815 "cs.ATG" stmt = null; } else SynErr(143); -#line 817 "cs.ATG" +#line 818 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(type, varName)); OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, @@ -1753,61 +1762,61 @@ out stmt); } else if (StartOf(17)) { TypeDecl( -#line 833 "cs.ATG" +#line 834 "cs.ATG" m, attributes); } else if (StartOf(9)) { Type( -#line 835 "cs.ATG" +#line 836 "cs.ATG" out type); -#line 835 "cs.ATG" +#line 836 "cs.ATG" Location startPos = t.Location; if (la.kind == 91) { -#line 837 "cs.ATG" +#line 838 "cs.ATG" OverloadableOperatorType op; m.Check(Modifiers.Operators); if (m.isNone) Error("at least one modifier must be set"); lexer.NextToken(); OverloadableOperator( -#line 841 "cs.ATG" +#line 842 "cs.ATG" out op); -#line 841 "cs.ATG" +#line 842 "cs.ATG" TypeReference firstType, secondType = null; string secondName = null; Expect(20); Type( -#line 842 "cs.ATG" +#line 843 "cs.ATG" out firstType); Expect(1); -#line 842 "cs.ATG" +#line 843 "cs.ATG" string firstName = t.val; if (la.kind == 14) { lexer.NextToken(); Type( -#line 843 "cs.ATG" +#line 844 "cs.ATG" out secondType); Expect(1); -#line 843 "cs.ATG" +#line 844 "cs.ATG" secondName = t.val; } else if (la.kind == 21) { } else SynErr(144); -#line 851 "cs.ATG" +#line 852 "cs.ATG" Location endPos = t.Location; Expect(21); if (la.kind == 16) { Block( -#line 852 "cs.ATG" +#line 853 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(145); -#line 854 "cs.ATG" +#line 855 "cs.ATG" List parameters = new List(); parameters.Add(new ParameterDeclarationExpression(firstType, firstName)); if (secondType != null) { @@ -1824,75 +1833,75 @@ out stmt); compilationUnit.AddChild(operatorDeclaration); } else if ( -#line 871 "cs.ATG" +#line 872 "cs.ATG" IsVarDecl()) { -#line 872 "cs.ATG" +#line 873 "cs.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); if ( -#line 876 "cs.ATG" +#line 877 "cs.ATG" m.Contains(Modifiers.Fixed)) { VariableDeclarator( -#line 877 "cs.ATG" +#line 878 "cs.ATG" variableDeclarators); Expect(18); Expr( -#line 879 "cs.ATG" +#line 880 "cs.ATG" out expr); -#line 879 "cs.ATG" +#line 880 "cs.ATG" if (variableDeclarators.Count > 0) variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr; Expect(19); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 883 "cs.ATG" +#line 884 "cs.ATG" variableDeclarators); Expect(18); Expr( -#line 885 "cs.ATG" +#line 886 "cs.ATG" out expr); -#line 885 "cs.ATG" +#line 886 "cs.ATG" if (variableDeclarators.Count > 0) variableDeclarators[variableDeclarators.Count-1].FixedArrayInitialization = expr; Expect(19); } } else if (la.kind == 1) { VariableDeclarator( -#line 890 "cs.ATG" +#line 891 "cs.ATG" variableDeclarators); while (la.kind == 14) { lexer.NextToken(); VariableDeclarator( -#line 891 "cs.ATG" +#line 892 "cs.ATG" variableDeclarators); } } else SynErr(146); Expect(11); -#line 893 "cs.ATG" +#line 894 "cs.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); } else if (la.kind == 110) { -#line 896 "cs.ATG" +#line 897 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(18); FormalParameterList( -#line 897 "cs.ATG" +#line 898 "cs.ATG" p); Expect(19); -#line 897 "cs.ATG" +#line 898 "cs.ATG" Location endLocation = t.EndLocation; Expect(16); -#line 898 "cs.ATG" +#line 899 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = startPos; indexer.EndLocation = endLocation; @@ -1901,58 +1910,58 @@ p); PropertySetRegion setRegion; AccessorDecls( -#line 905 "cs.ATG" +#line 906 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 906 "cs.ATG" +#line 907 "cs.ATG" indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; indexer.SetRegion = setRegion; compilationUnit.AddChild(indexer); } else if ( -#line 911 "cs.ATG" +#line 912 "cs.ATG" la.kind == Tokens.Identifier) { if ( -#line 912 "cs.ATG" +#line 913 "cs.ATG" IsExplicitInterfaceImplementation()) { TypeName( -#line 913 "cs.ATG" +#line 914 "cs.ATG" out explicitInterface, false); -#line 914 "cs.ATG" +#line 915 "cs.ATG" if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) { qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); } } else if (la.kind == 1) { lexer.NextToken(); -#line 917 "cs.ATG" +#line 918 "cs.ATG" qualident = t.val; } else SynErr(147); -#line 919 "cs.ATG" +#line 920 "cs.ATG" Location qualIdentEndLocation = t.EndLocation; if (la.kind == 16 || la.kind == 20 || la.kind == 23) { if (la.kind == 20 || la.kind == 23) { -#line 923 "cs.ATG" +#line 924 "cs.ATG" m.Check(Modifiers.PropertysEventsMethods); if (la.kind == 23) { TypeParameterList( -#line 925 "cs.ATG" +#line 926 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 926 "cs.ATG" +#line 927 "cs.ATG" p); } Expect(21); -#line 927 "cs.ATG" +#line 928 "cs.ATG" MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, m.Modifier, type, @@ -1966,26 +1975,26 @@ p); compilationUnit.AddChild(methodDeclaration); while ( -#line 939 "cs.ATG" +#line 940 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 939 "cs.ATG" +#line 940 "cs.ATG" templates); } if (la.kind == 16) { Block( -#line 940 "cs.ATG" +#line 941 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(148); -#line 940 "cs.ATG" +#line 941 "cs.ATG" methodDeclaration.Body = (BlockStatement)stmt; } else { lexer.NextToken(); -#line 943 "cs.ATG" +#line 944 "cs.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); if (explicitInterface != null) pDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); @@ -1996,11 +2005,11 @@ out stmt); PropertySetRegion setRegion; AccessorDecls( -#line 952 "cs.ATG" +#line 953 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 954 "cs.ATG" +#line 955 "cs.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2009,17 +2018,17 @@ out getRegion, out setRegion); } } else if (la.kind == 15) { -#line 962 "cs.ATG" +#line 963 "cs.ATG" m.Check(Modifiers.Indexers); lexer.NextToken(); Expect(110); Expect(18); FormalParameterList( -#line 963 "cs.ATG" +#line 964 "cs.ATG" p); Expect(19); -#line 964 "cs.ATG" +#line 965 "cs.ATG" IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes); indexer.StartLocation = m.GetDeclarationLocation(startPos); indexer.EndLocation = t.EndLocation; @@ -2030,14 +2039,14 @@ p); Expect(16); -#line 972 "cs.ATG" +#line 973 "cs.ATG" Location bodyStart = t.Location; AccessorDecls( -#line 973 "cs.ATG" +#line 974 "cs.ATG" out getRegion, out setRegion); Expect(17); -#line 974 "cs.ATG" +#line 975 "cs.ATG" indexer.BodyStart = bodyStart; indexer.BodyEnd = t.EndLocation; indexer.GetRegion = getRegion; @@ -2051,7 +2060,7 @@ out getRegion, out setRegion); void InterfaceMemberDecl() { -#line 1001 "cs.ATG" +#line 1002 "cs.ATG" TypeReference type; AttributeSection section; @@ -2066,51 +2075,51 @@ out getRegion, out setRegion); while (la.kind == 18) { AttributeSection( -#line 1014 "cs.ATG" +#line 1015 "cs.ATG" out section); -#line 1014 "cs.ATG" +#line 1015 "cs.ATG" attributes.Add(section); } if (la.kind == 88) { lexer.NextToken(); -#line 1015 "cs.ATG" +#line 1016 "cs.ATG" mod = Modifiers.New; startLocation = t.Location; } if ( -#line 1018 "cs.ATG" +#line 1019 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 1018 "cs.ATG" +#line 1019 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Expect(1); -#line 1018 "cs.ATG" +#line 1019 "cs.ATG" name = t.val; if (la.kind == 23) { TypeParameterList( -#line 1019 "cs.ATG" +#line 1020 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1020 "cs.ATG" +#line 1021 "cs.ATG" parameters); } Expect(21); while ( -#line 1021 "cs.ATG" +#line 1022 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1021 "cs.ATG" +#line 1022 "cs.ATG" templates); } Expect(11); -#line 1023 "cs.ATG" +#line 1024 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2120,39 +2129,39 @@ templates); } else if (StartOf(18)) { if (StartOf(9)) { Type( -#line 1030 "cs.ATG" +#line 1031 "cs.ATG" out type); -#line 1030 "cs.ATG" +#line 1031 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; if (la.kind == 1) { lexer.NextToken(); -#line 1032 "cs.ATG" +#line 1033 "cs.ATG" name = t.val; Location qualIdentEndLocation = t.EndLocation; if (la.kind == 20 || la.kind == 23) { if (la.kind == 23) { TypeParameterList( -#line 1036 "cs.ATG" +#line 1037 "cs.ATG" templates); } Expect(20); if (StartOf(10)) { FormalParameterList( -#line 1037 "cs.ATG" +#line 1038 "cs.ATG" parameters); } Expect(21); while ( -#line 1039 "cs.ATG" +#line 1040 "cs.ATG" IdentIsWhere()) { TypeParameterConstraintsClause( -#line 1039 "cs.ATG" +#line 1040 "cs.ATG" templates); } Expect(11); -#line 1040 "cs.ATG" +#line 1041 "cs.ATG" MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes); md.StartLocation = startLocation; md.EndLocation = t.EndLocation; @@ -2161,72 +2170,72 @@ templates); } else if (la.kind == 16) { -#line 1047 "cs.ATG" +#line 1048 "cs.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); lexer.NextToken(); -#line 1048 "cs.ATG" +#line 1049 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1048 "cs.ATG" +#line 1049 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1048 "cs.ATG" +#line 1049 "cs.ATG" pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; } else SynErr(152); } else if (la.kind == 110) { lexer.NextToken(); Expect(18); FormalParameterList( -#line 1051 "cs.ATG" +#line 1052 "cs.ATG" parameters); Expect(19); -#line 1051 "cs.ATG" +#line 1052 "cs.ATG" Location bracketEndLocation = t.EndLocation; -#line 1051 "cs.ATG" +#line 1052 "cs.ATG" IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes); compilationUnit.AddChild(id); Expect(16); -#line 1052 "cs.ATG" +#line 1053 "cs.ATG" Location bodyStart = t.Location; InterfaceAccessors( -#line 1052 "cs.ATG" +#line 1053 "cs.ATG" out getBlock, out setBlock); Expect(17); -#line 1052 "cs.ATG" +#line 1053 "cs.ATG" id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; } else SynErr(153); } else { lexer.NextToken(); -#line 1055 "cs.ATG" +#line 1056 "cs.ATG" if (startLocation.X == -1) startLocation = t.Location; Type( -#line 1055 "cs.ATG" +#line 1056 "cs.ATG" out type); Expect(1); -#line 1055 "cs.ATG" +#line 1056 "cs.ATG" EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null); compilationUnit.AddChild(ed); Expect(11); -#line 1058 "cs.ATG" +#line 1059 "cs.ATG" ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; } } else SynErr(154); } void EnumMemberDecl( -#line 1063 "cs.ATG" +#line 1064 "cs.ATG" out FieldDeclaration f) { -#line 1065 "cs.ATG" +#line 1066 "cs.ATG" Expression expr = null; List attributes = new List(); AttributeSection section = null; @@ -2234,15 +2243,15 @@ out FieldDeclaration f) { while (la.kind == 18) { AttributeSection( -#line 1071 "cs.ATG" +#line 1072 "cs.ATG" out section); -#line 1071 "cs.ATG" +#line 1072 "cs.ATG" attributes.Add(section); } Expect(1); -#line 1072 "cs.ATG" +#line 1073 "cs.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2251,10 +2260,10 @@ out section); if (la.kind == 3) { lexer.NextToken(); Expr( -#line 1077 "cs.ATG" +#line 1078 "cs.ATG" out expr); -#line 1077 "cs.ATG" +#line 1078 "cs.ATG" varDecl.Initializer = expr; } } @@ -2364,14 +2373,14 @@ out name); } void NullableQuestionMark( -#line 1985 "cs.ATG" +#line 1987 "cs.ATG" ref TypeReference typeRef) { -#line 1986 "cs.ATG" +#line 1988 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 1990 "cs.ATG" +#line 1992 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments); @@ -2461,11 +2470,11 @@ out ModifierList m) { } void Block( -#line 1202 "cs.ATG" +#line 1203 "cs.ATG" out Statement stmt) { Expect(16); -#line 1204 "cs.ATG" +#line 1205 "cs.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.EndLocation; compilationUnit.BlockStart(blockStmt); @@ -2476,7 +2485,7 @@ out Statement stmt) { } Expect(17); -#line 1211 "cs.ATG" +#line 1212 "cs.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2484,10 +2493,10 @@ out Statement stmt) { } void EventAccessorDecls( -#line 1137 "cs.ATG" +#line 1138 "cs.ATG" out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { -#line 1138 "cs.ATG" +#line 1139 "cs.ATG" AttributeSection section; List attributes = new List(); Statement stmt; @@ -2496,102 +2505,102 @@ out EventAddRegion addBlock, out EventRemoveRegion removeBlock) { while (la.kind == 18) { AttributeSection( -#line 1145 "cs.ATG" +#line 1146 "cs.ATG" out section); -#line 1145 "cs.ATG" +#line 1146 "cs.ATG" attributes.Add(section); } if ( -#line 1147 "cs.ATG" +#line 1148 "cs.ATG" IdentIsAdd()) { -#line 1147 "cs.ATG" +#line 1148 "cs.ATG" addBlock = new EventAddRegion(attributes); AddAccessorDecl( -#line 1148 "cs.ATG" +#line 1149 "cs.ATG" out stmt); -#line 1148 "cs.ATG" +#line 1149 "cs.ATG" attributes = new List(); addBlock.Block = (BlockStatement)stmt; while (la.kind == 18) { AttributeSection( -#line 1149 "cs.ATG" +#line 1150 "cs.ATG" out section); -#line 1149 "cs.ATG" +#line 1150 "cs.ATG" attributes.Add(section); } RemoveAccessorDecl( -#line 1150 "cs.ATG" +#line 1151 "cs.ATG" out stmt); -#line 1150 "cs.ATG" +#line 1151 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; } else if ( -#line 1151 "cs.ATG" +#line 1152 "cs.ATG" IdentIsRemove()) { RemoveAccessorDecl( -#line 1152 "cs.ATG" +#line 1153 "cs.ATG" out stmt); -#line 1152 "cs.ATG" +#line 1153 "cs.ATG" removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List(); while (la.kind == 18) { AttributeSection( -#line 1153 "cs.ATG" +#line 1154 "cs.ATG" out section); -#line 1153 "cs.ATG" +#line 1154 "cs.ATG" attributes.Add(section); } AddAccessorDecl( -#line 1154 "cs.ATG" +#line 1155 "cs.ATG" out stmt); -#line 1154 "cs.ATG" +#line 1155 "cs.ATG" addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; } else if (la.kind == 1) { lexer.NextToken(); -#line 1155 "cs.ATG" +#line 1156 "cs.ATG" Error("add or remove accessor declaration expected"); } else SynErr(159); } void ConstructorInitializer( -#line 1233 "cs.ATG" +#line 1234 "cs.ATG" out ConstructorInitializer ci) { -#line 1234 "cs.ATG" +#line 1235 "cs.ATG" Expression expr; ci = new ConstructorInitializer(); Expect(9); if (la.kind == 50) { lexer.NextToken(); -#line 1238 "cs.ATG" +#line 1239 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.Base; } else if (la.kind == 110) { lexer.NextToken(); -#line 1239 "cs.ATG" +#line 1240 "cs.ATG" ci.ConstructorInitializerType = ConstructorInitializerType.This; } else SynErr(160); Expect(20); if (StartOf(21)) { Argument( -#line 1242 "cs.ATG" +#line 1243 "cs.ATG" out expr); -#line 1242 "cs.ATG" +#line 1243 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1242 "cs.ATG" +#line 1243 "cs.ATG" out expr); -#line 1242 "cs.ATG" +#line 1243 "cs.ATG" if (expr != null) { ci.Arguments.Add(expr); } } } @@ -2599,161 +2608,161 @@ out expr); } void OverloadableOperator( -#line 1254 "cs.ATG" +#line 1255 "cs.ATG" out OverloadableOperatorType op) { -#line 1255 "cs.ATG" +#line 1256 "cs.ATG" op = OverloadableOperatorType.None; switch (la.kind) { case 4: { lexer.NextToken(); -#line 1257 "cs.ATG" +#line 1258 "cs.ATG" op = OverloadableOperatorType.Add; break; } case 5: { lexer.NextToken(); -#line 1258 "cs.ATG" +#line 1259 "cs.ATG" op = OverloadableOperatorType.Subtract; break; } case 24: { lexer.NextToken(); -#line 1260 "cs.ATG" +#line 1261 "cs.ATG" op = OverloadableOperatorType.Not; break; } case 27: { lexer.NextToken(); -#line 1261 "cs.ATG" +#line 1262 "cs.ATG" op = OverloadableOperatorType.BitNot; break; } case 31: { lexer.NextToken(); -#line 1263 "cs.ATG" +#line 1264 "cs.ATG" op = OverloadableOperatorType.Increment; break; } case 32: { lexer.NextToken(); -#line 1264 "cs.ATG" +#line 1265 "cs.ATG" op = OverloadableOperatorType.Decrement; break; } case 112: { lexer.NextToken(); -#line 1266 "cs.ATG" +#line 1267 "cs.ATG" op = OverloadableOperatorType.IsTrue; break; } case 71: { lexer.NextToken(); -#line 1267 "cs.ATG" +#line 1268 "cs.ATG" op = OverloadableOperatorType.IsFalse; break; } case 6: { lexer.NextToken(); -#line 1269 "cs.ATG" +#line 1270 "cs.ATG" op = OverloadableOperatorType.Multiply; break; } case 7: { lexer.NextToken(); -#line 1270 "cs.ATG" +#line 1271 "cs.ATG" op = OverloadableOperatorType.Divide; break; } case 8: { lexer.NextToken(); -#line 1271 "cs.ATG" +#line 1272 "cs.ATG" op = OverloadableOperatorType.Modulus; break; } case 28: { lexer.NextToken(); -#line 1273 "cs.ATG" +#line 1274 "cs.ATG" op = OverloadableOperatorType.BitwiseAnd; break; } case 29: { lexer.NextToken(); -#line 1274 "cs.ATG" +#line 1275 "cs.ATG" op = OverloadableOperatorType.BitwiseOr; break; } case 30: { lexer.NextToken(); -#line 1275 "cs.ATG" +#line 1276 "cs.ATG" op = OverloadableOperatorType.ExclusiveOr; break; } case 37: { lexer.NextToken(); -#line 1277 "cs.ATG" +#line 1278 "cs.ATG" op = OverloadableOperatorType.ShiftLeft; break; } case 33: { lexer.NextToken(); -#line 1278 "cs.ATG" +#line 1279 "cs.ATG" op = OverloadableOperatorType.Equality; break; } case 34: { lexer.NextToken(); -#line 1279 "cs.ATG" +#line 1280 "cs.ATG" op = OverloadableOperatorType.InEquality; break; } case 23: { lexer.NextToken(); -#line 1280 "cs.ATG" +#line 1281 "cs.ATG" op = OverloadableOperatorType.LessThan; break; } case 35: { lexer.NextToken(); -#line 1281 "cs.ATG" +#line 1282 "cs.ATG" op = OverloadableOperatorType.GreaterThanOrEqual; break; } case 36: { lexer.NextToken(); -#line 1282 "cs.ATG" +#line 1283 "cs.ATG" op = OverloadableOperatorType.LessThanOrEqual; break; } case 22: { lexer.NextToken(); -#line 1283 "cs.ATG" +#line 1284 "cs.ATG" op = OverloadableOperatorType.GreaterThan; if (la.kind == 22) { lexer.NextToken(); -#line 1283 "cs.ATG" +#line 1284 "cs.ATG" op = OverloadableOperatorType.ShiftRight; } break; @@ -2763,34 +2772,34 @@ out OverloadableOperatorType op) { } void VariableDeclarator( -#line 1195 "cs.ATG" +#line 1196 "cs.ATG" List fieldDeclaration) { -#line 1196 "cs.ATG" +#line 1197 "cs.ATG" Expression expr = null; Expect(1); -#line 1198 "cs.ATG" +#line 1199 "cs.ATG" VariableDeclaration f = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1199 "cs.ATG" +#line 1200 "cs.ATG" out expr); -#line 1199 "cs.ATG" +#line 1200 "cs.ATG" f.Initializer = expr; } -#line 1199 "cs.ATG" +#line 1200 "cs.ATG" fieldDeclaration.Add(f); } void AccessorDecls( -#line 1081 "cs.ATG" +#line 1082 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1083 "cs.ATG" +#line 1084 "cs.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2799,96 +2808,96 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1090 "cs.ATG" +#line 1091 "cs.ATG" out section); -#line 1090 "cs.ATG" +#line 1091 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1091 "cs.ATG" +#line 1092 "cs.ATG" out modifiers); } if ( -#line 1093 "cs.ATG" +#line 1094 "cs.ATG" IdentIsGet()) { GetAccessorDecl( -#line 1094 "cs.ATG" +#line 1095 "cs.ATG" out getBlock, attributes); -#line 1095 "cs.ATG" +#line 1096 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1096 "cs.ATG" +#line 1097 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1097 "cs.ATG" +#line 1098 "cs.ATG" out section); -#line 1097 "cs.ATG" +#line 1098 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1098 "cs.ATG" +#line 1099 "cs.ATG" out modifiers); } SetAccessorDecl( -#line 1099 "cs.ATG" +#line 1100 "cs.ATG" out setBlock, attributes); -#line 1100 "cs.ATG" +#line 1101 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } } } else if ( -#line 1102 "cs.ATG" +#line 1103 "cs.ATG" IdentIsSet()) { SetAccessorDecl( -#line 1103 "cs.ATG" +#line 1104 "cs.ATG" out setBlock, attributes); -#line 1104 "cs.ATG" +#line 1105 "cs.ATG" if (modifiers != null) {setBlock.Modifier = modifiers.Modifier; } if (StartOf(22)) { -#line 1105 "cs.ATG" +#line 1106 "cs.ATG" attributes = new List(); modifiers = null; while (la.kind == 18) { AttributeSection( -#line 1106 "cs.ATG" +#line 1107 "cs.ATG" out section); -#line 1106 "cs.ATG" +#line 1107 "cs.ATG" attributes.Add(section); } if (la.kind == 83 || la.kind == 95 || la.kind == 96) { AccessorModifiers( -#line 1107 "cs.ATG" +#line 1108 "cs.ATG" out modifiers); } GetAccessorDecl( -#line 1108 "cs.ATG" +#line 1109 "cs.ATG" out getBlock, attributes); -#line 1109 "cs.ATG" +#line 1110 "cs.ATG" if (modifiers != null) {getBlock.Modifier = modifiers.Modifier; } } } else if (la.kind == 1) { lexer.NextToken(); -#line 1111 "cs.ATG" +#line 1112 "cs.ATG" Error("get or set accessor declaration expected"); } else SynErr(162); } void InterfaceAccessors( -#line 1159 "cs.ATG" +#line 1160 "cs.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1161 "cs.ATG" +#line 1162 "cs.ATG" AttributeSection section; List attributes = new List(); getBlock = null; setBlock = null; @@ -2896,274 +2905,274 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 18) { AttributeSection( -#line 1167 "cs.ATG" +#line 1168 "cs.ATG" out section); -#line 1167 "cs.ATG" +#line 1168 "cs.ATG" attributes.Add(section); } -#line 1168 "cs.ATG" +#line 1169 "cs.ATG" Location startLocation = la.Location; if ( -#line 1170 "cs.ATG" +#line 1171 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1170 "cs.ATG" +#line 1171 "cs.ATG" getBlock = new PropertyGetRegion(null, attributes); } else if ( -#line 1171 "cs.ATG" +#line 1172 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1171 "cs.ATG" +#line 1172 "cs.ATG" setBlock = new PropertySetRegion(null, attributes); } else if (la.kind == 1) { lexer.NextToken(); -#line 1172 "cs.ATG" +#line 1173 "cs.ATG" Error("set or get expected"); } else SynErr(163); Expect(11); -#line 1175 "cs.ATG" +#line 1176 "cs.ATG" if (getBlock != null) { getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } if (setBlock != null) { setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } attributes = new List(); if (la.kind == 1 || la.kind == 18) { while (la.kind == 18) { AttributeSection( -#line 1179 "cs.ATG" +#line 1180 "cs.ATG" out section); -#line 1179 "cs.ATG" +#line 1180 "cs.ATG" attributes.Add(section); } -#line 1180 "cs.ATG" +#line 1181 "cs.ATG" startLocation = la.Location; if ( -#line 1182 "cs.ATG" +#line 1183 "cs.ATG" IdentIsGet()) { Expect(1); -#line 1182 "cs.ATG" +#line 1183 "cs.ATG" if (getBlock != null) Error("get already declared"); else { getBlock = new PropertyGetRegion(null, attributes); lastBlock = getBlock; } } else if ( -#line 1185 "cs.ATG" +#line 1186 "cs.ATG" IdentIsSet()) { Expect(1); -#line 1185 "cs.ATG" +#line 1186 "cs.ATG" if (setBlock != null) Error("set already declared"); else { setBlock = new PropertySetRegion(null, attributes); lastBlock = setBlock; } } else if (la.kind == 1) { lexer.NextToken(); -#line 1188 "cs.ATG" +#line 1189 "cs.ATG" Error("set or get expected"); } else SynErr(164); Expect(11); -#line 1191 "cs.ATG" +#line 1192 "cs.ATG" if (lastBlock != null) { lastBlock.StartLocation = startLocation; lastBlock.EndLocation = t.EndLocation; } } } void GetAccessorDecl( -#line 1115 "cs.ATG" +#line 1116 "cs.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1116 "cs.ATG" +#line 1117 "cs.ATG" Statement stmt = null; Expect(1); -#line 1119 "cs.ATG" +#line 1120 "cs.ATG" if (t.val != "get") Error("get expected"); -#line 1120 "cs.ATG" +#line 1121 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1121 "cs.ATG" +#line 1122 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(165); -#line 1122 "cs.ATG" +#line 1123 "cs.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); -#line 1123 "cs.ATG" +#line 1124 "cs.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; } void SetAccessorDecl( -#line 1126 "cs.ATG" +#line 1127 "cs.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1127 "cs.ATG" +#line 1128 "cs.ATG" Statement stmt = null; Expect(1); -#line 1130 "cs.ATG" +#line 1131 "cs.ATG" if (t.val != "set") Error("set expected"); -#line 1131 "cs.ATG" +#line 1132 "cs.ATG" Location startLocation = t.Location; if (la.kind == 16) { Block( -#line 1132 "cs.ATG" +#line 1133 "cs.ATG" out stmt); } else if (la.kind == 11) { lexer.NextToken(); } else SynErr(166); -#line 1133 "cs.ATG" +#line 1134 "cs.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); -#line 1134 "cs.ATG" +#line 1135 "cs.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; } void AddAccessorDecl( -#line 1217 "cs.ATG" +#line 1218 "cs.ATG" out Statement stmt) { -#line 1218 "cs.ATG" +#line 1219 "cs.ATG" stmt = null; Expect(1); -#line 1221 "cs.ATG" +#line 1222 "cs.ATG" if (t.val != "add") Error("add expected"); Block( -#line 1222 "cs.ATG" +#line 1223 "cs.ATG" out stmt); } void RemoveAccessorDecl( -#line 1225 "cs.ATG" +#line 1226 "cs.ATG" out Statement stmt) { -#line 1226 "cs.ATG" +#line 1227 "cs.ATG" stmt = null; Expect(1); -#line 1229 "cs.ATG" +#line 1230 "cs.ATG" if (t.val != "remove") Error("remove expected"); Block( -#line 1230 "cs.ATG" +#line 1231 "cs.ATG" out stmt); } void VariableInitializer( -#line 1246 "cs.ATG" +#line 1247 "cs.ATG" out Expression initializerExpression) { -#line 1247 "cs.ATG" +#line 1248 "cs.ATG" TypeReference type = null; Expression expr = null; initializerExpression = null; if (StartOf(5)) { Expr( -#line 1249 "cs.ATG" +#line 1250 "cs.ATG" out initializerExpression); } else if (la.kind == 16) { ArrayInitializer( -#line 1250 "cs.ATG" +#line 1251 "cs.ATG" out initializerExpression); } else if (la.kind == 105) { lexer.NextToken(); Type( -#line 1251 "cs.ATG" +#line 1252 "cs.ATG" out type); Expect(18); Expr( -#line 1251 "cs.ATG" +#line 1252 "cs.ATG" out expr); Expect(19); -#line 1251 "cs.ATG" +#line 1252 "cs.ATG" initializerExpression = new StackAllocExpression(type, expr); } else SynErr(167); } void Statement() { -#line 1363 "cs.ATG" +#line 1364 "cs.ATG" TypeReference type; Expression expr; Statement stmt = null; Location startPos = la.Location; if ( -#line 1371 "cs.ATG" +#line 1372 "cs.ATG" IsLabel()) { Expect(1); -#line 1371 "cs.ATG" +#line 1372 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 59) { lexer.NextToken(); Type( -#line 1374 "cs.ATG" +#line 1375 "cs.ATG" out type); -#line 1374 "cs.ATG" +#line 1375 "cs.ATG" LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; Expect(1); -#line 1375 "cs.ATG" +#line 1376 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1376 "cs.ATG" +#line 1377 "cs.ATG" out expr); -#line 1376 "cs.ATG" +#line 1377 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1377 "cs.ATG" +#line 1378 "cs.ATG" ident = t.val; Expect(3); Expr( -#line 1377 "cs.ATG" +#line 1378 "cs.ATG" out expr); -#line 1377 "cs.ATG" +#line 1378 "cs.ATG" var.Variables.Add(new VariableDeclaration(ident, expr)); } Expect(11); -#line 1378 "cs.ATG" +#line 1379 "cs.ATG" compilationUnit.AddChild(var); } else if ( -#line 1380 "cs.ATG" +#line 1381 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1380 "cs.ATG" +#line 1381 "cs.ATG" out stmt); Expect(11); -#line 1380 "cs.ATG" +#line 1381 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(23)) { EmbeddedStatement( -#line 1381 "cs.ATG" +#line 1382 "cs.ATG" out stmt); -#line 1381 "cs.ATG" +#line 1382 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(168); -#line 1387 "cs.ATG" +#line 1388 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3172,10 +3181,10 @@ out stmt); } void Argument( -#line 1286 "cs.ATG" +#line 1287 "cs.ATG" out Expression argumentexpr) { -#line 1288 "cs.ATG" +#line 1289 "cs.ATG" Expression expr; FieldDirection fd = FieldDirection.None; @@ -3183,48 +3192,48 @@ out Expression argumentexpr) { if (la.kind == 99) { lexer.NextToken(); -#line 1293 "cs.ATG" +#line 1294 "cs.ATG" fd = FieldDirection.Ref; } else { lexer.NextToken(); -#line 1294 "cs.ATG" +#line 1295 "cs.ATG" fd = FieldDirection.Out; } } Expr( -#line 1296 "cs.ATG" +#line 1297 "cs.ATG" out expr); -#line 1296 "cs.ATG" +#line 1297 "cs.ATG" argumentexpr = fd != FieldDirection.None ? argumentexpr = new DirectionExpression(fd, expr) : expr; } void ArrayInitializer( -#line 1316 "cs.ATG" +#line 1317 "cs.ATG" out Expression outExpr) { -#line 1318 "cs.ATG" +#line 1319 "cs.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(16); if (StartOf(24)) { VariableInitializer( -#line 1323 "cs.ATG" +#line 1324 "cs.ATG" out expr); -#line 1324 "cs.ATG" +#line 1325 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1325 "cs.ATG" +#line 1326 "cs.ATG" NotFinalComma()) { Expect(14); VariableInitializer( -#line 1326 "cs.ATG" +#line 1327 "cs.ATG" out expr); -#line 1327 "cs.ATG" +#line 1328 "cs.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } if (la.kind == 14) { @@ -3233,138 +3242,138 @@ out expr); } Expect(17); -#line 1331 "cs.ATG" +#line 1332 "cs.ATG" outExpr = initializer; } void AssignmentOperator( -#line 1299 "cs.ATG" +#line 1300 "cs.ATG" out AssignmentOperatorType op) { -#line 1300 "cs.ATG" +#line 1301 "cs.ATG" op = AssignmentOperatorType.None; if (la.kind == 3) { lexer.NextToken(); -#line 1302 "cs.ATG" +#line 1303 "cs.ATG" op = AssignmentOperatorType.Assign; } else if (la.kind == 38) { lexer.NextToken(); -#line 1303 "cs.ATG" +#line 1304 "cs.ATG" op = AssignmentOperatorType.Add; } else if (la.kind == 39) { lexer.NextToken(); -#line 1304 "cs.ATG" +#line 1305 "cs.ATG" op = AssignmentOperatorType.Subtract; } else if (la.kind == 40) { lexer.NextToken(); -#line 1305 "cs.ATG" +#line 1306 "cs.ATG" op = AssignmentOperatorType.Multiply; } else if (la.kind == 41) { lexer.NextToken(); -#line 1306 "cs.ATG" +#line 1307 "cs.ATG" op = AssignmentOperatorType.Divide; } else if (la.kind == 42) { lexer.NextToken(); -#line 1307 "cs.ATG" +#line 1308 "cs.ATG" op = AssignmentOperatorType.Modulus; } else if (la.kind == 43) { lexer.NextToken(); -#line 1308 "cs.ATG" +#line 1309 "cs.ATG" op = AssignmentOperatorType.BitwiseAnd; } else if (la.kind == 44) { lexer.NextToken(); -#line 1309 "cs.ATG" +#line 1310 "cs.ATG" op = AssignmentOperatorType.BitwiseOr; } else if (la.kind == 45) { lexer.NextToken(); -#line 1310 "cs.ATG" +#line 1311 "cs.ATG" op = AssignmentOperatorType.ExclusiveOr; } else if (la.kind == 46) { lexer.NextToken(); -#line 1311 "cs.ATG" +#line 1312 "cs.ATG" op = AssignmentOperatorType.ShiftLeft; } else if ( -#line 1312 "cs.ATG" +#line 1313 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { Expect(22); Expect(35); -#line 1313 "cs.ATG" +#line 1314 "cs.ATG" op = AssignmentOperatorType.ShiftRight; } else SynErr(169); } void LocalVariableDecl( -#line 1334 "cs.ATG" +#line 1335 "cs.ATG" out Statement stmt) { -#line 1336 "cs.ATG" +#line 1337 "cs.ATG" TypeReference type; VariableDeclaration var = null; LocalVariableDeclaration localVariableDeclaration; Type( -#line 1341 "cs.ATG" +#line 1342 "cs.ATG" out type); -#line 1341 "cs.ATG" +#line 1342 "cs.ATG" localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; LocalVariableDeclarator( -#line 1342 "cs.ATG" +#line 1343 "cs.ATG" out var); -#line 1342 "cs.ATG" +#line 1343 "cs.ATG" localVariableDeclaration.Variables.Add(var); while (la.kind == 14) { lexer.NextToken(); LocalVariableDeclarator( -#line 1343 "cs.ATG" +#line 1344 "cs.ATG" out var); -#line 1343 "cs.ATG" +#line 1344 "cs.ATG" localVariableDeclaration.Variables.Add(var); } -#line 1344 "cs.ATG" +#line 1345 "cs.ATG" stmt = localVariableDeclaration; } void LocalVariableDeclarator( -#line 1347 "cs.ATG" +#line 1348 "cs.ATG" out VariableDeclaration var) { -#line 1348 "cs.ATG" +#line 1349 "cs.ATG" Expression expr = null; Expect(1); -#line 1351 "cs.ATG" +#line 1352 "cs.ATG" var = new VariableDeclaration(t.val); if (la.kind == 3) { lexer.NextToken(); VariableInitializer( -#line 1351 "cs.ATG" +#line 1352 "cs.ATG" out expr); -#line 1351 "cs.ATG" +#line 1352 "cs.ATG" var.Initializer = expr; } } void EmbeddedStatement( -#line 1394 "cs.ATG" +#line 1395 "cs.ATG" out Statement statement) { -#line 1396 "cs.ATG" +#line 1397 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; @@ -3372,57 +3381,57 @@ out Statement statement) { if (la.kind == 16) { Block( -#line 1402 "cs.ATG" +#line 1403 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1404 "cs.ATG" +#line 1405 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1406 "cs.ATG" +#line 1407 "cs.ATG" UnCheckedAndLBrace()) { -#line 1406 "cs.ATG" +#line 1407 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 57) { lexer.NextToken(); } else if (la.kind == 117) { lexer.NextToken(); -#line 1407 "cs.ATG" +#line 1408 "cs.ATG" isChecked = false; } else SynErr(170); Block( -#line 1408 "cs.ATG" +#line 1409 "cs.ATG" out block); -#line 1408 "cs.ATG" +#line 1409 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 78) { lexer.NextToken(); -#line 1410 "cs.ATG" +#line 1411 "cs.ATG" Statement elseStatement = null; Expect(20); Expr( -#line 1411 "cs.ATG" +#line 1412 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1412 "cs.ATG" +#line 1413 "cs.ATG" out embeddedStatement); if (la.kind == 66) { lexer.NextToken(); EmbeddedStatement( -#line 1413 "cs.ATG" +#line 1414 "cs.ATG" out elseStatement); } -#line 1414 "cs.ATG" +#line 1415 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1415 "cs.ATG" +#line 1416 "cs.ATG" if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { /* else if-section (otherwise we would have a BlockStatment) */ (statement as IfElseStatement).ElseIfSections.Add( @@ -3434,99 +3443,99 @@ out elseStatement); } else if (la.kind == 109) { lexer.NextToken(); -#line 1423 "cs.ATG" +#line 1424 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1424 "cs.ATG" +#line 1425 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1425 "cs.ATG" +#line 1426 "cs.ATG" switchSections); Expect(17); -#line 1426 "cs.ATG" +#line 1427 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 124) { lexer.NextToken(); Expect(20); Expr( -#line 1428 "cs.ATG" +#line 1429 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1430 "cs.ATG" +#line 1431 "cs.ATG" out embeddedStatement); -#line 1430 "cs.ATG" +#line 1431 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 64) { lexer.NextToken(); EmbeddedStatement( -#line 1431 "cs.ATG" +#line 1432 "cs.ATG" out embeddedStatement); Expect(124); Expect(20); Expr( -#line 1432 "cs.ATG" +#line 1433 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1432 "cs.ATG" +#line 1433 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 75) { lexer.NextToken(); -#line 1433 "cs.ATG" +#line 1434 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(5)) { ForInitializer( -#line 1434 "cs.ATG" +#line 1435 "cs.ATG" out initializer); } Expect(11); if (StartOf(5)) { Expr( -#line 1435 "cs.ATG" +#line 1436 "cs.ATG" out expr); } Expect(11); if (StartOf(5)) { ForIterator( -#line 1436 "cs.ATG" +#line 1437 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1437 "cs.ATG" +#line 1438 "cs.ATG" out embeddedStatement); -#line 1437 "cs.ATG" +#line 1438 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 76) { lexer.NextToken(); Expect(20); Type( -#line 1438 "cs.ATG" +#line 1439 "cs.ATG" out type); Expect(1); -#line 1438 "cs.ATG" +#line 1439 "cs.ATG" string varName = t.val; Location start = t.Location; Expect(80); Expr( -#line 1439 "cs.ATG" +#line 1440 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1440 "cs.ATG" +#line 1441 "cs.ATG" out embeddedStatement); -#line 1440 "cs.ATG" +#line 1441 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); statement.EndLocation = t.EndLocation; @@ -3534,34 +3543,34 @@ out embeddedStatement); lexer.NextToken(); Expect(11); -#line 1444 "cs.ATG" +#line 1445 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 60) { lexer.NextToken(); Expect(11); -#line 1445 "cs.ATG" +#line 1446 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 77) { GotoStatement( -#line 1446 "cs.ATG" +#line 1447 "cs.ATG" out statement); } else if ( -#line 1447 "cs.ATG" +#line 1448 "cs.ATG" IsYieldStatement()) { Expect(1); if (la.kind == 100) { lexer.NextToken(); Expr( -#line 1447 "cs.ATG" +#line 1448 "cs.ATG" out expr); -#line 1447 "cs.ATG" +#line 1448 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 52) { lexer.NextToken(); -#line 1448 "cs.ATG" +#line 1449 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(171); Expect(11); @@ -3569,140 +3578,140 @@ out expr); lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1449 "cs.ATG" +#line 1450 "cs.ATG" out expr); } Expect(11); -#line 1449 "cs.ATG" +#line 1450 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 111) { lexer.NextToken(); if (StartOf(5)) { Expr( -#line 1450 "cs.ATG" +#line 1451 "cs.ATG" out expr); } Expect(11); -#line 1450 "cs.ATG" +#line 1451 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(5)) { StatementExpr( -#line 1453 "cs.ATG" +#line 1454 "cs.ATG" out statement); Expect(11); } else if (la.kind == 113) { TryStatement( -#line 1455 "cs.ATG" +#line 1456 "cs.ATG" out statement); } else if (la.kind == 85) { lexer.NextToken(); Expect(20); Expr( -#line 1457 "cs.ATG" +#line 1458 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1458 "cs.ATG" +#line 1459 "cs.ATG" out embeddedStatement); -#line 1458 "cs.ATG" +#line 1459 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 120) { -#line 1460 "cs.ATG" +#line 1461 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1462 "cs.ATG" +#line 1463 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1463 "cs.ATG" +#line 1464 "cs.ATG" out embeddedStatement); -#line 1463 "cs.ATG" +#line 1464 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 118) { lexer.NextToken(); Block( -#line 1465 "cs.ATG" +#line 1466 "cs.ATG" out embeddedStatement); -#line 1465 "cs.ATG" +#line 1466 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 73) { lexer.NextToken(); Expect(20); Type( -#line 1468 "cs.ATG" +#line 1469 "cs.ATG" out type); -#line 1468 "cs.ATG" +#line 1469 "cs.ATG" if (type.PointerNestingLevel == 0) Error("can only fix pointer types"); List pointerDeclarators = new List(1); Expect(1); -#line 1471 "cs.ATG" +#line 1472 "cs.ATG" string identifier = t.val; Expect(3); Expr( -#line 1472 "cs.ATG" +#line 1473 "cs.ATG" out expr); -#line 1472 "cs.ATG" +#line 1473 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); while (la.kind == 14) { lexer.NextToken(); Expect(1); -#line 1474 "cs.ATG" +#line 1475 "cs.ATG" identifier = t.val; Expect(3); Expr( -#line 1475 "cs.ATG" +#line 1476 "cs.ATG" out expr); -#line 1475 "cs.ATG" +#line 1476 "cs.ATG" pointerDeclarators.Add(new VariableDeclaration(identifier, expr)); } Expect(21); EmbeddedStatement( -#line 1477 "cs.ATG" +#line 1478 "cs.ATG" out embeddedStatement); -#line 1477 "cs.ATG" +#line 1478 "cs.ATG" statement = new FixedStatement(type, pointerDeclarators, embeddedStatement); } else SynErr(172); } void SwitchSections( -#line 1499 "cs.ATG" +#line 1500 "cs.ATG" List switchSections) { -#line 1501 "cs.ATG" +#line 1502 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1505 "cs.ATG" +#line 1506 "cs.ATG" out label); -#line 1505 "cs.ATG" +#line 1506 "cs.ATG" if (label != null) { switchSection.SwitchLabels.Add(label); } -#line 1506 "cs.ATG" +#line 1507 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(25)) { if (la.kind == 54 || la.kind == 62) { SwitchLabel( -#line 1508 "cs.ATG" +#line 1509 "cs.ATG" out label); -#line 1509 "cs.ATG" +#line 1510 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -3718,346 +3727,346 @@ out label); } } -#line 1521 "cs.ATG" +#line 1522 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1480 "cs.ATG" +#line 1481 "cs.ATG" out List initializer) { -#line 1482 "cs.ATG" +#line 1483 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1486 "cs.ATG" +#line 1487 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1486 "cs.ATG" +#line 1487 "cs.ATG" out stmt); -#line 1486 "cs.ATG" +#line 1487 "cs.ATG" initializer.Add(stmt); } else if (StartOf(5)) { StatementExpr( -#line 1487 "cs.ATG" +#line 1488 "cs.ATG" out stmt); -#line 1487 "cs.ATG" +#line 1488 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1487 "cs.ATG" +#line 1488 "cs.ATG" out stmt); -#line 1487 "cs.ATG" +#line 1488 "cs.ATG" initializer.Add(stmt); } } else SynErr(173); } void ForIterator( -#line 1490 "cs.ATG" +#line 1491 "cs.ATG" out List iterator) { -#line 1492 "cs.ATG" +#line 1493 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1496 "cs.ATG" +#line 1497 "cs.ATG" out stmt); -#line 1496 "cs.ATG" +#line 1497 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1496 "cs.ATG" +#line 1497 "cs.ATG" out stmt); -#line 1496 "cs.ATG" +#line 1497 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1574 "cs.ATG" +#line 1575 "cs.ATG" out Statement stmt) { -#line 1575 "cs.ATG" +#line 1576 "cs.ATG" Expression expr; stmt = null; Expect(77); if (la.kind == 1) { lexer.NextToken(); -#line 1579 "cs.ATG" +#line 1580 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 54) { lexer.NextToken(); Expr( -#line 1580 "cs.ATG" +#line 1581 "cs.ATG" out expr); Expect(11); -#line 1580 "cs.ATG" +#line 1581 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(11); -#line 1581 "cs.ATG" +#line 1582 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(174); } void StatementExpr( -#line 1601 "cs.ATG" +#line 1602 "cs.ATG" out Statement stmt) { -#line 1602 "cs.ATG" +#line 1603 "cs.ATG" Expression expr; Expr( -#line 1604 "cs.ATG" +#line 1605 "cs.ATG" out expr); -#line 1607 "cs.ATG" +#line 1608 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1531 "cs.ATG" +#line 1532 "cs.ATG" out Statement tryStatement) { -#line 1533 "cs.ATG" +#line 1534 "cs.ATG" Statement blockStmt = null, finallyStmt = null; List catchClauses = null; Expect(113); Block( -#line 1537 "cs.ATG" +#line 1538 "cs.ATG" out blockStmt); if (la.kind == 55) { CatchClauses( -#line 1539 "cs.ATG" +#line 1540 "cs.ATG" out catchClauses); if (la.kind == 72) { lexer.NextToken(); Block( -#line 1539 "cs.ATG" +#line 1540 "cs.ATG" out finallyStmt); } } else if (la.kind == 72) { lexer.NextToken(); Block( -#line 1540 "cs.ATG" +#line 1541 "cs.ATG" out finallyStmt); } else SynErr(175); -#line 1543 "cs.ATG" +#line 1544 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void ResourceAcquisition( -#line 1585 "cs.ATG" +#line 1586 "cs.ATG" out Statement stmt) { -#line 1587 "cs.ATG" +#line 1588 "cs.ATG" stmt = null; Expression expr; if ( -#line 1592 "cs.ATG" +#line 1593 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1592 "cs.ATG" +#line 1593 "cs.ATG" out stmt); } else if (StartOf(5)) { Expr( -#line 1593 "cs.ATG" +#line 1594 "cs.ATG" out expr); -#line 1597 "cs.ATG" +#line 1598 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(176); } void SwitchLabel( -#line 1524 "cs.ATG" +#line 1525 "cs.ATG" out CaseLabel label) { -#line 1525 "cs.ATG" +#line 1526 "cs.ATG" Expression expr = null; label = null; if (la.kind == 54) { lexer.NextToken(); Expr( -#line 1527 "cs.ATG" +#line 1528 "cs.ATG" out expr); Expect(9); -#line 1527 "cs.ATG" +#line 1528 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 62) { lexer.NextToken(); Expect(9); -#line 1528 "cs.ATG" +#line 1529 "cs.ATG" label = new CaseLabel(); } else SynErr(177); } void CatchClauses( -#line 1548 "cs.ATG" +#line 1549 "cs.ATG" out List catchClauses) { -#line 1550 "cs.ATG" +#line 1551 "cs.ATG" catchClauses = new List(); Expect(55); -#line 1553 "cs.ATG" +#line 1554 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; if (la.kind == 16) { Block( -#line 1559 "cs.ATG" +#line 1560 "cs.ATG" out stmt); -#line 1559 "cs.ATG" +#line 1560 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1561 "cs.ATG" +#line 1562 "cs.ATG" out typeRef, false); -#line 1561 "cs.ATG" +#line 1562 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1562 "cs.ATG" +#line 1563 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1563 "cs.ATG" +#line 1564 "cs.ATG" out stmt); -#line 1564 "cs.ATG" +#line 1565 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); while ( -#line 1565 "cs.ATG" +#line 1566 "cs.ATG" IsTypedCatch()) { Expect(55); Expect(20); ClassType( -#line 1565 "cs.ATG" +#line 1566 "cs.ATG" out typeRef, false); -#line 1565 "cs.ATG" +#line 1566 "cs.ATG" identifier = null; if (la.kind == 1) { lexer.NextToken(); -#line 1566 "cs.ATG" +#line 1567 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1567 "cs.ATG" +#line 1568 "cs.ATG" out stmt); -#line 1568 "cs.ATG" +#line 1569 "cs.ATG" catchClauses.Add(new CatchClause(typeRef, identifier, stmt)); } if (la.kind == 55) { lexer.NextToken(); Block( -#line 1570 "cs.ATG" +#line 1571 "cs.ATG" out stmt); -#line 1570 "cs.ATG" +#line 1571 "cs.ATG" catchClauses.Add(new CatchClause(stmt)); } } else SynErr(178); } void UnaryExpr( -#line 1628 "cs.ATG" +#line 1629 "cs.ATG" out Expression uExpr) { -#line 1630 "cs.ATG" +#line 1631 "cs.ATG" TypeReference type = null; Expression expr; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(26) || -#line 1652 "cs.ATG" +#line 1653 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1639 "cs.ATG" +#line 1640 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1640 "cs.ATG" +#line 1641 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 1641 "cs.ATG" +#line 1642 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1642 "cs.ATG" +#line 1643 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1643 "cs.ATG" +#line 1644 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Star)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1644 "cs.ATG" +#line 1645 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 1645 "cs.ATG" +#line 1646 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 1646 "cs.ATG" +#line 1647 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitWiseAnd)); } else { Expect(20); Type( -#line 1652 "cs.ATG" +#line 1653 "cs.ATG" out type); Expect(21); -#line 1652 "cs.ATG" +#line 1653 "cs.ATG" expressions.Add(new CastExpression(type)); } } PrimaryExpr( -#line 1656 "cs.ATG" +#line 1657 "cs.ATG" out expr); -#line 1656 "cs.ATG" +#line 1657 "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) { @@ -4075,33 +4084,33 @@ out expr); } void ConditionalOrExpr( -#line 1825 "cs.ATG" +#line 1827 "cs.ATG" ref Expression outExpr) { -#line 1826 "cs.ATG" +#line 1828 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 1828 "cs.ATG" +#line 1830 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 1828 "cs.ATG" +#line 1830 "cs.ATG" out expr); ConditionalAndExpr( -#line 1828 "cs.ATG" +#line 1830 "cs.ATG" ref expr); -#line 1828 "cs.ATG" +#line 1830 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1673 "cs.ATG" +#line 1674 "cs.ATG" out Expression pexpr) { -#line 1675 "cs.ATG" +#line 1676 "cs.ATG" TypeReference type = null; List typeList = null; bool isArrayCreation = false; @@ -4111,332 +4120,332 @@ out Expression pexpr) { if (la.kind == 112) { lexer.NextToken(); -#line 1683 "cs.ATG" +#line 1684 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 71) { lexer.NextToken(); -#line 1684 "cs.ATG" +#line 1685 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 89) { lexer.NextToken(); -#line 1685 "cs.ATG" +#line 1686 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1686 "cs.ATG" +#line 1687 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); } else if ( -#line 1687 "cs.ATG" +#line 1688 "cs.ATG" la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) { Expect(1); -#line 1688 "cs.ATG" +#line 1689 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1689 "cs.ATG" +#line 1690 "cs.ATG" pexpr = new TypeReferenceExpression(type); Expect(1); -#line 1690 "cs.ATG" +#line 1691 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); } else if (la.kind == 1) { lexer.NextToken(); -#line 1692 "cs.ATG" +#line 1693 "cs.ATG" pexpr = new IdentifierExpression(t.val); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1694 "cs.ATG" +#line 1695 "cs.ATG" out expr); Expect(21); -#line 1694 "cs.ATG" +#line 1695 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(27)) { -#line 1696 "cs.ATG" +#line 1697 "cs.ATG" string val = null; switch (la.kind) { case 51: { lexer.NextToken(); -#line 1698 "cs.ATG" +#line 1699 "cs.ATG" val = "bool"; break; } case 53: { lexer.NextToken(); -#line 1699 "cs.ATG" +#line 1700 "cs.ATG" val = "byte"; break; } case 56: { lexer.NextToken(); -#line 1700 "cs.ATG" +#line 1701 "cs.ATG" val = "char"; break; } case 61: { lexer.NextToken(); -#line 1701 "cs.ATG" +#line 1702 "cs.ATG" val = "decimal"; break; } case 65: { lexer.NextToken(); -#line 1702 "cs.ATG" +#line 1703 "cs.ATG" val = "double"; break; } case 74: { lexer.NextToken(); -#line 1703 "cs.ATG" +#line 1704 "cs.ATG" val = "float"; break; } case 81: { lexer.NextToken(); -#line 1704 "cs.ATG" +#line 1705 "cs.ATG" val = "int"; break; } case 86: { lexer.NextToken(); -#line 1705 "cs.ATG" +#line 1706 "cs.ATG" val = "long"; break; } case 90: { lexer.NextToken(); -#line 1706 "cs.ATG" +#line 1707 "cs.ATG" val = "object"; break; } case 101: { lexer.NextToken(); -#line 1707 "cs.ATG" +#line 1708 "cs.ATG" val = "sbyte"; break; } case 103: { lexer.NextToken(); -#line 1708 "cs.ATG" +#line 1709 "cs.ATG" val = "short"; break; } case 107: { lexer.NextToken(); -#line 1709 "cs.ATG" +#line 1710 "cs.ATG" val = "string"; break; } case 115: { lexer.NextToken(); -#line 1710 "cs.ATG" +#line 1711 "cs.ATG" val = "uint"; break; } case 116: { lexer.NextToken(); -#line 1711 "cs.ATG" +#line 1712 "cs.ATG" val = "ulong"; break; } case 119: { lexer.NextToken(); -#line 1712 "cs.ATG" +#line 1713 "cs.ATG" val = "ushort"; break; } } -#line 1713 "cs.ATG" +#line 1714 "cs.ATG" t.val = ""; Expect(15); Expect(1); -#line 1713 "cs.ATG" +#line 1714 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); } else if (la.kind == 110) { lexer.NextToken(); -#line 1715 "cs.ATG" +#line 1716 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 50) { lexer.NextToken(); -#line 1717 "cs.ATG" +#line 1718 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 1719 "cs.ATG" +#line 1720 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 18) { lexer.NextToken(); Expr( -#line 1720 "cs.ATG" +#line 1721 "cs.ATG" out expr); -#line 1720 "cs.ATG" +#line 1721 "cs.ATG" List indices = new List(); if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1721 "cs.ATG" +#line 1722 "cs.ATG" out expr); -#line 1721 "cs.ATG" +#line 1722 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 1722 "cs.ATG" +#line 1723 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); } else SynErr(179); -#line 1723 "cs.ATG" +#line 1724 "cs.ATG" pexpr = retExpr; } else if (la.kind == 88) { lexer.NextToken(); NonArrayType( -#line 1724 "cs.ATG" +#line 1725 "cs.ATG" out type); -#line 1725 "cs.ATG" +#line 1726 "cs.ATG" List parameters = new List(); if (la.kind == 20) { lexer.NextToken(); -#line 1730 "cs.ATG" +#line 1731 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); if (StartOf(21)) { Argument( -#line 1731 "cs.ATG" +#line 1732 "cs.ATG" out expr); -#line 1731 "cs.ATG" +#line 1732 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1732 "cs.ATG" +#line 1733 "cs.ATG" out expr); -#line 1732 "cs.ATG" +#line 1733 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(21); -#line 1734 "cs.ATG" +#line 1735 "cs.ATG" pexpr = oce; } else if (la.kind == 18) { lexer.NextToken(); -#line 1736 "cs.ATG" +#line 1737 "cs.ATG" isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; -#line 1737 "cs.ATG" +#line 1738 "cs.ATG" int dims = 0; List ranks = new List(); if (la.kind == 14 || la.kind == 19) { while (la.kind == 14) { lexer.NextToken(); -#line 1739 "cs.ATG" +#line 1740 "cs.ATG" dims += 1; } Expect(19); -#line 1740 "cs.ATG" +#line 1741 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1741 "cs.ATG" +#line 1742 "cs.ATG" ++dims; } Expect(19); -#line 1741 "cs.ATG" +#line 1742 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 1742 "cs.ATG" +#line 1743 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); ArrayInitializer( -#line 1743 "cs.ATG" +#line 1744 "cs.ATG" out expr); -#line 1743 "cs.ATG" +#line 1744 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } else if (StartOf(5)) { Expr( -#line 1744 "cs.ATG" +#line 1745 "cs.ATG" out expr); -#line 1744 "cs.ATG" +#line 1745 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 1745 "cs.ATG" +#line 1746 "cs.ATG" dims += 1; Expr( -#line 1746 "cs.ATG" +#line 1747 "cs.ATG" out expr); -#line 1746 "cs.ATG" +#line 1747 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 1748 "cs.ATG" +#line 1749 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1749 "cs.ATG" +#line 1750 "cs.ATG" ++dims; } Expect(19); -#line 1749 "cs.ATG" +#line 1750 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 1750 "cs.ATG" +#line 1751 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { ArrayInitializer( -#line 1751 "cs.ATG" +#line 1752 "cs.ATG" out expr); -#line 1751 "cs.ATG" +#line 1752 "cs.ATG" ace.ArrayInitializer = (ArrayInitializerExpression)expr; } } else SynErr(180); @@ -4445,202 +4454,202 @@ out expr); lexer.NextToken(); Expect(20); if ( -#line 1756 "cs.ATG" +#line 1757 "cs.ATG" NotVoidPointer()) { Expect(122); -#line 1756 "cs.ATG" +#line 1757 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(9)) { TypeWithRestriction( -#line 1757 "cs.ATG" +#line 1758 "cs.ATG" out type, true, true); } else SynErr(182); Expect(21); -#line 1758 "cs.ATG" +#line 1759 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 62) { lexer.NextToken(); Expect(20); Type( -#line 1760 "cs.ATG" +#line 1761 "cs.ATG" out type); Expect(21); -#line 1760 "cs.ATG" +#line 1761 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 104) { lexer.NextToken(); Expect(20); Type( -#line 1761 "cs.ATG" +#line 1762 "cs.ATG" out type); Expect(21); -#line 1761 "cs.ATG" +#line 1762 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 57) { lexer.NextToken(); Expect(20); Expr( -#line 1762 "cs.ATG" +#line 1763 "cs.ATG" out expr); Expect(21); -#line 1762 "cs.ATG" +#line 1763 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 117) { lexer.NextToken(); Expect(20); Expr( -#line 1763 "cs.ATG" +#line 1764 "cs.ATG" out expr); Expect(21); -#line 1763 "cs.ATG" +#line 1764 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 63) { lexer.NextToken(); AnonymousMethodExpr( -#line 1764 "cs.ATG" +#line 1765 "cs.ATG" out expr); -#line 1764 "cs.ATG" +#line 1765 "cs.ATG" pexpr = expr; } else SynErr(183); while (StartOf(28) || -#line 1775 "cs.ATG" +#line 1776 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || -#line 1784 "cs.ATG" +#line 1785 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { lexer.NextToken(); -#line 1768 "cs.ATG" +#line 1769 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 1769 "cs.ATG" +#line 1770 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(184); } else if (la.kind == 47) { lexer.NextToken(); Expect(1); -#line 1772 "cs.ATG" +#line 1773 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 15) { lexer.NextToken(); Expect(1); -#line 1773 "cs.ATG" +#line 1774 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if ( -#line 1775 "cs.ATG" +#line 1776 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) { TypeArgumentList( -#line 1776 "cs.ATG" +#line 1777 "cs.ATG" out typeList, false); Expect(15); Expect(1); -#line 1778 "cs.ATG" +#line 1779 "cs.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeList), t.val); } else if (la.kind == 20) { lexer.NextToken(); -#line 1780 "cs.ATG" +#line 1781 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 1781 "cs.ATG" +#line 1782 "cs.ATG" out expr); -#line 1781 "cs.ATG" +#line 1782 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1782 "cs.ATG" +#line 1783 "cs.ATG" out expr); -#line 1782 "cs.ATG" +#line 1783 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 1783 "cs.ATG" +#line 1784 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else if ( -#line 1784 "cs.ATG" +#line 1785 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { TypeArgumentList( -#line 1784 "cs.ATG" +#line 1785 "cs.ATG" out typeList, false); Expect(20); -#line 1785 "cs.ATG" +#line 1786 "cs.ATG" List parameters = new List(); if (StartOf(21)) { Argument( -#line 1786 "cs.ATG" +#line 1787 "cs.ATG" out expr); -#line 1786 "cs.ATG" +#line 1787 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1787 "cs.ATG" +#line 1788 "cs.ATG" out expr); -#line 1787 "cs.ATG" +#line 1788 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 1788 "cs.ATG" +#line 1789 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 1790 "cs.ATG" +#line 1791 "cs.ATG" if (isArrayCreation) Error("element access not allow on array creation"); List indices = new List(); lexer.NextToken(); Expr( -#line 1793 "cs.ATG" +#line 1794 "cs.ATG" out expr); -#line 1793 "cs.ATG" +#line 1794 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1794 "cs.ATG" +#line 1795 "cs.ATG" out expr); -#line 1794 "cs.ATG" +#line 1795 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 1795 "cs.ATG" +#line 1796 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void AnonymousMethodExpr( -#line 1799 "cs.ATG" +#line 1800 "cs.ATG" out Expression outExpr) { -#line 1801 "cs.ATG" +#line 1802 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; Statement stmt; @@ -4651,74 +4660,77 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(10)) { FormalParameterList( -#line 1810 "cs.ATG" +#line 1811 "cs.ATG" p); -#line 1810 "cs.ATG" +#line 1811 "cs.ATG" expr.Parameters = p; } Expect(21); + +#line 1813 "cs.ATG" + expr.HasParameterList = true; } -#line 1815 "cs.ATG" +#line 1817 "cs.ATG" if (compilationUnit != null) { Block( -#line 1816 "cs.ATG" +#line 1818 "cs.ATG" out stmt); -#line 1816 "cs.ATG" +#line 1818 "cs.ATG" expr.Body = (BlockStatement)stmt; -#line 1817 "cs.ATG" +#line 1819 "cs.ATG" } else { Expect(16); -#line 1819 "cs.ATG" +#line 1821 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 1821 "cs.ATG" +#line 1823 "cs.ATG" } -#line 1822 "cs.ATG" +#line 1824 "cs.ATG" expr.EndLocation = t.Location; } void TypeArgumentList( -#line 1995 "cs.ATG" +#line 1997 "cs.ATG" out List types, bool canBeUnbound) { -#line 1997 "cs.ATG" +#line 1999 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2002 "cs.ATG" +#line 2004 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2003 "cs.ATG" +#line 2005 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2004 "cs.ATG" +#line 2006 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(9)) { Type( -#line 2005 "cs.ATG" +#line 2007 "cs.ATG" out type); -#line 2005 "cs.ATG" +#line 2007 "cs.ATG" types.Add(type); while (la.kind == 14) { lexer.NextToken(); Type( -#line 2006 "cs.ATG" +#line 2008 "cs.ATG" out type); -#line 2006 "cs.ATG" +#line 2008 "cs.ATG" types.Add(type); } } else SynErr(185); @@ -4726,206 +4738,206 @@ out type); } void ConditionalAndExpr( -#line 1831 "cs.ATG" +#line 1833 "cs.ATG" ref Expression outExpr) { -#line 1832 "cs.ATG" +#line 1834 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 1834 "cs.ATG" +#line 1836 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 1834 "cs.ATG" +#line 1836 "cs.ATG" out expr); InclusiveOrExpr( -#line 1834 "cs.ATG" +#line 1836 "cs.ATG" ref expr); -#line 1834 "cs.ATG" +#line 1836 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 1837 "cs.ATG" +#line 1839 "cs.ATG" ref Expression outExpr) { -#line 1838 "cs.ATG" +#line 1840 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 1840 "cs.ATG" +#line 1842 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 1840 "cs.ATG" +#line 1842 "cs.ATG" out expr); ExclusiveOrExpr( -#line 1840 "cs.ATG" +#line 1842 "cs.ATG" ref expr); -#line 1840 "cs.ATG" +#line 1842 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 1843 "cs.ATG" +#line 1845 "cs.ATG" ref Expression outExpr) { -#line 1844 "cs.ATG" +#line 1846 "cs.ATG" Expression expr; AndExpr( -#line 1846 "cs.ATG" +#line 1848 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 1846 "cs.ATG" +#line 1848 "cs.ATG" out expr); AndExpr( -#line 1846 "cs.ATG" +#line 1848 "cs.ATG" ref expr); -#line 1846 "cs.ATG" +#line 1848 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 1849 "cs.ATG" +#line 1851 "cs.ATG" ref Expression outExpr) { -#line 1850 "cs.ATG" +#line 1852 "cs.ATG" Expression expr; EqualityExpr( -#line 1852 "cs.ATG" +#line 1854 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 1852 "cs.ATG" +#line 1854 "cs.ATG" out expr); EqualityExpr( -#line 1852 "cs.ATG" +#line 1854 "cs.ATG" ref expr); -#line 1852 "cs.ATG" +#line 1854 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 1855 "cs.ATG" +#line 1857 "cs.ATG" ref Expression outExpr) { -#line 1857 "cs.ATG" +#line 1859 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 1861 "cs.ATG" +#line 1863 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 1864 "cs.ATG" +#line 1866 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 1865 "cs.ATG" +#line 1867 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 1867 "cs.ATG" +#line 1869 "cs.ATG" out expr); RelationalExpr( -#line 1867 "cs.ATG" +#line 1869 "cs.ATG" ref expr); -#line 1867 "cs.ATG" +#line 1869 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 1871 "cs.ATG" +#line 1873 "cs.ATG" ref Expression outExpr) { -#line 1873 "cs.ATG" +#line 1875 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 1878 "cs.ATG" +#line 1880 "cs.ATG" ref outExpr); while (StartOf(29)) { if (StartOf(30)) { if (la.kind == 23) { lexer.NextToken(); -#line 1880 "cs.ATG" +#line 1882 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 1881 "cs.ATG" +#line 1883 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 1882 "cs.ATG" +#line 1884 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 1883 "cs.ATG" +#line 1885 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(186); UnaryExpr( -#line 1885 "cs.ATG" +#line 1887 "cs.ATG" out expr); ShiftExpr( -#line 1886 "cs.ATG" +#line 1888 "cs.ATG" ref expr); -#line 1887 "cs.ATG" +#line 1889 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 84) { lexer.NextToken(); TypeWithRestriction( -#line 1890 "cs.ATG" +#line 1892 "cs.ATG" out type, false, false); if ( -#line 1891 "cs.ATG" +#line 1893 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 1892 "cs.ATG" +#line 1894 "cs.ATG" ref type); } -#line 1893 "cs.ATG" +#line 1895 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 49) { lexer.NextToken(); TypeWithRestriction( -#line 1895 "cs.ATG" +#line 1897 "cs.ATG" out type, false, false); if ( -#line 1896 "cs.ATG" +#line 1898 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 1897 "cs.ATG" +#line 1899 "cs.ATG" ref type); } -#line 1898 "cs.ATG" +#line 1900 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(187); } @@ -4933,83 +4945,83 @@ ref type); } void ShiftExpr( -#line 1903 "cs.ATG" +#line 1905 "cs.ATG" ref Expression outExpr) { -#line 1905 "cs.ATG" +#line 1907 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 1909 "cs.ATG" +#line 1911 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 1912 "cs.ATG" +#line 1914 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 1911 "cs.ATG" +#line 1913 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 1913 "cs.ATG" +#line 1915 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 1916 "cs.ATG" +#line 1918 "cs.ATG" out expr); AdditiveExpr( -#line 1916 "cs.ATG" +#line 1918 "cs.ATG" ref expr); -#line 1916 "cs.ATG" +#line 1918 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 1920 "cs.ATG" +#line 1922 "cs.ATG" ref Expression outExpr) { -#line 1922 "cs.ATG" +#line 1924 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 1926 "cs.ATG" +#line 1928 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 1929 "cs.ATG" +#line 1931 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 1930 "cs.ATG" +#line 1932 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 1932 "cs.ATG" +#line 1934 "cs.ATG" out expr); MultiplicativeExpr( -#line 1932 "cs.ATG" +#line 1934 "cs.ATG" ref expr); -#line 1932 "cs.ATG" +#line 1934 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 1936 "cs.ATG" +#line 1938 "cs.ATG" ref Expression outExpr) { -#line 1938 "cs.ATG" +#line 1940 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5017,57 +5029,57 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 1944 "cs.ATG" +#line 1946 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 1945 "cs.ATG" +#line 1947 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 1946 "cs.ATG" +#line 1948 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 1948 "cs.ATG" +#line 1950 "cs.ATG" out expr); -#line 1948 "cs.ATG" +#line 1950 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2052 "cs.ATG" +#line 2054 "cs.ATG" out TypeReference type) { -#line 2053 "cs.ATG" +#line 2055 "cs.ATG" TypeReference t; type = null; if (la.kind == 108) { lexer.NextToken(); -#line 2055 "cs.ATG" +#line 2057 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 58) { lexer.NextToken(); -#line 2056 "cs.ATG" +#line 2058 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 88) { lexer.NextToken(); Expect(20); Expect(21); -#line 2057 "cs.ATG" +#line 2059 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(9)) { Type( -#line 2058 "cs.ATG" +#line 2060 "cs.ATG" out t); -#line 2058 "cs.ATG" +#line 2060 "cs.ATG" type = t; } else SynErr(188); } @@ -5292,7 +5304,7 @@ out t); {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,T, x,x,x,x, x,x,x}, {x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,T,x,x, T,T,x,x, x,T,T,T, x,T,x,x, x,x,x,T, x,x,T,x, x,x,x,x, x,T,x,x, x,x,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,T, x,x,T,x, T,x,T,T, T,T,x,T, x,x,x,x, x,x,x}, {x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, - {x,x,x,x, T,T,T,T, T,T,x,T, T,T,T,x, x,T,T,T, x,T,T,T, x,T,T,x, T,T,T,x, x,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,x,x, T,T,T,T, T,T,x,T, T,T,T,x, T,T,T,T, x,T,T,T, x,T,T,T, T,T,T,x, x,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, T,T,x,T, x,T,x,x, T,x,T,T, x,T,x,T, x,T,x,T, T,T,T,x, x,T,T,x, x,x,x,T, x,T,T,T, T,x,T,x, T,x,T,x, x,T,x,T, T,T,T,x, x,T,T,T, x,x,T,T, T,x,x,x, x,x,x,T, T,x,T,T, x,T,T,T, x,x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,T,x,T, x,x,x,T, x,x,x,x, x,x,x,T, T,x,x,T, x,x,T,x, x,x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, T,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, T,x,T,x, x,x,x,T, x,T,x,T, x,x,x,T, x,x,x,x, x,x,x,T, T,x,x,T, x,x,T,x, x,x,x}, diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index faca01bbcf..6b71b4c8e8 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -775,6 +775,7 @@ StructMemberDecl attributes> | ident (. qualident = t.val; .) ) (. eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; .) + [ "=" Expr (. eventDecl.Initializer = expr; .) ] [ "{" (. eventDecl.BodyStart = t.Location; .) EventAccessorDecls "}" (. eventDecl.BodyEnd = t.EndLocation; .) @@ -1809,6 +1810,7 @@ AnonymousMethodExpr "(" [ FormalParameterList

(. expr.Parameters = p; .) ] ")" + (. expr.HasParameterList = true; .) ] /*--- ParseExpression doesn't set a compilation unit, */ /*--- so we can't use block then -> skip body of anonymous method */ diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index 6fd2f325b7..0965df9903 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -559,7 +559,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.Indent(); OutputModifier(propertyGetRegion.Modifier); outputFormatter.PrintText("get"); - OutputBlock(propertyGetRegion.Block, prettyPrintOptions.PropertyGetBraceStyle); + OutputBlockAllowInline(propertyGetRegion.Block, prettyPrintOptions.PropertyGetBraceStyle); return null; } @@ -569,7 +569,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.Indent(); OutputModifier(propertySetRegion.Modifier); outputFormatter.PrintText("set"); - OutputBlock(propertySetRegion.Block, prettyPrintOptions.PropertySetBraceStyle); + OutputBlockAllowInline(propertySetRegion.Block, prettyPrintOptions.PropertySetBraceStyle); return null; } @@ -589,6 +589,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } outputFormatter.PrintIdentifier(eventDeclaration.Name); + + if (!eventDeclaration.Initializer.IsNull) { + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.Assign); + outputFormatter.Space(); + nodeTracker.TrackedVisit(eventDeclaration.Initializer, data); + } + if (eventDeclaration.AddRegion.IsNull && eventDeclaration.RemoveRegion.IsNull) { outputFormatter.PrintToken(Tokens.Semicolon); outputFormatter.NewLine(); @@ -606,7 +614,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter VisitAttributes(eventAddRegion.Attributes, data); outputFormatter.Indent(); outputFormatter.PrintText("add"); - OutputBlock(eventAddRegion.Block, prettyPrintOptions.EventAddBraceStyle); + OutputBlockAllowInline(eventAddRegion.Block, prettyPrintOptions.EventAddBraceStyle); return null; } @@ -615,7 +623,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter VisitAttributes(eventRemoveRegion.Attributes, data); outputFormatter.Indent(); outputFormatter.PrintText("remove"); - OutputBlock(eventRemoveRegion.Block, prettyPrintOptions.EventRemoveBraceStyle); + OutputBlockAllowInline(eventRemoveRegion.Block, prettyPrintOptions.EventRemoveBraceStyle); return null; } @@ -906,6 +914,46 @@ namespace ICSharpCode.NRefactory.PrettyPrinter nodeTracker.EndNode(blockStatement); } + void OutputBlockAllowInline(BlockStatement blockStatement, BraceStyle braceStyle) + { + OutputBlockAllowInline(blockStatement, braceStyle, true); + } + + void OutputBlockAllowInline(BlockStatement blockStatement, BraceStyle braceStyle, bool useNewLine) + { + if (!blockStatement.IsNull + && ( + blockStatement.Children.Count == 0 + || blockStatement.Children.Count == 1 + && (blockStatement.Children[0] is ExpressionStatement + || blockStatement.Children[0] is ReturnStatement + ))) + { + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.OpenCurlyBrace); + outputFormatter.Space(); + if (blockStatement.Children.Count != 0) { + bool doIndent = outputFormatter.DoIndent; + bool doNewLine = outputFormatter.DoNewLine; + outputFormatter.DoIndent = false; + outputFormatter.DoNewLine = false; + + nodeTracker.TrackedVisit(blockStatement.Children[0], null); + + outputFormatter.DoIndent = doIndent; + outputFormatter.DoNewLine = doNewLine; + + outputFormatter.Space(); + } + outputFormatter.PrintToken(Tokens.CloseCurlyBrace); + if (useNewLine) { + outputFormatter.NewLine(); + } + } else { + OutputBlock(blockStatement, braceStyle); + } + } + public object VisitBlockStatement(BlockStatement blockStatement, object data) { if (data is BraceStyle) @@ -2149,11 +2197,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter { outputFormatter.PrintToken(Tokens.Delegate); - outputFormatter.PrintToken(Tokens.OpenParenthesis); - AppendCommaSeparatedList(anonymousMethodExpression.Parameters); - outputFormatter.PrintToken(Tokens.CloseParenthesis); - OutputBlock(anonymousMethodExpression.Body, this.prettyPrintOptions.MethodBraceStyle); - + if (anonymousMethodExpression.Parameters.Count > 0 || anonymousMethodExpression.HasParameterList) { + outputFormatter.PrintToken(Tokens.OpenParenthesis); + AppendCommaSeparatedList(anonymousMethodExpression.Parameters); + outputFormatter.PrintToken(Tokens.CloseParenthesis); + } + OutputBlockAllowInline(anonymousMethodExpression.Body, this.prettyPrintOptions.MethodBraceStyle, false); return null; } diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs index 3b8532f90e..5a203a23d2 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs @@ -672,6 +672,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter nodeTracker.TrackedVisit(eventDeclaration.TypeReference, data); PrintInterfaceImplementations(eventDeclaration.InterfaceImplementations); + + if (!eventDeclaration.Initializer.IsNull) { + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.Assign); + outputFormatter.Space(); + nodeTracker.TrackedVisit(eventDeclaration.Initializer, data); + } + outputFormatter.NewLine(); if (customEvent) { diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs index 4f5a822fcc..6799c05684 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.88 +// Runtime Version:2.0.50727.42 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -341,6 +341,7 @@ namespace ICSharpCode.NRefactory.Visitors { Debug.Assert((eventDeclaration.AddRegion != null)); Debug.Assert((eventDeclaration.RemoveRegion != null)); Debug.Assert((eventDeclaration.RaiseRegion != null)); + Debug.Assert((eventDeclaration.Initializer != null)); foreach (AttributeSection o in eventDeclaration.Attributes) { Debug.Assert(o != null); o.AcceptVisitor(this, data); @@ -356,7 +357,8 @@ namespace ICSharpCode.NRefactory.Visitors { } eventDeclaration.AddRegion.AcceptVisitor(this, data); eventDeclaration.RemoveRegion.AcceptVisitor(this, data); - return eventDeclaration.RaiseRegion.AcceptVisitor(this, data); + eventDeclaration.RaiseRegion.AcceptVisitor(this, data); + return eventDeclaration.Initializer.AcceptVisitor(this, data); } public virtual object VisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data) { diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs b/src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs index 3142361ff0..f52e52b2fc 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs +++ b/src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.88 +// Runtime Version:2.0.50727.42 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -600,6 +600,7 @@ namespace ICSharpCode.NRefactory.Visitors { Debug.Assert((eventDeclaration.AddRegion != null)); Debug.Assert((eventDeclaration.RemoveRegion != null)); Debug.Assert((eventDeclaration.RaiseRegion != null)); + Debug.Assert((eventDeclaration.Initializer != null)); for (int i = 0; i < eventDeclaration.Attributes.Count; i++) { AttributeSection o = eventDeclaration.Attributes[i]; Debug.Assert(o != null); @@ -645,6 +646,9 @@ namespace ICSharpCode.NRefactory.Visitors { nodeStack.Push(eventDeclaration.RaiseRegion); eventDeclaration.RaiseRegion.AcceptVisitor(this, data); eventDeclaration.RaiseRegion = ((EventRaiseRegion)(nodeStack.Pop())); + nodeStack.Push(eventDeclaration.Initializer); + eventDeclaration.Initializer.AcceptVisitor(this, data); + eventDeclaration.Initializer = ((Expression)(nodeStack.Pop())); return null; } diff --git a/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs b/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs index 00c461105c..6209f0e45a 100644 --- a/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs +++ b/src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs @@ -69,6 +69,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter "}"); } + [Test] + public void EventWithInitializer() + { + TestTypeMember("public event EventHandler Click = delegate { };"); + } + [Test] public void Field() { @@ -326,6 +332,13 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter TestTypeMember("public abstract bool Run();"); } + [Test] + public void AnonymousMethod() + { + TestStatement("Func b = delegate { return true; };"); + TestStatement("Func a = delegate() { return false; };"); + } + [Test] public void Interface() { diff --git a/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs b/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs index 26efaf1039..b8f4dafb0d 100644 --- a/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs @@ -144,7 +144,7 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter public void Property() { TestMember("ReadOnly Property A()\nGet\nReturn Nothing\nEnd Get\nEnd Property", - "public object A {\n\tget {\n\t\treturn null;\n\t}\n}"); + "public object A {\n\tget { return null; }\n}"); } [Test] diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/AnonymousMethodTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/AnonymousMethodTests.cs index 9002d5f51e..c53ea10326 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/AnonymousMethodTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/AnonymousMethodTests.cs @@ -27,6 +27,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast AnonymousMethodExpression ame = Parse("delegate {}"); Assert.AreEqual(0, ame.Parameters.Count); Assert.AreEqual(0, ame.Body.Children.Count); + Assert.IsFalse(ame.HasParameterList); } [Test] @@ -45,6 +46,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast AnonymousMethodExpression ame = Parse("delegate() {}"); Assert.AreEqual(0, ame.Parameters.Count); Assert.AreEqual(0, ame.Body.Children.Count); + Assert.IsTrue(ame.HasParameterList); } [Test]