1 4 package jfun.parsec; 5 6 final class ManyAccumMinParser<R, From, To, A extends From> extends Parser<R> { 7 private final Accumulatable<From, To> accm; 8 9 private final int min; 10 11 private final Parser<A> p; 12 13 ManyAccumMinParser(String n, Accumulatable<From, To> accm, int min, Parser<A> p) { 14 super(n); 15 this.accm = accm; 16 this.min = min; 17 this.p = p; 18 } 19 20 boolean apply(final ParseContext ctxt) { 21 final Accumulator<From, To> acc = accm.getAccumulator(); 22 if (!ParserInternals.accm_repeat(acc, min, p, ctxt)) 23 return false; 24 if (ParserInternals.accm_many(acc, p, ctxt)) 25 return ParserInternals.returnValue(acc.getResult(), ctxt); 26 else 27 return false; 28 } 29 } | Popular Tags |