1 4 package jfun.parsec; 5 6 final class NestedParser<R> extends Parser<R> { 7 private final ShowToken show; 8 9 private final String module; 10 11 private final Parser<Tok[]> lexer; 12 13 private final Parser<R> p; 14 15 private final String eof_title; 16 17 NestedParser(String n, ShowToken show, String module, Parser<Tok[]> lexer, Parser<R> p, String 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 Tok[] toks = lexer.getReturn(ctxt); 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 |