public RootNode parseInternal(char[] source) { ParsingResult<Node> result = parseToParsingResult(source); if (result.hasErrors()) { throw new RuntimeException("Internal error during markdown parsing:\n--- ParseErrors ---\n" + printParseErrors(result)/* + "\n--- ParseTree ---\n" + printNodeTree(result)*/ ); } return (RootNode) result.resultValue; }
private Unit parseUnit(String templateText) throws Exception { ParsingResult<Object> result = new ReportingParseRunner<>(parser.Unit()).run(templateText); if (result.hasErrors()) { String errors = ErrorUtils.printParseErrors(result.parseErrors); throw new Exception(errors); } return (Unit) Iterables.getOnlyElement(result.valueStack); }
public static void main(String... args) { Parser templateParser = Parboiled.createParser(Parser.class); ParsingResult<Object> result = new ReportingParseRunner<>(templateParser.Unit()).run(input2); ImmutableList<Object> copy = ImmutableList.copyOf(result.valueStack.iterator()); if (!copy.isEmpty()) { Unit unit = (Unit) copy.get(0); Unit balance = Balancing.balance(unit); System.out.println(balance); } if (result.hasErrors()) { System.err.println(ErrorUtils.printParseErrors(result.parseErrors)); } // System.out.println(ParseTreeUtils.printNodeTree(result)); } }
public String getParsingErrorMessage() { return ErrorUtils.printParseErrors(parsingResult.parseErrors); } }
private ExpressionValidationResult(boolean validationSucceed, List<ParseError> parseErrors) { this.validationSucceed = validationSucceed; this.errorMessage = ErrorUtils.printParseErrors(parseErrors); }
/** * Pretty prints the parse errors of the given ParsingResult showing their location in the given input buffer. * * @param parsingResult the parsing result * @return the pretty print text */ public static String printParseErrors(ParsingResult<?> parsingResult) { checkArgNotNull(parsingResult, "parsingResult"); return printParseErrors(parsingResult.parseErrors); }
private Unit parseUnit(String templateText) throws Exception { ParsingResult<Object> result = new ReportingParseRunner<>(parser.Unit()).run(templateText); if (result.hasErrors()) { String errors = ErrorUtils.printParseErrors(result.parseErrors); throw new Exception(errors); } return (Unit) Iterables.getOnlyElement(result.valueStack); }
System.out.println("\nParse Errors:\n" + ErrorUtils.printParseErrors(result));
@Override public MongoDBQueryDescriptor parseNativeQuery(String nativeQuery) { NativeQueryParser localParser = NATIVE_QUERY_PARSER.newInstance(); ParsingResult<MongoDBQueryDescriptorBuilder> parseResult = new RecoveringParseRunner<MongoDBQueryDescriptorBuilder>( localParser.Query() ) .run( nativeQuery ); if ( parseResult.hasErrors() ) { throw new IllegalArgumentException( "Unsupported native query: " + ErrorUtils.printParseErrors( parseResult.parseErrors ) ); } return parseResult.resultValue.build(); }
@Override public MongoDBQueryDescriptor parseNativeQuery(String nativeQuery) { NativeQueryParser localParser = NATIVE_QUERY_PARSER.newInstance(); ParsingResult<MongoDBQueryDescriptorBuilder> parseResult = new RecoveringParseRunner<MongoDBQueryDescriptorBuilder>( localParser.Query() ) .run( nativeQuery ); if ( parseResult.hasErrors() ) { throw new IllegalArgumentException( "Unsupported native query: " + ErrorUtils.printParseErrors( parseResult.parseErrors ) ); } return parseResult.resultValue.build(); }