Line data Source code
1 : #include "../../../inc/visitors/printTree/printTree.h"
2 : #include "../../../inc/parsingAnalysis/ast/chained/ast_chained.h"
3 : #include <ostream>
4 :
5 : namespace nicole {
6 :
7 : std::expected<std::string, Error>
8 0 : PrintTree::visit(const AST_CHAINED *node) const noexcept {
9 0 : if (!node) {
10 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_CHAINED");
11 0 : }
12 0 : std::ostringstream result;
13 0 : result << indent_ << "Chained:\n";
14 0 : increaseIndent();
15 0 : if (!node->base()) {
16 0 : return createError(ERROR_TYPE::NULL_NODE, "print base");
17 0 : }
18 0 : const auto base{node->base()->accept(*this)};
19 0 : if (!base) {
20 0 : return createError(ERROR_TYPE::NULL_NODE, "print base boo");
21 0 : }
22 0 : result << indent_ << "Base:\n" << *base;
23 0 : result << indent_ << "Operations:\n";
24 0 : for (const auto &statement : node->operations()) {
25 0 : const auto val{statement->accept(*this)};
26 0 : if (!val) {
27 0 : return createError(val.error());
28 0 : }
29 0 : result << *val;
30 0 : }
31 0 : decreaseIndent();
32 0 : return result.str();
33 0 : }
34 :
35 : }
|