Package org.parboiled.parserunners
Class TracingParseRunner<V>
- java.lang.Object
-
- org.parboiled.parserunners.AbstractParseRunner<V>
-
- org.parboiled.parserunners.ReportingParseRunner<V>
-
- org.parboiled.parserunners.TracingParseRunner<V>
-
- All Implemented Interfaces:
MatchHandler
,ParseRunner<V>
public class TracingParseRunner<V> extends ReportingParseRunner<V> implements MatchHandler
AParseRunner
implementation used for debugging purposes. It exhibits the same behavior as theReportingParseRunner
but collects debugging information as to which rules did match and which didn't.
-
-
Constructor Summary
Constructors Constructor Description TracingParseRunner(Rule rule)
Creates a new TracingParseRunner instance without filter and a console log for the given rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Predicate<Tuple2<Context<?>,java.lang.Boolean>>
getFilter()
Sink<java.lang.String>
getLog()
boolean
match(MatcherContext<?> context)
Runs the given MatcherContext.protected ParsingResult<V>
runBasicMatch(InputBuffer inputBuffer)
TracingParseRunner<V>
withFilter(Predicate<?> filter)
Attaches the given filter to this TracingParseRunner instance.TracingParseRunner<V>
withLog(Sink<java.lang.String> log)
Attaches the given log to this TracingParseRunner instance.-
Methods inherited from class org.parboiled.parserunners.ReportingParseRunner
run, run, runLocatingMatch, runReportingMatch
-
Methods inherited from class org.parboiled.parserunners.AbstractParseRunner
createParsingResult, createRootContext, getParseErrors, getRootMatcher, getValueStack, resetValueStack, run, run, withParseErrors, withValueStack
-
-
-
-
Constructor Detail
-
TracingParseRunner
public TracingParseRunner(Rule rule)
Creates a new TracingParseRunner instance without filter and a console log for the given rule.- Parameters:
rule
- the parser rule
-
-
Method Detail
-
withFilter
public TracingParseRunner<V> withFilter(Predicate<?> filter)
Attaches the given filter to this TracingParseRunner instance. The given filter is used to select the matchers to print tracing statements for. NOTE: The given filter must be of type Predicate, Boolean>>. The reason this type is not directly specified in the constructors signature is that this would make predicate expressions using the Predicates
operations and the predefined predicate constructors inFilters
much more cumbersome to write (due to Java limited type parameters inference logic you would have to explicitly state the type parameters in many places).- Parameters:
filter
- the matcher filter selecting the matchers to print tracing statements for. Must be of type Predicate, Boolean>>. - Returns:
- this instance
-
withLog
public TracingParseRunner<V> withLog(Sink<java.lang.String> log)
Attaches the given log to this TracingParseRunner instance.- Parameters:
log
- the log to use- Returns:
- this instance
-
getLog
public Sink<java.lang.String> getLog()
-
runBasicMatch
protected ParsingResult<V> runBasicMatch(InputBuffer inputBuffer)
- Overrides:
runBasicMatch
in classReportingParseRunner<V>
-
match
public boolean match(MatcherContext<?> context)
Description copied from interface:MatchHandler
Runs the given MatcherContext.- Specified by:
match
in interfaceMatchHandler
- Parameters:
context
- the MatcherContext- Returns:
- true if matched
-
-