Rename name to formatted

This commit is contained in:
Sofia 2026-04-01 22:44:31 +03:00
parent e5f7430586
commit 856709e46a
2 changed files with 5 additions and 5 deletions

View File

@ -38,12 +38,12 @@ namespace token {
} }
} }
std::string Token::name() { std::string Token::formatted() {
return type_name(this->type); return type_name(this->type) + "(" + this->content + ")";
} }
std::ostream& operator<<(std::ostream& stream, Token& token) { std::ostream& operator<<(std::ostream& stream, Token& token) {
stream << token.name() << "(" << token.content << ")"; stream << token.formatted();
return stream; return stream;
} }
@ -72,7 +72,7 @@ namespace token {
if (next.type == type) { if (next.type == type) {
return next; return next;
} }
throw std::runtime_error("Expected " + type_name(type) + ", got " + type_name(next.type)); throw std::runtime_error("Expected " + type_name(type) + ", got " + next.formatted());
} }
std::vector<token::Token> tokenize(std::string_view text) { std::vector<token::Token> tokenize(std::string_view text) {

View File

@ -24,7 +24,7 @@ namespace token {
Type type; Type type;
std::string content; std::string content;
std::string name(); std::string formatted();
}; };
class TokenStream { class TokenStream {