diff options
Diffstat (limited to 'Shell/Formatter.cpp')
-rw-r--r-- | Shell/Formatter.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Shell/Formatter.cpp b/Shell/Formatter.cpp index 05975c4aca..e12b7b9551 100644 --- a/Shell/Formatter.cpp +++ b/Shell/Formatter.cpp @@ -261,6 +261,19 @@ void Formatter::visit(const AST::Comment* node) visited(node); } +void Formatter::visit(const AST::ContinuationControl* node) +{ + will_visit(node); + test_and_update_output_cursor(node); + if (node->continuation_kind() == AST::ContinuationControl::Break) + current_builder().append("break"); + else if (node->continuation_kind() == AST::ContinuationControl::Continue) + current_builder().append("continue"); + else + ASSERT_NOT_REACHED(); + visited(node); +} + void Formatter::visit(const AST::DynamicEvaluate* node) { will_visit(node); @@ -327,15 +340,18 @@ void Formatter::visit(const AST::ForLoop* node) { will_visit(node); test_and_update_output_cursor(node); - current_builder().append("for "); + auto is_loop = node->iterated_expression().is_null(); + current_builder().append(is_loop ? "loop" : "for "); TemporaryChange<const AST::Node*> parent { m_parent_node, node }; - if (node->variable_name() != "it") { - current_builder().append(node->variable_name()); - current_builder().append(" in "); - } + if (!is_loop) { + if (node->variable_name() != "it") { + current_builder().append(node->variable_name()); + current_builder().append(" in "); + } - node->iterated_expression()->visit(*this); + node->iterated_expression()->visit(*this); + } current_builder().append(' '); in_new_block([&] { |