mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce Token::friendlyName() helper
This commit is contained in:
parent
e3279d8af8
commit
252bde8542
@ -72,9 +72,9 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
|
|||||||
{
|
{
|
||||||
fatalParserError(
|
fatalParserError(
|
||||||
string("Expected '") +
|
string("Expected '") +
|
||||||
string(Token::toString(_value)) +
|
Token::friendlyName(_value) +
|
||||||
string("' but got reserved keyword '") +
|
string("' but got reserved keyword '") +
|
||||||
string(Token::toString(tok)) +
|
Token::friendlyName(tok) +
|
||||||
string("'")
|
string("'")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
|
|||||||
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
|
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
|
||||||
fatalParserError(
|
fatalParserError(
|
||||||
string("Expected '") +
|
string("Expected '") +
|
||||||
string(Token::toString(_value)) +
|
Token::friendlyName(_value) +
|
||||||
string("' but got '") +
|
string("' but got '") +
|
||||||
elemTypeName.toString() +
|
elemTypeName.toString() +
|
||||||
string("'")
|
string("'")
|
||||||
@ -92,9 +92,9 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
|
|||||||
else
|
else
|
||||||
fatalParserError(
|
fatalParserError(
|
||||||
string("Expected '") +
|
string("Expected '") +
|
||||||
string(Token::toString(_value)) +
|
Token::friendlyName(_value) +
|
||||||
string("' but got '") +
|
string("' but got '") +
|
||||||
string(Token::toString(m_scanner->currentToken())) +
|
Token::friendlyName(tok) +
|
||||||
string("'")
|
string("'")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -304,6 +304,17 @@ public:
|
|||||||
return m_string[tok];
|
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
|
// @returns the precedence > 0 for binary and compare
|
||||||
// operators; returns 0 otherwise.
|
// operators; returns 0 otherwise.
|
||||||
static int precedence(Value tok)
|
static int precedence(Value tok)
|
||||||
|
Loading…
Reference in New Issue
Block a user