1 4 package jfun.parsec; 5 6 final class StepParser<R> extends Parser<R> { 7 private final Parser<R> p; 8 9 private final int n; 10 11 StepParser(String name, Parser<R> p, int n) { 12 super(name); 13 this.p = p; 14 this.n = n; 15 } 16 17 boolean apply(final ParseContext ctxt) { 18 final int step = ctxt.getStep(); 19 if (!p.parse(ctxt)) 20 return false; 21 ctxt.setStep(step + n); 22 return true; 23 } 24 } | Popular Tags |