LCOV - code coverage report
Current view: top level - inc/lexicalAnalysis - category.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 12 12
Test Date: 2025-04-18 15:53:49 Functions: 100.0 % 6 6

            Line data    Source code
       1              : #ifndef CATEGORY_H
       2              : #define CATEGORY_H
       3              : 
       4              : #include <string>
       5              : 
       6              : #include "regexWrapper.h"
       7              : #include "token.h"
       8              : 
       9              : namespace nicole {
      10              : 
      11              : // Represents de category of a token
      12              : class Category final {
      13              : private:
      14              :   TokenType type_;
      15              :   RegexWrapper pattern_;
      16              :   bool skip_;
      17              : 
      18              : public:
      19              :   explicit Category(const TokenType &type, const std::string &matcher,
      20              :                     const bool skip) noexcept
      21         1719 :       : type_{type}, pattern_{matcher}, skip_{skip} {};
      22              : 
      23         9423 :   [[nodiscard]] TokenType type() const noexcept { return type_; }
      24              : 
      25       402273 :   [[nodiscard]] const RegexWrapper &pattern() const noexcept {
      26       402273 :     return pattern_;
      27       402273 :   }
      28              : 
      29         7236 :   [[nodiscard]] const std::string rawPattern() const noexcept {
      30         7236 :     return pattern_.str();
      31         7236 :   }
      32              : 
      33              :   // to know if it must be skipped like comments
      34        12186 :   [[nodiscard]] bool skip() const noexcept { return skip_; }
      35              : 
      36           18 :   [[nodiscard]] bool matchToken(const Token &token) const noexcept {
      37           18 :     return pattern_.match(token.raw());
      38           18 :   };
      39              : };
      40              : 
      41              : } // namespace nicole
      42              : 
      43              : #endif
        

Generated by: LCOV version 2.0-1