added parsing of if statements

This commit is contained in:
Karma Riuk
2025-07-14 15:19:05 +02:00
parent 86574552aa
commit 9e63c923da
7 changed files with 244 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#include "block.hpp"
#include <sstream>
namespace ast {
block_stmt::block_stmt(token::token token): token(std::move(token)) {}
std::string block_stmt::token_literal() const {
return token.literal;
}
block_stmt::~block_stmt() {
for (const auto& stmt : statements)
delete stmt;
};
std::string block_stmt::str() const {
std::stringstream ss;
ss << "{";
for (const auto& stmt : statements)
ss << stmt->str();
ss << "}";
return ss.str();
};
} // namespace ast

View File

@@ -0,0 +1,20 @@
#pragma once
#include "ast/ast.hpp"
#include "token/token.hpp"
#include <vector>
namespace ast {
struct block_stmt : statement {
block_stmt(token::token token);
token::token token;
std::vector<ast::statement*> statements;
std::string token_literal() const override;
std::string str() const override;
~block_stmt();
};
} // namespace ast