From 574e48b0b51bbf890702a0c0fbae799473945bdb Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Mon, 14 Dec 2015 17:40:35 -0600 Subject: Inline array declarations complete --- libsolidity/parsing/Parser.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libsolidity/parsing') 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 Parser::parsePrimaryExpression() expectToken(Token::RParen); return nodeFactory.createNode(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> 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()); + 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(components); + } default: if (Token::isElementaryTypeName(token)) { -- cgit v1.2.3