diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 4ac3381ce..cc06eb876 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -932,13 +932,26 @@ ASTPointer Parser::parseExpression( ) { ASTPointer expression = parseBinaryExpression(4, _lookAheadIndexAccessStructure); - if (!Token::isAssignmentOp(m_scanner->currentToken())) + if (Token::isAssignmentOp(m_scanner->currentToken())) + { + Token::Value assignmentOperator = expectAssignmentOperator(); + ASTPointer rightHandSide = parseExpression(); + ASTNodeFactory nodeFactory(*this, expression); + nodeFactory.setEndPositionFromNode(rightHandSide); + return nodeFactory.createNode(expression, assignmentOperator, rightHandSide); + } + else if (m_scanner->currentToken() == Token::Value::Conditional) + { + m_scanner->next(); + ASTPointer trueExpression = parseExpression(); + expectToken(Token::Colon); + ASTPointer falseExpression = parseExpression(); + ASTNodeFactory nodeFactory(*this, expression); + nodeFactory.setEndPositionFromNode(falseExpression); // TODO: + return nodeFactory.createNode(expression, trueExpression, falseExpression); + } + else return expression; - Token::Value assignmentOperator = expectAssignmentOperator(); - ASTPointer rightHandSide = parseExpression(); - ASTNodeFactory nodeFactory(*this, expression); - nodeFactory.setEndPositionFromNode(rightHandSide); - return nodeFactory.createNode(expression, assignmentOperator, rightHandSide); } ASTPointer Parser::parseBinaryExpression(