fixed implementation of parse block
This commit is contained in:
@@ -301,18 +301,22 @@ namespace parser {
|
|||||||
ast::block_stmt* parser::parse_block() {
|
ast::block_stmt* parser::parse_block() {
|
||||||
TRACE_FUNCTION;
|
TRACE_FUNCTION;
|
||||||
ast::block_stmt* ret = new ast::block_stmt(current);
|
ast::block_stmt* ret = new ast::block_stmt(current);
|
||||||
// ret->statements.push_back(parse_statement());
|
|
||||||
next_token();
|
for (next_token(); current.type != token::type::RBRACE
|
||||||
int i = 0;
|
&& current.type != token::type::END_OF_FILE;
|
||||||
while (current.type != token::type::RBRACE && i++ < 10) {
|
next_token()) {
|
||||||
// for (next_token(); next.type != token::type::RBRACE;
|
|
||||||
// next_token()) {
|
|
||||||
ast::statement* stmt = parse_statement();
|
ast::statement* stmt = parse_statement();
|
||||||
if (stmt != nullptr)
|
if (stmt != nullptr)
|
||||||
ret->statements.push_back(stmt);
|
ret->statements.push_back(stmt);
|
||||||
next_token();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current.type != token::type::RBRACE) {
|
||||||
|
next_error(token::type::RBRACE);
|
||||||
|
delete ret;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user