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

@@ -0,0 +1,16 @@
#include "expression.hpp"
namespace ast {
expression_stmt::expression_stmt(token::token token)
: token(std::move(token)),
expression(nullptr) {}
std::string expression_stmt::token_literal() const {
return token.literal;
}
expression_stmt::~expression_stmt() {
delete expression;
}
} // namespace ast

View File

@@ -0,0 +1,15 @@
#include "ast/ast.hpp"
#include "token/token.hpp"
namespace ast {
struct expression_stmt : statement {
expression_stmt(token::token token);
token::token token;
ast::expression* expression;
std::string token_literal() const override;
~expression_stmt();
};
} // namespace ast