aboutsummaryrefslogtreecommitdiff
path: root/boot/ast.cc
diff options
context:
space:
mode:
Diffstat (limited to 'boot/ast.cc')
-rw-r--r--boot/ast.cc63
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);