if ((Character) current.getNextConsCell(2).getCar() == '-')
negate = !negate;
current.getNextConsCell(2).remove();
}
if (current.getNextConsCell(2).getCarType() != ConsType.NUMBER)
throw new UndefinedResultException("For stacked exponents, each subsequent exponent must evaluate to a number", null);
num2 = num2.pow(negate ? ((BigDec) current.getNextConsCell(2).getCar()).multiply(BigDec.MINUSONE) : (BigDec) current.getNextConsCell(2).getCar());
current.getNextConsCell().remove();
current.getNextConsCell().remove();
}
output = num1.pow(num2);
}
else if (operator == '*')
output = num1.multiply(num2);
else if (operator == '/')
output = num1.divide(num2);
else if (operator == '+')
output = num1.add(num2);
else if (operator == '-')
output = num1.subtract(num2);
else
throw new UndefinedResultException(lastPlugin);
current.replaceCar(new ConsCell(output, ConsType.NUMBER));
forward = false;
}
else if ((current.getCarType() == ConsType.STRING || second.getCarType() == ConsType.STRING) &&
!(current.getCarType() == ConsType.NUMBER || second.getCarType() == ConsType.NUMBER)) {
if (operator != '+')
throw new UndefinedResultException(lastPlugin);
current.replaceCar(new ConsCell(current.carToString() + second.carToString(), ConsType.STRING));
second.remove();
current.getNextConsCell().remove();
forward = false;
}
else if (current.getCarType() == ConsType.NUMBER && second.getCarType() == ConsType.STRING) {
if (operator == '+')
current.replaceCar(new ConsCell(current.carToString() + second.carToString(), ConsType.STRING));
else if (operator == '*')
current.replaceCar(new ConsCell(stringMultiplier(second.carToString(), ((BigDec) current.getCar()).intValue()), ConsType.STRING));
else
throw new UndefinedResultException(lastPlugin);
second.remove();
current.getNextConsCell().remove();
forward = false;
}
else if (current.getCarType() == ConsType.STRING && second.getCarType() == ConsType.NUMBER) {
if (operator == '+')
current.replaceCar(new ConsCell(current.carToString() + second.carToString(), ConsType.STRING));
else if (operator == '*')
current.replaceCar(new ConsCell(stringMultiplier(current.carToString(), ((BigDec) second.getCar()).intValue()), ConsType.STRING));
else
throw new UndefinedResultException(lastPlugin);
second.remove();
current.getNextConsCell().remove();
forward = false;
}
else if (current.getCarType() == ConsType.OBJECT && second.getCarType() == ConsType.OBJECT) {