Allow only one return statement

This commit is contained in:
2025-05-17 23:12:44 +02:00
parent 573d812f1c
commit 8206b48dbd
6 changed files with 69 additions and 91 deletions

View File

@ -795,7 +795,7 @@ namespace elna::boot
}
return_statement::return_statement(const struct position position, expression *return_expression)
: node(position), return_expression(return_expression)
: node(position), m_return_expression(return_expression)
{
}
@ -804,9 +804,14 @@ namespace elna::boot
visitor->visit(this);
}
expression& return_statement::return_expression()
{
return *m_return_expression;
}
return_statement::~return_statement()
{
delete this->return_expression;
delete m_return_expression;
}
case_statement::case_statement(const struct position position,
@ -914,13 +919,6 @@ namespace elna::boot
{
}
while_statement::while_statement(const struct position position, conditional_statements *body,
std::vector<conditional_statements *>&& branches, const std::string& label,
std::vector<statement *> *alternative)
: node(position), m_body(body), branches(std::move(branches)), label(label), alternative(alternative)
{
}
void while_statement::accept(parser_visitor *visitor)
{
visitor->visit(this);