#ifndef TOKEN_HPP
|
#define TOKEN_HPP
|
|
#include <iostream>
|
#include <string> // <<< Hozzáadva
|
#include <string_view> // <<< Hozzáadva
|
|
#include "Lexer/TokenType.hpp" // Feltételezzük, hogy ez definiálja Type-ot és TypeToString-ot
|
|
namespace Lexer::Tokens {
|
|
struct Token {
|
Lexer::Tokens::Type type;
|
std::string value; // A token feldolgozott értéke
|
std::string_view lexeme; // A nyers szövegrész az eredeti stringből
|
size_t start_pos; // Kezdő index
|
size_t end_pos; // Vég index (exclusive)
|
int line_number;
|
int column_number;
|
|
// Módosított print metódus a lexeme kiírásával
|
void print() const {
|
std::cout << "Token { Type: " << Lexer::Tokens::TypeToString(type) << ", Value: \"" << value << "\""
|
<< ", Pos: [" << start_pos << ", " << end_pos
|
<< ")"
|
// Lexeme kiírása (stringgé konvertálva a biztonság kedvéért, ha pl. null lenne)
|
<< ", Lexeme: \"" << std::string(lexeme) << "\""
|
<< " }" << '\n';
|
}
|
};
|
|
inline bool operator==(const Token & lhs, const Token & rhs) {
|
return lhs.type == rhs.type && lhs.value == rhs.value && lhs.start_pos == rhs.start_pos &&
|
lhs.end_pos == rhs.end_pos;
|
}
|
}; // namespace Lexer::Tokens
|
#endif // TOKEN_HPP
|