- formatted += "for(";
- iter.init_statement->visit(*this);
- formatted += ' ';
- iter.condition->visit(*this);
- formatted += "; ";
- iter.loop_expression->visit(*this);
- formatted += ")\n";
- iter.body.visit(*this);
+ if(!iter.init_statement && iter.condition && !iter.loop_expression)
+ {
+ append("while(");
+ iter.condition->visit(*this);
+ append(')');
+ }
+ else
+ {
+ append("for(");
+ if(iter.init_statement)
+ iter.init_statement->visit(*this);
+ else
+ append(';');
+ if(iter.condition)
+ {
+ append(' ');
+ iter.condition->visit(*this);
+ }
+ append(';');
+ if(iter.loop_expression)
+ {
+ append(' ');
+ iter.loop_expression->visit(*this);
+ }
+ append(')');
+ }
+
+ if(iter.body.body.empty())
+ append(" { }");
+ else
+ {
+ append('\n');
+ iter.body.visit(*this);
+ }