diff --git a/src/tokens.cpp b/src/tokens.cpp index b768f24..6864e74 100644 --- a/src/tokens.cpp +++ b/src/tokens.cpp @@ -38,12 +38,12 @@ namespace token { } } - std::string Token::name() { - return type_name(this->type); + std::string Token::formatted() { + return type_name(this->type) + "(" + this->content + ")"; } std::ostream& operator<<(std::ostream& stream, Token& token) { - stream << token.name() << "(" << token.content << ")"; + stream << token.formatted(); return stream; } @@ -72,7 +72,7 @@ namespace token { if (next.type == type) { 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 tokenize(std::string_view text) { diff --git a/src/tokens.h b/src/tokens.h index bcc07dc..38f3d93 100644 --- a/src/tokens.h +++ b/src/tokens.h @@ -24,7 +24,7 @@ namespace token { Type type; std::string content; - std::string name(); + std::string formatted(); }; class TokenStream {