/** * Pretty prints the given parse errors showing their location in the given input buffer. * * @param errors the parse errors * @return the pretty print text */ public static String printParseErrors(List<ParseError> errors) { checkArgNotNull(errors, "errors"); StringBuilder sb = new StringBuilder(); for (ParseError error : errors) { if (sb.length() > 0) sb.append("---\n"); sb.append(printParseError(error)); } return sb.toString(); }
/** * Pretty prints the given parse error showing its location in the given input buffer. * * @param error the parse error * @return the pretty print text */ public static String printParseError(ParseError error) { checkArgNotNull(error, "error"); return printParseError(error, new DefaultInvalidInputErrorFormatter()); }
public boolean runMatcher() { try { if (matchHandler.match(this)) { if (parent != null) { parent.currentIndex = currentIndex; parent.currentChar = currentChar; } matcher = null; // "retire" this context return true; } matcher = null; // "retire" this context until is "activated" again by a getSubContext(...) on the parent return false; } catch (ParserRuntimeException e) { throw e; // don't wrap, just bubble up } catch (RecoveringParseRunner.TimeoutException e) { throw e; // don't wrap, just bubble up } catch (Throwable e) { throw new ParserRuntimeException(e, printParseError(new BasicParseError(inputBuffer, currentIndex, StringUtils.escape(String.format("Error while parsing %s '%s' at input position", matcher instanceof ActionMatcher ? "action" : "rule", getPath())))) + '\n' + e); } } }