diff options
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 4ac3381c..cc06eb87 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -932,13 +932,26 @@ ASTPointer<Expression> Parser::parseExpression( ) { ASTPointer<Expression> expression = parseBinaryExpression(4, _lookAheadIndexAccessStructure); - if (!Token::isAssignmentOp(m_scanner->currentToken())) + if (Token::isAssignmentOp(m_scanner->currentToken())) + { + Token::Value assignmentOperator = expectAssignmentOperator(); + ASTPointer<Expression> rightHandSide = parseExpression(); + ASTNodeFactory nodeFactory(*this, expression); + nodeFactory.setEndPositionFromNode(rightHandSide); + return nodeFactory.createNode<Assignment>(expression, assignmentOperator, rightHandSide); + } + else if (m_scanner->currentToken() == Token::Value::Conditional) + { + m_scanner->next(); + ASTPointer<Expression> trueExpression = parseExpression(); + expectToken(Token::Colon); + ASTPointer<Expression> falseExpression = parseExpression(); + ASTNodeFactory nodeFactory(*this, expression); + nodeFactory.setEndPositionFromNode(falseExpression); // TODO: + return nodeFactory.createNode<Conditional>(expression, trueExpression, falseExpression); + } + else return expression; - Token::Value assignmentOperator = expectAssignmentOperator(); - ASTPointer<Expression> rightHandSide = parseExpression(); - ASTNodeFactory nodeFactory(*this, expression); - nodeFactory.setEndPositionFromNode(rightHandSide); - return nodeFactory.createNode<Assignment>(expression, assignmentOperator, rightHandSide); } ASTPointer<Expression> Parser::parseBinaryExpression( |