LCOV - code coverage report
Current view: top level - src/visitors/validateTree - validateOperations.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 35 0
Test Date: 2025-04-18 15:53:49 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #include "../../../inc/visitors/validateTree/validateTree.h"
       2              : #include "../../../inc/parsingAnalysis/ast/operators/ast_binary.h"
       3              : #include "../../../inc/parsingAnalysis/ast/operators/ast_unary.h"
       4              : #include "../../../inc/parsingAnalysis/checkPosition.h"
       5              : 
       6              : namespace nicole {
       7              : 
       8              : std::expected<bool, Error>
       9            0 : ValidateTree::visit(const AST_BINARY *node) const noexcept {
      10            0 :   if (!node) {
      11            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_ADD");
      12            0 :   }
      13            0 :   if (CheckPosition::isOutOfScope(node)) {
      14            0 :     return createError(ERROR_TYPE::VALIDATE_TREE,
      15            0 :                        node->op().raw() +
      16            0 :                            " operation cannot appear outside of a scope, at " +
      17            0 :                            node->op().locInfo());
      18            0 :   }
      19            0 :   const auto left{node->left()->accept(*this)};
      20            0 :   if (!left) {
      21            0 :     return createError(left.error());
      22            0 :   }
      23            0 :   const auto right{node->right()->accept(*this)};
      24            0 :   if (!right) {
      25            0 :     return createError(right.error());
      26            0 :   }
      27            0 :   return true;
      28            0 : }
      29              : 
      30              : std::expected<bool, Error>
      31            0 : ValidateTree::visit(const AST_UNARY *node) const noexcept {
      32            0 :   if (!node) {
      33            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_NEG");
      34            0 :   }
      35            0 :   if (CheckPosition::isOutOfScope(node)) {
      36            0 :     return createError(ERROR_TYPE::VALIDATE_TREE,
      37            0 :                        node->op().raw() +
      38            0 :                            " operation cannot appear outside of a scope");
      39            0 :   }
      40            0 :   const auto left{node->value()->accept(*this)};
      41            0 :   if (!left) {
      42            0 :     return createError(left.error());
      43            0 :   }
      44            0 :   return true;
      45            0 : }
      46              : 
      47              : }
        

Generated by: LCOV version 2.0-1