Line data Source code
1 : #include "../../../inc/visitors/printTree/printTree.h"
2 : #include "../../../inc/parsingAnalysis/ast/assignments/ast_assignment.h"
3 : #include <ostream>
4 :
5 : namespace nicole {
6 :
7 : std::expected<std::string, Error>
8 0 : PrintTree::visit(const AST_ASSIGNMENT *node) const noexcept {
9 0 : if (!node) {
10 0 : return createError(ERROR_TYPE::NULL_NODE, "invalid AST_ASSIGNMENT");
11 0 : }
12 0 : std::ostringstream result;
13 0 : result << indent_ << "Assignment:\n";
14 0 : increaseIndent();
15 0 : result << indent_ << "Operator: " << node->op().raw() << "\n";
16 0 : const auto left{node->left()->accept(*this)};
17 0 : if (!left) {
18 0 : return createError(left.error());
19 0 : }
20 0 : result << indent_ << "left:\n" << *left << "\n";
21 0 : const auto val{node->value()->accept(*this)};
22 0 : if (!val) {
23 0 : return createError(val.error());
24 0 : }
25 0 : result << indent_ << "Value:\n" << *val << "\n";
26 0 : decreaseIndent();
27 0 : return result.str();
28 0 : }
29 :
30 : }
|