diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 59627eabb5..323f664bea 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -487,68 +487,68 @@ out expr); } void Expr( -#line 1786 "cs.ATG" +#line 1770 "cs.ATG" out Expression expr) { -#line 1787 "cs.ATG" +#line 1771 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; -#line 1789 "cs.ATG" +#line 1773 "cs.ATG" Location startLocation = la.Location; UnaryExpr( -#line 1790 "cs.ATG" +#line 1774 "cs.ATG" out expr); if (StartOf(7)) { AssignmentOperator( -#line 1793 "cs.ATG" +#line 1777 "cs.ATG" out op); Expr( -#line 1793 "cs.ATG" +#line 1777 "cs.ATG" out expr1); -#line 1793 "cs.ATG" +#line 1777 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1794 "cs.ATG" +#line 1778 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1795 "cs.ATG" +#line 1779 "cs.ATG" out op); Expr( -#line 1795 "cs.ATG" +#line 1779 "cs.ATG" out expr1); -#line 1795 "cs.ATG" +#line 1779 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(8)) { ConditionalOrExpr( -#line 1797 "cs.ATG" +#line 1781 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1798 "cs.ATG" +#line 1782 "cs.ATG" out expr1); -#line 1798 "cs.ATG" +#line 1782 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1799 "cs.ATG" +#line 1783 "cs.ATG" out expr1); Expect(9); Expr( -#line 1799 "cs.ATG" +#line 1783 "cs.ATG" out expr2); -#line 1799 "cs.ATG" +#line 1783 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(150); -#line 1802 "cs.ATG" +#line 1786 "cs.ATG" if (expr != null) { expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; @@ -955,39 +955,39 @@ templates); } void TypeParameterList( -#line 2363 "cs.ATG" +#line 2347 "cs.ATG" List templates) { -#line 2365 "cs.ATG" +#line 2349 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2369 "cs.ATG" +#line 2353 "cs.ATG" out section); -#line 2369 "cs.ATG" +#line 2353 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2370 "cs.ATG" +#line 2354 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2371 "cs.ATG" +#line 2355 "cs.ATG" out section); -#line 2371 "cs.ATG" +#line 2355 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2372 "cs.ATG" +#line 2356 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -1020,22 +1020,22 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2376 "cs.ATG" +#line 2360 "cs.ATG" List templates) { -#line 2377 "cs.ATG" +#line 2361 "cs.ATG" string name = ""; TypeReference type; Expect(127); Identifier(); -#line 2380 "cs.ATG" +#line 2364 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2382 "cs.ATG" +#line 2366 "cs.ATG" out type); -#line 2383 "cs.ATG" +#line 2367 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1048,10 +1048,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2392 "cs.ATG" +#line 2376 "cs.ATG" out type); -#line 2393 "cs.ATG" +#line 2377 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1387,34 +1387,34 @@ out r, canBeUnbound); } void TypeName( -#line 2304 "cs.ATG" +#line 2288 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2305 "cs.ATG" +#line 2289 "cs.ATG" List typeArguments = null; string alias = null; string qualident; Location startLocation = la.Location; if ( -#line 2311 "cs.ATG" +#line 2295 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 2312 "cs.ATG" +#line 2296 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2315 "cs.ATG" +#line 2299 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2316 "cs.ATG" +#line 2300 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2318 "cs.ATG" +#line 2302 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1425,26 +1425,26 @@ out typeArguments, canBeUnbound); } while ( -#line 2327 "cs.ATG" +#line 2311 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2328 "cs.ATG" +#line 2312 "cs.ATG" typeArguments = null; Qualident( -#line 2329 "cs.ATG" +#line 2313 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2330 "cs.ATG" +#line 2314 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2331 "cs.ATG" +#line 2315 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } -#line 2333 "cs.ATG" +#line 2317 "cs.ATG" typeRef.StartLocation = startLocation; } @@ -2573,14 +2573,14 @@ out name); } void NullableQuestionMark( -#line 2337 "cs.ATG" +#line 2321 "cs.ATG" ref TypeReference typeRef) { -#line 2338 "cs.ATG" +#line 2322 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2342 "cs.ATG" +#line 2326 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -3277,71 +3277,36 @@ IsLabel()) { Statement(); } else if (la.kind == 60) { lexer.NextToken(); - Type( -#line 1498 "cs.ATG" -out type); - -#line 1498 "cs.ATG" - LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; - Identifier(); - + LocalVariableDecl( #line 1499 "cs.ATG" - ident = t.val; Location varStart = t.Location; - Expect(3); - Expr( -#line 1500 "cs.ATG" -out expr); - -#line 1502 "cs.ATG" - SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) { - StartLocation = varStart, - EndLocation = t.EndLocation, - TypeReference = type - }); - - while (la.kind == 14) { - lexer.NextToken(); - Identifier(); - -#line 1508 "cs.ATG" - ident = t.val; - Expect(3); - Expr( -#line 1508 "cs.ATG" -out expr); +out stmt); -#line 1510 "cs.ATG" - SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) { - StartLocation = varStart, - EndLocation = t.EndLocation, - TypeReference = type - }); - - } +#line 1500 "cs.ATG" + if (stmt != null) { ((LocalVariableDeclaration)stmt).Modifier |= Modifiers.Const; } Expect(11); -#line 1516 "cs.ATG" - var.EndLocation = t.EndLocation; compilationUnit.AddChild(var); +#line 1501 "cs.ATG" + compilationUnit.AddChild(stmt); } else if ( -#line 1519 "cs.ATG" +#line 1503 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1519 "cs.ATG" +#line 1503 "cs.ATG" out stmt); Expect(11); -#line 1519 "cs.ATG" +#line 1503 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(30)) { EmbeddedStatement( -#line 1521 "cs.ATG" +#line 1505 "cs.ATG" out stmt); -#line 1521 "cs.ATG" +#line 1505 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(193); -#line 1527 "cs.ATG" +#line 1511 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3621,180 +3586,180 @@ out expr); } void EmbeddedStatement( -#line 1534 "cs.ATG" +#line 1518 "cs.ATG" out Statement statement) { -#line 1536 "cs.ATG" +#line 1520 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; statement = null; -#line 1542 "cs.ATG" +#line 1526 "cs.ATG" Location startLocation = la.Location; if (la.kind == 16) { Block( -#line 1544 "cs.ATG" +#line 1528 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1547 "cs.ATG" +#line 1531 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1550 "cs.ATG" +#line 1534 "cs.ATG" UnCheckedAndLBrace()) { -#line 1550 "cs.ATG" +#line 1534 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 58) { lexer.NextToken(); } else if (la.kind == 118) { lexer.NextToken(); -#line 1551 "cs.ATG" +#line 1535 "cs.ATG" isChecked = false; } else SynErr(197); Block( -#line 1552 "cs.ATG" +#line 1536 "cs.ATG" out block); -#line 1552 "cs.ATG" +#line 1536 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 79) { IfStatement( -#line 1555 "cs.ATG" +#line 1539 "cs.ATG" out statement); } else if (la.kind == 110) { lexer.NextToken(); -#line 1557 "cs.ATG" +#line 1541 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1558 "cs.ATG" +#line 1542 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1559 "cs.ATG" +#line 1543 "cs.ATG" switchSections); Expect(17); -#line 1561 "cs.ATG" +#line 1545 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 125) { lexer.NextToken(); Expect(20); Expr( -#line 1564 "cs.ATG" +#line 1548 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1565 "cs.ATG" +#line 1549 "cs.ATG" out embeddedStatement); -#line 1566 "cs.ATG" +#line 1550 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1568 "cs.ATG" +#line 1552 "cs.ATG" out embeddedStatement); Expect(125); Expect(20); Expr( -#line 1569 "cs.ATG" +#line 1553 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1570 "cs.ATG" +#line 1554 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 76) { lexer.NextToken(); -#line 1572 "cs.ATG" +#line 1556 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(6)) { ForInitializer( -#line 1573 "cs.ATG" +#line 1557 "cs.ATG" out initializer); } Expect(11); if (StartOf(6)) { Expr( -#line 1574 "cs.ATG" +#line 1558 "cs.ATG" out expr); } Expect(11); if (StartOf(6)) { ForIterator( -#line 1575 "cs.ATG" +#line 1559 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1576 "cs.ATG" +#line 1560 "cs.ATG" out embeddedStatement); -#line 1577 "cs.ATG" +#line 1561 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 77) { lexer.NextToken(); Expect(20); Type( -#line 1579 "cs.ATG" +#line 1563 "cs.ATG" out type); Identifier(); -#line 1579 "cs.ATG" +#line 1563 "cs.ATG" string varName = t.val; Expect(81); Expr( -#line 1580 "cs.ATG" +#line 1564 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1581 "cs.ATG" +#line 1565 "cs.ATG" out embeddedStatement); -#line 1582 "cs.ATG" +#line 1566 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); } else if (la.kind == 53) { lexer.NextToken(); Expect(11); -#line 1585 "cs.ATG" +#line 1569 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1586 "cs.ATG" +#line 1570 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 78) { GotoStatement( -#line 1587 "cs.ATG" +#line 1571 "cs.ATG" out statement); } else if ( -#line 1589 "cs.ATG" +#line 1573 "cs.ATG" IsYieldStatement()) { Expect(132); if (la.kind == 101) { lexer.NextToken(); Expr( -#line 1590 "cs.ATG" +#line 1574 "cs.ATG" out expr); -#line 1590 "cs.ATG" +#line 1574 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 53) { lexer.NextToken(); -#line 1591 "cs.ATG" +#line 1575 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(198); Expect(11); @@ -3802,90 +3767,90 @@ out expr); lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1594 "cs.ATG" +#line 1578 "cs.ATG" out expr); } Expect(11); -#line 1594 "cs.ATG" +#line 1578 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 112) { lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1595 "cs.ATG" +#line 1579 "cs.ATG" out expr); } Expect(11); -#line 1595 "cs.ATG" +#line 1579 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(6)) { StatementExpr( -#line 1598 "cs.ATG" +#line 1582 "cs.ATG" out statement); while (!(la.kind == 0 || la.kind == 11)) {SynErr(199); lexer.NextToken(); } Expect(11); } else if (la.kind == 114) { TryStatement( -#line 1601 "cs.ATG" +#line 1585 "cs.ATG" out statement); } else if (la.kind == 86) { lexer.NextToken(); Expect(20); Expr( -#line 1604 "cs.ATG" +#line 1588 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1605 "cs.ATG" +#line 1589 "cs.ATG" out embeddedStatement); -#line 1605 "cs.ATG" +#line 1589 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 121) { -#line 1608 "cs.ATG" +#line 1592 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1610 "cs.ATG" +#line 1594 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1611 "cs.ATG" +#line 1595 "cs.ATG" out embeddedStatement); -#line 1611 "cs.ATG" +#line 1595 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 119) { lexer.NextToken(); Block( -#line 1614 "cs.ATG" +#line 1598 "cs.ATG" out embeddedStatement); -#line 1614 "cs.ATG" +#line 1598 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 74) { -#line 1616 "cs.ATG" +#line 1600 "cs.ATG" Statement pointerDeclarationStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1618 "cs.ATG" +#line 1602 "cs.ATG" out pointerDeclarationStmt); Expect(21); EmbeddedStatement( -#line 1619 "cs.ATG" +#line 1603 "cs.ATG" out embeddedStatement); -#line 1619 "cs.ATG" +#line 1603 "cs.ATG" statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); } else SynErr(200); -#line 1621 "cs.ATG" +#line 1605 "cs.ATG" if (statement != null) { statement.StartLocation = startLocation; statement.EndLocation = t.EndLocation; @@ -3894,10 +3859,10 @@ out embeddedStatement); } void IfStatement( -#line 1628 "cs.ATG" +#line 1612 "cs.ATG" out Statement statement) { -#line 1630 "cs.ATG" +#line 1614 "cs.ATG" Expression expr = null; Statement embeddedStatement = null; statement = null; @@ -3905,26 +3870,26 @@ out Statement statement) { Expect(79); Expect(20); Expr( -#line 1636 "cs.ATG" +#line 1620 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1637 "cs.ATG" +#line 1621 "cs.ATG" out embeddedStatement); -#line 1638 "cs.ATG" +#line 1622 "cs.ATG" Statement elseStatement = null; if (la.kind == 67) { lexer.NextToken(); EmbeddedStatement( -#line 1639 "cs.ATG" +#line 1623 "cs.ATG" out elseStatement); } -#line 1640 "cs.ATG" +#line 1624 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1641 "cs.ATG" +#line 1625 "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( @@ -3937,29 +3902,29 @@ out elseStatement); } void SwitchSections( -#line 1671 "cs.ATG" +#line 1655 "cs.ATG" List switchSections) { -#line 1673 "cs.ATG" +#line 1657 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1677 "cs.ATG" +#line 1661 "cs.ATG" out label); -#line 1677 "cs.ATG" +#line 1661 "cs.ATG" SafeAdd(switchSection, switchSection.SwitchLabels, label); -#line 1678 "cs.ATG" +#line 1662 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(32)) { if (la.kind == 55 || la.kind == 63) { SwitchLabel( -#line 1680 "cs.ATG" +#line 1664 "cs.ATG" out label); -#line 1681 "cs.ATG" +#line 1665 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -3975,145 +3940,145 @@ out label); } } -#line 1693 "cs.ATG" +#line 1677 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1652 "cs.ATG" +#line 1636 "cs.ATG" out List initializer) { -#line 1654 "cs.ATG" +#line 1638 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1658 "cs.ATG" +#line 1642 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1658 "cs.ATG" +#line 1642 "cs.ATG" out stmt); -#line 1658 "cs.ATG" +#line 1642 "cs.ATG" initializer.Add(stmt); } else if (StartOf(6)) { StatementExpr( -#line 1659 "cs.ATG" +#line 1643 "cs.ATG" out stmt); -#line 1659 "cs.ATG" +#line 1643 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1659 "cs.ATG" +#line 1643 "cs.ATG" out stmt); -#line 1659 "cs.ATG" +#line 1643 "cs.ATG" initializer.Add(stmt); } } else SynErr(201); } void ForIterator( -#line 1662 "cs.ATG" +#line 1646 "cs.ATG" out List iterator) { -#line 1664 "cs.ATG" +#line 1648 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1668 "cs.ATG" +#line 1652 "cs.ATG" out stmt); -#line 1668 "cs.ATG" +#line 1652 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1668 "cs.ATG" +#line 1652 "cs.ATG" out stmt); -#line 1668 "cs.ATG" +#line 1652 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1750 "cs.ATG" +#line 1734 "cs.ATG" out Statement stmt) { -#line 1751 "cs.ATG" +#line 1735 "cs.ATG" Expression expr; stmt = null; Expect(78); if (StartOf(19)) { Identifier(); -#line 1755 "cs.ATG" +#line 1739 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1756 "cs.ATG" +#line 1740 "cs.ATG" out expr); Expect(11); -#line 1756 "cs.ATG" +#line 1740 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(11); -#line 1757 "cs.ATG" +#line 1741 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(202); } void StatementExpr( -#line 1777 "cs.ATG" +#line 1761 "cs.ATG" out Statement stmt) { -#line 1778 "cs.ATG" +#line 1762 "cs.ATG" Expression expr; Expr( -#line 1780 "cs.ATG" +#line 1764 "cs.ATG" out expr); -#line 1783 "cs.ATG" +#line 1767 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1703 "cs.ATG" +#line 1687 "cs.ATG" out Statement tryStatement) { -#line 1705 "cs.ATG" +#line 1689 "cs.ATG" Statement blockStmt = null, finallyStmt = null; CatchClause catchClause = null; List catchClauses = new List(); Expect(114); Block( -#line 1710 "cs.ATG" +#line 1694 "cs.ATG" out blockStmt); while (la.kind == 56) { CatchClause( -#line 1712 "cs.ATG" +#line 1696 "cs.ATG" out catchClause); -#line 1713 "cs.ATG" +#line 1697 "cs.ATG" if (catchClause != null) catchClauses.Add(catchClause); } if (la.kind == 73) { lexer.NextToken(); Block( -#line 1715 "cs.ATG" +#line 1699 "cs.ATG" out finallyStmt); } -#line 1717 "cs.ATG" +#line 1701 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); if (catchClauses != null) { foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; @@ -4122,59 +4087,59 @@ out finallyStmt); } void ResourceAcquisition( -#line 1761 "cs.ATG" +#line 1745 "cs.ATG" out Statement stmt) { -#line 1763 "cs.ATG" +#line 1747 "cs.ATG" stmt = null; Expression expr; if ( -#line 1768 "cs.ATG" +#line 1752 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1768 "cs.ATG" +#line 1752 "cs.ATG" out stmt); } else if (StartOf(6)) { Expr( -#line 1769 "cs.ATG" +#line 1753 "cs.ATG" out expr); -#line 1773 "cs.ATG" +#line 1757 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(203); } void SwitchLabel( -#line 1696 "cs.ATG" +#line 1680 "cs.ATG" out CaseLabel label) { -#line 1697 "cs.ATG" +#line 1681 "cs.ATG" Expression expr = null; label = null; if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1699 "cs.ATG" +#line 1683 "cs.ATG" out expr); Expect(9); -#line 1699 "cs.ATG" +#line 1683 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(9); -#line 1700 "cs.ATG" +#line 1684 "cs.ATG" label = new CaseLabel(); } else SynErr(204); } void CatchClause( -#line 1724 "cs.ATG" +#line 1708 "cs.ATG" out CatchClause catchClause) { Expect(56); -#line 1726 "cs.ATG" +#line 1710 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; @@ -4183,35 +4148,35 @@ out CatchClause catchClause) { if (la.kind == 16) { Block( -#line 1734 "cs.ATG" +#line 1718 "cs.ATG" out stmt); -#line 1734 "cs.ATG" +#line 1718 "cs.ATG" catchClause = new CatchClause(stmt); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1737 "cs.ATG" +#line 1721 "cs.ATG" out typeRef, false); -#line 1737 "cs.ATG" +#line 1721 "cs.ATG" identifier = null; if (StartOf(19)) { Identifier(); -#line 1738 "cs.ATG" +#line 1722 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1739 "cs.ATG" +#line 1723 "cs.ATG" out stmt); -#line 1740 "cs.ATG" +#line 1724 "cs.ATG" catchClause = new CatchClause(typeRef, identifier, stmt); } else SynErr(205); -#line 1743 "cs.ATG" +#line 1727 "cs.ATG" if (catchClause != null) { catchClause.StartLocation = startPos; catchClause.EndLocation = t.Location; @@ -4220,75 +4185,75 @@ out stmt); } void UnaryExpr( -#line 1810 "cs.ATG" +#line 1794 "cs.ATG" out Expression uExpr) { -#line 1812 "cs.ATG" +#line 1796 "cs.ATG" TypeReference type = null; Expression expr = null; ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(33) || -#line 1834 "cs.ATG" +#line 1818 "cs.ATG" IsTypeCast()) { if (la.kind == 4) { lexer.NextToken(); -#line 1821 "cs.ATG" +#line 1805 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Plus)); } else if (la.kind == 5) { lexer.NextToken(); -#line 1822 "cs.ATG" +#line 1806 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Minus)); } else if (la.kind == 24) { lexer.NextToken(); -#line 1823 "cs.ATG" +#line 1807 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Not)); } else if (la.kind == 27) { lexer.NextToken(); -#line 1824 "cs.ATG" +#line 1808 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.BitNot)); } else if (la.kind == 6) { lexer.NextToken(); -#line 1825 "cs.ATG" +#line 1809 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Dereference)); } else if (la.kind == 31) { lexer.NextToken(); -#line 1826 "cs.ATG" +#line 1810 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Increment)); } else if (la.kind == 32) { lexer.NextToken(); -#line 1827 "cs.ATG" +#line 1811 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.Decrement)); } else if (la.kind == 28) { lexer.NextToken(); -#line 1828 "cs.ATG" +#line 1812 "cs.ATG" expressions.Add(new UnaryOperatorExpression(UnaryOperatorType.AddressOf)); } else { Expect(20); Type( -#line 1834 "cs.ATG" +#line 1818 "cs.ATG" out type); Expect(21); -#line 1834 "cs.ATG" +#line 1818 "cs.ATG" expressions.Add(new CastExpression(type)); } } if ( -#line 1839 "cs.ATG" +#line 1823 "cs.ATG" LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) { Expect(2); -#line 1842 "cs.ATG" +#line 1826 "cs.ATG" expressions.RemoveAt(expressions.Count - 1); if (t.literalValue is uint) { expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString()); @@ -4300,11 +4265,11 @@ LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffi } else if (StartOf(34)) { PrimaryExpr( -#line 1851 "cs.ATG" +#line 1835 "cs.ATG" out expr); } else SynErr(206); -#line 1853 "cs.ATG" +#line 1837 "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) { @@ -4322,325 +4287,325 @@ out expr); } void ConditionalOrExpr( -#line 2175 "cs.ATG" +#line 2159 "cs.ATG" ref Expression outExpr) { -#line 2176 "cs.ATG" +#line 2160 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2178 "cs.ATG" +#line 2162 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2178 "cs.ATG" +#line 2162 "cs.ATG" out expr); ConditionalAndExpr( -#line 2178 "cs.ATG" +#line 2162 "cs.ATG" ref expr); -#line 2178 "cs.ATG" +#line 2162 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1870 "cs.ATG" +#line 1854 "cs.ATG" out Expression pexpr) { -#line 1872 "cs.ATG" +#line 1856 "cs.ATG" TypeReference type = null; Expression expr; pexpr = null; -#line 1877 "cs.ATG" +#line 1861 "cs.ATG" Location startLocation = la.Location; if (la.kind == 113) { lexer.NextToken(); -#line 1879 "cs.ATG" +#line 1863 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); -#line 1880 "cs.ATG" +#line 1864 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); -#line 1881 "cs.ATG" +#line 1865 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1882 "cs.ATG" +#line 1866 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat }; } else if ( -#line 1883 "cs.ATG" +#line 1867 "cs.ATG" StartOfQueryExpression()) { QueryExpression( -#line 1884 "cs.ATG" +#line 1868 "cs.ATG" out pexpr); } else if ( -#line 1885 "cs.ATG" +#line 1869 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 1886 "cs.ATG" +#line 1870 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1887 "cs.ATG" +#line 1871 "cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); -#line 1888 "cs.ATG" +#line 1872 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); } else if (StartOf(19)) { Identifier(); -#line 1892 "cs.ATG" +#line 1876 "cs.ATG" pexpr = new IdentifierExpression(t.val); if (la.kind == 48 || -#line 1895 "cs.ATG" +#line 1879 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { if (la.kind == 48) { ShortedLambdaExpression( -#line 1894 "cs.ATG" +#line 1878 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); } else { -#line 1896 "cs.ATG" +#line 1880 "cs.ATG" List typeList; TypeArgumentList( -#line 1897 "cs.ATG" +#line 1881 "cs.ATG" out typeList, false); -#line 1898 "cs.ATG" +#line 1882 "cs.ATG" ((IdentifierExpression)pexpr).TypeArguments = typeList; } } } else if ( -#line 1900 "cs.ATG" +#line 1884 "cs.ATG" IsLambdaExpression()) { LambdaExpression( -#line 1901 "cs.ATG" +#line 1885 "cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1904 "cs.ATG" +#line 1888 "cs.ATG" out expr); Expect(21); -#line 1904 "cs.ATG" +#line 1888 "cs.ATG" pexpr = new ParenthesizedExpression(expr); } else if (StartOf(35)) { -#line 1907 "cs.ATG" +#line 1891 "cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); -#line 1908 "cs.ATG" +#line 1892 "cs.ATG" val = "System.Boolean"; break; } case 54: { lexer.NextToken(); -#line 1909 "cs.ATG" +#line 1893 "cs.ATG" val = "System.Byte"; break; } case 57: { lexer.NextToken(); -#line 1910 "cs.ATG" +#line 1894 "cs.ATG" val = "System.Char"; break; } case 62: { lexer.NextToken(); -#line 1911 "cs.ATG" +#line 1895 "cs.ATG" val = "System.Decimal"; break; } case 66: { lexer.NextToken(); -#line 1912 "cs.ATG" +#line 1896 "cs.ATG" val = "System.Double"; break; } case 75: { lexer.NextToken(); -#line 1913 "cs.ATG" +#line 1897 "cs.ATG" val = "System.Single"; break; } case 82: { lexer.NextToken(); -#line 1914 "cs.ATG" +#line 1898 "cs.ATG" val = "System.Int32"; break; } case 87: { lexer.NextToken(); -#line 1915 "cs.ATG" +#line 1899 "cs.ATG" val = "System.Int64"; break; } case 91: { lexer.NextToken(); -#line 1916 "cs.ATG" +#line 1900 "cs.ATG" val = "System.Object"; break; } case 102: { lexer.NextToken(); -#line 1917 "cs.ATG" +#line 1901 "cs.ATG" val = "System.SByte"; break; } case 104: { lexer.NextToken(); -#line 1918 "cs.ATG" +#line 1902 "cs.ATG" val = "System.Int16"; break; } case 108: { lexer.NextToken(); -#line 1919 "cs.ATG" +#line 1903 "cs.ATG" val = "System.String"; break; } case 116: { lexer.NextToken(); -#line 1920 "cs.ATG" +#line 1904 "cs.ATG" val = "System.UInt32"; break; } case 117: { lexer.NextToken(); -#line 1921 "cs.ATG" +#line 1905 "cs.ATG" val = "System.UInt64"; break; } case 120: { lexer.NextToken(); -#line 1922 "cs.ATG" +#line 1906 "cs.ATG" val = "System.UInt16"; break; } case 123: { lexer.NextToken(); -#line 1923 "cs.ATG" +#line 1907 "cs.ATG" val = "System.Void"; break; } } -#line 1925 "cs.ATG" +#line 1909 "cs.ATG" pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; } else if (la.kind == 111) { lexer.NextToken(); -#line 1928 "cs.ATG" +#line 1912 "cs.ATG" pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 51) { lexer.NextToken(); -#line 1930 "cs.ATG" +#line 1914 "cs.ATG" pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; } else if (la.kind == 89) { NewExpression( -#line 1933 "cs.ATG" +#line 1917 "cs.ATG" out pexpr); } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( -#line 1937 "cs.ATG" +#line 1921 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1937 "cs.ATG" +#line 1921 "cs.ATG" type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( -#line 1938 "cs.ATG" +#line 1922 "cs.ATG" out type, true, true); } else SynErr(207); Expect(21); -#line 1940 "cs.ATG" +#line 1924 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( -#line 1942 "cs.ATG" +#line 1926 "cs.ATG" out type); Expect(21); -#line 1942 "cs.ATG" +#line 1926 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( -#line 1943 "cs.ATG" +#line 1927 "cs.ATG" out type); Expect(21); -#line 1943 "cs.ATG" +#line 1927 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( -#line 1944 "cs.ATG" +#line 1928 "cs.ATG" out expr); Expect(21); -#line 1944 "cs.ATG" +#line 1928 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( -#line 1945 "cs.ATG" +#line 1929 "cs.ATG" out expr); Expect(21); -#line 1945 "cs.ATG" +#line 1929 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( -#line 1946 "cs.ATG" +#line 1930 "cs.ATG" out expr); -#line 1946 "cs.ATG" +#line 1930 "cs.ATG" pexpr = expr; } else SynErr(208); -#line 1948 "cs.ATG" +#line 1932 "cs.ATG" if (pexpr != null) { if (pexpr.StartLocation.IsEmpty) pexpr.StartLocation = startLocation; @@ -4651,78 +4616,78 @@ out expr); while (StartOf(36)) { if (la.kind == 31 || la.kind == 32) { -#line 1956 "cs.ATG" +#line 1940 "cs.ATG" startLocation = la.Location; if (la.kind == 31) { lexer.NextToken(); -#line 1958 "cs.ATG" +#line 1942 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 1959 "cs.ATG" +#line 1943 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); } else SynErr(209); } else if (la.kind == 47) { PointerMemberAccess( -#line 1962 "cs.ATG" +#line 1946 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 15) { MemberAccess( -#line 1963 "cs.ATG" +#line 1947 "cs.ATG" out pexpr, pexpr); } else if (la.kind == 20) { lexer.NextToken(); -#line 1967 "cs.ATG" +#line 1951 "cs.ATG" List parameters = new List(); -#line 1968 "cs.ATG" +#line 1952 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); if (StartOf(26)) { Argument( -#line 1969 "cs.ATG" +#line 1953 "cs.ATG" out expr); -#line 1969 "cs.ATG" +#line 1953 "cs.ATG" SafeAdd(pexpr, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1970 "cs.ATG" +#line 1954 "cs.ATG" out expr); -#line 1970 "cs.ATG" +#line 1954 "cs.ATG" SafeAdd(pexpr, parameters, expr); } } Expect(21); } else { -#line 1976 "cs.ATG" +#line 1960 "cs.ATG" List indices = new List(); pexpr = new IndexerExpression(pexpr, indices); lexer.NextToken(); Expr( -#line 1979 "cs.ATG" +#line 1963 "cs.ATG" out expr); -#line 1979 "cs.ATG" +#line 1963 "cs.ATG" SafeAdd(pexpr, indices, expr); while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1980 "cs.ATG" +#line 1964 "cs.ATG" out expr); -#line 1980 "cs.ATG" +#line 1964 "cs.ATG" SafeAdd(pexpr, indices, expr); } Expect(19); -#line 1983 "cs.ATG" +#line 1967 "cs.ATG" if (pexpr != null) { pexpr.StartLocation = startLocation; pexpr.EndLocation = t.EndLocation; @@ -4733,83 +4698,83 @@ out expr); } void QueryExpression( -#line 2413 "cs.ATG" +#line 2397 "cs.ATG" out Expression outExpr) { -#line 2414 "cs.ATG" +#line 2398 "cs.ATG" QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; QueryExpressionFromClause fromClause; QueryExpressionFromClause( -#line 2418 "cs.ATG" +#line 2402 "cs.ATG" out fromClause); -#line 2418 "cs.ATG" +#line 2402 "cs.ATG" q.FromClause = fromClause; QueryExpressionBody( -#line 2419 "cs.ATG" +#line 2403 "cs.ATG" ref q); -#line 2420 "cs.ATG" +#line 2404 "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 2095 "cs.ATG" +#line 2079 "cs.ATG" IdentifierExpression ident, out Expression pexpr) { -#line 2096 "cs.ATG" +#line 2080 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); -#line 2101 "cs.ATG" +#line 2085 "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 2106 "cs.ATG" +#line 2090 "cs.ATG" lambda); } void TypeArgumentList( -#line 2347 "cs.ATG" +#line 2331 "cs.ATG" out List types, bool canBeUnbound) { -#line 2349 "cs.ATG" +#line 2333 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2354 "cs.ATG" +#line 2338 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2355 "cs.ATG" +#line 2339 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2356 "cs.ATG" +#line 2340 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(10)) { Type( -#line 2357 "cs.ATG" +#line 2341 "cs.ATG" out type); -#line 2357 "cs.ATG" +#line 2341 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2358 "cs.ATG" +#line 2342 "cs.ATG" out type); -#line 2358 "cs.ATG" +#line 2342 "cs.ATG" if (type != null) { types.Add(type); } } } else SynErr(210); @@ -4817,10 +4782,10 @@ out type); } void LambdaExpression( -#line 2075 "cs.ATG" +#line 2059 "cs.ATG" out Expression outExpr) { -#line 2077 "cs.ATG" +#line 2061 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; ParameterDeclarationExpression p; @@ -4829,33 +4794,33 @@ out Expression outExpr) { Expect(20); if (StartOf(18)) { LambdaExpressionParameter( -#line 2085 "cs.ATG" +#line 2069 "cs.ATG" out p); -#line 2085 "cs.ATG" +#line 2069 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); while (la.kind == 14) { lexer.NextToken(); LambdaExpressionParameter( -#line 2087 "cs.ATG" +#line 2071 "cs.ATG" out p); -#line 2087 "cs.ATG" +#line 2071 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); } } Expect(21); Expect(48); LambdaExpressionBody( -#line 2092 "cs.ATG" +#line 2076 "cs.ATG" lambda); } void NewExpression( -#line 2022 "cs.ATG" +#line 2006 "cs.ATG" out Expression pexpr) { -#line 2023 "cs.ATG" +#line 2007 "cs.ATG" pexpr = null; List parameters = new List(); TypeReference type = null; @@ -4864,65 +4829,65 @@ out Expression pexpr) { Expect(89); if (StartOf(10)) { NonArrayType( -#line 2030 "cs.ATG" +#line 2014 "cs.ATG" out type); } if (la.kind == 16 || la.kind == 20) { if (la.kind == 20) { -#line 2036 "cs.ATG" +#line 2020 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); lexer.NextToken(); -#line 2037 "cs.ATG" +#line 2021 "cs.ATG" if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); if (StartOf(26)) { Argument( -#line 2038 "cs.ATG" +#line 2022 "cs.ATG" out expr); -#line 2038 "cs.ATG" +#line 2022 "cs.ATG" SafeAdd(oce, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2039 "cs.ATG" +#line 2023 "cs.ATG" out expr); -#line 2039 "cs.ATG" +#line 2023 "cs.ATG" SafeAdd(oce, parameters, expr); } } Expect(21); -#line 2041 "cs.ATG" +#line 2025 "cs.ATG" pexpr = oce; if (la.kind == 16) { CollectionOrObjectInitializer( -#line 2042 "cs.ATG" +#line 2026 "cs.ATG" out expr); -#line 2042 "cs.ATG" +#line 2026 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; } } else { -#line 2043 "cs.ATG" +#line 2027 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); CollectionOrObjectInitializer( -#line 2044 "cs.ATG" +#line 2028 "cs.ATG" out expr); -#line 2044 "cs.ATG" +#line 2028 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; -#line 2045 "cs.ATG" +#line 2029 "cs.ATG" pexpr = oce; } } else if (la.kind == 18) { lexer.NextToken(); -#line 2050 "cs.ATG" +#line 2034 "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(""); } @@ -4933,80 +4898,80 @@ out expr); while (la.kind == 14) { lexer.NextToken(); -#line 2057 "cs.ATG" +#line 2041 "cs.ATG" dims += 1; } Expect(19); -#line 2058 "cs.ATG" +#line 2042 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2059 "cs.ATG" +#line 2043 "cs.ATG" ++dims; } Expect(19); -#line 2059 "cs.ATG" +#line 2043 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2060 "cs.ATG" +#line 2044 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); CollectionInitializer( -#line 2061 "cs.ATG" +#line 2045 "cs.ATG" out expr); -#line 2061 "cs.ATG" +#line 2045 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } else if (StartOf(6)) { Expr( -#line 2062 "cs.ATG" +#line 2046 "cs.ATG" out expr); -#line 2062 "cs.ATG" +#line 2046 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2063 "cs.ATG" +#line 2047 "cs.ATG" dims += 1; Expr( -#line 2064 "cs.ATG" +#line 2048 "cs.ATG" out expr); -#line 2064 "cs.ATG" +#line 2048 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2066 "cs.ATG" +#line 2050 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2067 "cs.ATG" +#line 2051 "cs.ATG" ++dims; } Expect(19); -#line 2067 "cs.ATG" +#line 2051 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2068 "cs.ATG" +#line 2052 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { CollectionInitializer( -#line 2069 "cs.ATG" +#line 2053 "cs.ATG" out expr); -#line 2069 "cs.ATG" +#line 2053 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } } else SynErr(211); @@ -5014,10 +4979,10 @@ out expr); } void AnonymousMethodExpr( -#line 2142 "cs.ATG" +#line 2126 "cs.ATG" out Expression outExpr) { -#line 2144 "cs.ATG" +#line 2128 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; BlockStatement stmt; @@ -5028,59 +4993,59 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(11)) { FormalParameterList( -#line 2153 "cs.ATG" +#line 2137 "cs.ATG" p); -#line 2153 "cs.ATG" +#line 2137 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 2155 "cs.ATG" +#line 2139 "cs.ATG" expr.HasParameterList = true; } BlockInsideExpression( -#line 2157 "cs.ATG" +#line 2141 "cs.ATG" out stmt); -#line 2157 "cs.ATG" +#line 2141 "cs.ATG" expr.Body = stmt; -#line 2158 "cs.ATG" +#line 2142 "cs.ATG" expr.EndLocation = t.Location; } void PointerMemberAccess( -#line 2010 "cs.ATG" +#line 1994 "cs.ATG" out Expression expr, Expression target) { -#line 2011 "cs.ATG" +#line 1995 "cs.ATG" List typeList; Expect(47); Identifier(); -#line 2015 "cs.ATG" +#line 1999 "cs.ATG" expr = new PointerReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 2016 "cs.ATG" +#line 2000 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2017 "cs.ATG" +#line 2001 "cs.ATG" out typeList, false); -#line 2018 "cs.ATG" +#line 2002 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void MemberAccess( -#line 1991 "cs.ATG" +#line 1975 "cs.ATG" out Expression expr, Expression target) { -#line 1992 "cs.ATG" +#line 1976 "cs.ATG" List typeList; -#line 1994 "cs.ATG" +#line 1978 "cs.ATG" if (ShouldConvertTargetExpressionToTypeReference(target)) { TypeReference type = GetTypeReferenceFromExpression(target); if (type != null) { @@ -5091,35 +5056,35 @@ out Expression expr, Expression target) { Expect(15); Identifier(); -#line 2003 "cs.ATG" +#line 1987 "cs.ATG" expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 2004 "cs.ATG" +#line 1988 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2005 "cs.ATG" +#line 1989 "cs.ATG" out typeList, false); -#line 2006 "cs.ATG" +#line 1990 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void LambdaExpressionParameter( -#line 2109 "cs.ATG" +#line 2093 "cs.ATG" out ParameterDeclarationExpression p) { -#line 2110 "cs.ATG" +#line 2094 "cs.ATG" Location start = la.Location; p = null; TypeReference type; ParameterModifiers mod = ParameterModifiers.In; if ( -#line 2115 "cs.ATG" +#line 2099 "cs.ATG" Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { Identifier(); -#line 2117 "cs.ATG" +#line 2101 "cs.ATG" p = new ParameterDeclarationExpression(null, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5128,21 +5093,21 @@ Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { if (la.kind == 100) { lexer.NextToken(); -#line 2120 "cs.ATG" +#line 2104 "cs.ATG" mod = ParameterModifiers.Ref; } else { lexer.NextToken(); -#line 2121 "cs.ATG" +#line 2105 "cs.ATG" mod = ParameterModifiers.Out; } } Type( -#line 2123 "cs.ATG" +#line 2107 "cs.ATG" out type); Identifier(); -#line 2125 "cs.ATG" +#line 2109 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5150,263 +5115,263 @@ out type); } void LambdaExpressionBody( -#line 2131 "cs.ATG" +#line 2115 "cs.ATG" LambdaExpression lambda) { -#line 2132 "cs.ATG" +#line 2116 "cs.ATG" Expression expr; BlockStatement stmt; if (la.kind == 16) { BlockInsideExpression( -#line 2135 "cs.ATG" +#line 2119 "cs.ATG" out stmt); -#line 2135 "cs.ATG" +#line 2119 "cs.ATG" lambda.StatementBody = stmt; } else if (StartOf(6)) { Expr( -#line 2136 "cs.ATG" +#line 2120 "cs.ATG" out expr); -#line 2136 "cs.ATG" +#line 2120 "cs.ATG" lambda.ExpressionBody = expr; } else SynErr(214); -#line 2138 "cs.ATG" +#line 2122 "cs.ATG" lambda.EndLocation = t.EndLocation; -#line 2139 "cs.ATG" +#line 2123 "cs.ATG" lambda.ExtendedEndLocation = la.Location; } void BlockInsideExpression( -#line 2161 "cs.ATG" +#line 2145 "cs.ATG" out BlockStatement outStmt) { -#line 2162 "cs.ATG" +#line 2146 "cs.ATG" Statement stmt = null; outStmt = null; -#line 2166 "cs.ATG" +#line 2150 "cs.ATG" if (compilationUnit != null) { Block( -#line 2167 "cs.ATG" +#line 2151 "cs.ATG" out stmt); -#line 2167 "cs.ATG" +#line 2151 "cs.ATG" outStmt = (BlockStatement)stmt; -#line 2168 "cs.ATG" +#line 2152 "cs.ATG" } else { Expect(16); -#line 2170 "cs.ATG" +#line 2154 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 2172 "cs.ATG" +#line 2156 "cs.ATG" } } void ConditionalAndExpr( -#line 2181 "cs.ATG" +#line 2165 "cs.ATG" ref Expression outExpr) { -#line 2182 "cs.ATG" +#line 2166 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2184 "cs.ATG" +#line 2168 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2184 "cs.ATG" +#line 2168 "cs.ATG" out expr); InclusiveOrExpr( -#line 2184 "cs.ATG" +#line 2168 "cs.ATG" ref expr); -#line 2184 "cs.ATG" +#line 2168 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2187 "cs.ATG" +#line 2171 "cs.ATG" ref Expression outExpr) { -#line 2188 "cs.ATG" +#line 2172 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2190 "cs.ATG" +#line 2174 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2190 "cs.ATG" +#line 2174 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2190 "cs.ATG" +#line 2174 "cs.ATG" ref expr); -#line 2190 "cs.ATG" +#line 2174 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2193 "cs.ATG" +#line 2177 "cs.ATG" ref Expression outExpr) { -#line 2194 "cs.ATG" +#line 2178 "cs.ATG" Expression expr; AndExpr( -#line 2196 "cs.ATG" +#line 2180 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2196 "cs.ATG" +#line 2180 "cs.ATG" out expr); AndExpr( -#line 2196 "cs.ATG" +#line 2180 "cs.ATG" ref expr); -#line 2196 "cs.ATG" +#line 2180 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2199 "cs.ATG" +#line 2183 "cs.ATG" ref Expression outExpr) { -#line 2200 "cs.ATG" +#line 2184 "cs.ATG" Expression expr; EqualityExpr( -#line 2202 "cs.ATG" +#line 2186 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2202 "cs.ATG" +#line 2186 "cs.ATG" out expr); EqualityExpr( -#line 2202 "cs.ATG" +#line 2186 "cs.ATG" ref expr); -#line 2202 "cs.ATG" +#line 2186 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2205 "cs.ATG" +#line 2189 "cs.ATG" ref Expression outExpr) { -#line 2207 "cs.ATG" +#line 2191 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2211 "cs.ATG" +#line 2195 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2214 "cs.ATG" +#line 2198 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2215 "cs.ATG" +#line 2199 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2217 "cs.ATG" +#line 2201 "cs.ATG" out expr); RelationalExpr( -#line 2217 "cs.ATG" +#line 2201 "cs.ATG" ref expr); -#line 2217 "cs.ATG" +#line 2201 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2221 "cs.ATG" +#line 2205 "cs.ATG" ref Expression outExpr) { -#line 2223 "cs.ATG" +#line 2207 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2228 "cs.ATG" +#line 2212 "cs.ATG" ref outExpr); while (StartOf(37)) { if (StartOf(38)) { if (la.kind == 23) { lexer.NextToken(); -#line 2230 "cs.ATG" +#line 2214 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2231 "cs.ATG" +#line 2215 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2232 "cs.ATG" +#line 2216 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2233 "cs.ATG" +#line 2217 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; } else SynErr(215); UnaryExpr( -#line 2235 "cs.ATG" +#line 2219 "cs.ATG" out expr); ShiftExpr( -#line 2236 "cs.ATG" +#line 2220 "cs.ATG" ref expr); -#line 2237 "cs.ATG" +#line 2221 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 85) { lexer.NextToken(); TypeWithRestriction( -#line 2240 "cs.ATG" +#line 2224 "cs.ATG" out type, false, false); if ( -#line 2241 "cs.ATG" +#line 2225 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2242 "cs.ATG" +#line 2226 "cs.ATG" ref type); } -#line 2243 "cs.ATG" +#line 2227 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 50) { lexer.NextToken(); TypeWithRestriction( -#line 2245 "cs.ATG" +#line 2229 "cs.ATG" out type, false, false); if ( -#line 2246 "cs.ATG" +#line 2230 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2247 "cs.ATG" +#line 2231 "cs.ATG" ref type); } -#line 2248 "cs.ATG" +#line 2232 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); } else SynErr(216); } @@ -5414,83 +5379,83 @@ ref type); } void ShiftExpr( -#line 2253 "cs.ATG" +#line 2237 "cs.ATG" ref Expression outExpr) { -#line 2255 "cs.ATG" +#line 2239 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2259 "cs.ATG" +#line 2243 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2262 "cs.ATG" +#line 2246 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2261 "cs.ATG" +#line 2245 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2263 "cs.ATG" +#line 2247 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2266 "cs.ATG" +#line 2250 "cs.ATG" out expr); AdditiveExpr( -#line 2266 "cs.ATG" +#line 2250 "cs.ATG" ref expr); -#line 2266 "cs.ATG" +#line 2250 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2270 "cs.ATG" +#line 2254 "cs.ATG" ref Expression outExpr) { -#line 2272 "cs.ATG" +#line 2256 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2276 "cs.ATG" +#line 2260 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2279 "cs.ATG" +#line 2263 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2280 "cs.ATG" +#line 2264 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2282 "cs.ATG" +#line 2266 "cs.ATG" out expr); MultiplicativeExpr( -#line 2282 "cs.ATG" +#line 2266 "cs.ATG" ref expr); -#line 2282 "cs.ATG" +#line 2266 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2286 "cs.ATG" +#line 2270 "cs.ATG" ref Expression outExpr) { -#line 2288 "cs.ATG" +#line 2272 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5498,82 +5463,82 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2294 "cs.ATG" +#line 2278 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2295 "cs.ATG" +#line 2279 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2296 "cs.ATG" +#line 2280 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2298 "cs.ATG" +#line 2282 "cs.ATG" out expr); -#line 2298 "cs.ATG" +#line 2282 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2404 "cs.ATG" +#line 2388 "cs.ATG" out TypeReference type) { -#line 2405 "cs.ATG" +#line 2389 "cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); -#line 2407 "cs.ATG" +#line 2391 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); -#line 2408 "cs.ATG" +#line 2392 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); -#line 2409 "cs.ATG" +#line 2393 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( -#line 2410 "cs.ATG" +#line 2394 "cs.ATG" out t); -#line 2410 "cs.ATG" +#line 2394 "cs.ATG" type = t; } else SynErr(217); } void QueryExpressionFromClause( -#line 2425 "cs.ATG" +#line 2409 "cs.ATG" out QueryExpressionFromClause fc) { -#line 2426 "cs.ATG" +#line 2410 "cs.ATG" fc = new QueryExpressionFromClause(); fc.StartLocation = la.Location; Expect(137); QueryExpressionFromOrJoinClause( -#line 2430 "cs.ATG" +#line 2414 "cs.ATG" fc); -#line 2431 "cs.ATG" +#line 2415 "cs.ATG" fc.EndLocation = t.EndLocation; } void QueryExpressionBody( -#line 2461 "cs.ATG" +#line 2445 "cs.ATG" ref QueryExpression q) { -#line 2462 "cs.ATG" +#line 2446 "cs.ATG" QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; QueryExpressionOrderClause orderClause; @@ -5582,249 +5547,249 @@ ref QueryExpression q) { while (StartOf(39)) { if (la.kind == 137) { QueryExpressionFromClause( -#line 2468 "cs.ATG" +#line 2452 "cs.ATG" out fromClause); -#line 2468 "cs.ATG" +#line 2452 "cs.ATG" SafeAdd(q, q.MiddleClauses, fromClause); } else if (la.kind == 127) { QueryExpressionWhereClause( -#line 2469 "cs.ATG" +#line 2453 "cs.ATG" out whereClause); -#line 2469 "cs.ATG" +#line 2453 "cs.ATG" SafeAdd(q, q.MiddleClauses, whereClause); } else if (la.kind == 141) { QueryExpressionLetClause( -#line 2470 "cs.ATG" +#line 2454 "cs.ATG" out letClause); -#line 2470 "cs.ATG" +#line 2454 "cs.ATG" SafeAdd(q, q.MiddleClauses, letClause); } else if (la.kind == 142) { QueryExpressionJoinClause( -#line 2471 "cs.ATG" +#line 2455 "cs.ATG" out joinClause); -#line 2471 "cs.ATG" +#line 2455 "cs.ATG" SafeAdd(q, q.MiddleClauses, joinClause); } else { QueryExpressionOrderByClause( -#line 2472 "cs.ATG" +#line 2456 "cs.ATG" out orderClause); -#line 2472 "cs.ATG" +#line 2456 "cs.ATG" SafeAdd(q, q.MiddleClauses, orderClause); } } if (la.kind == 133) { QueryExpressionSelectClause( -#line 2474 "cs.ATG" +#line 2458 "cs.ATG" out selectClause); -#line 2474 "cs.ATG" +#line 2458 "cs.ATG" q.SelectOrGroupClause = selectClause; } else if (la.kind == 134) { QueryExpressionGroupClause( -#line 2475 "cs.ATG" +#line 2459 "cs.ATG" out groupClause); -#line 2475 "cs.ATG" +#line 2459 "cs.ATG" q.SelectOrGroupClause = groupClause; } else SynErr(218); if (la.kind == 136) { QueryExpressionIntoClause( -#line 2477 "cs.ATG" +#line 2461 "cs.ATG" ref q); } } void QueryExpressionFromOrJoinClause( -#line 2451 "cs.ATG" +#line 2435 "cs.ATG" QueryExpressionFromOrJoinClause fjc) { -#line 2452 "cs.ATG" +#line 2436 "cs.ATG" TypeReference type; Expression expr; -#line 2454 "cs.ATG" +#line 2438 "cs.ATG" fjc.Type = null; if ( -#line 2455 "cs.ATG" +#line 2439 "cs.ATG" IsLocalVarDecl()) { Type( -#line 2455 "cs.ATG" +#line 2439 "cs.ATG" out type); -#line 2455 "cs.ATG" +#line 2439 "cs.ATG" fjc.Type = type; } Identifier(); -#line 2456 "cs.ATG" +#line 2440 "cs.ATG" fjc.Identifier = t.val; Expect(81); Expr( -#line 2458 "cs.ATG" +#line 2442 "cs.ATG" out expr); -#line 2458 "cs.ATG" +#line 2442 "cs.ATG" fjc.InExpression = expr; } void QueryExpressionJoinClause( -#line 2434 "cs.ATG" +#line 2418 "cs.ATG" out QueryExpressionJoinClause jc) { -#line 2435 "cs.ATG" +#line 2419 "cs.ATG" jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; Expression expr; Expect(142); QueryExpressionFromOrJoinClause( -#line 2440 "cs.ATG" +#line 2424 "cs.ATG" jc); Expect(143); Expr( -#line 2442 "cs.ATG" +#line 2426 "cs.ATG" out expr); -#line 2442 "cs.ATG" +#line 2426 "cs.ATG" jc.OnExpression = expr; Expect(144); Expr( -#line 2444 "cs.ATG" +#line 2428 "cs.ATG" out expr); -#line 2444 "cs.ATG" +#line 2428 "cs.ATG" jc.EqualsExpression = expr; if (la.kind == 136) { lexer.NextToken(); Identifier(); -#line 2446 "cs.ATG" +#line 2430 "cs.ATG" jc.IntoIdentifier = t.val; } -#line 2448 "cs.ATG" +#line 2432 "cs.ATG" jc.EndLocation = t.EndLocation; } void QueryExpressionWhereClause( -#line 2480 "cs.ATG" +#line 2464 "cs.ATG" out QueryExpressionWhereClause wc) { -#line 2481 "cs.ATG" +#line 2465 "cs.ATG" Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; Expect(127); Expr( -#line 2484 "cs.ATG" +#line 2468 "cs.ATG" out expr); -#line 2484 "cs.ATG" +#line 2468 "cs.ATG" wc.Condition = expr; -#line 2485 "cs.ATG" +#line 2469 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionLetClause( -#line 2488 "cs.ATG" +#line 2472 "cs.ATG" out QueryExpressionLetClause wc) { -#line 2489 "cs.ATG" +#line 2473 "cs.ATG" Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; Expect(141); Identifier(); -#line 2492 "cs.ATG" +#line 2476 "cs.ATG" wc.Identifier = t.val; Expect(3); Expr( -#line 2494 "cs.ATG" +#line 2478 "cs.ATG" out expr); -#line 2494 "cs.ATG" +#line 2478 "cs.ATG" wc.Expression = expr; -#line 2495 "cs.ATG" +#line 2479 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionOrderByClause( -#line 2498 "cs.ATG" +#line 2482 "cs.ATG" out QueryExpressionOrderClause oc) { -#line 2499 "cs.ATG" +#line 2483 "cs.ATG" QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; Expect(140); QueryExpressionOrdering( -#line 2502 "cs.ATG" +#line 2486 "cs.ATG" out ordering); -#line 2502 "cs.ATG" +#line 2486 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); while (la.kind == 14) { lexer.NextToken(); QueryExpressionOrdering( -#line 2504 "cs.ATG" +#line 2488 "cs.ATG" out ordering); -#line 2504 "cs.ATG" +#line 2488 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); } -#line 2506 "cs.ATG" +#line 2490 "cs.ATG" oc.EndLocation = t.EndLocation; } void QueryExpressionSelectClause( -#line 2519 "cs.ATG" +#line 2503 "cs.ATG" out QueryExpressionSelectClause sc) { -#line 2520 "cs.ATG" +#line 2504 "cs.ATG" Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; Expect(133); Expr( -#line 2523 "cs.ATG" +#line 2507 "cs.ATG" out expr); -#line 2523 "cs.ATG" +#line 2507 "cs.ATG" sc.Projection = expr; -#line 2524 "cs.ATG" +#line 2508 "cs.ATG" sc.EndLocation = t.EndLocation; } void QueryExpressionGroupClause( -#line 2527 "cs.ATG" +#line 2511 "cs.ATG" out QueryExpressionGroupClause gc) { -#line 2528 "cs.ATG" +#line 2512 "cs.ATG" Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; Expect(134); Expr( -#line 2531 "cs.ATG" +#line 2515 "cs.ATG" out expr); -#line 2531 "cs.ATG" +#line 2515 "cs.ATG" gc.Projection = expr; Expect(135); Expr( -#line 2533 "cs.ATG" +#line 2517 "cs.ATG" out expr); -#line 2533 "cs.ATG" +#line 2517 "cs.ATG" gc.GroupBy = expr; -#line 2534 "cs.ATG" +#line 2518 "cs.ATG" gc.EndLocation = t.EndLocation; } void QueryExpressionIntoClause( -#line 2537 "cs.ATG" +#line 2521 "cs.ATG" ref QueryExpression q) { -#line 2538 "cs.ATG" +#line 2522 "cs.ATG" QueryExpression firstQuery = q; QueryExpression continuedQuery = new QueryExpression(); continuedQuery.StartLocation = q.StartLocation; @@ -5839,43 +5804,43 @@ ref QueryExpression q) { Expect(136); Identifier(); -#line 2551 "cs.ATG" +#line 2535 "cs.ATG" continuedQuery.FromClause.Identifier = t.val; -#line 2552 "cs.ATG" +#line 2536 "cs.ATG" continuedQuery.FromClause.EndLocation = t.EndLocation; QueryExpressionBody( -#line 2553 "cs.ATG" +#line 2537 "cs.ATG" ref q); } void QueryExpressionOrdering( -#line 2509 "cs.ATG" +#line 2493 "cs.ATG" out QueryExpressionOrdering ordering) { -#line 2510 "cs.ATG" +#line 2494 "cs.ATG" Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; Expr( -#line 2512 "cs.ATG" +#line 2496 "cs.ATG" out expr); -#line 2512 "cs.ATG" +#line 2496 "cs.ATG" ordering.Criteria = expr; if (la.kind == 138 || la.kind == 139) { if (la.kind == 138) { lexer.NextToken(); -#line 2513 "cs.ATG" +#line 2497 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2514 "cs.ATG" +#line 2498 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2516 "cs.ATG" +#line 2500 "cs.ATG" ordering.EndLocation = t.EndLocation; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 1901e1978b..208129e8c9 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -1483,8 +1483,6 @@ LocalVariableDeclarator Statement (. - TypeReference type; - Expression expr; Statement stmt = null; Location startPos = la.Location; .) @@ -1495,26 +1493,10 @@ Statement IF (IsLabel()) Identifier (. compilationUnit.AddChild(new LabelStatement(t.val)); .) ":" Statement /*--- local constant declaration: */ - | "const" Type (. LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifiers.Const); string ident = null; var.StartLocation = t.Location; .) - Identifier (. ident = t.val; Location varStart = t.Location; .) - "=" Expr - (. - SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) { - StartLocation = varStart, - EndLocation = t.EndLocation, - TypeReference = type - }); - .) - { "," Identifier (. ident = t.val; .) "=" Expr - (. - SafeAdd(var, var.Variables, new VariableDeclaration(ident, expr) { - StartLocation = varStart, - EndLocation = t.EndLocation, - TypeReference = type - }); - .) } - ";" (. var.EndLocation = t.EndLocation; compilationUnit.AddChild(var); .) - + | "const" + LocalVariableDecl + (. if (stmt != null) { ((LocalVariableDeclaration)stmt).Modifier |= Modifiers.Const; } .) + ";" (. compilationUnit.AddChild(stmt); .) /*--- local variable declaration: */ | IF (IsLocalVarDecl()) LocalVariableDecl ";" (. compilationUnit.AddChild(stmt); .) diff --git a/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs index f9b5f460d9..d4548c104f 100644 --- a/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs @@ -208,6 +208,28 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual("System.Nullable", type.GenericTypes[0].GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].GenericTypes[0].Type); } + + [Test] + public void PositionTestWithoutModifier() + { + LocalVariableDeclaration lvd = ParseUtilCSharp.ParseStatement("\ndouble w = 7;"); + Assert.AreEqual(2, lvd.StartLocation.Line); + Assert.AreEqual(1, lvd.StartLocation.Column); + Assert.AreEqual(2, lvd.EndLocation.Line); + Assert.AreEqual(14, lvd.EndLocation.Column); + } + + [Test] + public void PositionTestWithModifier() + { + LocalVariableDeclaration lvd = ParseUtilCSharp.ParseStatement("\nconst double w = 7;"); + Assert.AreEqual(Modifiers.Const, lvd.Modifier); + Assert.AreEqual(2, lvd.StartLocation.Line); + Assert.AreEqual(1, lvd.StartLocation.Column); + Assert.AreEqual(2, lvd.EndLocation.Line); + Assert.AreEqual(20, lvd.EndLocation.Column); + } + #endregion #region VB.NET