Format function after parsing

This commit is contained in:
Sofia 2026-04-02 16:13:53 +03:00
parent ab406df610
commit 87dceb5b7c

View File

@ -1,15 +1,30 @@
#include "ast.h"
#include <sstream>
namespace AST {
std::string ReturnStatement::formatted() {
return "ReturnStatement";
std::stringstream out{ "" };
out << "return ";
out << this->m_expr->formatted();
out << ";";
return out.str();
}
std::string IntLiteralExpression::formatted() {
return "IntLiteral";
std::stringstream out{ "" };
out << this->m_value;
return out.str();
}
std::string Function::formatted() {
return "Function";
std::stringstream out{ "" };
out << "Function() {\n";
for (auto& statement : this->m_statements) {
out << " " << statement->formatted() << "\n";
}
out << "}";
return out.str();
}
}