diff --git a/src/ast.cpp b/src/ast.cpp index d5b434d..b2373a7 100644 --- a/src/ast.cpp +++ b/src/ast.cpp @@ -1,15 +1,30 @@ #include "ast.h" +#include + 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(); } } \ No newline at end of file