@NotNull @Override public Pair<R2, State> parse(@NotNull List<Token<T>> tokens, @NotNull State state) throws ParserException { final Pair<R, State> result = myParser.parse(tokens, state); return Pair.create(myFunction.fun(result.getFirst()), result.getSecond()); }
@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 FunctionalParser<R, T> endOfInput() { return this.thenSkip(FunctionalParserBase.<T>finished()); }
@NotNull public static <R, T> FunctionalParser<R, T> maybe(@NotNull final FunctionalParser<R, T> parser) { return parser.or(FunctionalParserBase.<R, T>pure(null)); }