Added equality operator to Token, will be useful for testing.

This commit is contained in:
2025-09-30 20:58:56 +03:00
committed by Emin Arslan
parent f93b2deda2
commit 8d3cc2181e
2 changed files with 6 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ enum TokenType {
struct Token {
enum TokenType type;
std::variant<int64_t, double, std::string> value;
bool operator==(Token const& other);
};
std::ostream &operator<<(std::ostream &os, Token const &t);

View File

@@ -23,6 +23,10 @@ std::ostream &operator<<(std::ostream &os, Token const &t) {
return os;
}
bool Token::operator==(Token const& other) {
return this->type == other.type && this->value == other.value;
}
bool ispunct(char c) {
for (char i : "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~") {
if (i == c) return true;