org.parboiled.parserunners
Class ReportingParseRunner<V>

java.lang.Object
  extended by org.parboiled.parserunners.BasicParseRunner<V>
      extended by org.parboiled.parserunners.ReportingParseRunner<V>
All Implemented Interfaces:
ParseRunner<V>

public class ReportingParseRunner<V>
extends BasicParseRunner<V>

A ParseRunner implementation that properly reports the first InvalidInputError if the input does not conform to the rule grammar. It performs exactly as the BasicParseRunner on valid input, however, on invalid input two more parsing runs are initiated: one for recording the first parse error and one for collecting the error report information.


Nested Class Summary
static class ReportingParseRunner.Handler
          A MatchHandler implementation that reports the InvalidInputError at a given error index.
 
Field Summary
 
Fields inherited from class org.parboiled.parserunners.BasicParseRunner
initialValueStackSnapshot, inputBuffer, matched, parseErrors, rootContext, rootMatcher, valueStack
 
Constructor Summary
ReportingParseRunner(Rule rule)
          Creates a new ReportingParseRunner instance for the given rule.
ReportingParseRunner(Rule rule, ValueStack<V> valueStack)
          Creates a new ReportingParseRunner instance for the given rule using the given ValueStack instance.
 
Method Summary
static
<V> ParsingResult<V>
run(Rule rule, java.lang.String input)
          Create a new ReportingParseRunner instance with the given rule and input text and returns the result of its BasicParseRunner.run(String) method invocation.
protected  boolean runRootContext()
           
 
Methods inherited from class org.parboiled.parserunners.BasicParseRunner
run, run, run, runRootContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReportingParseRunner

public ReportingParseRunner(Rule rule)
Creates a new ReportingParseRunner instance for the given rule.

Parameters:
rule - the parser rule

ReportingParseRunner

public ReportingParseRunner(Rule rule,
                            ValueStack<V> valueStack)
Creates a new ReportingParseRunner instance for the given rule using the given ValueStack instance.

Parameters:
rule - the parser rule
valueStack - the value stack
Method Detail

run

public static <V> ParsingResult<V> run(Rule rule,
                                       java.lang.String input)
Create a new ReportingParseRunner instance with the given rule and input text and returns the result of its BasicParseRunner.run(String) method invocation.

Parameters:
rule - the parser rule to run
input - the input text to run on
Returns:
the ParsingResult for the parsing run

runRootContext

protected boolean runRootContext()
Overrides:
runRootContext in class BasicParseRunner<V>