// assignableExpression is a subset of conditionalExpression, so we can parse a conditional
// expression and then determine whether it is followed by an assignmentOperator, checking for
// conformance to the restricted grammar after making that determination.
//
Expression expression = parseConditionalExpression();
TokenType tokenType = currentToken.getType();
if (tokenType == TokenType.PERIOD_PERIOD) {
List<Expression> cascadeSections = new ArrayList<Expression>();
while (tokenType == TokenType.PERIOD_PERIOD) {
Expression section = parseCascadeSection();
if (section != null) {
cascadeSections.add(section);
}
tokenType = currentToken.getType();
}
return new CascadeExpression(expression, cascadeSections);
} else if (tokenType.isAssignmentOperator()) {
Token operator = getAndAdvance();
ensureAssignable(expression);
return new AssignmentExpression(expression, operator, parseExpression());
}
return expression;