Line data Source code
1 : #include "../../../inc/visitors/validateTree/validateTree.h"
2 : #include "../../../inc/parsingAnalysis/ast/chained/ast_chained.h"
3 : #include "../../../inc/parsingAnalysis/checkPosition.h"
4 :
5 : namespace nicole {
6 :
7 : std::expected<bool, Error>
8 0 : ValidateTree::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 : if (CheckPosition::isOutOfScope(node)) {
13 0 : return createError(ERROR_TYPE::VALIDATE_TREE,
14 0 : "chained expressions cannot appear outside of scopes");
15 0 : }
16 0 : const auto base{node->base()->accept(*this)};
17 0 : if (!base) {
18 0 : return createError(base.error());
19 0 : }
20 0 : for (const auto &chain : node->operations()) {
21 0 : const auto result{chain->accept(*this)};
22 0 : if (!result) {
23 0 : return createError(result.error());
24 0 : }
25 0 : }
26 0 : return true;
27 0 : }
28 :
29 : }
|