// unlike other scalars.
if ((leftToken instanceof ScalarToken)
&& (rightToken instanceof ScalarToken)
&& !(leftToken instanceof BooleanToken)) {
// handle the relations like x == 2.0
ScalarToken difference = (ScalarToken) leftToken
.subtract(rightToken);
if (((BooleanToken) result).booleanValue()) {
_relationType = RelationType.EQUAL_INEQUAL;
} else {
if (difference.doubleValue() < 0) {
_relationType = RelationType.LESS_THAN;
} else {
_relationType = RelationType.GREATER_THAN;
}
}
_difference = difference.doubleValue();
} else {
// handle the relations like x == true, x == "str", or x!= false
if (((BooleanToken) result).booleanValue()) {
_relationType = RelationType.TRUE;
} else {
_relationType = RelationType.FALSE;
}
_difference = 0.0;
}
} else {
// If the operator is neither about equal nor not-equal relations,
// both tokens must be scalar tokens.
if (!((leftToken instanceof ScalarToken) && (rightToken instanceof ScalarToken))) {
throw new IllegalActionException("The " + operator.image
+ " operator can only be applied between scalars.");
}
ScalarToken leftScalar = (ScalarToken) leftToken;
ScalarToken rightScalar = (ScalarToken) rightToken;
// A relation needs strictly satisfied.
if (operator.kind == PtParserConstants.GTE) {
result = leftScalar.isLessThan(rightScalar).not();
} else if (operator.kind == PtParserConstants.GT) {
result = rightScalar.isLessThan(leftScalar);
} else if (operator.kind == PtParserConstants.LTE) {
result = rightScalar.isLessThan(leftScalar).not();
} else if (operator.kind == PtParserConstants.LT) {
result = leftScalar.isLessThan(rightScalar);
} else {
throw new IllegalActionException("Invalid operation "
+ operator.image + " between "