2024-01-05 12:04
BullseyeCoverage 9.6.4
expr/ Lexer.h
1 // Expression evaluator lexer interface 2 3 #ifndef Token_h 4 #define Token_h 1 5 6 #include <cstdint> 7 8 struct Token { 9 enum class Kind { 10 endOfInput, 11 bitwiseAnd, 12 bitwiseNot, 13 bitwiseOr, 14 bitwiseXor, 15 divide, 16 equal, 17 greaterThan, 18 greaterThanEq, 19 lessThan, 20 lessThanEq, 21 logicalAnd, 22 logicalNot, 23 logicalOr, 24 notEqual, 25 number, 26 minus, 27 modulus, 28 multiply, 29 parenLeft, 30 parenRight, 31 plus, 32 shiftLeft, 33 shiftRight, 34 }; 35 Kind kind = Kind::endOfInput; 36 int64_t value = 0; 37 }; 38 39 class Lexer { 40 public: 41 explicit Lexer(const char* string) : m_next(string) { } 42 bool read(Token& token); 43 static void unitTest(); 44 private: 45 const char* m_next; 46 static Token::Kind unitTest(const char* string); 47 }; 48 49 #endif