}
SimpleNode token = nodes.get(i);
SimpleNode right = i < nodes.size() - 1 ? nodes.get(i + 1) : null;
if (token instanceof LogicalExpression) {
LogicalExpression logical = (LogicalExpression) token;
// remember the logical operator
String operator = logical.getOperator().toString();
if (left == null) {
throw new SimpleParserException("Logical operator " + operator + " has no left hand side token", token.getToken().getIndex());
}
if (!logical.acceptLeftNode(left)) {
throw new SimpleParserException("Logical operator " + operator + " does not support left hand side token " + left.getToken(), token.getToken().getIndex());
}
if (right == null) {
throw new SimpleParserException("Logical operator " + operator + " has no right hand side token", token.getToken().getIndex());
}
if (!logical.acceptRightNode(right)) {
throw new SimpleParserException("Logical operator " + operator + " does not support right hand side token " + left.getToken(), token.getToken().getIndex());
}
// pop previous as we need to replace it with this binary operator
stack.pop();