KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > IsConsumedParser


1 /**
2  *
3  */

4 package jfun.parsec;
5
6 final class IsConsumedParser<R> extends Parser<R> {
7   private final Parser<R> p;
8
9   private final String JavaDoc err;
10
11   IsConsumedParser(String JavaDoc n, Parser<R> p, String JavaDoc err) {
12     super(n);
13     this.p = p;
14     this.err = err;
15   }
16
17   boolean apply(final ParseContext ctxt) {
18     final int at = ctxt.getAt();
19     if (!p.parse(ctxt))
20       return false;
21     if (ctxt.getAt() != at)
22       return true;
23     return ParserInternals.raiseRaw(err, ctxt);
24   }
25 }
Popular Tags