// sum_op -> PLUSMINUS term sum_op
// sum_op -> EPSILON
private ExpressionNode sumOperation(ExpressionNode expression) {
// sum_op -> PLUSMINUS term sum_op
if (lookahead.tokenType == TokenTypes.ADDITION) {
AdditionExpressionNode sum;
// This means we are actually dealing with a sum
// If expr is not already a sum, we have to create one
if (expression.getType() == TokenTypes.ADDITION) {
sum = (AdditionExpressionNode) expression;
} else {
sum = new AdditionExpressionNode(expression, true);
}
// reduce the input and recursively call sum_op
boolean positive = lookahead.sequence.equals("+");
nextToken();
ExpressionNode term = term();
sum.add(term, positive);
return sumOperation(sum);
}
// sum_op -> EPSILON