fixed implementation of parse block

This commit is contained in:
Karma Riuk
2025-07-15 00:04:58 +02:00
parent 7c55e58e1a
commit d94bb99381

View File

@@ -301,18 +301,22 @@ namespace parser {
ast::block_stmt* parser::parse_block() {
TRACE_FUNCTION;
ast::block_stmt* ret = new ast::block_stmt(current);
// ret->statements.push_back(parse_statement());
next_token();
int i = 0;
while (current.type != token::type::RBRACE && i++ < 10) {
// for (next_token(); next.type != token::type::RBRACE;
// next_token()) {
for (next_token(); current.type != token::type::RBRACE
&& current.type != token::type::END_OF_FILE;
next_token()) {
ast::statement* stmt = parse_statement();
if (stmt != nullptr)
ret->statements.push_back(stmt);
next_token();
}
if (current.type != token::type::RBRACE) {
next_error(token::type::RBRACE);
delete ret;
return nullptr;
}
return ret;
}