1 4 package jfun.parsec; 5 6 final class Map5Parser<R, A, B, C, D, E> extends Parser<R> { 7 private final Parser<A> p1; 8 9 private final Parser<C> p3; 10 11 private final Parser<D> p4; 12 13 private final Parser<B> p2; 14 15 private final Map5<? super A, ? super B, ? super C, ? super D, ? super E, R> m5; 16 17 private final Parser<E> p5; 18 19 Map5Parser(String n, Parser<A> p1, Parser<C> p3, Parser<D> p4, Parser<B> p2, Map5<? super A, ? super B, ? super C, ? super D, ? super E, R> m5, Parser<E> p5) { 20 super(n); 21 this.p1 = p1; 22 this.p3 = p3; 23 this.p4 = p4; 24 this.p2 = p2; 25 this.m5 = m5; 26 this.p5 = p5; 27 } 28 29 boolean apply(final ParseContext ctxt) { 30 final boolean r1 = p1.parse(ctxt); 31 if (!r1) 32 return false; 33 final A o1 = p1.getReturn(ctxt); 34 final boolean r2 = p2.parse(ctxt); 35 if (!r2) 36 return false; 37 final B o2 = p2.getReturn(ctxt); 38 final boolean r3 = p3.parse(ctxt); 39 if (!r3) 40 return false; 41 final C o3 = p3.getReturn(ctxt); 42 final boolean r4 = p4.parse(ctxt); 43 if (!r4) 44 return false; 45 final D o4 = p4.getReturn(ctxt); 46 final boolean r5 = p5.parse(ctxt); 47 if (!r5) 48 return false; 49 final E o5 = p5.getReturn(ctxt); 50 ctxt.setReturn(m5.map(o1, o2, o3, o4, o5)); 51 return true; 52 } 53 } | Popular Tags |