@NotNull @Override public Pair<R, State> parse(@NotNull List<Token<T>> tokens, @NotNull State state) throws ParserException { try { return myFirst.parse(tokens, state); } catch (ParserException e) { return mySecond.parse(tokens, new State(state, state.getPos(), e.getState().getMax())); } }
@NotNull @Override public Pair<List<R>, State> parse(@NotNull List<Token<T>> tokens, @NotNull State state) throws ParserException { final List<R> list = new ArrayList<R>(); try { //noinspection InfiniteLoopStatement while (true) { final Pair<R, State> result = myParser.parse(tokens, state); state = result.getSecond(); list.add(result.getFirst()); } } catch (ParserException e) { return Pair.create(list, new State(state, state.getPos(), e.getState().getMax())); } }