Format function after parsing
This commit is contained in:
parent
ab406df610
commit
87dceb5b7c
21
src/ast.cpp
21
src/ast.cpp
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user