diff options
author | RJ Catalano <catalanor0220@gmail.com> | 2015-12-15 07:40:35 +0800 |
---|---|---|
committer | RJ Catalano <catalanor0220@gmail.com> | 2015-12-15 07:40:35 +0800 |
commit | 574e48b0b51bbf890702a0c0fbae799473945bdb (patch) | |
tree | d76f74a2f7d4f60296b567fcb8c30d651bd9c6cd /libsolidity/parsing | |
parent | 98684cca9035c754adcdc99fd196716cb7802efd (diff) | |
download | dexon-solidity-574e48b0b51bbf890702a0c0fbae799473945bdb.tar.gz dexon-solidity-574e48b0b51bbf890702a0c0fbae799473945bdb.tar.zst dexon-solidity-574e48b0b51bbf890702a0c0fbae799473945bdb.zip |
Inline array declarations complete
Diffstat (limited to 'libsolidity/parsing')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 2b886121..50e4d29d 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -1056,6 +1056,28 @@ ASTPointer<Expression> Parser::parsePrimaryExpression() expectToken(Token::RParen); return nodeFactory.createNode<TupleExpression>(components); } + case Token::LBrack: + { + // Inline array expression + // Special cases: [] is empty tuple type, (x) is not a real tuple, (x,) is one-dimensional tuple + m_scanner->next(); + vector<ASTPointer<Expression>> components; + if (m_scanner->currentToken() != Token::RBrack) + while (true) + { + if (m_scanner->currentToken() != Token::Comma && m_scanner->currentToken() != Token::RBrack) + components.push_back(parseExpression()); + else + components.push_back(ASTPointer<Expression>()); + if (m_scanner->currentToken() == Token::RBrack) + break; + else if (m_scanner->currentToken() == Token::Comma) + m_scanner->next(); + } + nodeFactory.markEndPosition(); + expectToken(Token::RBrack); + return nodeFactory.createNode<TupleExpression>(components); + } default: if (Token::isElementaryTypeName(token)) { |