1 8 14 package jfun.parsec; 15 16 24 final class MergedParsecError extends AbstractParsecError { 25 ParsecError render() { 26 return getMerged(err1.render(), err2.render()); 27 } 28 AbstractParsecError setExpecting(String s){ 29 return ParsecError.raiseExpecting(getIndex(), s, this); 30 } 31 private ParsecError getMerged(ParsecError e1, ParsecError e2){ 32 return ParsecError.mergeError(getIndex(), getException(), e1, e2); 33 } 34 private final AbstractParsecError err1; 35 private final AbstractParsecError err2; 36 MergedParsecError(int ind, int pred, 37 final AbstractParsecError err1, final AbstractParsecError err2) { 38 super(false, ind, pred, mergeObj(err1.getException(), err2.getException())); 39 this.err1 = err1; 40 this.err2 = err2; 41 } 42 static Object mergeObj(final Object a, final Object b){ 43 return a==null?b:a; 44 } 45 } 46 | Popular Tags |