Rename name to formatted
This commit is contained in:
parent
e5f7430586
commit
856709e46a
@ -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) {
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user