return new Conditional(input.get(lhs.size()).getPosition(), lhsInvokable, mhsInvokable, rhsInvokable);
}
private static RValue processUnaryOps(LinkedList<Identifiable> input) throws ParserException {
// Preprocess postfix operators into unary operators
final Identifiable center;
LinkedList<UnaryOperator> postfixes = new LinkedList<UnaryOperator>();
do {
if (input.isEmpty()) {
throw new ParserException(-1, "Expression missing.");
}
final Identifiable last = input.removeLast();
if (last instanceof OperatorToken) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((OperatorToken) last).operator));
} else if (last instanceof UnaryOperator) {
postfixes.addLast(new UnaryOperator(last.getPosition(), "x" + ((UnaryOperator) last).operator));
} else {
center = last;
break;
}
} while (true);
if (!(center instanceof RValue)) {
throw new ParserException(center.getPosition(), "Expected expression, found " + center);
}
input.addAll(postfixes);
RValue ret = (RValue) center;
while (!input.isEmpty()) {
final Identifiable last = input.removeLast();
final int lastPosition = last.getPosition();
if (last instanceof UnaryOperator) {
final String operator = ((UnaryOperator) last).operator;
if (operator.equals("+")) {
continue;
}