aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp14
-rw-r--r--libsolidity/inlineasm/AsmParser.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp
index 63c08b15..537a39a1 100644
--- a/libsolidity/inlineasm/AsmParser.cpp
+++ b/libsolidity/inlineasm/AsmParser.cpp
@@ -75,7 +75,7 @@ assembly::Statement Parser::parseStatement()
while (m_scanner->currentToken() == Token::Case)
_switch.cases.emplace_back(parseCase());
if (m_scanner->currentToken() == Token::Default)
- _switch.cases.emplace_back(parseCase(true));
+ _switch.cases.emplace_back(parseCase());
if (_switch.cases.size() == 0)
fatalParserError("Switch statement without any cases.");
_switch.location.end = _switch.cases.back().body.location.end;
@@ -148,19 +148,21 @@ assembly::Statement Parser::parseStatement()
return statement;
}
-assembly::Case Parser::parseCase(bool _defaultCase)
+assembly::Case Parser::parseCase()
{
assembly::Case _case = createWithLocation<assembly::Case>();
- if (_defaultCase)
- expectToken(Token::Default);
- else
+ if (m_scanner->currentToken() == Token::Default)
+ m_scanner->next();
+ else if (m_scanner->currentToken() == Token::Case)
{
- expectToken(Token::Case);
+ m_scanner->next();
assembly::Statement statement = parseElementaryOperation();
if (statement.type() != typeid(assembly::Literal))
fatalParserError("Literal expected.");
_case.value = make_shared<Literal>(std::move(boost::get<assembly::Literal>(statement)));
}
+ else
+ fatalParserError("Case or default case expected.");
_case.body = parseBlock();
_case.location.end = _case.body.location.end;
return _case;
diff --git a/libsolidity/inlineasm/AsmParser.h b/libsolidity/inlineasm/AsmParser.h
index d1d0c1cc..138af337 100644
--- a/libsolidity/inlineasm/AsmParser.h
+++ b/libsolidity/inlineasm/AsmParser.h
@@ -62,7 +62,7 @@ protected:
Block parseBlock();
Statement parseStatement();
- Case parseCase(bool _defaultCase = false);
+ Case parseCase();
/// Parses a functional expression that has to push exactly one stack element
Statement parseExpression();
std::map<std::string, dev::solidity::Instruction> const& instructions();