aboutsummaryrefslogtreecommitdiffstats
path: root/Parser.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-22 01:25:08 +0800
committerChristian <c@ethdev.com>2015-02-22 01:25:08 +0800
commit261786d909262e6cb4e9602cced76a3a22b7cb88 (patch)
treef4003a11a769bd9c15758b23fe24ec7f38482f57 /Parser.cpp
parentbe15e0b424d9a7bd181c8525dbb2eb0a26806c13 (diff)
downloaddexon-solidity-261786d909262e6cb4e9602cced76a3a22b7cb88.tar
dexon-solidity-261786d909262e6cb4e9602cced76a3a22b7cb88.tar.gz
dexon-solidity-261786d909262e6cb4e9602cced76a3a22b7cb88.tar.bz2
dexon-solidity-261786d909262e6cb4e9602cced76a3a22b7cb88.tar.lz
dexon-solidity-261786d909262e6cb4e9602cced76a3a22b7cb88.tar.xz
dexon-solidity-261786d909262e6cb4e9602cced76a3a22b7cb88.tar.zst
dexon-solidity-261786d909262e6cb4e9602cced76a3a22b7cb88.zip
Allow conversion to dynamic arrays and update grammar.
Diffstat (limited to 'Parser.cpp')
-rw-r--r--Parser.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/Parser.cpp b/Parser.cpp
index 97506179..def8b9ac 100644
--- a/Parser.cpp
+++ b/Parser.cpp
@@ -645,14 +645,11 @@ ASTPointer<Statement> Parser::parseSimpleStatement()
vector<pair<ASTPointer<Expression>, Location>> indices;
solAssert(m_scanner->getCurrentToken() == Token::LBrack, "");
Location indexLocation = primary->getLocation();
- bool encounteredEmptyBrackets = false;
do
{
expectToken(Token::LBrack);
ASTPointer<Expression> index;
- if (m_scanner->getCurrentToken() == Token::RBrack)
- encounteredEmptyBrackets = true;
- else
+ if (m_scanner->getCurrentToken() != Token::RBrack)
index = parseExpression();
indexLocation.end = getEndPosition();
indices.push_back(make_pair(index, indexLocation));
@@ -660,7 +657,7 @@ ASTPointer<Statement> Parser::parseSimpleStatement()
}
while (m_scanner->getCurrentToken() == Token::LBrack);
- if (m_scanner->getCurrentToken() == Token::Identifier || encounteredEmptyBrackets)
+ if (m_scanner->getCurrentToken() == Token::Identifier)
return parseVariableDeclarationStatement(typeNameFromArrayIndexStructure(primary, indices));
else
return parseExpressionStatement(expressionFromArrayIndexStructure(primary, indices));
@@ -768,7 +765,9 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression(
case Token::LBrack:
{
m_scanner->next();
- ASTPointer<Expression> index = parseExpression();
+ ASTPointer<Expression> index;
+ if (m_scanner->getCurrentToken() != Token::RBrack)
+ index = parseExpression();
nodeFactory.markEndPosition();
expectToken(Token::RBrack);
expression = nodeFactory.createNode<IndexAccess>(expression, index);