KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > ManyAccumParser


1 /**
2  *
3  */

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