diff options
author | Mike Krüger <mkrueger@novell.com> | 2009-09-18 15:16:39 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2009-09-18 15:16:39 +0400 |
commit | 70af1971537da7188c62efa70a9104d21043d321 (patch) | |
tree | b9200328628d3d663b997fca9e180fde5e9eb4e8 /main/contrib | |
parent | 119fd354eb43590e2269c399c664993d20192b40 (diff) |
* Src/Ast/AbstractNode.cs:
* Src/Parser/CSharp/cs.ATG:
* Src/Parser/CSharp/Parser.cs:
* Src/Ast/General/Statement.cs:
* Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs:
* Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs: Added option to
place else if on new line, elseif sections have now location set.
svn path=/trunk/monodevelop/; revision=142181
Diffstat (limited to 'main/contrib')
7 files changed, 515 insertions, 494 deletions
diff --git a/main/contrib/NRefactory/Project/ChangeLog b/main/contrib/NRefactory/Project/ChangeLog index b53206c156..f90971c2f1 100644 --- a/main/contrib/NRefactory/Project/ChangeLog +++ b/main/contrib/NRefactory/Project/ChangeLog @@ -1,3 +1,14 @@ +2009-09-18 Mike Krüger <mkrueger@novell.com> + + * Src/Ast/AbstractNode.cs: + * Src/Parser/CSharp/cs.ATG: + * Src/Parser/CSharp/Parser.cs: + * Src/Ast/General/Statement.cs: + * Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs: + * Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs: Added + option to place else if on new line, elseif sections have + now location set. + 2009-09-16 Mike Krüger <mkrueger@novell.com> * Src/Parser/CSharp/CSharpParser.cs: diff --git a/main/contrib/NRefactory/Project/Src/Ast/AbstractNode.cs b/main/contrib/NRefactory/Project/Src/Ast/AbstractNode.cs index 1b8c8ab274..4d1e3a7aad 100644 --- a/main/contrib/NRefactory/Project/Src/Ast/AbstractNode.cs +++ b/main/contrib/NRefactory/Project/Src/Ast/AbstractNode.cs @@ -1,4 +1,4 @@ -// <file> +// <file> // <copyright see="prj:///doc/copyright.txt"/> // <license see="prj:///doc/license.txt"/> // <owner name="Mike Krüger" email="mike@icsharpcode.net"/> diff --git a/main/contrib/NRefactory/Project/Src/Ast/General/Statement.cs b/main/contrib/NRefactory/Project/Src/Ast/General/Statement.cs index 6ceb4cff7d..d8260c0326 100644 --- a/main/contrib/NRefactory/Project/Src/Ast/General/Statement.cs +++ b/main/contrib/NRefactory/Project/Src/Ast/General/Statement.cs @@ -1,4 +1,4 @@ -// <file> +// <file> // <copyright see="prj:///doc/copyright.txt"/> // <license see="prj:///doc/license.txt"/> // <owner name="Mike Krüger" email="mike@icsharpcode.net"/> diff --git a/main/contrib/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/main/contrib/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 53eb1efde4..d7c0d4b46c 100644 --- a/main/contrib/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/main/contrib/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -490,68 +490,68 @@ out expr); } void Expr( -#line 1789 "cs.ATG" +#line 1791 "cs.ATG" out Expression expr) { -#line 1790 "cs.ATG" +#line 1792 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; -#line 1792 "cs.ATG" +#line 1794 "cs.ATG" Location startLocation = la.Location; UnaryExpr( -#line 1793 "cs.ATG" +#line 1795 "cs.ATG" out expr); if (StartOf(7)) { AssignmentOperator( -#line 1796 "cs.ATG" +#line 1798 "cs.ATG" out op); Expr( -#line 1796 "cs.ATG" +#line 1798 "cs.ATG" out expr1); -#line 1796 "cs.ATG" +#line 1798 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1797 "cs.ATG" +#line 1799 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1798 "cs.ATG" +#line 1800 "cs.ATG" out op); Expr( -#line 1798 "cs.ATG" +#line 1800 "cs.ATG" out expr1); -#line 1798 "cs.ATG" +#line 1800 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(8)) { ConditionalOrExpr( -#line 1800 "cs.ATG" +#line 1802 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1801 "cs.ATG" +#line 1803 "cs.ATG" out expr1); -#line 1801 "cs.ATG" +#line 1803 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1802 "cs.ATG" +#line 1804 "cs.ATG" out expr1); Expect(9); Expr( -#line 1802 "cs.ATG" +#line 1804 "cs.ATG" out expr2); -#line 1802 "cs.ATG" +#line 1804 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(150); -#line 1805 "cs.ATG" +#line 1807 "cs.ATG" if (expr != null) { expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; @@ -958,39 +958,39 @@ templates); } void TypeParameterList( -#line 2366 "cs.ATG" +#line 2368 "cs.ATG" List<TemplateDefinition> templates) { -#line 2368 "cs.ATG" +#line 2370 "cs.ATG" AttributeSection section; List<AttributeSection> attributes = new List<AttributeSection>(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2372 "cs.ATG" +#line 2374 "cs.ATG" out section); -#line 2372 "cs.ATG" +#line 2374 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2373 "cs.ATG" +#line 2375 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2374 "cs.ATG" +#line 2376 "cs.ATG" out section); -#line 2374 "cs.ATG" +#line 2376 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2375 "cs.ATG" +#line 2377 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -1023,22 +1023,22 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2379 "cs.ATG" +#line 2381 "cs.ATG" List<TemplateDefinition> templates) { -#line 2380 "cs.ATG" +#line 2382 "cs.ATG" string name = ""; TypeReference type; Expect(127); Identifier(); -#line 2383 "cs.ATG" +#line 2385 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2385 "cs.ATG" +#line 2387 "cs.ATG" out type); -#line 2386 "cs.ATG" +#line 2388 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1051,10 +1051,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2395 "cs.ATG" +#line 2397 "cs.ATG" out type); -#line 2396 "cs.ATG" +#line 2398 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1390,34 +1390,34 @@ out r, canBeUnbound); } void TypeName( -#line 2307 "cs.ATG" +#line 2309 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2308 "cs.ATG" +#line 2310 "cs.ATG" List<TypeReference> typeArguments = null; string alias = null; string qualident; Location startLocation = la.Location; if ( -#line 2314 "cs.ATG" +#line 2316 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 2315 "cs.ATG" +#line 2317 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2318 "cs.ATG" +#line 2320 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2319 "cs.ATG" +#line 2321 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2321 "cs.ATG" +#line 2323 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1428,26 +1428,26 @@ out typeArguments, canBeUnbound); } while ( -#line 2330 "cs.ATG" +#line 2332 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2331 "cs.ATG" +#line 2333 "cs.ATG" typeArguments = null; Qualident( -#line 2332 "cs.ATG" +#line 2334 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2333 "cs.ATG" +#line 2335 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2334 "cs.ATG" +#line 2336 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } -#line 2336 "cs.ATG" +#line 2338 "cs.ATG" typeRef.StartLocation = startLocation; } @@ -2575,14 +2575,14 @@ out name); } void NullableQuestionMark( -#line 2340 "cs.ATG" +#line 2342 "cs.ATG" ref TypeReference typeRef) { -#line 2341 "cs.ATG" +#line 2343 "cs.ATG" List<TypeReference> typeArguments = new List<TypeReference>(1); Expect(12); -#line 2345 "cs.ATG" +#line 2347 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -3903,35 +3903,40 @@ out Statement statement) { Expression expr = null; Statement embeddedStatement = null; statement = null; + Location elseStart = Location.Empty; Expect(79); Expect(20); Expr( -#line 1639 "cs.ATG" +#line 1640 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1640 "cs.ATG" +#line 1641 "cs.ATG" out embeddedStatement); -#line 1641 "cs.ATG" +#line 1642 "cs.ATG" Statement elseStatement = null; if (la.kind == 67) { lexer.NextToken(); + +#line 1643 "cs.ATG" + elseStart = t.Location; EmbeddedStatement( -#line 1642 "cs.ATG" +#line 1643 "cs.ATG" out elseStatement); } -#line 1643 "cs.ATG" +#line 1644 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1644 "cs.ATG" +#line 1645 "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( - new ElseIfSection((elseStatement as IfElseStatement).Condition, - (elseStatement as IfElseStatement).TrueStatement[0])); + ElseIfSection elseIfSection = new ElseIfSection((elseStatement as IfElseStatement).Condition, (elseStatement as IfElseStatement).TrueStatement[0]); + elseIfSection.StartLocation = elseStart; + elseIfSection.EndLocation = (elseStatement as IfElseStatement).TrueStatement[0].EndLocation; + (statement as IfElseStatement).ElseIfSections.Add(elseIfSection); (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; } @@ -3939,29 +3944,29 @@ out elseStatement); } void SwitchSections( -#line 1674 "cs.ATG" +#line 1676 "cs.ATG" List<SwitchSection> switchSections) { -#line 1676 "cs.ATG" +#line 1678 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1680 "cs.ATG" +#line 1682 "cs.ATG" out label); -#line 1680 "cs.ATG" +#line 1682 "cs.ATG" SafeAdd(switchSection, switchSection.SwitchLabels, label); -#line 1681 "cs.ATG" +#line 1683 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(32)) { if (la.kind == 55 || la.kind == 63) { SwitchLabel( -#line 1683 "cs.ATG" +#line 1685 "cs.ATG" out label); -#line 1684 "cs.ATG" +#line 1686 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -3977,145 +3982,145 @@ out label); } } -#line 1696 "cs.ATG" +#line 1698 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1655 "cs.ATG" +#line 1657 "cs.ATG" out List<Statement> initializer) { -#line 1657 "cs.ATG" +#line 1659 "cs.ATG" Statement stmt; initializer = new List<Statement>(); if ( -#line 1661 "cs.ATG" +#line 1663 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1661 "cs.ATG" +#line 1663 "cs.ATG" out stmt); -#line 1661 "cs.ATG" +#line 1663 "cs.ATG" initializer.Add(stmt); } else if (StartOf(6)) { StatementExpr( -#line 1662 "cs.ATG" +#line 1664 "cs.ATG" out stmt); -#line 1662 "cs.ATG" +#line 1664 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1662 "cs.ATG" +#line 1664 "cs.ATG" out stmt); -#line 1662 "cs.ATG" +#line 1664 "cs.ATG" initializer.Add(stmt); } } else SynErr(201); } void ForIterator( -#line 1665 "cs.ATG" +#line 1667 "cs.ATG" out List<Statement> iterator) { -#line 1667 "cs.ATG" +#line 1669 "cs.ATG" Statement stmt; iterator = new List<Statement>(); StatementExpr( -#line 1671 "cs.ATG" +#line 1673 "cs.ATG" out stmt); -#line 1671 "cs.ATG" +#line 1673 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1671 "cs.ATG" +#line 1673 "cs.ATG" out stmt); -#line 1671 "cs.ATG" +#line 1673 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1753 "cs.ATG" +#line 1755 "cs.ATG" out Statement stmt) { -#line 1754 "cs.ATG" +#line 1756 "cs.ATG" Expression expr; stmt = null; Expect(78); if (StartOf(19)) { Identifier(); -#line 1758 "cs.ATG" +#line 1760 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1759 "cs.ATG" +#line 1761 "cs.ATG" out expr); Expect(11); -#line 1759 "cs.ATG" +#line 1761 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(11); -#line 1760 "cs.ATG" +#line 1762 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(202); } void StatementExpr( -#line 1780 "cs.ATG" +#line 1782 "cs.ATG" out Statement stmt) { -#line 1781 "cs.ATG" +#line 1783 "cs.ATG" Expression expr; Expr( -#line 1783 "cs.ATG" +#line 1785 "cs.ATG" out expr); -#line 1786 "cs.ATG" +#line 1788 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1706 "cs.ATG" +#line 1708 "cs.ATG" out Statement tryStatement) { -#line 1708 "cs.ATG" +#line 1710 "cs.ATG" Statement blockStmt = null, finallyStmt = null; CatchClause catchClause = null; List<CatchClause> catchClauses = new List<CatchClause>(); Expect(114); Block( -#line 1713 "cs.ATG" +#line 1715 "cs.ATG" out blockStmt); while (la.kind == 56) { CatchClause( -#line 1715 "cs.ATG" +#line 1717 "cs.ATG" out catchClause); -#line 1716 "cs.ATG" +#line 1718 "cs.ATG" if (catchClause != null) catchClauses.Add(catchClause); } if (la.kind == 73) { lexer.NextToken(); Block( -#line 1718 "cs.ATG" +#line 1720 "cs.ATG" out finallyStmt); } -#line 1720 "cs.ATG" +#line 1722 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); if (catchClauses != null) { foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; @@ -4124,59 +4129,59 @@ out finallyStmt); } void ResourceAcquisition( -#line 1764 "cs.ATG" +#line 1766 "cs.ATG" out Statement stmt) { -#line 1766 "cs.ATG" +#line 1768 "cs.ATG" stmt = null; Expression expr; if ( -#line 1771 "cs.ATG" +#line 1773 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1771 "cs.ATG" +#line 1773 "cs.ATG" out stmt); } else if (StartOf(6)) { Expr( -#line 1772 "cs.ATG" +#line 1774 "cs.ATG" out expr); -#line 1776 "cs.ATG" +#line 1778 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(203); } void SwitchLabel( -#line 1699 "cs.ATG" +#line 1701 "cs.ATG" out CaseLabel label) { -#line 1700 "cs.ATG" +#line 1702 "cs.ATG" Expression expr = null; label = null; if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1702 "cs.ATG" +#line 1704 "cs.ATG" out expr); Expect(9); -#line 1702 "cs.ATG" +#line 1704 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(9); -#line 1703 "cs.ATG" +#line 1705 "cs.ATG" label = new CaseLabel(); } else SynErr(204); } void CatchClause( -#line 1727 "cs.ATG" +#line 1729 "cs.ATG" out CatchClause catchClause) { Expect(56); -#line 1729 "cs.ATG" +#line 1731 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; @@ -4185,35 +4190,35 @@ out CatchClause catchClause) { if (la.kind == 16) { Block( -#line 1737 "cs.ATG" +#line 1739 "cs.ATG" out stmt); -#line 1737 "cs.ATG" +#line 1739 "cs.ATG" catchClause = new CatchClause(stmt); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1740 "cs.ATG" +#line 1742 "cs.ATG" out typeRef, false); -#line 1740 "cs.ATG" +#line 1742 "cs.ATG" identifier = null; if (StartOf(19)) { Identifier(); -#line 1741 "cs.ATG" +#line 1743 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1742 "cs.ATG" +#line 1744 "cs.ATG" out stmt); -#line 1743 "cs.ATG" +#line 1745 "cs.ATG" catchClause = new CatchClause(typeRef, identifier, stmt); } else SynErr(205); -#line 1746 "cs.ATG" +#line 1748 "cs.ATG" if (catchClause != null) { catchClause.StartLocation = startPos; catchClause.EndLocation = t.Location; @@ -4222,75 +4227,75 @@ out stmt); } void UnaryExpr( -#line 1813 "cs.ATG" +#line 1815 "cs.ATG" out Expression uExpr) { -#line 1815 "cs.ATG" +#line 1817 "cs.ATG" TypeReference type = null; Expression expr = null; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(33) || -#line 1837 "cs.ATG" +#line 1839 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1824 "cs.ATG" +#line 1826 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1825 "cs.ATG" +#line 1827 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 1826 "cs.ATG" +#line 1828 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1827 "cs.ATG" +#line 1829 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1828 "cs.ATG" +#line 1830 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1829 "cs.ATG" +#line 1831 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 1830 "cs.ATG" +#line 1832 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 1831 "cs.ATG" +#line 1833 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf)); } else { Expect(20); Type( -#line 1837 "cs.ATG" +#line 1839 "cs.ATG" out type); Expect(21); -#line 1837 "cs.ATG" +#line 1839 "cs.ATG" expressions.Add(new CastExpression(type)); } } if ( -#line 1842 "cs.ATG" +#line 1844 "cs.ATG" LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) { Expect(2); -#line 1845 "cs.ATG" +#line 1847 "cs.ATG" expressions.RemoveAt(expressions.Count - 1); if (t.literalValue is uint) { expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString()); @@ -4302,11 +4307,11 @@ LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffi } else if (StartOf(34)) { PrimaryExpr( -#line 1854 "cs.ATG" +#line 1856 "cs.ATG" out expr); } else SynErr(206); -#line 1856 "cs.ATG" +#line 1858 "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) { @@ -4324,325 +4329,325 @@ out expr); } void ConditionalOrExpr( -#line 2178 "cs.ATG" +#line 2180 "cs.ATG" ref Expression outExpr) { -#line 2179 "cs.ATG" +#line 2181 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2181 "cs.ATG" +#line 2183 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2181 "cs.ATG" +#line 2183 "cs.ATG" out expr); ConditionalAndExpr( -#line 2181 "cs.ATG" +#line 2183 "cs.ATG" ref expr); -#line 2181 "cs.ATG" +#line 2183 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1873 "cs.ATG" +#line 1875 "cs.ATG" out Expression pexpr) { -#line 1875 "cs.ATG" +#line 1877 "cs.ATG" TypeReference type = null; Expression expr; pexpr = null; -#line 1880 "cs.ATG" +#line 1882 "cs.ATG" Location startLocation = la.Location; if (la.kind == 113) { lexer.NextToken(); -#line 1882 "cs.ATG" +#line 1884 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); -#line 1883 "cs.ATG" +#line 1885 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); -#line 1884 "cs.ATG" +#line 1886 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1885 "cs.ATG" +#line 1887 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; } else if ( -#line 1886 "cs.ATG" +#line 1888 "cs.ATG" StartOfQueryExpression()) { QueryExpression( -#line 1887 "cs.ATG" +#line 1889 "cs.ATG" out pexpr); } else if ( -#line 1888 "cs.ATG" +#line 1890 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 1889 "cs.ATG" +#line 1891 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1890 "cs.ATG" +#line 1892 "cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); -#line 1891 "cs.ATG" +#line 1893 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); } else if (StartOf(19)) { Identifier(); -#line 1895 "cs.ATG" +#line 1897 "cs.ATG" pexpr = new IdentifierExpression(t.val); if (la.kind == 48 || -#line 1898 "cs.ATG" +#line 1900 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { if (la.kind == 48) { ShortedLambdaExpression( -#line 1897 "cs.ATG" +#line 1899 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); } else { -#line 1899 "cs.ATG" +#line 1901 "cs.ATG" List<TypeReference> typeList; TypeArgumentList( -#line 1900 "cs.ATG" +#line 1902 "cs.ATG" out typeList, false); -#line 1901 "cs.ATG" +#line 1903 "cs.ATG" ((IdentifierExpression)pexpr).TypeArguments = typeList; } } } else if ( -#line 1903 "cs.ATG" +#line 1905 "cs.ATG" IsLambdaExpression()) { LambdaExpression( -#line 1904 "cs.ATG" +#line 1906 "cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1907 "cs.ATG" +#line 1909 "cs.ATG" out expr); Expect(21); -#line 1907 "cs.ATG" +#line 1909 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(35)) { -#line 1910 "cs.ATG" +#line 1912 "cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); -#line 1911 "cs.ATG" +#line 1913 "cs.ATG" val = "System.Boolean"; break; } case 54: { lexer.NextToken(); -#line 1912 "cs.ATG" +#line 1914 "cs.ATG" val = "System.Byte"; break; } case 57: { lexer.NextToken(); -#line 1913 "cs.ATG" +#line 1915 "cs.ATG" val = "System.Char"; break; } case 62: { lexer.NextToken(); -#line 1914 "cs.ATG" +#line 1916 "cs.ATG" val = "System.Decimal"; break; } case 66: { lexer.NextToken(); -#line 1915 "cs.ATG" +#line 1917 "cs.ATG" val = "System.Double"; break; } case 75: { lexer.NextToken(); -#line 1916 "cs.ATG" +#line 1918 "cs.ATG" val = "System.Single"; break; } case 82: { lexer.NextToken(); -#line 1917 "cs.ATG" +#line 1919 "cs.ATG" val = "System.Int32"; break; } case 87: { lexer.NextToken(); -#line 1918 "cs.ATG" +#line 1920 "cs.ATG" val = "System.Int64"; break; } case 91: { lexer.NextToken(); -#line 1919 "cs.ATG" +#line 1921 "cs.ATG" val = "System.Object"; break; } case 102: { lexer.NextToken(); -#line 1920 "cs.ATG" +#line 1922 "cs.ATG" val = "System.SByte"; break; } case 104: { lexer.NextToken(); -#line 1921 "cs.ATG" +#line 1923 "cs.ATG" val = "System.Int16"; break; } case 108: { lexer.NextToken(); -#line 1922 "cs.ATG" +#line 1924 "cs.ATG" val = "System.String"; break; } case 116: { lexer.NextToken(); -#line 1923 "cs.ATG" +#line 1925 "cs.ATG" val = "System.UInt32"; break; } case 117: { lexer.NextToken(); -#line 1924 "cs.ATG" +#line 1926 "cs.ATG" val = "System.UInt64"; break; } case 120: { lexer.NextToken(); -#line 1925 "cs.ATG" +#line 1927 "cs.ATG" val = "System.UInt16"; break; } case 123: { lexer.NextToken(); -#line 1926 "cs.ATG" +#line 1928 "cs.ATG" val = "System.Void"; break; } } -#line 1928 "cs.ATG" +#line 1930 "cs.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; } else if (la.kind == 111) { lexer.NextToken(); -#line 1931 "cs.ATG" +#line 1933 "cs.ATG" pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 51) { lexer.NextToken(); -#line 1933 "cs.ATG" +#line 1935 "cs.ATG" pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 89) { NewExpression( -#line 1936 "cs.ATG" +#line 1938 "cs.ATG" out pexpr); } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( -#line 1940 "cs.ATG" +#line 1942 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1940 "cs.ATG" +#line 1942 "cs.ATG" type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( -#line 1941 "cs.ATG" +#line 1943 "cs.ATG" out type, true, true); } else SynErr(207); Expect(21); -#line 1943 "cs.ATG" +#line 1945 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( -#line 1945 "cs.ATG" +#line 1947 "cs.ATG" out type); Expect(21); -#line 1945 "cs.ATG" +#line 1947 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( -#line 1946 "cs.ATG" +#line 1948 "cs.ATG" out type); Expect(21); -#line 1946 "cs.ATG" +#line 1948 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( -#line 1947 "cs.ATG" +#line 1949 "cs.ATG" out expr); Expect(21); -#line 1947 "cs.ATG" +#line 1949 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( -#line 1948 "cs.ATG" +#line 1950 "cs.ATG" out expr); Expect(21); -#line 1948 "cs.ATG" +#line 1950 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( -#line 1949 "cs.ATG" +#line 1951 "cs.ATG" out expr); -#line 1949 "cs.ATG" +#line 1951 "cs.ATG" pexpr = expr; } else SynErr(208); -#line 1951 "cs.ATG" +#line 1953 "cs.ATG" if (pexpr != null) { if (pexpr.StartLocation.IsEmpty) pexpr.StartLocation = startLocation; @@ -4653,78 +4658,78 @@ out expr); while (StartOf(36)) { if (la.kind == 31 || la.kind == 32) { -#line 1959 "cs.ATG" +#line 1961 "cs.ATG" startLocation = la.Location; if (la.kind == 31) { lexer.NextToken(); -#line 1961 "cs.ATG" +#line 1963 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 1962 "cs.ATG" +#line 1964 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(209); } else if (la.kind == 47) { PointerMemberAccess( -#line 1965 "cs.ATG" +#line 1967 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 15) { MemberAccess( -#line 1966 "cs.ATG" +#line 1968 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 20) { lexer.NextToken(); -#line 1970 "cs.ATG" +#line 1972 "cs.ATG" List<Expression> parameters = new List<Expression>(); -#line 1971 "cs.ATG" +#line 1973 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); if (StartOf(26)) { Argument( -#line 1972 "cs.ATG" +#line 1974 "cs.ATG" out expr); -#line 1972 "cs.ATG" +#line 1974 "cs.ATG" SafeAdd(pexpr, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1973 "cs.ATG" +#line 1975 "cs.ATG" out expr); -#line 1973 "cs.ATG" +#line 1975 "cs.ATG" SafeAdd(pexpr, parameters, expr); } } Expect(21); } else { -#line 1979 "cs.ATG" +#line 1981 "cs.ATG" List<Expression> indices = new List<Expression>(); pexpr = new IndexerExpression(pexpr, indices); lexer.NextToken(); Expr( -#line 1982 "cs.ATG" +#line 1984 "cs.ATG" out expr); -#line 1982 "cs.ATG" +#line 1984 "cs.ATG" SafeAdd(pexpr, indices, expr); while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1983 "cs.ATG" +#line 1985 "cs.ATG" out expr); -#line 1983 "cs.ATG" +#line 1985 "cs.ATG" SafeAdd(pexpr, indices, expr); } Expect(19); -#line 1986 "cs.ATG" +#line 1988 "cs.ATG" if (pexpr != null) { pexpr.StartLocation = startLocation; pexpr.EndLocation = t.EndLocation; @@ -4735,83 +4740,83 @@ out expr); } void QueryExpression( -#line 2416 "cs.ATG" +#line 2418 "cs.ATG" out Expression outExpr) { -#line 2417 "cs.ATG" +#line 2419 "cs.ATG" QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; QueryExpressionFromClause fromClause; QueryExpressionFromClause( -#line 2421 "cs.ATG" +#line 2423 "cs.ATG" out fromClause); -#line 2421 "cs.ATG" +#line 2423 "cs.ATG" q.FromClause = fromClause; QueryExpressionBody( -#line 2422 "cs.ATG" +#line 2424 "cs.ATG" ref q); -#line 2423 "cs.ATG" +#line 2425 "cs.ATG" q.EndLocation = t.EndLocation; outExpr = q; /* set outExpr to q again if QueryExpressionBody changed it (can happen with 'into' clauses) */ } void ShortedLambdaExpression( -#line 2098 "cs.ATG" +#line 2100 "cs.ATG" IdentifierExpression ident, out Expression pexpr) { -#line 2099 "cs.ATG" +#line 2101 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); -#line 2104 "cs.ATG" +#line 2106 "cs.ATG" lambda.StartLocation = ident.StartLocation; SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier)); lambda.Parameters[0].StartLocation = ident.StartLocation; lambda.Parameters[0].EndLocation = ident.EndLocation; LambdaExpressionBody( -#line 2109 "cs.ATG" +#line 2111 "cs.ATG" lambda); } void TypeArgumentList( -#line 2350 "cs.ATG" +#line 2352 "cs.ATG" out List<TypeReference> types, bool canBeUnbound) { -#line 2352 "cs.ATG" +#line 2354 "cs.ATG" types = new List<TypeReference>(); TypeReference type = null; Expect(23); if ( -#line 2357 "cs.ATG" +#line 2359 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2358 "cs.ATG" +#line 2360 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2359 "cs.ATG" +#line 2361 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(10)) { Type( -#line 2360 "cs.ATG" +#line 2362 "cs.ATG" out type); -#line 2360 "cs.ATG" +#line 2362 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2361 "cs.ATG" +#line 2363 "cs.ATG" out type); -#line 2361 "cs.ATG" +#line 2363 "cs.ATG" if (type != null) { types.Add(type); } } } else SynErr(210); @@ -4819,10 +4824,10 @@ out type); } void LambdaExpression( -#line 2078 "cs.ATG" +#line 2080 "cs.ATG" out Expression outExpr) { -#line 2080 "cs.ATG" +#line 2082 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; ParameterDeclarationExpression p; @@ -4831,33 +4836,33 @@ out Expression outExpr) { Expect(20); if (StartOf(18)) { LambdaExpressionParameter( -#line 2088 "cs.ATG" +#line 2090 "cs.ATG" out p); -#line 2088 "cs.ATG" +#line 2090 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); while (la.kind == 14) { lexer.NextToken(); LambdaExpressionParameter( -#line 2090 "cs.ATG" +#line 2092 "cs.ATG" out p); -#line 2090 "cs.ATG" +#line 2092 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); } } Expect(21); Expect(48); LambdaExpressionBody( -#line 2095 "cs.ATG" +#line 2097 "cs.ATG" lambda); } void NewExpression( -#line 2025 "cs.ATG" +#line 2027 "cs.ATG" out Expression pexpr) { -#line 2026 "cs.ATG" +#line 2028 "cs.ATG" pexpr = null; List<Expression> parameters = new List<Expression>(); TypeReference type = null; @@ -4866,65 +4871,65 @@ out Expression pexpr) { Expect(89); if (StartOf(10)) { NonArrayType( -#line 2033 "cs.ATG" +#line 2035 "cs.ATG" out type); } if (la.kind == 16 || la.kind == 20) { if (la.kind == 20) { -#line 2039 "cs.ATG" +#line 2041 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); lexer.NextToken(); -#line 2040 "cs.ATG" +#line 2042 "cs.ATG" if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); if (StartOf(26)) { Argument( -#line 2041 "cs.ATG" +#line 2043 "cs.ATG" out expr); -#line 2041 "cs.ATG" +#line 2043 "cs.ATG" SafeAdd(oce, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2042 "cs.ATG" +#line 2044 "cs.ATG" out expr); -#line 2042 "cs.ATG" +#line 2044 "cs.ATG" SafeAdd(oce, parameters, expr); } } Expect(21); -#line 2044 "cs.ATG" +#line 2046 "cs.ATG" pexpr = oce; if (la.kind == 16) { CollectionOrObjectInitializer( -#line 2045 "cs.ATG" +#line 2047 "cs.ATG" out expr); -#line 2045 "cs.ATG" +#line 2047 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; } } else { -#line 2046 "cs.ATG" +#line 2048 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); CollectionOrObjectInitializer( -#line 2047 "cs.ATG" +#line 2049 "cs.ATG" out expr); -#line 2047 "cs.ATG" +#line 2049 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; -#line 2048 "cs.ATG" +#line 2050 "cs.ATG" pexpr = oce; } } else if (la.kind == 18) { lexer.NextToken(); -#line 2053 "cs.ATG" +#line 2055 "cs.ATG" ArrayCreateExpression ace = new ArrayCreateExpression(type); /* we must not change RankSpecifier on the null type reference*/ if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); } @@ -4935,80 +4940,80 @@ out expr); while (la.kind == 14) { lexer.NextToken(); -#line 2060 "cs.ATG" +#line 2062 "cs.ATG" dims += 1; } Expect(19); -#line 2061 "cs.ATG" +#line 2063 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2062 "cs.ATG" +#line 2064 "cs.ATG" ++dims; } Expect(19); -#line 2062 "cs.ATG" +#line 2064 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2063 "cs.ATG" +#line 2065 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); CollectionInitializer( -#line 2064 "cs.ATG" +#line 2066 "cs.ATG" out expr); -#line 2064 "cs.ATG" +#line 2066 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } else if (StartOf(6)) { Expr( -#line 2065 "cs.ATG" +#line 2067 "cs.ATG" out expr); -#line 2065 "cs.ATG" +#line 2067 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2066 "cs.ATG" +#line 2068 "cs.ATG" dims += 1; Expr( -#line 2067 "cs.ATG" +#line 2069 "cs.ATG" out expr); -#line 2067 "cs.ATG" +#line 2069 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2069 "cs.ATG" +#line 2071 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2070 "cs.ATG" +#line 2072 "cs.ATG" ++dims; } Expect(19); -#line 2070 "cs.ATG" +#line 2072 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2071 "cs.ATG" +#line 2073 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { CollectionInitializer( -#line 2072 "cs.ATG" +#line 2074 "cs.ATG" out expr); -#line 2072 "cs.ATG" +#line 2074 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } } else SynErr(211); @@ -5016,10 +5021,10 @@ out expr); } void AnonymousMethodExpr( -#line 2145 "cs.ATG" +#line 2147 "cs.ATG" out Expression outExpr) { -#line 2147 "cs.ATG" +#line 2149 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; BlockStatement stmt; @@ -5030,59 +5035,59 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(11)) { FormalParameterList( -#line 2156 "cs.ATG" +#line 2158 "cs.ATG" p); -#line 2156 "cs.ATG" +#line 2158 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 2158 "cs.ATG" +#line 2160 "cs.ATG" expr.HasParameterList = true; } BlockInsideExpression( -#line 2160 "cs.ATG" +#line 2162 "cs.ATG" out stmt); -#line 2160 "cs.ATG" +#line 2162 "cs.ATG" expr.Body = stmt; -#line 2161 "cs.ATG" +#line 2163 "cs.ATG" expr.EndLocation = t.Location; } void PointerMemberAccess( -#line 2013 "cs.ATG" +#line 2015 "cs.ATG" out Expression expr, Expression target) { -#line 2014 "cs.ATG" +#line 2016 "cs.ATG" List<TypeReference> typeList; Expect(47); Identifier(); -#line 2018 "cs.ATG" +#line 2020 "cs.ATG" expr = new PointerReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 2019 "cs.ATG" +#line 2021 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2020 "cs.ATG" +#line 2022 "cs.ATG" out typeList, false); -#line 2021 "cs.ATG" +#line 2023 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void MemberAccess( -#line 1994 "cs.ATG" +#line 1996 "cs.ATG" out Expression expr, Expression target) { -#line 1995 "cs.ATG" +#line 1997 "cs.ATG" List<TypeReference> typeList; -#line 1997 "cs.ATG" +#line 1999 "cs.ATG" if (ShouldConvertTargetExpressionToTypeReference(target)) { TypeReference type = GetTypeReferenceFromExpression(target); if (type != null) { @@ -5093,35 +5098,35 @@ out Expression expr, Expression target) { Expect(15); Identifier(); -#line 2006 "cs.ATG" +#line 2008 "cs.ATG" expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 2007 "cs.ATG" +#line 2009 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2008 "cs.ATG" +#line 2010 "cs.ATG" out typeList, false); -#line 2009 "cs.ATG" +#line 2011 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void LambdaExpressionParameter( -#line 2112 "cs.ATG" +#line 2114 "cs.ATG" out ParameterDeclarationExpression p) { -#line 2113 "cs.ATG" +#line 2115 "cs.ATG" Location start = la.Location; p = null; TypeReference type; ParameterModifiers mod = ParameterModifiers.In; if ( -#line 2118 "cs.ATG" +#line 2120 "cs.ATG" Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { Identifier(); -#line 2120 "cs.ATG" +#line 2122 "cs.ATG" p = new ParameterDeclarationExpression(null, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5130,21 +5135,21 @@ Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { if (la.kind == 100) { lexer.NextToken(); -#line 2123 "cs.ATG" +#line 2125 "cs.ATG" mod = ParameterModifiers.Ref; } else { lexer.NextToken(); -#line 2124 "cs.ATG" +#line 2126 "cs.ATG" mod = ParameterModifiers.Out; } } Type( -#line 2126 "cs.ATG" +#line 2128 "cs.ATG" out type); Identifier(); -#line 2128 "cs.ATG" +#line 2130 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5152,263 +5157,263 @@ out type); } void LambdaExpressionBody( -#line 2134 "cs.ATG" +#line 2136 "cs.ATG" LambdaExpression lambda) { -#line 2135 "cs.ATG" +#line 2137 "cs.ATG" Expression expr; BlockStatement stmt; if (la.kind == 16) { BlockInsideExpression( -#line 2138 "cs.ATG" +#line 2140 "cs.ATG" out stmt); -#line 2138 "cs.ATG" +#line 2140 "cs.ATG" lambda.StatementBody = stmt; } else if (StartOf(6)) { Expr( -#line 2139 "cs.ATG" +#line 2141 "cs.ATG" out expr); -#line 2139 "cs.ATG" +#line 2141 "cs.ATG" lambda.ExpressionBody = expr; } else SynErr(214); -#line 2141 "cs.ATG" +#line 2143 "cs.ATG" lambda.EndLocation = t.EndLocation; -#line 2142 "cs.ATG" +#line 2144 "cs.ATG" lambda.ExtendedEndLocation = la.Location; } void BlockInsideExpression( -#line 2164 "cs.ATG" +#line 2166 "cs.ATG" out BlockStatement outStmt) { -#line 2165 "cs.ATG" +#line 2167 "cs.ATG" Statement stmt = null; outStmt = null; -#line 2169 "cs.ATG" +#line 2171 "cs.ATG" if (compilationUnit != null) { Block( -#line 2170 "cs.ATG" +#line 2172 "cs.ATG" out stmt); -#line 2170 "cs.ATG" +#line 2172 "cs.ATG" outStmt = (BlockStatement)stmt; -#line 2171 "cs.ATG" +#line 2173 "cs.ATG" } else { Expect(16); -#line 2173 "cs.ATG" +#line 2175 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 2175 "cs.ATG" +#line 2177 "cs.ATG" } } void ConditionalAndExpr( -#line 2184 "cs.ATG" +#line 2186 "cs.ATG" ref Expression outExpr) { -#line 2185 "cs.ATG" +#line 2187 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2187 "cs.ATG" +#line 2189 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2187 "cs.ATG" +#line 2189 "cs.ATG" out expr); InclusiveOrExpr( -#line 2187 "cs.ATG" +#line 2189 "cs.ATG" ref expr); -#line 2187 "cs.ATG" +#line 2189 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2190 "cs.ATG" +#line 2192 "cs.ATG" ref Expression outExpr) { -#line 2191 "cs.ATG" +#line 2193 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2193 "cs.ATG" +#line 2195 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2193 "cs.ATG" +#line 2195 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2193 "cs.ATG" +#line 2195 "cs.ATG" ref expr); -#line 2193 "cs.ATG" +#line 2195 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2196 "cs.ATG" +#line 2198 "cs.ATG" ref Expression outExpr) { -#line 2197 "cs.ATG" +#line 2199 "cs.ATG" Expression expr; AndExpr( -#line 2199 "cs.ATG" +#line 2201 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2199 "cs.ATG" +#line 2201 "cs.ATG" out expr); AndExpr( -#line 2199 "cs.ATG" +#line 2201 "cs.ATG" ref expr); -#line 2199 "cs.ATG" +#line 2201 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2202 "cs.ATG" +#line 2204 "cs.ATG" ref Expression outExpr) { -#line 2203 "cs.ATG" +#line 2205 "cs.ATG" Expression expr; EqualityExpr( -#line 2205 "cs.ATG" +#line 2207 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2205 "cs.ATG" +#line 2207 "cs.ATG" out expr); EqualityExpr( -#line 2205 "cs.ATG" +#line 2207 "cs.ATG" ref expr); -#line 2205 "cs.ATG" +#line 2207 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2208 "cs.ATG" +#line 2210 "cs.ATG" ref Expression outExpr) { -#line 2210 "cs.ATG" +#line 2212 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2214 "cs.ATG" +#line 2216 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2217 "cs.ATG" +#line 2219 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2218 "cs.ATG" +#line 2220 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2220 "cs.ATG" +#line 2222 "cs.ATG" out expr); RelationalExpr( -#line 2220 "cs.ATG" +#line 2222 "cs.ATG" ref expr); -#line 2220 "cs.ATG" +#line 2222 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2224 "cs.ATG" +#line 2226 "cs.ATG" ref Expression outExpr) { -#line 2226 "cs.ATG" +#line 2228 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2231 "cs.ATG" +#line 2233 "cs.ATG" ref outExpr); while (StartOf(37)) { if (StartOf(38)) { if (la.kind == 23) { lexer.NextToken(); -#line 2233 "cs.ATG" +#line 2235 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2234 "cs.ATG" +#line 2236 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2235 "cs.ATG" +#line 2237 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2236 "cs.ATG" +#line 2238 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(215); UnaryExpr( -#line 2238 "cs.ATG" +#line 2240 "cs.ATG" out expr); ShiftExpr( -#line 2239 "cs.ATG" +#line 2241 "cs.ATG" ref expr); -#line 2240 "cs.ATG" +#line 2242 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 85) { lexer.NextToken(); TypeWithRestriction( -#line 2243 "cs.ATG" +#line 2245 "cs.ATG" out type, false, false); if ( -#line 2244 "cs.ATG" +#line 2246 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2245 "cs.ATG" +#line 2247 "cs.ATG" ref type); } -#line 2246 "cs.ATG" +#line 2248 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 50) { lexer.NextToken(); TypeWithRestriction( -#line 2248 "cs.ATG" +#line 2250 "cs.ATG" out type, false, false); if ( -#line 2249 "cs.ATG" +#line 2251 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2250 "cs.ATG" +#line 2252 "cs.ATG" ref type); } -#line 2251 "cs.ATG" +#line 2253 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(216); } @@ -5416,83 +5421,83 @@ ref type); } void ShiftExpr( -#line 2256 "cs.ATG" +#line 2258 "cs.ATG" ref Expression outExpr) { -#line 2258 "cs.ATG" +#line 2260 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2262 "cs.ATG" +#line 2264 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2265 "cs.ATG" +#line 2267 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2264 "cs.ATG" +#line 2266 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2266 "cs.ATG" +#line 2268 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2269 "cs.ATG" +#line 2271 "cs.ATG" out expr); AdditiveExpr( -#line 2269 "cs.ATG" +#line 2271 "cs.ATG" ref expr); -#line 2269 "cs.ATG" +#line 2271 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2273 "cs.ATG" +#line 2275 "cs.ATG" ref Expression outExpr) { -#line 2275 "cs.ATG" +#line 2277 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2279 "cs.ATG" +#line 2281 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2282 "cs.ATG" +#line 2284 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2283 "cs.ATG" +#line 2285 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2285 "cs.ATG" +#line 2287 "cs.ATG" out expr); MultiplicativeExpr( -#line 2285 "cs.ATG" +#line 2287 "cs.ATG" ref expr); -#line 2285 "cs.ATG" +#line 2287 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2289 "cs.ATG" +#line 2291 "cs.ATG" ref Expression outExpr) { -#line 2291 "cs.ATG" +#line 2293 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5500,82 +5505,82 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2297 "cs.ATG" +#line 2299 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2298 "cs.ATG" +#line 2300 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2299 "cs.ATG" +#line 2301 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2301 "cs.ATG" +#line 2303 "cs.ATG" out expr); -#line 2301 "cs.ATG" +#line 2303 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2407 "cs.ATG" +#line 2409 "cs.ATG" out TypeReference type) { -#line 2408 "cs.ATG" +#line 2410 "cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); -#line 2410 "cs.ATG" +#line 2412 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); -#line 2411 "cs.ATG" +#line 2413 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); -#line 2412 "cs.ATG" +#line 2414 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( -#line 2413 "cs.ATG" +#line 2415 "cs.ATG" out t); -#line 2413 "cs.ATG" +#line 2415 "cs.ATG" type = t; } else SynErr(217); } void QueryExpressionFromClause( -#line 2428 "cs.ATG" +#line 2430 "cs.ATG" out QueryExpressionFromClause fc) { -#line 2429 "cs.ATG" +#line 2431 "cs.ATG" fc = new QueryExpressionFromClause(); fc.StartLocation = la.Location; Expect(137); QueryExpressionFromOrJoinClause( -#line 2433 "cs.ATG" +#line 2435 "cs.ATG" fc); -#line 2434 "cs.ATG" +#line 2436 "cs.ATG" fc.EndLocation = t.EndLocation; } void QueryExpressionBody( -#line 2464 "cs.ATG" +#line 2466 "cs.ATG" ref QueryExpression q) { -#line 2465 "cs.ATG" +#line 2467 "cs.ATG" QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; QueryExpressionOrderClause orderClause; @@ -5584,249 +5589,249 @@ ref QueryExpression q) { while (StartOf(39)) { if (la.kind == 137) { QueryExpressionFromClause( -#line 2471 "cs.ATG" +#line 2473 "cs.ATG" out fromClause); -#line 2471 "cs.ATG" +#line 2473 "cs.ATG" SafeAdd<QueryExpressionClause>(q, q.MiddleClauses, fromClause); } else if (la.kind == 127) { QueryExpressionWhereClause( -#line 2472 "cs.ATG" +#line 2474 "cs.ATG" out whereClause); -#line 2472 "cs.ATG" +#line 2474 "cs.ATG" SafeAdd<QueryExpressionClause>(q, q.MiddleClauses, whereClause); } else if (la.kind == 141) { QueryExpressionLetClause( -#line 2473 "cs.ATG" +#line 2475 "cs.ATG" out letClause); -#line 2473 "cs.ATG" +#line 2475 "cs.ATG" SafeAdd<QueryExpressionClause>(q, q.MiddleClauses, letClause); } else if (la.kind == 142) { QueryExpressionJoinClause( -#line 2474 "cs.ATG" +#line 2476 "cs.ATG" out joinClause); -#line 2474 "cs.ATG" +#line 2476 "cs.ATG" SafeAdd<QueryExpressionClause>(q, q.MiddleClauses, joinClause); } else { QueryExpressionOrderByClause( -#line 2475 "cs.ATG" +#line 2477 "cs.ATG" out orderClause); -#line 2475 "cs.ATG" +#line 2477 "cs.ATG" SafeAdd<QueryExpressionClause>(q, q.MiddleClauses, orderClause); } } if (la.kind == 133) { QueryExpressionSelectClause( -#line 2477 "cs.ATG" +#line 2479 "cs.ATG" out selectClause); -#line 2477 "cs.ATG" +#line 2479 "cs.ATG" q.SelectOrGroupClause = selectClause; } else if (la.kind == 134) { QueryExpressionGroupClause( -#line 2478 "cs.ATG" +#line 2480 "cs.ATG" out groupClause); -#line 2478 "cs.ATG" +#line 2480 "cs.ATG" q.SelectOrGroupClause = groupClause; } else SynErr(218); if (la.kind == 136) { QueryExpressionIntoClause( -#line 2480 "cs.ATG" +#line 2482 "cs.ATG" ref q); } } void QueryExpressionFromOrJoinClause( -#line 2454 "cs.ATG" +#line 2456 "cs.ATG" QueryExpressionFromOrJoinClause fjc) { -#line 2455 "cs.ATG" +#line 2457 "cs.ATG" TypeReference type; Expression expr; -#line 2457 "cs.ATG" +#line 2459 "cs.ATG" fjc.Type = null; if ( -#line 2458 "cs.ATG" +#line 2460 "cs.ATG" IsLocalVarDecl()) { Type( -#line 2458 "cs.ATG" +#line 2460 "cs.ATG" out type); -#line 2458 "cs.ATG" +#line 2460 "cs.ATG" fjc.Type = type; } Identifier(); -#line 2459 "cs.ATG" +#line 2461 "cs.ATG" fjc.Identifier = t.val; Expect(81); Expr( -#line 2461 "cs.ATG" +#line 2463 "cs.ATG" out expr); -#line 2461 "cs.ATG" +#line 2463 "cs.ATG" fjc.InExpression = expr; } void QueryExpressionJoinClause( -#line 2437 "cs.ATG" +#line 2439 "cs.ATG" out QueryExpressionJoinClause jc) { -#line 2438 "cs.ATG" +#line 2440 "cs.ATG" jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; Expression expr; Expect(142); QueryExpressionFromOrJoinClause( -#line 2443 "cs.ATG" +#line 2445 "cs.ATG" jc); Expect(143); Expr( -#line 2445 "cs.ATG" +#line 2447 "cs.ATG" out expr); -#line 2445 "cs.ATG" +#line 2447 "cs.ATG" jc.OnExpression = expr; Expect(144); Expr( -#line 2447 "cs.ATG" +#line 2449 "cs.ATG" out expr); -#line 2447 "cs.ATG" +#line 2449 "cs.ATG" jc.EqualsExpression = expr; if (la.kind == 136) { lexer.NextToken(); Identifier(); -#line 2449 "cs.ATG" +#line 2451 "cs.ATG" jc.IntoIdentifier = t.val; } -#line 2451 "cs.ATG" +#line 2453 "cs.ATG" jc.EndLocation = t.EndLocation; } void QueryExpressionWhereClause( -#line 2483 "cs.ATG" +#line 2485 "cs.ATG" out QueryExpressionWhereClause wc) { -#line 2484 "cs.ATG" +#line 2486 "cs.ATG" Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; Expect(127); Expr( -#line 2487 "cs.ATG" +#line 2489 "cs.ATG" out expr); -#line 2487 "cs.ATG" +#line 2489 "cs.ATG" wc.Condition = expr; -#line 2488 "cs.ATG" +#line 2490 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionLetClause( -#line 2491 "cs.ATG" +#line 2493 "cs.ATG" out QueryExpressionLetClause wc) { -#line 2492 "cs.ATG" +#line 2494 "cs.ATG" Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; Expect(141); Identifier(); -#line 2495 "cs.ATG" +#line 2497 "cs.ATG" wc.Identifier = t.val; Expect(3); Expr( -#line 2497 "cs.ATG" +#line 2499 "cs.ATG" out expr); -#line 2497 "cs.ATG" +#line 2499 "cs.ATG" wc.Expression = expr; -#line 2498 "cs.ATG" +#line 2500 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionOrderByClause( -#line 2501 "cs.ATG" +#line 2503 "cs.ATG" out QueryExpressionOrderClause oc) { -#line 2502 "cs.ATG" +#line 2504 "cs.ATG" QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; Expect(140); QueryExpressionOrdering( -#line 2505 "cs.ATG" +#line 2507 "cs.ATG" out ordering); -#line 2505 "cs.ATG" +#line 2507 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); while (la.kind == 14) { lexer.NextToken(); QueryExpressionOrdering( -#line 2507 "cs.ATG" +#line 2509 "cs.ATG" out ordering); -#line 2507 "cs.ATG" +#line 2509 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); } -#line 2509 "cs.ATG" +#line 2511 "cs.ATG" oc.EndLocation = t.EndLocation; } void QueryExpressionSelectClause( -#line 2522 "cs.ATG" +#line 2524 "cs.ATG" out QueryExpressionSelectClause sc) { -#line 2523 "cs.ATG" +#line 2525 "cs.ATG" Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; Expect(133); Expr( -#line 2526 "cs.ATG" +#line 2528 "cs.ATG" out expr); -#line 2526 "cs.ATG" +#line 2528 "cs.ATG" sc.Projection = expr; -#line 2527 "cs.ATG" +#line 2529 "cs.ATG" sc.EndLocation = t.EndLocation; } void QueryExpressionGroupClause( -#line 2530 "cs.ATG" +#line 2532 "cs.ATG" out QueryExpressionGroupClause gc) { -#line 2531 "cs.ATG" +#line 2533 "cs.ATG" Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; Expect(134); Expr( -#line 2534 "cs.ATG" +#line 2536 "cs.ATG" out expr); -#line 2534 "cs.ATG" +#line 2536 "cs.ATG" gc.Projection = expr; Expect(135); Expr( -#line 2536 "cs.ATG" +#line 2538 "cs.ATG" out expr); -#line 2536 "cs.ATG" +#line 2538 "cs.ATG" gc.GroupBy = expr; -#line 2537 "cs.ATG" +#line 2539 "cs.ATG" gc.EndLocation = t.EndLocation; } void QueryExpressionIntoClause( -#line 2540 "cs.ATG" +#line 2542 "cs.ATG" ref QueryExpression q) { -#line 2541 "cs.ATG" +#line 2543 "cs.ATG" QueryExpression firstQuery = q; QueryExpression continuedQuery = new QueryExpression(); continuedQuery.StartLocation = q.StartLocation; @@ -5841,43 +5846,43 @@ ref QueryExpression q) { Expect(136); Identifier(); -#line 2554 "cs.ATG" +#line 2556 "cs.ATG" continuedQuery.FromClause.Identifier = t.val; -#line 2555 "cs.ATG" +#line 2557 "cs.ATG" continuedQuery.FromClause.EndLocation = t.EndLocation; QueryExpressionBody( -#line 2556 "cs.ATG" +#line 2558 "cs.ATG" ref q); } void QueryExpressionOrdering( -#line 2512 "cs.ATG" +#line 2514 "cs.ATG" out QueryExpressionOrdering ordering) { -#line 2513 "cs.ATG" +#line 2515 "cs.ATG" Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; Expr( -#line 2515 "cs.ATG" +#line 2517 "cs.ATG" out expr); -#line 2515 "cs.ATG" +#line 2517 "cs.ATG" ordering.Criteria = expr; if (la.kind == 138 || la.kind == 139) { if (la.kind == 138) { lexer.NextToken(); -#line 2516 "cs.ATG" +#line 2518 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2517 "cs.ATG" +#line 2519 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2519 "cs.ATG" +#line 2521 "cs.ATG" ordering.EndLocation = t.EndLocation; } diff --git a/main/contrib/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/main/contrib/NRefactory/Project/Src/Parser/CSharp/cs.ATG index e49da6c2b0..1357a3c9c2 100644 --- a/main/contrib/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/main/contrib/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -1633,19 +1633,21 @@ IfStatement<out Statement statement> Expression expr = null; Statement embeddedStatement = null; statement = null; + Location elseStart = Location.Empty; .) = "if" "(" Expr<out expr> ")" EmbeddedStatement<out embeddedStatement> (. Statement elseStatement = null; .) - [ "else" EmbeddedStatement<out elseStatement> ] + [ "else" (. elseStart = t.Location; .) EmbeddedStatement<out elseStatement> ] (. statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); .) (. if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) { /* else if-section (otherwise we would have a BlockStatment) */ - (statement as IfElseStatement).ElseIfSections.Add( - new ElseIfSection((elseStatement as IfElseStatement).Condition, - (elseStatement as IfElseStatement).TrueStatement[0])); + ElseIfSection elseIfSection = new ElseIfSection((elseStatement as IfElseStatement).Condition, (elseStatement as IfElseStatement).TrueStatement[0]); + elseIfSection.StartLocation = elseStart; + elseIfSection.EndLocation = (elseStatement as IfElseStatement).TrueStatement[0].EndLocation; + (statement as IfElseStatement).ElseIfSections.Add(elseIfSection); (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; } diff --git a/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index 484f053342..39e9212be9 100644 --- a/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -1361,7 +1361,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public override object TrackedVisitElseIfSection(ElseIfSection elseIfSection, object data) { - if (prettyPrintOptions.PlaceElseOnNewLine) { + if (prettyPrintOptions.PlaceElseIfOnNewLine) { + outputFormatter.NewLine(); outputFormatter.Indent(); } else { outputFormatter.Space(); diff --git a/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs b/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs index d4015de268..10c13f219d 100644 --- a/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs +++ b/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs @@ -1,4 +1,4 @@ -// <file> +// <file> // <copyright see="prj:///doc/copyright.txt"/> // <license see="prj:///doc/license.txt"/> // <owner name="Mike Krüger" email="mike@icsharpcode.net"/> @@ -423,6 +423,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public bool PlaceCatchOnNewLine { get; set; } public bool PlaceFinallyOnNewLine { get; set; } public bool PlaceElseOnNewLine { get; set; } + public bool PlaceElseIfOnNewLine { get; set; } public bool PlaceNonBlockElseOnNewLine { get; set; } public bool PlaceWhileOnNewLine { get; set; } #endregion @@ -930,6 +931,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public PrettyPrintOptions () { PlaceNonBlockElseOnNewLine = true; + PlaceElseIfOnNewLine = true; } } }
\ No newline at end of file |