fixed token header and made the tokenTypeStrings
not seeable from outside modules
This commit is contained in:
21
src/token/type.cpp
Normal file
21
src/token/type.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "type.hpp"
|
||||
|
||||
namespace token {
|
||||
|
||||
// Array mapping enum values to their string representations
|
||||
constexpr std::array<std::string_view, static_cast<size_t>(type::LET) + 1>
|
||||
tokenTypeStrings = {
|
||||
#define X(name, str) str,
|
||||
TOKEN_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
// Stream insertion operator using the lookup array
|
||||
std::ostream& operator<<(std::ostream& os, type type) {
|
||||
auto idx = static_cast<size_t>(type);
|
||||
if (idx < tokenTypeStrings.size())
|
||||
return os << tokenTypeStrings[idx];
|
||||
return os << "Unknown";
|
||||
}
|
||||
|
||||
} // namespace token
|
@@ -30,20 +30,5 @@ namespace token {
|
||||
#undef X
|
||||
};
|
||||
|
||||
// Array mapping enum values to their string representations
|
||||
static constexpr std::
|
||||
array<std::string_view, static_cast<size_t>(type::LET) + 1>
|
||||
tokenTypeStrings = {
|
||||
#define X(name, str) str,
|
||||
TOKEN_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
// Stream insertion operator using the lookup array
|
||||
inline std::ostream& operator<<(std::ostream& os, type type) {
|
||||
auto idx = static_cast<size_t>(type);
|
||||
if (idx < tokenTypeStrings.size())
|
||||
return os << tokenTypeStrings[idx];
|
||||
return os << "Unknown";
|
||||
}
|
||||
std::ostream& operator<<(std::ostream& os, type type);
|
||||
} // namespace token
|
||||
|
Reference in New Issue
Block a user