org.parboiled.parserunners
Class RecordingParseRunner<V>

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

public class RecordingParseRunner<V>
extends BasicParseRunner<V>

A ParseRunner implementation that records the location of the first InvalidInputError found, without actually creating a InvalidInputError instance and adding it to the list of ParseErrors. It never causes the parser to perform more than one parsing run and is rarely used directly. Instead its functionality is relied upon by the ReportingParseRunner and RecoveringParseRunner classes.


Nested Class Summary
static class RecordingParseRunner.Handler
          A MatchHandler implementation keeping track of the furthest match in the current input buffer, and therefore the first location corresponding to an InvalidInputError.
 
Field Summary
 
Fields inherited from class org.parboiled.parserunners.BasicParseRunner
initialValueStackSnapshot, inputBuffer, matched, parseErrors, rootContext, rootMatcher, valueStack
 
Constructor Summary
RecordingParseRunner(Rule rule)
          Creates a new RecordingParseRunner instance for the given rule.
RecordingParseRunner(Rule rule, ValueStack<V> valueStack)
          Creates a new RecordingParseRunner instance for the given rule using the given ValueStack instance.
 
Method Summary
 int getErrorIndex()
          Returns the index of the first InvalidInputError in the input text.
static
<V> ParsingResult<V>
run(Rule rule, java.lang.String input)
          Create a new RecordingParseRunner 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

RecordingParseRunner

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

Parameters:
rule - the parser rule

RecordingParseRunner

public RecordingParseRunner(Rule rule,
                            ValueStack<V> valueStack)
Creates a new RecordingParseRunner 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 RecordingParseRunner 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>

getErrorIndex

public int getErrorIndex()
Returns the index of the first InvalidInputError in the input text. Must not be called before the BasicParseRunner.run(String) has been called.

Returns:
the index of the first parse error or -1, if the input is error free.