mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove code duplication in expectToken
This commit is contained in:
parent
252bde8542
commit
882248ce75
@ -68,35 +68,23 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
|
|||||||
Token::Value tok = m_scanner->currentToken();
|
Token::Value tok = m_scanner->currentToken();
|
||||||
if (tok != _value)
|
if (tok != _value)
|
||||||
{
|
{
|
||||||
|
string got;
|
||||||
if (Token::isReservedKeyword(tok))
|
if (Token::isReservedKeyword(tok))
|
||||||
{
|
got = "reserved keyword '" + Token::friendlyName(tok) + "'";
|
||||||
fatalParserError(
|
|
||||||
string("Expected '") +
|
|
||||||
Token::friendlyName(_value) +
|
|
||||||
string("' but got reserved keyword '") +
|
|
||||||
Token::friendlyName(tok) +
|
|
||||||
string("'")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (Token::isElementaryTypeName(tok)) //for the sake of accuracy in reporting
|
else if (Token::isElementaryTypeName(tok)) //for the sake of accuracy in reporting
|
||||||
{
|
{
|
||||||
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
|
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
|
||||||
fatalParserError(
|
got = "'" + elemTypeName.toString() + "'";
|
||||||
string("Expected '") +
|
|
||||||
Token::friendlyName(_value) +
|
|
||||||
string("' but got '") +
|
|
||||||
elemTypeName.toString() +
|
|
||||||
string("'")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fatalParserError(
|
got = "'" + Token::friendlyName(tok) + "'";
|
||||||
string("Expected '") +
|
|
||||||
Token::friendlyName(_value) +
|
fatalParserError(
|
||||||
string("' but got '") +
|
string("Expected '") +
|
||||||
Token::friendlyName(tok) +
|
Token::friendlyName(_value) +
|
||||||
string("'")
|
string("' but got ") +
|
||||||
);
|
got
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (_advance)
|
if (_advance)
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
|
Loading…
Reference in New Issue
Block a user