KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > SomeAccumMaxParser


1 /**
2  *
3  */

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