KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > NestedParser


1 /**
2  *
3  */

4 package jfun.parsec;
5
6 final class NestedParser<R> extends Parser<R> {
7   private final ShowToken show;
8
9   private final String JavaDoc module;
10
11   private final Parser<Tok[]> lexer;
12
13   private final Parser<R> p;
14
15   private final String JavaDoc eof_title;
16
17   NestedParser(String JavaDoc n, ShowToken show, String JavaDoc module, Parser<Tok[]> lexer, Parser<R> p, String JavaDoc eof_title) {
18     super(n);
19     this.show = show;
20     this.module = module;
21     this.lexer = lexer;
22     this.p = p;
23     this.eof_title = eof_title;
24   }
25
26   boolean apply(final ParseContext ctxt) {
27     if (!lexer.parse(ctxt))
28       return false;
29     // final R obj = p.getReturn(ctxt);
30
final Tok[] toks = lexer.getReturn(ctxt);// toTokens(obj);
31
final ParserState s0 = new ParserState(toks, ctxt.getUserState(), toks,
32         0, module, ctxt.getPositionMap(), ctxt.getIndex(), eof_title, show);
33     return ParserInternals.cont(ctxt, s0, p);
34   }
35 }
Popular Tags