LCOV - code coverage report
Current view: top level - inc/visitors - visitor.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 1 0
Test Date: 2025-04-18 15:53:49 Functions: 0.0 % 5 0

            Line data    Source code
       1              : #ifndef VISITOR_H
       2              : #define VISITOR_H
       3              : 
       4              : #include "../errors.h"
       5              : #include <expected>
       6              : 
       7              : namespace nicole {
       8              : 
       9              : // Forward declaration to avoid circular dependency
      10              : enum class TokenType;
      11              : 
      12              : class AST;
      13              : 
      14              : class AST_BOOL;
      15              : class AST_CHAR;
      16              : class AST_DOUBLE;
      17              : class AST_FLOAT;
      18              : class AST_INT;
      19              : class AST_NULL;
      20              : class AST_STRING;
      21              : 
      22              : class AST_VECTOR;
      23              : class AST_INDEX;
      24              : 
      25              : class AST_DELETE;
      26              : class AST_NEW;
      27              : class AST_DEREF;
      28              : 
      29              : class AST_BINARY;
      30              : 
      31              : class AST_UNARY;
      32              : 
      33              : class AST_ASSIGNMENT;
      34              : 
      35              : class AST_PRINT;
      36              : class AST_IMPORT;
      37              : 
      38              : class AST_STATEMENT;
      39              : class AST_BODY;
      40              : 
      41              : class AST_WHILE;
      42              : class AST_FOR;
      43              : class AST_DO_WHILE;
      44              : class AST_PASS;
      45              : class AST_STOP;
      46              : 
      47              : class AST_IF;
      48              : class AST_ELSE_IF;
      49              : class AST_SWITCH;
      50              : class AST_CASE;
      51              : class AST_DEFAULT;
      52              : class AST_TERNARY;
      53              : class AST_CONDITION;
      54              : 
      55              : class AST_FUNC_CALL;
      56              : class AST_FUNC_DECL;
      57              : class AST_RETURN;
      58              : 
      59              : class AST_ENUM;
      60              : class AST_ENUM_ACCESS;
      61              : 
      62              : class AST_STRUCT;
      63              : class AST_ATTR_ACCESS;
      64              : class AST_METHOD_CALL;
      65              : class AST_THIS;
      66              : class AST_CONSTRUCTOR_CALL;
      67              : class AST_METHOD_DECL;
      68              : class AST_CONSTRUCTOR_DECL;
      69              : class AST_DESTRUCTOR_DECL;
      70              : class AST_SUPER;
      71              : 
      72              : class AST_AUTO_DECL;
      73              : class AST_VAR_TYPED_DECL;
      74              : class AST_VAR_CALL;
      75              : 
      76              : class AST_CHAINED;
      77              : 
      78              : class Tree;
      79              : 
      80              : // Abstract class that represents the visitor pattern
      81              : template <class T> class Visitor {
      82              : public:
      83            0 :   virtual ~Visitor() = default;
      84              : 
      85              :   [[nodiscard]] virtual std::expected<T, Error>
      86              :   visit(const AST_BOOL *node) const noexcept = 0;
      87              : 
      88              :   [[nodiscard]] virtual std::expected<T, Error>
      89              :   visit(const AST_CHAR *node) const noexcept = 0;
      90              : 
      91              :   [[nodiscard]] virtual std::expected<T, Error>
      92              :   visit(const AST_DOUBLE *node) const noexcept = 0;
      93              : 
      94              :   [[nodiscard]] virtual std::expected<T, Error>
      95              :   visit(const AST_FLOAT *node) const noexcept = 0;
      96              : 
      97              :   [[nodiscard]] virtual std::expected<T, Error>
      98              :   visit(const AST_INT *node) const noexcept = 0;
      99              : 
     100              :   [[nodiscard]] virtual std::expected<T, Error>
     101              :   visit(const AST_NULL *node) const noexcept = 0;
     102              : 
     103              :   [[nodiscard]] virtual std::expected<T, Error>
     104              :   visit(const AST_STRING *node) const noexcept = 0;
     105              : 
     106              :   [[nodiscard]] virtual std::expected<T, Error>
     107              :   visit(const AST_VECTOR *node) const noexcept = 0;
     108              : 
     109              :   [[nodiscard]] virtual std::expected<T, Error>
     110              :   visit(const AST_INDEX *node) const noexcept = 0;
     111              : 
     112              :   [[nodiscard]] virtual std::expected<T, Error>
     113              :   visit(const AST_DELETE *node) const noexcept = 0;
     114              : 
     115              :   [[nodiscard]] virtual std::expected<T, Error>
     116              :   visit(const AST_NEW *node) const noexcept = 0;
     117              : 
     118              :   [[nodiscard]] virtual std::expected<T, Error>
     119              :   visit(const AST_DEREF *node) const noexcept = 0;
     120              : 
     121              :   [[nodiscard]] virtual std::expected<T, Error>
     122              :   visit(const AST_BINARY *node) const noexcept = 0;
     123              : 
     124              :   [[nodiscard]] virtual std::expected<T, Error>
     125              :   visit(const AST_UNARY *node) const noexcept = 0;
     126              : 
     127              :   [[nodiscard]] virtual std::expected<T, Error>
     128              :   visit(const AST_ASSIGNMENT *node) const noexcept = 0;
     129              : 
     130              :   [[nodiscard]] virtual std::expected<T, Error>
     131              :   visit(const AST_PRINT *node) const noexcept = 0;
     132              : 
     133              :   [[nodiscard]] virtual std::expected<T, Error>
     134              :   visit(const AST_IMPORT *node) const noexcept = 0;
     135              : 
     136              :   [[nodiscard]] virtual std::expected<T, Error>
     137              :   visit(const AST_STATEMENT *node) const noexcept = 0;
     138              : 
     139              :   [[nodiscard]] virtual std::expected<T, Error>
     140              :   visit(const AST_BODY *node) const noexcept = 0;
     141              : 
     142              :   [[nodiscard]] virtual std::expected<T, Error>
     143              :   visit(const AST_WHILE *node) const noexcept = 0;
     144              : 
     145              :   [[nodiscard]] virtual std::expected<T, Error>
     146              :   visit(const AST_FOR *node) const noexcept = 0;
     147              : 
     148              :   [[nodiscard]] virtual std::expected<T, Error>
     149              :   visit(const AST_DO_WHILE *node) const noexcept = 0;
     150              : 
     151              :   [[nodiscard]] virtual std::expected<T, Error>
     152              :   visit(const AST_PASS *node) const noexcept = 0;
     153              : 
     154              :   [[nodiscard]] virtual std::expected<T, Error>
     155              :   visit(const AST_STOP *node) const noexcept = 0;
     156              : 
     157              :   [[nodiscard]] virtual std::expected<T, Error>
     158              :   visit(const AST_IF *node) const noexcept = 0;
     159              : 
     160              :   [[nodiscard]] virtual std::expected<T, Error>
     161              :   visit(const AST_ELSE_IF *node) const noexcept = 0;
     162              : 
     163              :   [[nodiscard]] virtual std::expected<T, Error>
     164              :   visit(const AST_SWITCH *node) const noexcept = 0;
     165              : 
     166              :   [[nodiscard]] virtual std::expected<T, Error>
     167              :   visit(const AST_CASE *node) const noexcept = 0;
     168              : 
     169              :   [[nodiscard]] virtual std::expected<T, Error>
     170              :   visit(const AST_DEFAULT *node) const noexcept = 0;
     171              : 
     172              :   [[nodiscard]] virtual std::expected<T, Error>
     173              :   visit(const AST_TERNARY *node) const noexcept = 0;
     174              : 
     175              :   [[nodiscard]] virtual std::expected<T, Error>
     176              :   visit(const AST_CONDITION *node) const noexcept = 0;
     177              : 
     178              :   [[nodiscard]] virtual std::expected<T, Error>
     179              :   visit(const AST_FUNC_CALL *node) const noexcept = 0;
     180              : 
     181              :   [[nodiscard]] virtual std::expected<T, Error>
     182              :   visit(const AST_FUNC_DECL *node) const noexcept = 0;
     183              : 
     184              :   [[nodiscard]] virtual std::expected<T, Error>
     185              :   visit(const AST_RETURN *node) const noexcept = 0;
     186              : 
     187              :   [[nodiscard]] virtual std::expected<T, Error>
     188              :   visit(const AST_ENUM *node) const noexcept = 0;
     189              : 
     190              :   [[nodiscard]] virtual std::expected<T, Error>
     191              :   visit(const AST_ENUM_ACCESS *node) const noexcept = 0;
     192              : 
     193              :   [[nodiscard]] virtual std::expected<T, Error>
     194              :   visit(const AST_STRUCT *node) const noexcept = 0;
     195              : 
     196              :   [[nodiscard]] virtual std::expected<T, Error>
     197              :   visit(const AST_ATTR_ACCESS *node) const noexcept = 0;
     198              : 
     199              :   [[nodiscard]] virtual std::expected<T, Error>
     200              :   visit(const AST_METHOD_CALL *node) const noexcept = 0;
     201              : 
     202              :   [[nodiscard]] virtual std::expected<T, Error>
     203              :   visit(const AST_THIS *node) const noexcept = 0;
     204              : 
     205              :   [[nodiscard]] virtual std::expected<T, Error>
     206              :   visit(const AST_CONSTRUCTOR_CALL *node) const noexcept = 0;
     207              : 
     208              :   [[nodiscard]] virtual std::expected<T, Error>
     209              :   visit(const AST_METHOD_DECL *node) const noexcept = 0;
     210              : 
     211              :   [[nodiscard]] virtual std::expected<T, Error>
     212              :   visit(const AST_CONSTRUCTOR_DECL *node) const noexcept = 0;
     213              : 
     214              :   [[nodiscard]] virtual std::expected<T, Error>
     215              :   visit(const AST_SUPER *node) const noexcept = 0;
     216              : 
     217              :   [[nodiscard]] virtual std::expected<T, Error>
     218              :   visit(const AST_DESTRUCTOR_DECL *node) const noexcept = 0;
     219              : 
     220              :   [[nodiscard]] virtual std::expected<T, Error>
     221              :   visit(const AST_AUTO_DECL *node) const noexcept = 0;
     222              : 
     223              :   [[nodiscard]] virtual std::expected<T, Error>
     224              :   visit(const AST_VAR_TYPED_DECL *node) const noexcept = 0;
     225              : 
     226              :   [[nodiscard]] virtual std::expected<T, Error>
     227              :   visit(const AST_VAR_CALL *node) const noexcept = 0;
     228              : 
     229              :   [[nodiscard]] virtual std::expected<T, Error>
     230              :   visit(const AST_CHAINED *node) const noexcept = 0;
     231              : 
     232              :   [[nodiscard]] virtual std::expected<T, Error>
     233              :   visit(const Tree *tree) const noexcept = 0;
     234              : };
     235              : 
     236              : } // namespace nicole
     237              : 
     238              : #endif
        

Generated by: LCOV version 2.0-1