public override void PostWalk(IndexExpression node) { if (IsInRange(node) && IsValidTarget(node.Target) && IsValidTarget(node.Index)) { _expressions.Remove(node.Target); _expressions.Add(node, node.Target); } }
// trailer: '(' [ arglist_genexpr ] ')' | '[' subscriptlist ']' | '.' NAME private Expression AddTrailers(Expression ret, bool allowGeneratorExpression) { bool prevAllow = _allowIncomplete; try { _allowIncomplete = true; while (true) { switch (PeekToken().Kind) { case TokenKind.LeftParenthesis: if (!allowGeneratorExpression) return ret; NextToken(); string whitespace = _tokenWhiteSpace; List<string> commaWhiteSpace; bool ateTerminator; Arg[] args = FinishArgListOrGenExpr(out commaWhiteSpace, out ateTerminator); string closeParenWhiteSpace = _tokenWhiteSpace; CallExpression call; if (args != null) { call = FinishCallExpr(ret, args); } else { call = new CallExpression(ret, new Arg[0]); } if (_verbatim) { AddPreceedingWhiteSpace(call, whitespace); AddSecondPreceedingWhiteSpace(call, closeParenWhiteSpace); if (commaWhiteSpace != null) { AddListWhiteSpace(call, commaWhiteSpace.ToArray()); } if (!ateTerminator) { AddErrorMissingCloseGrouping(call); } } call.SetLoc(ret.StartIndex, GetEnd()); ret = call; break; case TokenKind.LeftBracket: NextToken(); whitespace = _tokenWhiteSpace; Expression index = ParseSubscriptList(out ateTerminator); IndexExpression ie = new IndexExpression(ret, index); string finishWhiteSpace = _tokenWhiteSpace; ie.SetLoc(ret.StartIndex, GetEnd()); if (_verbatim) { AddPreceedingWhiteSpace(ie, whitespace); AddSecondPreceedingWhiteSpace(ie, finishWhiteSpace); if (!ateTerminator) { AddErrorMissingCloseGrouping(ie); } } ret = ie; break; case TokenKind.Dot: NextToken(); whitespace = _tokenWhiteSpace; var name = ReadNameMaybeNone(); string nameWhitespace = _tokenWhiteSpace; MemberExpression fe = MakeMember(ret, name); fe.SetLoc(ret.StartIndex, GetStart(), GetEnd()); if (_verbatim) { AddPreceedingWhiteSpace(fe, whitespace); AddSecondPreceedingWhiteSpace(fe, nameWhitespace); if (!name.HasName) { AddErrorIsIncompleteNode(fe); } } ret = fe; break; case TokenKind.Constant: // abc.1, abc"", abc 1L, abc 0j ReportSyntaxError("invalid syntax"); ret = Error(_verbatim ? _lookaheadWhiteSpace + _lookahead.Token.VerbatimImage : null, ret); NextToken(); break; default: return ret; } } } finally { _allowIncomplete = prevAllow; } }
public override bool Walk(IndexExpression node) { return UpdateLineInfo(node, true); }
public override bool Walk(IndexExpression node) { node.Walk(_fc); return false; }
public override void PostWalk(IndexExpression node) { PostWalkWorker(node); }
// IndexExpression public override bool Walk(IndexExpression node) { return ShouldWalkWorker(node); }