KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > SomeMinMaxParser


1 /**
2  *
3  */

4 package jfun.parsec;
5
6 final class SomeMinMaxParser extends Parser<_> {
7   private final int max;
8
9   private final Parser<?> p;
10
11   private final int min;
12
13   SomeMinMaxParser(String JavaDoc n, int max, Parser<?> p, int min) {
14     super(n);
15     this.max = max;
16     this.p = p;
17     this.min = min;
18   }
19
20   boolean apply(final ParseContext ctxt) {
21     if (!ParserInternals.run_repeat(min, p, ctxt))
22       return false;
23     if (ParserInternals.run_some(max - min, p, ctxt))
24       return ParserInternals.returnValue(null, ctxt);
25     else
26       return false;
27   }
28 }
Popular Tags