aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-05-04 20:07:43 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-05-04 20:27:05 +0800
commit882248ce755d8c905b69bc25964b343906bb94ae (patch)
tree02a71cbdbb889312124176d4eae4a67cd753c65f /libsolidity
parent252bde8542222953f4432c166d83ba6775a546da (diff)
downloaddexon-solidity-882248ce755d8c905b69bc25964b343906bb94ae.tar.gz
dexon-solidity-882248ce755d8c905b69bc25964b343906bb94ae.tar.zst
dexon-solidity-882248ce755d8c905b69bc25964b343906bb94ae.zip
Remove code duplication in expectToken
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/parsing/ParserBase.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/libsolidity/parsing/ParserBase.cpp b/libsolidity/parsing/ParserBase.cpp
index 797dea71..8277ff46 100644
--- a/libsolidity/parsing/ParserBase.cpp
+++ b/libsolidity/parsing/ParserBase.cpp
@@ -68,35 +68,23 @@ void ParserBase::expectToken(Token::Value _value, bool _advance)
Token::Value tok = m_scanner->currentToken();
if (tok != _value)
{
+ string got;
if (Token::isReservedKeyword(tok))
- {
- fatalParserError(
- string("Expected '") +
- Token::friendlyName(_value) +
- string("' but got reserved keyword '") +
- Token::friendlyName(tok) +
- string("'")
- );
- }
+ got = "reserved keyword '" + Token::friendlyName(tok) + "'";
else if (Token::isElementaryTypeName(tok)) //for the sake of accuracy in reporting
{
ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken();
- fatalParserError(
- string("Expected '") +
- Token::friendlyName(_value) +
- string("' but got '") +
- elemTypeName.toString() +
- string("'")
- );
+ got = "'" + elemTypeName.toString() + "'";
}
else
- fatalParserError(
- string("Expected '") +
- Token::friendlyName(_value) +
- string("' but got '") +
- Token::friendlyName(tok) +
- string("'")
- );
+ got = "'" + Token::friendlyName(tok) + "'";
+
+ fatalParserError(
+ string("Expected '") +
+ Token::friendlyName(_value) +
+ string("' but got ") +
+ got
+ );
}
if (_advance)
m_scanner->next();