KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > PeekParser


1 /**
2  *
3  */

4 package jfun.parsec;
5
6 final class PeekParser<R> extends Parser<R> {
7   private final Parser<R> p;
8
9   PeekParser(String JavaDoc n, Parser<R> p) {
10     super(n);
11     this.p = p;
12   }
13
14   boolean apply(final ParseContext ctxt) {
15     final int step = ctxt.getStep();
16     final int at = ctxt.getAt();
17     final boolean r = p.parse(ctxt);
18     ctxt.setAt(step, at);
19     return r;
20   }
21 }
Popular Tags