diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-08-25 22:54:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-25 22:54:46 +0800 |
commit | ec6d8007db3577c7899a0ef531a8c9b632156860 (patch) | |
tree | c64d8fa4bf64f30f3e65a2b5711778a1f404b26d /libsolidity | |
parent | 92ef30b7480d2fc0035aff232b558bb6d7419cc0 (diff) | |
parent | f2317670faf1984fe1b92696a50439bd0b33d39b (diff) | |
download | dexon-solidity-ec6d8007db3577c7899a0ef531a8c9b632156860.tar.gz dexon-solidity-ec6d8007db3577c7899a0ef531a8c9b632156860.tar.zst dexon-solidity-ec6d8007db3577c7899a0ef531a8c9b632156860.zip |
Merge pull request #2815 from ethereum/parser-fallthrough
Remove fallthrough from literal parsing
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 21 | ||||
-rw-r--r-- | libsolidity/parsing/Scanner.cpp | 2 |
2 files changed, 14 insertions, 9 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index ddfdb667..8429bf79 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -903,11 +903,13 @@ ASTPointer<Statement> Parser::parseStatement() { statement = ASTNodeFactory(*this).createNode<PlaceholderStatement>(docString); m_scanner->next(); - break; } - // fall-through + else + statement = parseSimpleStatement(docString); + break; default: statement = parseSimpleStatement(docString); + break; } expectToken(Token::Semicolon); return statement; @@ -1309,18 +1311,21 @@ ASTPointer<Expression> Parser::parsePrimaryExpression() Literal::SubDenomination subdenomination = static_cast<Literal::SubDenomination>(m_scanner->currentToken()); m_scanner->next(); expression = nodeFactory.createNode<Literal>(token, literal, subdenomination); - break; } - if (Token::isTimeSubdenomination(m_scanner->peekNextToken())) + else if (Token::isTimeSubdenomination(m_scanner->peekNextToken())) { ASTPointer<ASTString> literal = getLiteralAndAdvance(); nodeFactory.markEndPosition(); Literal::SubDenomination subdenomination = static_cast<Literal::SubDenomination>(m_scanner->currentToken()); m_scanner->next(); expression = nodeFactory.createNode<Literal>(token, literal, subdenomination); - break; } - // fall-through + else + { + nodeFactory.markEndPosition(); + expression = nodeFactory.createNode<Literal>(token, getLiteralAndAdvance()); + } + break; case Token::StringLiteral: nodeFactory.markEndPosition(); expression = nodeFactory.createNode<Literal>(token, getLiteralAndAdvance()); @@ -1357,9 +1362,9 @@ ASTPointer<Expression> Parser::parsePrimaryExpression() } nodeFactory.markEndPosition(); expectToken(oppositeToken); - return nodeFactory.createNode<TupleExpression>(components, isArray); + expression = nodeFactory.createNode<TupleExpression>(components, isArray); + break; } - default: if (Token::isElementaryTypeName(token)) { diff --git a/libsolidity/parsing/Scanner.cpp b/libsolidity/parsing/Scanner.cpp index fdca23ea..6541f6c2 100644 --- a/libsolidity/parsing/Scanner.cpp +++ b/libsolidity/parsing/Scanner.cpp @@ -435,7 +435,7 @@ void Scanner::scanToken() m_nextToken.location.start = sourcePos(); switch (m_char) { - case '\n': // fall-through + case '\n': case ' ': case '\t': token = selectToken(Token::Whitespace); |