/** * A {@link Parser} that runs {@code this} for 1 ore more times separated and optionally terminated by {@code * delim}. For example: {@code "foo;foo;foo"} and {@code "foo;foo;"} both matches {@code foo.sepEndBy1(semicolon)}. * * <p>The return values are collected in a {@link List}. */ public final Parser<List<T>> sepEndBy1(final Parser<?> delim) { return next(first -> new DelimitedParser<T>(this, delim, ListFactory.arrayListFactoryWithFirstElement(first))); }
/** * A {@link Parser} that runs {@code this} 1 or more times separated by {@code delim}. * * <p>The return values are collected in a {@link List}. */ public final Parser<List<T>> sepBy1(Parser<?> delim) { final Parser<T> afterFirst = delim.asDelimiter().next(this); return next((Function<T, Parser<List<T>>>) firstValue -> new RepeatAtLeastParser<T>( afterFirst, 0, ListFactory.arrayListFactoryWithFirstElement(firstValue))); }