Line data Source code
1 : #include "../../../inc/visitors/printTree/printTree.h"
2 : #include "../../../inc/parsingAnalysis/ast/enum/ast_enum.h"
3 : #include "../../../inc/parsingAnalysis/ast/enum/ast_enumAccess.h"
4 : #include <ostream>
5 :
6 : namespace nicole {
7 :
8 : std::expected<std::string, Error>
9 0 : PrintTree::visit(const AST_ENUM *node) const noexcept {
10 0 : if (!node) {
11 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_ENUM");
12 0 : }
13 0 : std::ostringstream result;
14 0 : result << indent_ << "Enum:\n";
15 0 : increaseIndent();
16 0 : result << indent_ << "id: " << node->id() << "\n";
17 0 : result << indent_ << "names:\n";
18 0 : for (const auto &id : node->identifiers()) {
19 0 : result << indent_ << id << "\n";
20 0 : }
21 0 : decreaseIndent();
22 0 : return result.str();
23 0 : }
24 :
25 : std::expected<std::string, Error>
26 0 : PrintTree::visit(const AST_ENUM_ACCESS *node) const noexcept {
27 0 : if (!node) {
28 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_ENUM_ACCESS");
29 0 : }
30 0 : std::ostringstream result;
31 0 : result << indent_ << "Enum Access:\n";
32 0 : increaseIndent();
33 0 : result << indent_ << "id: " << node->enumId() << "\n";
34 0 : result << indent_ << "name: " + node->identifier() + "\n";
35 0 : decreaseIndent();
36 0 : return result.str();
37 0 : }
38 :
39 : }
|