KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > RepeatParser


1 /**
2  *
3  */

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