private Result consume(Parser parser, Context context) { Result result = parser.parseOn(context); while (result.isSuccess()) { result = parser.parseOn(result); } return result; }
@Override public Result parseOn(Context context) { Result leftResult = consume(left, context); Result delegateResult = delegate.parseOn(leftResult); if (delegateResult.isFailure()) { return delegateResult; } Result rightResult = consume(right, delegateResult); return rightResult.success(delegateResult.get()); }