aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-20 01:04:40 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-26 10:20:15 +0800
commite48e84ca2bfdf863a798c88c329796284b2a87cb (patch)
tree4423ade342384e1343f71e5dbbaf9f8d7f8c4929 /libsolidity
parentdb3d9e0416e7ac69ddf13eb6e2fd4e0a35dd1a63 (diff)
downloaddexon-solidity-e48e84ca2bfdf863a798c88c329796284b2a87cb.tar
dexon-solidity-e48e84ca2bfdf863a798c88c329796284b2a87cb.tar.gz
dexon-solidity-e48e84ca2bfdf863a798c88c329796284b2a87cb.tar.bz2
dexon-solidity-e48e84ca2bfdf863a798c88c329796284b2a87cb.tar.lz
dexon-solidity-e48e84ca2bfdf863a798c88c329796284b2a87cb.tar.xz
dexon-solidity-e48e84ca2bfdf863a798c88c329796284b2a87cb.tar.zst
dexon-solidity-e48e84ca2bfdf863a798c88c329796284b2a87cb.zip
Check token within parseCase
Diffstat (limited to 'libsolidity')
-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();