mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
updated attempt, a couple of more things to sort through and change
This commit is contained in:
parent
591a4f1ff4
commit
42c4339404
@ -1034,26 +1034,28 @@ ASTPointer<Expression> Parser::parsePrimaryExpression()
|
|||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
expression = nodeFactory.createNode<Identifier>(getLiteralAndAdvance());
|
expression = nodeFactory.createNode<Identifier>(getLiteralAndAdvance());
|
||||||
break;
|
break;
|
||||||
case Token::LParen:
|
case Token::LParen || Token::LBrack:
|
||||||
{
|
{
|
||||||
// Tuple or parenthesized expression.
|
// Tuple or parenthesized expression.
|
||||||
// Special cases: () is empty tuple type, (x) is not a real tuple, (x,) is one-dimensional tuple
|
// Special cases: () is empty tuple type, (x) is not a real tuple, (x,) is one-dimensional tuple
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
vector<ASTPointer<Expression>> components;
|
vector<ASTPointer<Expression>> components;
|
||||||
|
Token::Value oppositeToken = (token == LParen ? Token::RParen : Token::RBrack);
|
||||||
|
|
||||||
if (m_scanner->currentToken() != Token::RParen)
|
if (m_scanner->currentToken() != Token::RParen)
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (m_scanner->currentToken() != Token::Comma && m_scanner->currentToken() != Token::RParen)
|
if (m_scanner->currentToken() != Token::Comma && m_scanner->currentToken() != oppositeToken)
|
||||||
components.push_back(parseExpression());
|
components.push_back(parseExpression());
|
||||||
else
|
else
|
||||||
components.push_back(ASTPointer<Expression>());
|
components.push_back(ASTPointer<Expression>());
|
||||||
if (m_scanner->currentToken() == Token::RParen)
|
if (m_scanner->currentToken() == oppositeToken)
|
||||||
break;
|
break;
|
||||||
else if (m_scanner->currentToken() == Token::Comma)
|
else if (m_scanner->currentToken() == Token::Comma)
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
}
|
}
|
||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
expectToken(Token::RParen);
|
expectToken(oppositeToken);
|
||||||
return nodeFactory.createNode<TupleExpression>(components);
|
return nodeFactory.createNode<TupleExpression>(components);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -1047,6 +1047,20 @@ BOOST_AUTO_TEST_CASE(using_for)
|
|||||||
BOOST_CHECK(successParse(text));
|
BOOST_CHECK(successParse(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(inline_array_declaration)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract c {
|
||||||
|
uint[] a;
|
||||||
|
function f() returns (uint, uint) {
|
||||||
|
a = [1,2,3];
|
||||||
|
return (a[3], [3,4][0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(successParse(text));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user