diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-16 11:49:35 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-16 11:49:35 +0200 |
| commit | b575036fe804f14b78da74897a74b010cc94f730 (patch) | |
| tree | 054dcb6e932bc8cf5faf2a0158794913fc6e8be3 /boot/ast.cc | |
| parent | 52c8ca2c06da93c8d14e80a256e8996c1fa1e885 (diff) | |
| download | elna-b575036fe804f14b78da74897a74b010cc94f730.tar.gz | |
Implement named blocks
Diffstat (limited to 'boot/ast.cc')
| -rw-r--r-- | boot/ast.cc | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/boot/ast.cc b/boot/ast.cc index 04e9230..4a596e5 100644 --- a/boot/ast.cc +++ b/boot/ast.cc @@ -112,6 +112,16 @@ namespace elna::boot __builtin_unreachable(); } + void empty_visitor::visit(block_statement *) + { + __builtin_unreachable(); + } + + void empty_visitor::visit(break_statement *) + { + __builtin_unreachable(); + } + void empty_visitor::visit(empty_statement *) { __builtin_unreachable(); @@ -306,12 +316,24 @@ namespace elna::boot void walking_visitor::visit(defer_statement *statement) { - for (auto *block_statement : statement->statements) + for (auto *body_statement : statement->statements) + { + body_statement->accept(this); + } + } + + void walking_visitor::visit(block_statement *statement) + { + for (auto *body_statement : statement->statements) { - block_statement->accept(this); + body_statement->accept(this); } } + void walking_visitor::visit(break_statement *) + { + } + void walking_visitor::visit(empty_statement *) { } @@ -325,16 +347,16 @@ namespace elna::boot { case_label->accept(this); } - for (auto *block_statement : case_block.statements) + for (auto *body_statement : case_block.statements) { - block_statement->accept(this); + body_statement->accept(this); } } if (statement->alternative != nullptr) { - for (auto *block_statement : *statement->alternative) + for (auto *body_statement : *statement->alternative) { - block_statement->accept(this); + body_statement->accept(this); } } } @@ -1171,6 +1193,35 @@ namespace elna::boot } } + block_statement::block_statement(const source_position position, identifier&& name, + std::vector<statement *>&& statements) + : node(position), name(std::move(name)), statements(std::move(statements)) + { + } + + void block_statement::accept(parser_visitor *visitor) + { + visitor->visit(this); + } + + block_statement::~block_statement() + { + for (const statement *body_statement : statements) + { + delete body_statement; + } + } + + break_statement::break_statement(const source_position position, identifier&& label) + : node(position), label(std::move(label)) + { + } + + void break_statement::accept(parser_visitor *visitor) + { + visitor->visit(this); + } + void empty_statement::accept(parser_visitor *visitor) { visitor->visit(this); |
