public override void VisitChildren(IVisitor visitor) { InitialStatement.Visit(visitor); Condition.Visit(visitor); RepeatStatement.Visit(visitor); Body.Visit(visitor); }
/// <summary> /// Returns the string representation of the statement. /// </summary> /// <returns>Returns the string representation of the statement.</returns> /// <param name="indentation">The number of indented characters.</param> /// <exception cref="ArgumentOutOfRangeException"><paramref name="indentation"/> is negative.</exception> public override string ToString(int indentation) { if (indentation < 0) { throw new ArgumentOutOfRangeException(); } var ind = new string(' ', indentation); var sb = new StringBuilder(); sb.Append(ind).Append("for").Append(" ("); if (InitialStatement != null) { sb.Append(InitialStatement.ToString()).Append(" "); } else { sb.Append("; "); } if (TestExpression != null) { sb.Append(TestExpression.ToString()).Append("; "); } else { sb.Append("; "); } if (IncrementStatement != null) { sb.Append(IncrementStatement.ToString().TrimEnd(';')); } sb.Append(")\n"); if (Statements != null) { sb.Append(ind).Append("{\n") .Append(Statements.ToString(indentation + 4)).Append("\n") .Append(ind).Append("}"); } else { sb.Append(ind).Append("{ }"); } return(sb.ToString()); }