KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > EofParser


1 /**
2  *
3  */

4 package jfun.parsec;
5
6 final class EofParser extends Parser<Object JavaDoc> {
7   private final String JavaDoc msg;
8
9   EofParser(String JavaDoc n, String JavaDoc msg) {
10     super(n);
11     this.msg = msg;
12   }
13
14   boolean apply(final ParseContext ctxt) {
15     if (ctxt.isEof())
16       return true;
17     else {
18       final AbstractParsecError expecting = ParserInternals.errExpecting(msg, ctxt);
19       final AbstractParsecError unexpected = ctxt.getSysUnexpected();
20       ctxt.setError(AbstractParsecError.mergeError(expecting, unexpected));
21       return false;
22     }
23   }
24 }
Popular Tags