Added equality operator to Token, will be useful for testing.
This commit is contained in:
		@@ -19,6 +19,8 @@ enum TokenType {
 | 
				
			|||||||
struct Token {
 | 
					struct Token {
 | 
				
			||||||
    enum TokenType type;
 | 
					    enum TokenType type;
 | 
				
			||||||
    std::variant<int64_t, double, std::string> value;
 | 
					    std::variant<int64_t, double, std::string> value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool operator==(Token const& other);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
std::ostream &operator<<(std::ostream &os, Token const &t);
 | 
					std::ostream &operator<<(std::ostream &os, Token const &t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,10 @@ std::ostream &operator<<(std::ostream &os, Token const &t) {
 | 
				
			|||||||
    return os;
 | 
					    return os;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool Token::operator==(Token const& other) {
 | 
				
			||||||
 | 
					    return this->type == other.type && this->value == other.value; 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool ispunct(char c) {
 | 
					bool ispunct(char c) {
 | 
				
			||||||
    for (char i : "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~") {
 | 
					    for (char i : "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~") {
 | 
				
			||||||
        if (i == c) return true;
 | 
					        if (i == c) return true;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user