diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs index cfc15b546a..fd3adc8edf 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs @@ -73,8 +73,10 @@ namespace ICSharpCode.NRefactory.Parser.CSharp // SEMICOLON HACK : without a trailing semicolon, parsing expressions does not work correctly if (la.kind == Tokens.Semicolon) lexer.NextToken(); if (expr != null) { - expr.StartLocation = startLocation; - expr.EndLocation = t.EndLocation; + if (expr.StartLocation.IsEmpty) + expr.StartLocation = startLocation; + if (expr.EndLocation.IsEmpty) + expr.EndLocation = t.EndLocation; expr.AcceptVisitor(new SetParentVisitor(), null); } Expect(Tokens.EOF); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 323f664bea..933d98504f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -487,71 +487,73 @@ out expr); } void Expr( -#line 1770 "cs.ATG" +#line 1768 "cs.ATG" out Expression expr) { -#line 1771 "cs.ATG" +#line 1769 "cs.ATG" expr = null; Expression expr1 = null, expr2 = null; AssignmentOperatorType op; -#line 1773 "cs.ATG" +#line 1771 "cs.ATG" Location startLocation = la.Location; UnaryExpr( -#line 1774 "cs.ATG" +#line 1772 "cs.ATG" out expr); if (StartOf(7)) { AssignmentOperator( -#line 1777 "cs.ATG" +#line 1775 "cs.ATG" out op); Expr( -#line 1777 "cs.ATG" +#line 1775 "cs.ATG" out expr1); -#line 1777 "cs.ATG" +#line 1775 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if ( -#line 1778 "cs.ATG" +#line 1776 "cs.ATG" la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) { AssignmentOperator( -#line 1779 "cs.ATG" +#line 1777 "cs.ATG" out op); Expr( -#line 1779 "cs.ATG" +#line 1777 "cs.ATG" out expr1); -#line 1779 "cs.ATG" +#line 1777 "cs.ATG" expr = new AssignmentExpression(expr, op, expr1); } else if (StartOf(8)) { ConditionalOrExpr( -#line 1781 "cs.ATG" +#line 1779 "cs.ATG" ref expr); if (la.kind == 13) { lexer.NextToken(); Expr( -#line 1782 "cs.ATG" +#line 1780 "cs.ATG" out expr1); -#line 1782 "cs.ATG" +#line 1780 "cs.ATG" expr = new BinaryOperatorExpression(expr, BinaryOperatorType.NullCoalescing, expr1); } if (la.kind == 12) { lexer.NextToken(); Expr( -#line 1783 "cs.ATG" +#line 1781 "cs.ATG" out expr1); Expect(9); Expr( -#line 1783 "cs.ATG" +#line 1781 "cs.ATG" out expr2); -#line 1783 "cs.ATG" +#line 1781 "cs.ATG" expr = new ConditionalExpression(expr, expr1, expr2); } } else SynErr(150); -#line 1786 "cs.ATG" +#line 1784 "cs.ATG" if (expr != null) { - expr.StartLocation = startLocation; - expr.EndLocation = t.EndLocation; + if (expr.StartLocation.IsEmpty) + expr.StartLocation = startLocation; + if (expr.EndLocation.IsEmpty) + expr.EndLocation = t.EndLocation; } } @@ -955,39 +957,39 @@ templates); } void TypeParameterList( -#line 2347 "cs.ATG" +#line 2349 "cs.ATG" List templates) { -#line 2349 "cs.ATG" +#line 2351 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2353 "cs.ATG" +#line 2355 "cs.ATG" out section); -#line 2353 "cs.ATG" +#line 2355 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2354 "cs.ATG" +#line 2356 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2355 "cs.ATG" +#line 2357 "cs.ATG" out section); -#line 2355 "cs.ATG" +#line 2357 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2356 "cs.ATG" +#line 2358 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -1020,22 +1022,22 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2360 "cs.ATG" +#line 2362 "cs.ATG" List templates) { -#line 2361 "cs.ATG" +#line 2363 "cs.ATG" string name = ""; TypeReference type; Expect(127); Identifier(); -#line 2364 "cs.ATG" +#line 2366 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2366 "cs.ATG" +#line 2368 "cs.ATG" out type); -#line 2367 "cs.ATG" +#line 2369 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1048,10 +1050,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2376 "cs.ATG" +#line 2378 "cs.ATG" out type); -#line 2377 "cs.ATG" +#line 2379 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1387,34 +1389,34 @@ out r, canBeUnbound); } void TypeName( -#line 2288 "cs.ATG" +#line 2290 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2289 "cs.ATG" +#line 2291 "cs.ATG" List typeArguments = null; string alias = null; string qualident; Location startLocation = la.Location; if ( -#line 2295 "cs.ATG" +#line 2297 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 2296 "cs.ATG" +#line 2298 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2299 "cs.ATG" +#line 2301 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2300 "cs.ATG" +#line 2302 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2302 "cs.ATG" +#line 2304 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1425,26 +1427,26 @@ out typeArguments, canBeUnbound); } while ( -#line 2311 "cs.ATG" +#line 2313 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2312 "cs.ATG" +#line 2314 "cs.ATG" typeArguments = null; Qualident( -#line 2313 "cs.ATG" +#line 2315 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2314 "cs.ATG" +#line 2316 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2315 "cs.ATG" +#line 2317 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } -#line 2317 "cs.ATG" +#line 2319 "cs.ATG" typeRef.StartLocation = startLocation; } @@ -2573,14 +2575,14 @@ out name); } void NullableQuestionMark( -#line 2321 "cs.ATG" +#line 2323 "cs.ATG" ref TypeReference typeRef) { -#line 2322 "cs.ATG" +#line 2324 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2326 "cs.ATG" +#line 2328 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; @@ -3260,53 +3262,51 @@ out expr); void Statement() { #line 1486 "cs.ATG" - TypeReference type; - Expression expr; Statement stmt = null; Location startPos = la.Location; while (!(StartOf(29))) {SynErr(192); lexer.NextToken(); } if ( -#line 1495 "cs.ATG" +#line 1493 "cs.ATG" IsLabel()) { Identifier(); -#line 1495 "cs.ATG" +#line 1493 "cs.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(9); Statement(); } else if (la.kind == 60) { lexer.NextToken(); LocalVariableDecl( -#line 1499 "cs.ATG" +#line 1497 "cs.ATG" out stmt); -#line 1500 "cs.ATG" +#line 1498 "cs.ATG" if (stmt != null) { ((LocalVariableDeclaration)stmt).Modifier |= Modifiers.Const; } Expect(11); -#line 1501 "cs.ATG" +#line 1499 "cs.ATG" compilationUnit.AddChild(stmt); } else if ( -#line 1503 "cs.ATG" +#line 1501 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1503 "cs.ATG" +#line 1501 "cs.ATG" out stmt); Expect(11); -#line 1503 "cs.ATG" +#line 1501 "cs.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(30)) { EmbeddedStatement( -#line 1505 "cs.ATG" +#line 1503 "cs.ATG" out stmt); -#line 1505 "cs.ATG" +#line 1503 "cs.ATG" compilationUnit.AddChild(stmt); } else SynErr(193); -#line 1511 "cs.ATG" +#line 1509 "cs.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.EndLocation; @@ -3586,180 +3586,180 @@ out expr); } void EmbeddedStatement( -#line 1518 "cs.ATG" +#line 1516 "cs.ATG" out Statement statement) { -#line 1520 "cs.ATG" +#line 1518 "cs.ATG" TypeReference type = null; Expression expr = null; Statement embeddedStatement = null; statement = null; -#line 1526 "cs.ATG" +#line 1524 "cs.ATG" Location startLocation = la.Location; if (la.kind == 16) { Block( -#line 1528 "cs.ATG" +#line 1526 "cs.ATG" out statement); } else if (la.kind == 11) { lexer.NextToken(); -#line 1531 "cs.ATG" +#line 1529 "cs.ATG" statement = new EmptyStatement(); } else if ( -#line 1534 "cs.ATG" +#line 1532 "cs.ATG" UnCheckedAndLBrace()) { -#line 1534 "cs.ATG" +#line 1532 "cs.ATG" Statement block; bool isChecked = true; if (la.kind == 58) { lexer.NextToken(); } else if (la.kind == 118) { lexer.NextToken(); -#line 1535 "cs.ATG" +#line 1533 "cs.ATG" isChecked = false; } else SynErr(197); Block( -#line 1536 "cs.ATG" +#line 1534 "cs.ATG" out block); -#line 1536 "cs.ATG" +#line 1534 "cs.ATG" statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); } else if (la.kind == 79) { IfStatement( -#line 1539 "cs.ATG" +#line 1537 "cs.ATG" out statement); } else if (la.kind == 110) { lexer.NextToken(); -#line 1541 "cs.ATG" +#line 1539 "cs.ATG" List switchSections = new List(); Expect(20); Expr( -#line 1542 "cs.ATG" +#line 1540 "cs.ATG" out expr); Expect(21); Expect(16); SwitchSections( -#line 1543 "cs.ATG" +#line 1541 "cs.ATG" switchSections); Expect(17); -#line 1545 "cs.ATG" +#line 1543 "cs.ATG" statement = new SwitchStatement(expr, switchSections); } else if (la.kind == 125) { lexer.NextToken(); Expect(20); Expr( -#line 1548 "cs.ATG" +#line 1546 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1549 "cs.ATG" +#line 1547 "cs.ATG" out embeddedStatement); -#line 1550 "cs.ATG" +#line 1548 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); } else if (la.kind == 65) { lexer.NextToken(); EmbeddedStatement( -#line 1552 "cs.ATG" +#line 1550 "cs.ATG" out embeddedStatement); Expect(125); Expect(20); Expr( -#line 1553 "cs.ATG" +#line 1551 "cs.ATG" out expr); Expect(21); Expect(11); -#line 1554 "cs.ATG" +#line 1552 "cs.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); } else if (la.kind == 76) { lexer.NextToken(); -#line 1556 "cs.ATG" +#line 1554 "cs.ATG" List initializer = null; List iterator = null; Expect(20); if (StartOf(6)) { ForInitializer( -#line 1557 "cs.ATG" +#line 1555 "cs.ATG" out initializer); } Expect(11); if (StartOf(6)) { Expr( -#line 1558 "cs.ATG" +#line 1556 "cs.ATG" out expr); } Expect(11); if (StartOf(6)) { ForIterator( -#line 1559 "cs.ATG" +#line 1557 "cs.ATG" out iterator); } Expect(21); EmbeddedStatement( -#line 1560 "cs.ATG" +#line 1558 "cs.ATG" out embeddedStatement); -#line 1561 "cs.ATG" +#line 1559 "cs.ATG" statement = new ForStatement(initializer, expr, iterator, embeddedStatement); } else if (la.kind == 77) { lexer.NextToken(); Expect(20); Type( -#line 1563 "cs.ATG" +#line 1561 "cs.ATG" out type); Identifier(); -#line 1563 "cs.ATG" +#line 1561 "cs.ATG" string varName = t.val; Expect(81); Expr( -#line 1564 "cs.ATG" +#line 1562 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1565 "cs.ATG" +#line 1563 "cs.ATG" out embeddedStatement); -#line 1566 "cs.ATG" +#line 1564 "cs.ATG" statement = new ForeachStatement(type, varName , expr, embeddedStatement); } else if (la.kind == 53) { lexer.NextToken(); Expect(11); -#line 1569 "cs.ATG" +#line 1567 "cs.ATG" statement = new BreakStatement(); } else if (la.kind == 61) { lexer.NextToken(); Expect(11); -#line 1570 "cs.ATG" +#line 1568 "cs.ATG" statement = new ContinueStatement(); } else if (la.kind == 78) { GotoStatement( -#line 1571 "cs.ATG" +#line 1569 "cs.ATG" out statement); } else if ( -#line 1573 "cs.ATG" +#line 1571 "cs.ATG" IsYieldStatement()) { Expect(132); if (la.kind == 101) { lexer.NextToken(); Expr( -#line 1574 "cs.ATG" +#line 1572 "cs.ATG" out expr); -#line 1574 "cs.ATG" +#line 1572 "cs.ATG" statement = new YieldStatement(new ReturnStatement(expr)); } else if (la.kind == 53) { lexer.NextToken(); -#line 1575 "cs.ATG" +#line 1573 "cs.ATG" statement = new YieldStatement(new BreakStatement()); } else SynErr(198); Expect(11); @@ -3767,90 +3767,90 @@ out expr); lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1578 "cs.ATG" +#line 1576 "cs.ATG" out expr); } Expect(11); -#line 1578 "cs.ATG" +#line 1576 "cs.ATG" statement = new ReturnStatement(expr); } else if (la.kind == 112) { lexer.NextToken(); if (StartOf(6)) { Expr( -#line 1579 "cs.ATG" +#line 1577 "cs.ATG" out expr); } Expect(11); -#line 1579 "cs.ATG" +#line 1577 "cs.ATG" statement = new ThrowStatement(expr); } else if (StartOf(6)) { StatementExpr( -#line 1582 "cs.ATG" +#line 1580 "cs.ATG" out statement); while (!(la.kind == 0 || la.kind == 11)) {SynErr(199); lexer.NextToken(); } Expect(11); } else if (la.kind == 114) { TryStatement( -#line 1585 "cs.ATG" +#line 1583 "cs.ATG" out statement); } else if (la.kind == 86) { lexer.NextToken(); Expect(20); Expr( -#line 1588 "cs.ATG" +#line 1586 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1589 "cs.ATG" +#line 1587 "cs.ATG" out embeddedStatement); -#line 1589 "cs.ATG" +#line 1587 "cs.ATG" statement = new LockStatement(expr, embeddedStatement); } else if (la.kind == 121) { -#line 1592 "cs.ATG" +#line 1590 "cs.ATG" Statement resourceAcquisitionStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1594 "cs.ATG" +#line 1592 "cs.ATG" out resourceAcquisitionStmt); Expect(21); EmbeddedStatement( -#line 1595 "cs.ATG" +#line 1593 "cs.ATG" out embeddedStatement); -#line 1595 "cs.ATG" +#line 1593 "cs.ATG" statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); } else if (la.kind == 119) { lexer.NextToken(); Block( -#line 1598 "cs.ATG" +#line 1596 "cs.ATG" out embeddedStatement); -#line 1598 "cs.ATG" +#line 1596 "cs.ATG" statement = new UnsafeStatement(embeddedStatement); } else if (la.kind == 74) { -#line 1600 "cs.ATG" +#line 1598 "cs.ATG" Statement pointerDeclarationStmt = null; lexer.NextToken(); Expect(20); ResourceAcquisition( -#line 1602 "cs.ATG" +#line 1600 "cs.ATG" out pointerDeclarationStmt); Expect(21); EmbeddedStatement( -#line 1603 "cs.ATG" +#line 1601 "cs.ATG" out embeddedStatement); -#line 1603 "cs.ATG" +#line 1601 "cs.ATG" statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); } else SynErr(200); -#line 1605 "cs.ATG" +#line 1603 "cs.ATG" if (statement != null) { statement.StartLocation = startLocation; statement.EndLocation = t.EndLocation; @@ -3859,10 +3859,10 @@ out embeddedStatement); } void IfStatement( -#line 1612 "cs.ATG" +#line 1610 "cs.ATG" out Statement statement) { -#line 1614 "cs.ATG" +#line 1612 "cs.ATG" Expression expr = null; Statement embeddedStatement = null; statement = null; @@ -3870,26 +3870,26 @@ out Statement statement) { Expect(79); Expect(20); Expr( -#line 1620 "cs.ATG" +#line 1618 "cs.ATG" out expr); Expect(21); EmbeddedStatement( -#line 1621 "cs.ATG" +#line 1619 "cs.ATG" out embeddedStatement); -#line 1622 "cs.ATG" +#line 1620 "cs.ATG" Statement elseStatement = null; if (la.kind == 67) { lexer.NextToken(); EmbeddedStatement( -#line 1623 "cs.ATG" +#line 1621 "cs.ATG" out elseStatement); } -#line 1624 "cs.ATG" +#line 1622 "cs.ATG" statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); -#line 1625 "cs.ATG" +#line 1623 "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( @@ -3902,29 +3902,29 @@ out elseStatement); } void SwitchSections( -#line 1655 "cs.ATG" +#line 1653 "cs.ATG" List switchSections) { -#line 1657 "cs.ATG" +#line 1655 "cs.ATG" SwitchSection switchSection = new SwitchSection(); CaseLabel label; SwitchLabel( -#line 1661 "cs.ATG" +#line 1659 "cs.ATG" out label); -#line 1661 "cs.ATG" +#line 1659 "cs.ATG" SafeAdd(switchSection, switchSection.SwitchLabels, label); -#line 1662 "cs.ATG" +#line 1660 "cs.ATG" compilationUnit.BlockStart(switchSection); while (StartOf(32)) { if (la.kind == 55 || la.kind == 63) { SwitchLabel( -#line 1664 "cs.ATG" +#line 1662 "cs.ATG" out label); -#line 1665 "cs.ATG" +#line 1663 "cs.ATG" if (label != null) { if (switchSection.Children.Count > 0) { // open new section @@ -3940,145 +3940,145 @@ out label); } } -#line 1677 "cs.ATG" +#line 1675 "cs.ATG" compilationUnit.BlockEnd(); switchSections.Add(switchSection); } void ForInitializer( -#line 1636 "cs.ATG" +#line 1634 "cs.ATG" out List initializer) { -#line 1638 "cs.ATG" +#line 1636 "cs.ATG" Statement stmt; initializer = new List(); if ( -#line 1642 "cs.ATG" +#line 1640 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1642 "cs.ATG" +#line 1640 "cs.ATG" out stmt); -#line 1642 "cs.ATG" +#line 1640 "cs.ATG" initializer.Add(stmt); } else if (StartOf(6)) { StatementExpr( -#line 1643 "cs.ATG" +#line 1641 "cs.ATG" out stmt); -#line 1643 "cs.ATG" +#line 1641 "cs.ATG" initializer.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1643 "cs.ATG" +#line 1641 "cs.ATG" out stmt); -#line 1643 "cs.ATG" +#line 1641 "cs.ATG" initializer.Add(stmt); } } else SynErr(201); } void ForIterator( -#line 1646 "cs.ATG" +#line 1644 "cs.ATG" out List iterator) { -#line 1648 "cs.ATG" +#line 1646 "cs.ATG" Statement stmt; iterator = new List(); StatementExpr( -#line 1652 "cs.ATG" +#line 1650 "cs.ATG" out stmt); -#line 1652 "cs.ATG" +#line 1650 "cs.ATG" iterator.Add(stmt); while (la.kind == 14) { lexer.NextToken(); StatementExpr( -#line 1652 "cs.ATG" +#line 1650 "cs.ATG" out stmt); -#line 1652 "cs.ATG" +#line 1650 "cs.ATG" iterator.Add(stmt); } } void GotoStatement( -#line 1734 "cs.ATG" +#line 1732 "cs.ATG" out Statement stmt) { -#line 1735 "cs.ATG" +#line 1733 "cs.ATG" Expression expr; stmt = null; Expect(78); if (StartOf(19)) { Identifier(); -#line 1739 "cs.ATG" +#line 1737 "cs.ATG" stmt = new GotoStatement(t.val); Expect(11); } else if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1740 "cs.ATG" +#line 1738 "cs.ATG" out expr); Expect(11); -#line 1740 "cs.ATG" +#line 1738 "cs.ATG" stmt = new GotoCaseStatement(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(11); -#line 1741 "cs.ATG" +#line 1739 "cs.ATG" stmt = new GotoCaseStatement(null); } else SynErr(202); } void StatementExpr( -#line 1761 "cs.ATG" +#line 1759 "cs.ATG" out Statement stmt) { -#line 1762 "cs.ATG" +#line 1760 "cs.ATG" Expression expr; Expr( -#line 1764 "cs.ATG" +#line 1762 "cs.ATG" out expr); -#line 1767 "cs.ATG" +#line 1765 "cs.ATG" stmt = new ExpressionStatement(expr); } void TryStatement( -#line 1687 "cs.ATG" +#line 1685 "cs.ATG" out Statement tryStatement) { -#line 1689 "cs.ATG" +#line 1687 "cs.ATG" Statement blockStmt = null, finallyStmt = null; CatchClause catchClause = null; List catchClauses = new List(); Expect(114); Block( -#line 1694 "cs.ATG" +#line 1692 "cs.ATG" out blockStmt); while (la.kind == 56) { CatchClause( -#line 1696 "cs.ATG" +#line 1694 "cs.ATG" out catchClause); -#line 1697 "cs.ATG" +#line 1695 "cs.ATG" if (catchClause != null) catchClauses.Add(catchClause); } if (la.kind == 73) { lexer.NextToken(); Block( -#line 1699 "cs.ATG" +#line 1697 "cs.ATG" out finallyStmt); } -#line 1701 "cs.ATG" +#line 1699 "cs.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); if (catchClauses != null) { foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement; @@ -4087,59 +4087,59 @@ out finallyStmt); } void ResourceAcquisition( -#line 1745 "cs.ATG" +#line 1743 "cs.ATG" out Statement stmt) { -#line 1747 "cs.ATG" +#line 1745 "cs.ATG" stmt = null; Expression expr; if ( -#line 1752 "cs.ATG" +#line 1750 "cs.ATG" IsLocalVarDecl()) { LocalVariableDecl( -#line 1752 "cs.ATG" +#line 1750 "cs.ATG" out stmt); } else if (StartOf(6)) { Expr( -#line 1753 "cs.ATG" +#line 1751 "cs.ATG" out expr); -#line 1757 "cs.ATG" +#line 1755 "cs.ATG" stmt = new ExpressionStatement(expr); } else SynErr(203); } void SwitchLabel( -#line 1680 "cs.ATG" +#line 1678 "cs.ATG" out CaseLabel label) { -#line 1681 "cs.ATG" +#line 1679 "cs.ATG" Expression expr = null; label = null; if (la.kind == 55) { lexer.NextToken(); Expr( -#line 1683 "cs.ATG" +#line 1681 "cs.ATG" out expr); Expect(9); -#line 1683 "cs.ATG" +#line 1681 "cs.ATG" label = new CaseLabel(expr); } else if (la.kind == 63) { lexer.NextToken(); Expect(9); -#line 1684 "cs.ATG" +#line 1682 "cs.ATG" label = new CaseLabel(); } else SynErr(204); } void CatchClause( -#line 1708 "cs.ATG" +#line 1706 "cs.ATG" out CatchClause catchClause) { Expect(56); -#line 1710 "cs.ATG" +#line 1708 "cs.ATG" string identifier; Statement stmt; TypeReference typeRef; @@ -4148,35 +4148,35 @@ out CatchClause catchClause) { if (la.kind == 16) { Block( -#line 1718 "cs.ATG" +#line 1716 "cs.ATG" out stmt); -#line 1718 "cs.ATG" +#line 1716 "cs.ATG" catchClause = new CatchClause(stmt); } else if (la.kind == 20) { lexer.NextToken(); ClassType( -#line 1721 "cs.ATG" +#line 1719 "cs.ATG" out typeRef, false); -#line 1721 "cs.ATG" +#line 1719 "cs.ATG" identifier = null; if (StartOf(19)) { Identifier(); -#line 1722 "cs.ATG" +#line 1720 "cs.ATG" identifier = t.val; } Expect(21); Block( -#line 1723 "cs.ATG" +#line 1721 "cs.ATG" out stmt); -#line 1724 "cs.ATG" +#line 1722 "cs.ATG" catchClause = new CatchClause(typeRef, identifier, stmt); } else SynErr(205); -#line 1727 "cs.ATG" +#line 1725 "cs.ATG" if (catchClause != null) { catchClause.StartLocation = startPos; catchClause.EndLocation = t.Location; @@ -4287,24 +4287,24 @@ out expr); } void ConditionalOrExpr( -#line 2159 "cs.ATG" +#line 2161 "cs.ATG" ref Expression outExpr) { -#line 2160 "cs.ATG" +#line 2162 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 2162 "cs.ATG" +#line 2164 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 2162 "cs.ATG" +#line 2164 "cs.ATG" out expr); ConditionalAndExpr( -#line 2162 "cs.ATG" +#line 2164 "cs.ATG" ref expr); -#line 2162 "cs.ATG" +#line 2164 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } @@ -4614,30 +4614,37 @@ out expr); } while (StartOf(36)) { - if (la.kind == 31 || la.kind == 32) { #line 1940 "cs.ATG" - startLocation = la.Location; - if (la.kind == 31) { - lexer.NextToken(); + startLocation = la.Location; + switch (la.kind) { + case 31: { + lexer.NextToken(); #line 1942 "cs.ATG" - pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); - } else if (la.kind == 32) { - lexer.NextToken(); + pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); + break; + } + case 32: { + lexer.NextToken(); -#line 1943 "cs.ATG" - pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); - } else SynErr(209); - } else if (la.kind == 47) { +#line 1944 "cs.ATG" + pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); + break; + } + case 47: { PointerMemberAccess( #line 1946 "cs.ATG" out pexpr, pexpr); - } else if (la.kind == 15) { + break; + } + case 15: { MemberAccess( #line 1947 "cs.ATG" out pexpr, pexpr); - } else if (la.kind == 20) { + break; + } + case 20: { lexer.NextToken(); #line 1951 "cs.ATG" @@ -4663,7 +4670,9 @@ out expr); } } Expect(21); - } else { + break; + } + case 18: { #line 1960 "cs.ATG" List indices = new List(); @@ -4686,106 +4695,110 @@ out expr); SafeAdd(pexpr, indices, expr); } Expect(19); + break; + } + } #line 1967 "cs.ATG" - if (pexpr != null) { + if (pexpr != null) { + if (pexpr.StartLocation.IsEmpty) pexpr.StartLocation = startLocation; + if (pexpr.EndLocation.IsEmpty) pexpr.EndLocation = t.EndLocation; - } - } + } } void QueryExpression( -#line 2397 "cs.ATG" +#line 2399 "cs.ATG" out Expression outExpr) { -#line 2398 "cs.ATG" +#line 2400 "cs.ATG" QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; QueryExpressionFromClause fromClause; QueryExpressionFromClause( -#line 2402 "cs.ATG" +#line 2404 "cs.ATG" out fromClause); -#line 2402 "cs.ATG" +#line 2404 "cs.ATG" q.FromClause = fromClause; QueryExpressionBody( -#line 2403 "cs.ATG" +#line 2405 "cs.ATG" ref q); -#line 2404 "cs.ATG" +#line 2406 "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 2079 "cs.ATG" +#line 2081 "cs.ATG" IdentifierExpression ident, out Expression pexpr) { -#line 2080 "cs.ATG" +#line 2082 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); -#line 2085 "cs.ATG" +#line 2087 "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 2090 "cs.ATG" +#line 2092 "cs.ATG" lambda); } void TypeArgumentList( -#line 2331 "cs.ATG" +#line 2333 "cs.ATG" out List types, bool canBeUnbound) { -#line 2333 "cs.ATG" +#line 2335 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2338 "cs.ATG" +#line 2340 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2339 "cs.ATG" +#line 2341 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2340 "cs.ATG" +#line 2342 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(10)) { Type( -#line 2341 "cs.ATG" +#line 2343 "cs.ATG" out type); -#line 2341 "cs.ATG" +#line 2343 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2342 "cs.ATG" +#line 2344 "cs.ATG" out type); -#line 2342 "cs.ATG" +#line 2344 "cs.ATG" if (type != null) { types.Add(type); } } - } else SynErr(210); + } else SynErr(209); Expect(22); } void LambdaExpression( -#line 2059 "cs.ATG" +#line 2061 "cs.ATG" out Expression outExpr) { -#line 2061 "cs.ATG" +#line 2063 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; ParameterDeclarationExpression p; @@ -4794,33 +4807,33 @@ out Expression outExpr) { Expect(20); if (StartOf(18)) { LambdaExpressionParameter( -#line 2069 "cs.ATG" +#line 2071 "cs.ATG" out p); -#line 2069 "cs.ATG" +#line 2071 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); while (la.kind == 14) { lexer.NextToken(); LambdaExpressionParameter( -#line 2071 "cs.ATG" +#line 2073 "cs.ATG" out p); -#line 2071 "cs.ATG" +#line 2073 "cs.ATG" SafeAdd(lambda, lambda.Parameters, p); } } Expect(21); Expect(48); LambdaExpressionBody( -#line 2076 "cs.ATG" +#line 2078 "cs.ATG" lambda); } void NewExpression( -#line 2006 "cs.ATG" +#line 2008 "cs.ATG" out Expression pexpr) { -#line 2007 "cs.ATG" +#line 2009 "cs.ATG" pexpr = null; List parameters = new List(); TypeReference type = null; @@ -4829,65 +4842,65 @@ out Expression pexpr) { Expect(89); if (StartOf(10)) { NonArrayType( -#line 2014 "cs.ATG" +#line 2016 "cs.ATG" out type); } if (la.kind == 16 || la.kind == 20) { if (la.kind == 20) { -#line 2020 "cs.ATG" +#line 2022 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); lexer.NextToken(); -#line 2021 "cs.ATG" +#line 2023 "cs.ATG" if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); if (StartOf(26)) { Argument( -#line 2022 "cs.ATG" +#line 2024 "cs.ATG" out expr); -#line 2022 "cs.ATG" +#line 2024 "cs.ATG" SafeAdd(oce, parameters, expr); while (la.kind == 14) { lexer.NextToken(); Argument( -#line 2023 "cs.ATG" +#line 2025 "cs.ATG" out expr); -#line 2023 "cs.ATG" +#line 2025 "cs.ATG" SafeAdd(oce, parameters, expr); } } Expect(21); -#line 2025 "cs.ATG" +#line 2027 "cs.ATG" pexpr = oce; if (la.kind == 16) { CollectionOrObjectInitializer( -#line 2026 "cs.ATG" +#line 2028 "cs.ATG" out expr); -#line 2026 "cs.ATG" +#line 2028 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; } } else { -#line 2027 "cs.ATG" +#line 2029 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); CollectionOrObjectInitializer( -#line 2028 "cs.ATG" +#line 2030 "cs.ATG" out expr); -#line 2028 "cs.ATG" +#line 2030 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; -#line 2029 "cs.ATG" +#line 2031 "cs.ATG" pexpr = oce; } } else if (la.kind == 18) { lexer.NextToken(); -#line 2034 "cs.ATG" +#line 2036 "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(""); } @@ -4898,91 +4911,91 @@ out expr); while (la.kind == 14) { lexer.NextToken(); -#line 2041 "cs.ATG" +#line 2043 "cs.ATG" dims += 1; } Expect(19); -#line 2042 "cs.ATG" +#line 2044 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2043 "cs.ATG" +#line 2045 "cs.ATG" ++dims; } Expect(19); -#line 2043 "cs.ATG" +#line 2045 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2044 "cs.ATG" +#line 2046 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); CollectionInitializer( -#line 2045 "cs.ATG" +#line 2047 "cs.ATG" out expr); -#line 2045 "cs.ATG" +#line 2047 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } else if (StartOf(6)) { Expr( -#line 2046 "cs.ATG" +#line 2048 "cs.ATG" out expr); -#line 2046 "cs.ATG" +#line 2048 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 2047 "cs.ATG" +#line 2049 "cs.ATG" dims += 1; Expr( -#line 2048 "cs.ATG" +#line 2050 "cs.ATG" out expr); -#line 2048 "cs.ATG" +#line 2050 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 2050 "cs.ATG" +#line 2052 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 2051 "cs.ATG" +#line 2053 "cs.ATG" ++dims; } Expect(19); -#line 2051 "cs.ATG" +#line 2053 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 2052 "cs.ATG" +#line 2054 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { CollectionInitializer( -#line 2053 "cs.ATG" +#line 2055 "cs.ATG" out expr); -#line 2053 "cs.ATG" +#line 2055 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } - } else SynErr(211); - } else SynErr(212); + } else SynErr(210); + } else SynErr(211); } void AnonymousMethodExpr( -#line 2126 "cs.ATG" +#line 2128 "cs.ATG" out Expression outExpr) { -#line 2128 "cs.ATG" +#line 2130 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; BlockStatement stmt; @@ -4993,59 +5006,59 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(11)) { FormalParameterList( -#line 2137 "cs.ATG" +#line 2139 "cs.ATG" p); -#line 2137 "cs.ATG" +#line 2139 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 2139 "cs.ATG" +#line 2141 "cs.ATG" expr.HasParameterList = true; } BlockInsideExpression( -#line 2141 "cs.ATG" +#line 2143 "cs.ATG" out stmt); -#line 2141 "cs.ATG" +#line 2143 "cs.ATG" expr.Body = stmt; -#line 2142 "cs.ATG" +#line 2144 "cs.ATG" expr.EndLocation = t.Location; } void PointerMemberAccess( -#line 1994 "cs.ATG" +#line 1996 "cs.ATG" out Expression expr, Expression target) { -#line 1995 "cs.ATG" +#line 1997 "cs.ATG" List typeList; Expect(47); Identifier(); -#line 1999 "cs.ATG" +#line 2001 "cs.ATG" expr = new PointerReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; if ( -#line 2000 "cs.ATG" +#line 2002 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 2001 "cs.ATG" +#line 2003 "cs.ATG" out typeList, false); -#line 2002 "cs.ATG" +#line 2004 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void MemberAccess( -#line 1975 "cs.ATG" +#line 1977 "cs.ATG" out Expression expr, Expression target) { -#line 1976 "cs.ATG" +#line 1978 "cs.ATG" List typeList; -#line 1978 "cs.ATG" +#line 1980 "cs.ATG" if (ShouldConvertTargetExpressionToTypeReference(target)) { TypeReference type = GetTypeReferenceFromExpression(target); if (type != null) { @@ -5054,37 +5067,40 @@ out Expression expr, Expression target) { } Expect(15); - Identifier(); #line 1987 "cs.ATG" - expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; + Location startLocation = t.Location; + Identifier(); + +#line 1989 "cs.ATG" + expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; if ( -#line 1988 "cs.ATG" +#line 1990 "cs.ATG" IsGenericInSimpleNameOrMemberAccess()) { TypeArgumentList( -#line 1989 "cs.ATG" +#line 1991 "cs.ATG" out typeList, false); -#line 1990 "cs.ATG" +#line 1992 "cs.ATG" ((MemberReferenceExpression)expr).TypeArguments = typeList; } } void LambdaExpressionParameter( -#line 2093 "cs.ATG" +#line 2095 "cs.ATG" out ParameterDeclarationExpression p) { -#line 2094 "cs.ATG" +#line 2096 "cs.ATG" Location start = la.Location; p = null; TypeReference type; ParameterModifiers mod = ParameterModifiers.In; if ( -#line 2099 "cs.ATG" +#line 2101 "cs.ATG" Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { Identifier(); -#line 2101 "cs.ATG" +#line 2103 "cs.ATG" p = new ParameterDeclarationExpression(null, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; @@ -5093,369 +5109,369 @@ Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { if (la.kind == 100) { lexer.NextToken(); -#line 2104 "cs.ATG" +#line 2106 "cs.ATG" mod = ParameterModifiers.Ref; } else { lexer.NextToken(); -#line 2105 "cs.ATG" +#line 2107 "cs.ATG" mod = ParameterModifiers.Out; } } Type( -#line 2107 "cs.ATG" +#line 2109 "cs.ATG" out type); Identifier(); -#line 2109 "cs.ATG" +#line 2111 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val, mod); p.StartLocation = start; p.EndLocation = t.EndLocation; - } else SynErr(213); + } else SynErr(212); } void LambdaExpressionBody( -#line 2115 "cs.ATG" +#line 2117 "cs.ATG" LambdaExpression lambda) { -#line 2116 "cs.ATG" +#line 2118 "cs.ATG" Expression expr; BlockStatement stmt; if (la.kind == 16) { BlockInsideExpression( -#line 2119 "cs.ATG" +#line 2121 "cs.ATG" out stmt); -#line 2119 "cs.ATG" +#line 2121 "cs.ATG" lambda.StatementBody = stmt; } else if (StartOf(6)) { Expr( -#line 2120 "cs.ATG" +#line 2122 "cs.ATG" out expr); -#line 2120 "cs.ATG" +#line 2122 "cs.ATG" lambda.ExpressionBody = expr; - } else SynErr(214); + } else SynErr(213); -#line 2122 "cs.ATG" +#line 2124 "cs.ATG" lambda.EndLocation = t.EndLocation; -#line 2123 "cs.ATG" +#line 2125 "cs.ATG" lambda.ExtendedEndLocation = la.Location; } void BlockInsideExpression( -#line 2145 "cs.ATG" +#line 2147 "cs.ATG" out BlockStatement outStmt) { -#line 2146 "cs.ATG" +#line 2148 "cs.ATG" Statement stmt = null; outStmt = null; -#line 2150 "cs.ATG" +#line 2152 "cs.ATG" if (compilationUnit != null) { Block( -#line 2151 "cs.ATG" +#line 2153 "cs.ATG" out stmt); -#line 2151 "cs.ATG" +#line 2153 "cs.ATG" outStmt = (BlockStatement)stmt; -#line 2152 "cs.ATG" +#line 2154 "cs.ATG" } else { Expect(16); -#line 2154 "cs.ATG" +#line 2156 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 2156 "cs.ATG" +#line 2158 "cs.ATG" } } void ConditionalAndExpr( -#line 2165 "cs.ATG" +#line 2167 "cs.ATG" ref Expression outExpr) { -#line 2166 "cs.ATG" +#line 2168 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 2168 "cs.ATG" +#line 2170 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 2168 "cs.ATG" +#line 2170 "cs.ATG" out expr); InclusiveOrExpr( -#line 2168 "cs.ATG" +#line 2170 "cs.ATG" ref expr); -#line 2168 "cs.ATG" +#line 2170 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 2171 "cs.ATG" +#line 2173 "cs.ATG" ref Expression outExpr) { -#line 2172 "cs.ATG" +#line 2174 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 2174 "cs.ATG" +#line 2176 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 2174 "cs.ATG" +#line 2176 "cs.ATG" out expr); ExclusiveOrExpr( -#line 2174 "cs.ATG" +#line 2176 "cs.ATG" ref expr); -#line 2174 "cs.ATG" +#line 2176 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 2177 "cs.ATG" +#line 2179 "cs.ATG" ref Expression outExpr) { -#line 2178 "cs.ATG" +#line 2180 "cs.ATG" Expression expr; AndExpr( -#line 2180 "cs.ATG" +#line 2182 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 2180 "cs.ATG" +#line 2182 "cs.ATG" out expr); AndExpr( -#line 2180 "cs.ATG" +#line 2182 "cs.ATG" ref expr); -#line 2180 "cs.ATG" +#line 2182 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 2183 "cs.ATG" +#line 2185 "cs.ATG" ref Expression outExpr) { -#line 2184 "cs.ATG" +#line 2186 "cs.ATG" Expression expr; EqualityExpr( -#line 2186 "cs.ATG" +#line 2188 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 2186 "cs.ATG" +#line 2188 "cs.ATG" out expr); EqualityExpr( -#line 2186 "cs.ATG" +#line 2188 "cs.ATG" ref expr); -#line 2186 "cs.ATG" +#line 2188 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 2189 "cs.ATG" +#line 2191 "cs.ATG" ref Expression outExpr) { -#line 2191 "cs.ATG" +#line 2193 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2195 "cs.ATG" +#line 2197 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2198 "cs.ATG" +#line 2200 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2199 "cs.ATG" +#line 2201 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2201 "cs.ATG" +#line 2203 "cs.ATG" out expr); RelationalExpr( -#line 2201 "cs.ATG" +#line 2203 "cs.ATG" ref expr); -#line 2201 "cs.ATG" +#line 2203 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2205 "cs.ATG" +#line 2207 "cs.ATG" ref Expression outExpr) { -#line 2207 "cs.ATG" +#line 2209 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2212 "cs.ATG" +#line 2214 "cs.ATG" ref outExpr); while (StartOf(37)) { if (StartOf(38)) { if (la.kind == 23) { lexer.NextToken(); -#line 2214 "cs.ATG" +#line 2216 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2215 "cs.ATG" +#line 2217 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2216 "cs.ATG" +#line 2218 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2217 "cs.ATG" +#line 2219 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; - } else SynErr(215); + } else SynErr(214); UnaryExpr( -#line 2219 "cs.ATG" +#line 2221 "cs.ATG" out expr); ShiftExpr( -#line 2220 "cs.ATG" +#line 2222 "cs.ATG" ref expr); -#line 2221 "cs.ATG" +#line 2223 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 85) { lexer.NextToken(); TypeWithRestriction( -#line 2224 "cs.ATG" +#line 2226 "cs.ATG" out type, false, false); if ( -#line 2225 "cs.ATG" +#line 2227 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2226 "cs.ATG" +#line 2228 "cs.ATG" ref type); } -#line 2227 "cs.ATG" +#line 2229 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 50) { lexer.NextToken(); TypeWithRestriction( -#line 2229 "cs.ATG" +#line 2231 "cs.ATG" out type, false, false); if ( -#line 2230 "cs.ATG" +#line 2232 "cs.ATG" la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind)) { NullableQuestionMark( -#line 2231 "cs.ATG" +#line 2233 "cs.ATG" ref type); } -#line 2232 "cs.ATG" +#line 2234 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); - } else SynErr(216); + } else SynErr(215); } } } void ShiftExpr( -#line 2237 "cs.ATG" +#line 2239 "cs.ATG" ref Expression outExpr) { -#line 2239 "cs.ATG" +#line 2241 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2243 "cs.ATG" +#line 2245 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2246 "cs.ATG" +#line 2248 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2245 "cs.ATG" +#line 2247 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2247 "cs.ATG" +#line 2249 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2250 "cs.ATG" +#line 2252 "cs.ATG" out expr); AdditiveExpr( -#line 2250 "cs.ATG" +#line 2252 "cs.ATG" ref expr); -#line 2250 "cs.ATG" +#line 2252 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2254 "cs.ATG" +#line 2256 "cs.ATG" ref Expression outExpr) { -#line 2256 "cs.ATG" +#line 2258 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2260 "cs.ATG" +#line 2262 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2263 "cs.ATG" +#line 2265 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2264 "cs.ATG" +#line 2266 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2266 "cs.ATG" +#line 2268 "cs.ATG" out expr); MultiplicativeExpr( -#line 2266 "cs.ATG" +#line 2268 "cs.ATG" ref expr); -#line 2266 "cs.ATG" +#line 2268 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2270 "cs.ATG" +#line 2272 "cs.ATG" ref Expression outExpr) { -#line 2272 "cs.ATG" +#line 2274 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5463,82 +5479,82 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2278 "cs.ATG" +#line 2280 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2279 "cs.ATG" +#line 2281 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2280 "cs.ATG" +#line 2282 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2282 "cs.ATG" +#line 2284 "cs.ATG" out expr); -#line 2282 "cs.ATG" +#line 2284 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2388 "cs.ATG" +#line 2390 "cs.ATG" out TypeReference type) { -#line 2389 "cs.ATG" +#line 2391 "cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); -#line 2391 "cs.ATG" +#line 2393 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); -#line 2392 "cs.ATG" +#line 2394 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); -#line 2393 "cs.ATG" +#line 2395 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( -#line 2394 "cs.ATG" +#line 2396 "cs.ATG" out t); -#line 2394 "cs.ATG" +#line 2396 "cs.ATG" type = t; - } else SynErr(217); + } else SynErr(216); } void QueryExpressionFromClause( -#line 2409 "cs.ATG" +#line 2411 "cs.ATG" out QueryExpressionFromClause fc) { -#line 2410 "cs.ATG" +#line 2412 "cs.ATG" fc = new QueryExpressionFromClause(); fc.StartLocation = la.Location; Expect(137); QueryExpressionFromOrJoinClause( -#line 2414 "cs.ATG" +#line 2416 "cs.ATG" fc); -#line 2415 "cs.ATG" +#line 2417 "cs.ATG" fc.EndLocation = t.EndLocation; } void QueryExpressionBody( -#line 2445 "cs.ATG" +#line 2447 "cs.ATG" ref QueryExpression q) { -#line 2446 "cs.ATG" +#line 2448 "cs.ATG" QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; QueryExpressionOrderClause orderClause; @@ -5547,249 +5563,249 @@ ref QueryExpression q) { while (StartOf(39)) { if (la.kind == 137) { QueryExpressionFromClause( -#line 2452 "cs.ATG" +#line 2454 "cs.ATG" out fromClause); -#line 2452 "cs.ATG" +#line 2454 "cs.ATG" SafeAdd(q, q.MiddleClauses, fromClause); } else if (la.kind == 127) { QueryExpressionWhereClause( -#line 2453 "cs.ATG" +#line 2455 "cs.ATG" out whereClause); -#line 2453 "cs.ATG" +#line 2455 "cs.ATG" SafeAdd(q, q.MiddleClauses, whereClause); } else if (la.kind == 141) { QueryExpressionLetClause( -#line 2454 "cs.ATG" +#line 2456 "cs.ATG" out letClause); -#line 2454 "cs.ATG" +#line 2456 "cs.ATG" SafeAdd(q, q.MiddleClauses, letClause); } else if (la.kind == 142) { QueryExpressionJoinClause( -#line 2455 "cs.ATG" +#line 2457 "cs.ATG" out joinClause); -#line 2455 "cs.ATG" +#line 2457 "cs.ATG" SafeAdd(q, q.MiddleClauses, joinClause); } else { QueryExpressionOrderByClause( -#line 2456 "cs.ATG" +#line 2458 "cs.ATG" out orderClause); -#line 2456 "cs.ATG" +#line 2458 "cs.ATG" SafeAdd(q, q.MiddleClauses, orderClause); } } if (la.kind == 133) { QueryExpressionSelectClause( -#line 2458 "cs.ATG" +#line 2460 "cs.ATG" out selectClause); -#line 2458 "cs.ATG" +#line 2460 "cs.ATG" q.SelectOrGroupClause = selectClause; } else if (la.kind == 134) { QueryExpressionGroupClause( -#line 2459 "cs.ATG" +#line 2461 "cs.ATG" out groupClause); -#line 2459 "cs.ATG" +#line 2461 "cs.ATG" q.SelectOrGroupClause = groupClause; - } else SynErr(218); + } else SynErr(217); if (la.kind == 136) { QueryExpressionIntoClause( -#line 2461 "cs.ATG" +#line 2463 "cs.ATG" ref q); } } void QueryExpressionFromOrJoinClause( -#line 2435 "cs.ATG" +#line 2437 "cs.ATG" QueryExpressionFromOrJoinClause fjc) { -#line 2436 "cs.ATG" +#line 2438 "cs.ATG" TypeReference type; Expression expr; -#line 2438 "cs.ATG" +#line 2440 "cs.ATG" fjc.Type = null; if ( -#line 2439 "cs.ATG" +#line 2441 "cs.ATG" IsLocalVarDecl()) { Type( -#line 2439 "cs.ATG" +#line 2441 "cs.ATG" out type); -#line 2439 "cs.ATG" +#line 2441 "cs.ATG" fjc.Type = type; } Identifier(); -#line 2440 "cs.ATG" +#line 2442 "cs.ATG" fjc.Identifier = t.val; Expect(81); Expr( -#line 2442 "cs.ATG" +#line 2444 "cs.ATG" out expr); -#line 2442 "cs.ATG" +#line 2444 "cs.ATG" fjc.InExpression = expr; } void QueryExpressionJoinClause( -#line 2418 "cs.ATG" +#line 2420 "cs.ATG" out QueryExpressionJoinClause jc) { -#line 2419 "cs.ATG" +#line 2421 "cs.ATG" jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; Expression expr; Expect(142); QueryExpressionFromOrJoinClause( -#line 2424 "cs.ATG" +#line 2426 "cs.ATG" jc); Expect(143); Expr( -#line 2426 "cs.ATG" +#line 2428 "cs.ATG" out expr); -#line 2426 "cs.ATG" +#line 2428 "cs.ATG" jc.OnExpression = expr; Expect(144); Expr( -#line 2428 "cs.ATG" +#line 2430 "cs.ATG" out expr); -#line 2428 "cs.ATG" +#line 2430 "cs.ATG" jc.EqualsExpression = expr; if (la.kind == 136) { lexer.NextToken(); Identifier(); -#line 2430 "cs.ATG" +#line 2432 "cs.ATG" jc.IntoIdentifier = t.val; } -#line 2432 "cs.ATG" +#line 2434 "cs.ATG" jc.EndLocation = t.EndLocation; } void QueryExpressionWhereClause( -#line 2464 "cs.ATG" +#line 2466 "cs.ATG" out QueryExpressionWhereClause wc) { -#line 2465 "cs.ATG" +#line 2467 "cs.ATG" Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; Expect(127); Expr( -#line 2468 "cs.ATG" +#line 2470 "cs.ATG" out expr); -#line 2468 "cs.ATG" +#line 2470 "cs.ATG" wc.Condition = expr; -#line 2469 "cs.ATG" +#line 2471 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionLetClause( -#line 2472 "cs.ATG" +#line 2474 "cs.ATG" out QueryExpressionLetClause wc) { -#line 2473 "cs.ATG" +#line 2475 "cs.ATG" Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; Expect(141); Identifier(); -#line 2476 "cs.ATG" +#line 2478 "cs.ATG" wc.Identifier = t.val; Expect(3); Expr( -#line 2478 "cs.ATG" +#line 2480 "cs.ATG" out expr); -#line 2478 "cs.ATG" +#line 2480 "cs.ATG" wc.Expression = expr; -#line 2479 "cs.ATG" +#line 2481 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionOrderByClause( -#line 2482 "cs.ATG" +#line 2484 "cs.ATG" out QueryExpressionOrderClause oc) { -#line 2483 "cs.ATG" +#line 2485 "cs.ATG" QueryExpressionOrdering ordering; oc = new QueryExpressionOrderClause(); oc.StartLocation = la.Location; Expect(140); QueryExpressionOrdering( -#line 2486 "cs.ATG" +#line 2488 "cs.ATG" out ordering); -#line 2486 "cs.ATG" +#line 2488 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); while (la.kind == 14) { lexer.NextToken(); QueryExpressionOrdering( -#line 2488 "cs.ATG" +#line 2490 "cs.ATG" out ordering); -#line 2488 "cs.ATG" +#line 2490 "cs.ATG" SafeAdd(oc, oc.Orderings, ordering); } -#line 2490 "cs.ATG" +#line 2492 "cs.ATG" oc.EndLocation = t.EndLocation; } void QueryExpressionSelectClause( -#line 2503 "cs.ATG" +#line 2505 "cs.ATG" out QueryExpressionSelectClause sc) { -#line 2504 "cs.ATG" +#line 2506 "cs.ATG" Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; Expect(133); Expr( -#line 2507 "cs.ATG" +#line 2509 "cs.ATG" out expr); -#line 2507 "cs.ATG" +#line 2509 "cs.ATG" sc.Projection = expr; -#line 2508 "cs.ATG" +#line 2510 "cs.ATG" sc.EndLocation = t.EndLocation; } void QueryExpressionGroupClause( -#line 2511 "cs.ATG" +#line 2513 "cs.ATG" out QueryExpressionGroupClause gc) { -#line 2512 "cs.ATG" +#line 2514 "cs.ATG" Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; Expect(134); Expr( -#line 2515 "cs.ATG" +#line 2517 "cs.ATG" out expr); -#line 2515 "cs.ATG" +#line 2517 "cs.ATG" gc.Projection = expr; Expect(135); Expr( -#line 2517 "cs.ATG" +#line 2519 "cs.ATG" out expr); -#line 2517 "cs.ATG" +#line 2519 "cs.ATG" gc.GroupBy = expr; -#line 2518 "cs.ATG" +#line 2520 "cs.ATG" gc.EndLocation = t.EndLocation; } void QueryExpressionIntoClause( -#line 2521 "cs.ATG" +#line 2523 "cs.ATG" ref QueryExpression q) { -#line 2522 "cs.ATG" +#line 2524 "cs.ATG" QueryExpression firstQuery = q; QueryExpression continuedQuery = new QueryExpression(); continuedQuery.StartLocation = q.StartLocation; @@ -5804,43 +5820,43 @@ ref QueryExpression q) { Expect(136); Identifier(); -#line 2535 "cs.ATG" +#line 2537 "cs.ATG" continuedQuery.FromClause.Identifier = t.val; -#line 2536 "cs.ATG" +#line 2538 "cs.ATG" continuedQuery.FromClause.EndLocation = t.EndLocation; QueryExpressionBody( -#line 2537 "cs.ATG" +#line 2539 "cs.ATG" ref q); } void QueryExpressionOrdering( -#line 2493 "cs.ATG" +#line 2495 "cs.ATG" out QueryExpressionOrdering ordering) { -#line 2494 "cs.ATG" +#line 2496 "cs.ATG" Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; Expr( -#line 2496 "cs.ATG" +#line 2498 "cs.ATG" out expr); -#line 2496 "cs.ATG" +#line 2498 "cs.ATG" ordering.Criteria = expr; if (la.kind == 138 || la.kind == 139) { if (la.kind == 138) { lexer.NextToken(); -#line 2497 "cs.ATG" +#line 2499 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2498 "cs.ATG" +#line 2500 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2500 "cs.ATG" +#line 2502 "cs.ATG" ordering.EndLocation = t.EndLocation; } @@ -6065,16 +6081,15 @@ out expr); case 206: s = "invalid UnaryExpr"; break; case 207: s = "invalid PrimaryExpr"; break; case 208: s = "invalid PrimaryExpr"; break; - case 209: s = "invalid PrimaryExpr"; break; - case 210: s = "invalid TypeArgumentList"; break; + case 209: s = "invalid TypeArgumentList"; break; + case 210: s = "invalid NewExpression"; break; case 211: s = "invalid NewExpression"; break; - case 212: s = "invalid NewExpression"; break; - case 213: s = "invalid LambdaExpressionParameter"; break; - case 214: s = "invalid LambdaExpressionBody"; break; + case 212: s = "invalid LambdaExpressionParameter"; break; + case 213: s = "invalid LambdaExpressionBody"; break; + case 214: s = "invalid RelationalExpr"; break; case 215: s = "invalid RelationalExpr"; break; - case 216: s = "invalid RelationalExpr"; break; - case 217: s = "invalid TypeParameterConstraintsClauseBase"; break; - case 218: s = "invalid QueryExpressionBody"; break; + case 216: s = "invalid TypeParameterConstraintsClauseBase"; break; + case 217: s = "invalid QueryExpressionBody"; break; default: s = "error " + errorNumber; break; } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 208129e8c9..3084b7ba5e 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -1782,8 +1782,10 @@ Expr ) ) (. if (expr != null) { - expr.StartLocation = startLocation; - expr.EndLocation = t.EndLocation; + if (expr.StartLocation.IsEmpty) + expr.StartLocation = startLocation; + if (expr.EndLocation.IsEmpty) + expr.EndLocation = t.EndLocation; } .) . @@ -1938,14 +1940,14 @@ PrimaryExpr (. startLocation = la.Location; .) ( "++" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); .) - | "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .) - ) + | + "--" (. pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); .) /*--- member access */ - | PointerMemberAccess - | MemberAccess + | PointerMemberAccess + | MemberAccess /*--- invocation expression: */ - | "(" + | "(" (. List parameters = new List(); .) (. pexpr = new InvocationExpression(pexpr, parameters); .) [ Argument (. SafeAdd(pexpr, parameters, expr); .) @@ -1958,13 +1960,15 @@ PrimaryExpr List indices = new List(); pexpr = new IndexerExpression(pexpr, indices); .) - "[" Expr (. SafeAdd(pexpr, indices, expr); .) - { "," Expr (. SafeAdd(pexpr, indices, expr); .) - } "]" - + "[" Expr (. SafeAdd(pexpr, indices, expr); .) + { "," Expr (. SafeAdd(pexpr, indices, expr); .) + } "]" + ) (. if (pexpr != null) { - pexpr.StartLocation = startLocation; - pexpr.EndLocation = t.EndLocation; + if (pexpr.StartLocation.IsEmpty) + pexpr.StartLocation = startLocation; + if (pexpr.EndLocation.IsEmpty) + pexpr.EndLocation = t.EndLocation; } .) } @@ -1980,9 +1984,9 @@ MemberAccess } } .) - "." + "." (. Location startLocation = t.Location; .) Identifier - (. expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = t.Location; expr.EndLocation = t.EndLocation; .) + (. expr = new MemberReferenceExpression(target, t.val); expr.StartLocation = startLocation; expr.EndLocation = t.EndLocation; .) [ IF (IsGenericInSimpleNameOrMemberAccess()) TypeArgumentList (. ((MemberReferenceExpression)expr).TypeArguments = typeList; .) diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs index 1fbfe6fce5..87f3560d24 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs @@ -103,6 +103,20 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.IsTrue(expr.Arguments[0] is InvocationExpression); CheckSimpleInvoke((InvocationExpression)expr.Arguments[0]); } + + [Test] + public void NestedInvocationPositions() + { + InvocationExpression expr = ParseUtilCSharp.ParseExpression("a.B().C(args)"); + Assert.AreEqual(new Location(8, 1), expr.StartLocation); + Assert.AreEqual(new Location(14, 1), expr.EndLocation); + MemberReferenceExpression mre = (MemberReferenceExpression)expr.TargetObject; + Assert.AreEqual(new Location(6, 1), mre.StartLocation); + Assert.AreEqual(new Location(8, 1), mre.EndLocation); + + Assert.AreEqual(new Location(4, 1), mre.TargetObject.StartLocation); + Assert.AreEqual(new Location(6, 1), mre.TargetObject.EndLocation); + } #endregion #region VB.NET