Do not wrap simple expressions in braces.

This commit is contained in:
Stefano Sanfilippo 2014-12-10 19:50:51 +01:00
parent d8a895773a
commit eb072a063d

View File

@ -161,9 +161,19 @@ void Assignment::emit(std::ostream &stream, int indent) {
} }
void Print::emit(std::ostream &stream, int indent) { void Print::emit(std::ostream &stream, int indent) {
stream << "std::cout << ("; bool simpleExpression = (dynamic_cast<SimpleExpression*>(expression.get()) != nullptr);
stream << "std::cout << ";
if (!simpleExpression) {
stream << '(';
}
expression->emit(stream); expression->emit(stream);
stream << ") << std::endl";
if (!simpleExpression) {
stream << ')';
}
stream << " << std::endl";
} }
void Input::emit(std::ostream &stream, int indent) { void Input::emit(std::ostream &stream, int indent) {