} else {
result = parsePropertyValue(tokens, typeSystem, source);
}
// Is this operand followed by an arithmetic operation ...
ArithmeticOperator arithmeticOperator = null;
if (tokens.canConsume('+')) {
arithmeticOperator = ArithmeticOperator.ADD;
} else if (tokens.canConsume('-')) {
arithmeticOperator = ArithmeticOperator.SUBTRACT;
} else if (tokens.canConsume('*')) {
arithmeticOperator = ArithmeticOperator.MULTIPLY;
} else if (tokens.canConsume('/')) {
arithmeticOperator = ArithmeticOperator.DIVIDE;
}
if (arithmeticOperator != null) {
if (tokens.matches('(')) {
// Don't use precendence, but instead use the next DynamicOperand as the RHS ...
DynamicOperand right = parseDynamicOperand(tokens, typeSystem, source);
result = new ArithmeticOperand(result, arithmeticOperator, right);
} else {
// There is no parenthesis, so use operator precedence ...
DynamicOperand right = parseDynamicOperand(tokens, typeSystem, source);
if (right instanceof ArithmeticOperand) {
// But the RHS is an arithmetic operand, so we need to use operator precedence ...
ArithmeticOperand arithRhs = (ArithmeticOperand)right;
ArithmeticOperator rhsOperator = arithRhs.getOperator();
if (arithmeticOperator.precedes(rhsOperator)) {
// This operand's operator does take precedence, so this must be computed before working with the RHS ...
DynamicOperand newRhs = arithRhs.getRight();
DynamicOperand newLhs = new ArithmeticOperand(result, arithmeticOperator, arithRhs.getLeft());
result = new ArithmeticOperand(newLhs, rhsOperator, newRhs);