diff --git a/src/include/lex.hpp b/src/include/lex.hpp index 1329a08..add0c91 100644 --- a/src/include/lex.hpp +++ b/src/include/lex.hpp @@ -19,6 +19,8 @@ enum TokenType { struct Token { enum TokenType type; std::variant value; + + bool operator==(Token const& other); }; std::ostream &operator<<(std::ostream &os, Token const &t); diff --git a/src/lex.cpp b/src/lex.cpp index d04ea83..ce4d7a8 100644 --- a/src/lex.cpp +++ b/src/lex.cpp @@ -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;