aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorRJ Catalano <catalanor0220@gmail.com>2015-12-17 06:47:37 +0800
committerRJ Catalano <catalanor0220@gmail.com>2015-12-17 06:47:37 +0800
commit905d55e34f85184d0e549b4b2708eb80b933fa8b (patch)
tree55be2a34f5a2ab7f8014c47cc0b259ad40040db6 /libsolidity
parent559c2106432c8af121cb794d596fd79cf1031973 (diff)
downloaddexon-solidity-905d55e34f85184d0e549b4b2708eb80b933fa8b.tar
dexon-solidity-905d55e34f85184d0e549b4b2708eb80b933fa8b.tar.gz
dexon-solidity-905d55e34f85184d0e549b4b2708eb80b933fa8b.tar.bz2
dexon-solidity-905d55e34f85184d0e549b4b2708eb80b933fa8b.tar.lz
dexon-solidity-905d55e34f85184d0e549b4b2708eb80b933fa8b.tar.xz
dexon-solidity-905d55e34f85184d0e549b4b2708eb80b933fa8b.tar.zst
dexon-solidity-905d55e34f85184d0e549b4b2708eb80b933fa8b.zip
updated tests and much simpler algorithm for parsing errors
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/parsing/Parser.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index 4fad65bb..c7b2bb50 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -1038,26 +1038,25 @@ ASTPointer<Expression> Parser::parsePrimaryExpression()
case Token::LBrack:
{
// Tuple/parenthesized expression or inline array/bracketed expression.
- // Special cases: ()/[] is empty tuple/array type, (x)/[] is not a real tuple/array,
- // (x,) is one-dimensional tuple
+ // Special cases: ()/[] is empty tuple/array type, (x) is not a real tuple,
+ // (x,) is one-dimensional tuple, elements in arrays cannot be left out, only in tuples.
m_scanner->next();
vector<ASTPointer<Expression>> components;
Token::Value oppositeToken = (token == Token::LParen ? Token::RParen : Token::RBrack);
- bool isArray = (token == Token::LBrack ? true : false);
- if (isArray && (m_scanner->currentToken() == Token::Comma))
- fatalParserError(std::string("Expected value in array cell after '[' ."));
+ bool isArray = (token == Token::LBrack);
+
if (m_scanner->currentToken() != oppositeToken)
while (true)
{
if (m_scanner->currentToken() != Token::Comma && m_scanner->currentToken() != oppositeToken)
components.push_back(parseExpression());
+ else if (isArray)
+ parserError(std::string("Expected value in array cell after"));
else
components.push_back(ASTPointer<Expression>());
if (m_scanner->currentToken() == oppositeToken)
break;
else if (m_scanner->currentToken() == Token::Comma)
- if (isArray && (m_scanner->peekNextToken() == Token::Comma || m_scanner->peekNextToken() == oppositeToken))
- fatalParserError(std::string("Expected value in array cell after ',' ."));
m_scanner->next();
}
nodeFactory.markEndPosition();