added the parsing of expression statements

This commit is contained in:
Karma Riuk
2025-07-08 09:51:15 +02:00
parent 08aacf0416
commit d13f9bf9f8
4 changed files with 47 additions and 8 deletions

View File

@@ -42,14 +42,6 @@ namespace parser {
}
}
bool parser::expect_next(token::type t) {
if (next.type == t) {
next_token();
return true;
}
next_error(t);
return false;
}
ast::expression* parser::parse_expression() {
// TODO: we are currently skipping expressions until we encounter a
// semicolon
@@ -85,7 +77,21 @@ namespace parser {
return stmt;
}
ast::expression_stmt* parser::parse_expression_stmt() {
ast::expression_stmt* stmt = new ast::expression_stmt(current);
stmt->expression = parse_expression();
return stmt;
};
bool parser::expect_next(token::type t) {
if (next.type == t) {
next_token();
return true;
}
next_error(t);
return false;
}
void parser::next_error(token::type t) {