aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/parsing/ParserBase.cpp10
-rw-r--r--libsolidity/parsing/Token.h11
2 files changed, 16 insertions, 5 deletions
diff --git a/libsolidity/parsing/ParserBase.cpp b/libsolidity/parsing/ParserBase.cpp
index 1dd3bdd2..797dea71 100644
--- a/libsolidity/parsing/ParserBase.cpp
+++ b/libsolidity/parsing/ParserBase.cpp
@@ -72,9 +72,9 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
{
fatalParserError(
string("Expected '") +
- string(Token::toString(_value)) +
+ Token::friendlyName(_value) +
string("' but got reserved keyword '") +
- string(Token::toString(tok)) +
+ Token::friendlyName(tok) +
string("'")
);
}
@@ -83,7 +83,7 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
fatalParserError(
string("Expected '") +
- string(Token::toString(_value)) +
+ Token::friendlyName(_value) +
string("' but got '") +
elemTypeName.toString() +
string("'")
@@ -92,9 +92,9 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
else
fatalParserError(
string("Expected '") +
- string(Token::toString(_value)) +
+ Token::friendlyName(_value) +
string("' but got '") +
- string(Token::toString(m_scanner->currentToken())) +
+ Token::friendlyName(tok) +
string("'")
);
}
diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h
index 805fbf5d..4d7a7bc6 100644
--- a/libsolidity/parsing/Token.h
+++ b/libsolidity/parsing/Token.h
@@ -304,6 +304,17 @@ public:
return m_string[tok];
}
+ static std::string friendlyName(Value tok)
+ {
+ char const* ret = toString(tok);
+ if (ret == nullptr)
+ {
+ ret = name(tok);
+ solAssert(ret != nullptr, "");
+ }
+ return std::string(ret);
+ }
+
// @returns the precedence > 0 for binary and compare
// operators; returns 0 otherwise.
static int precedence(Value tok)