public TestResult<V> testWithRecovery(Rule rule, String input) { return new TestResult<V>(new RecoveringParseRunner<V>(rule).run(input)); }
private void performFinalRun() { resetValueStack(); Handler handler = new Handler(); MatcherContext<V> rootContext = createRootContext(buffer, handler, false); boolean matched = handler.match(rootContext); lastParsingResult = createParsingResult(matched, rootContext); }
AbcGrammar grammar = AbcGrammar.getInstance(); ParsingResult<?> result = RecoveringParseRunner.run(grammar.AbcFile(), abcString); if (DEBUG) {
private boolean fixError(int fixIndex) { if (tryFixBySingleCharDeletion(fixIndex)) return true; int nextErrorAfterDeletion = errorIndex; Character bestInsertionCharacter = findBestSingleCharInsertion(fixIndex); if (bestInsertionCharacter == null) return true; int nextErrorAfterBestInsertion = errorIndex; Character bestReplacementCharacter = findBestSingleCharReplacement(fixIndex); if (bestReplacementCharacter == null) return true; int nextErrorAfterBestReplacement = errorIndex; performLocatingRun(buffer); // find the next parse error
private Character findBestSingleCharReplacement(int fixIndex) { buffer.insertChar(fixIndex, DEL_ERROR); Character bestChar = findBestSingleCharInsertion(fixIndex + 2); if (bestChar == null) { // success, we found a fix that renders the complete input error free currentError .shiftIndexDeltaBy(-1); // delta from DEL_ERROR char insertion and index shift by insertion method } else { buffer.undoCharInsertion(fixIndex); errorIndex = Math.max(errorIndex - 3, 0); } return bestChar; }
public TestResult<V> testWithRecovery(Rule rule, InputBuffer inputBuffer) { return new TestResult<V>(new RecoveringParseRunner<V>(rule).run(inputBuffer)); }
@Override public void parseQueryParameters(String nativeQuery, Recognizer journaler) { QueryParser parser = Parboiled.createParser( QueryParser.class, journaler ); new RecoveringParseRunner<Recognizer>( parser.Query() ).run( nativeQuery ); } }
/** * Create a new RecoveringParseRunner instance with the given rule and input text and returns the result of * its {@link #run(String)} method invocation. * * @param rule the parser rule to run * @param input the input text to run on * @return the ParsingResult for the parsing run * @deprecated As of 0.11.0 you should use the "regular" constructor and one of the "run" methods rather than * this static method. This method will be removed in one of the coming releases. */ @Deprecated public static <V> ParsingResult<V> run(Rule rule, String input) { checkArgNotNull(rule, "rule"); checkArgNotNull(input, "input"); return new RecoveringParseRunner<V>(rule).run(input); }
public static ExpressionList parse (String input) { if (parser == null) parser = Parboiled.createParser(PluralPropertyParser.class); ParsingResult<Object> result = new RecoveringParseRunner<Object>(parser.Translate()).run(input); Object e = result.valueStack.pop(); return (ExpressionList) e; }
@Override public void parse(Snapshot snapshot, Task task, SourceModificationEvent sme) throws ParseException { logger.fine("Parsing..."); this.snapshot = snapshot; RecoveringParseRunner runner = new RecoveringParseRunner(parboiled.cfgProps()); parboiled.reset(); parbResult = runner.run(snapshot.getText().toString()); logParsingResult(); }
@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(); }