/** * Split the left term and transform it into the right deep expression. * * @param binary - to be splited * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* y'. * * @throws CloneNotSupportedException */ public static PartialBinaryExpr splitRightTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getRightExpr() instanceof BinaryEval) { return splitRightTerm((BinaryEval) binary.getRightExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getRightExpr()); binary.setRightExpr(null); return splitted; }
/** * Split the left term and transform it into the right deep expression. * * @param binary - to be splited * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* y'. * * @throws CloneNotSupportedException */ public static PartialBinaryExpr splitRightTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getRightExpr() instanceof BinaryEval) { return splitRightTerm((BinaryEval) binary.getRightExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getRightExpr()); binary.setRightExpr(null); return splitted; }
PartialBinaryExpr tmpTerm = splitRightTerm((BinaryEval) left); tmpTerm.type = inverseOperator(tmpTerm.type); tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());
PartialBinaryExpr tmpTerm = splitRightTerm((BinaryEval) left); tmpTerm.type = inverseOperator(tmpTerm.type); tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());