Add a character cast operator to tok in lex.hpp

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-03-12 11:16:14 +01:00
parent 2425d19f9f
commit 74c5904d21
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 1 additions and 0 deletions

View File

@ -26,6 +26,7 @@ struct tok {
tok() = delete;
tok(const type& Type, std::string_view Text, const decltype(line)& line = 1): toktype(Type), toktext(Text), line(line) {}
explicit tok(const type& Type, const decltype(line)& line = 1): tok(Type, std::string(1, Type), line) {};
operator char() const { return static_cast<char>(toktype); }
friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; }
};
std::vector<tok> lex(const std::string& in);