Java源码示例:org.parboiled.parserunners.TracingParseRunner
示例1
@Test
public void expressionRule() throws Exception {
DefaultJtwigParserConfiguration config = new DefaultJtwigParserConfiguration();
ParserContext context = ParserContext.instance(
ResourceReference.inline("Hello"),
config,
config.getAddonParserProviders(),
config.getUnaryOperators(),
config.getBinaryOperators(),
config.getTestExpressionParsers()
);
MapSelectionExpressionParser parser = context.parser(MapSelectionExpressionParser.class);
TracingParseRunner<Expression> runner = new TracingParseRunner<>(parser.ExpressionRule());
ParsingResult<Expression> result = runner.run("list[position.size]");
Expression resultValue = result.resultValue;
System.out.println(resultValue);
}
示例2
/** Like {@link #toJavaRegex(String)}, but for debugging. */
@SuppressWarnings("unused") // leaving here for future debugging.
@Nonnull
static String debugToJavaRegex(String regex) {
GroupWildcard parser = Parboiled.createParser(GroupWildcard.class);
TracingParseRunner<String> runner =
new TracingParseRunner<String>(parser.TopLevel()).withLog(new StringBuilderSink());
ParsingResult<String> result = runner.run(regex);
if (!result.matched) {
throw new IllegalArgumentException("Unhandled input: " + regex + "\n" + runner.getLog());
}
return result.resultValue;
}
示例3
/** Like {@link #convertToJavaRegex(String)}, but for debugging. */
@SuppressWarnings("unused") // leaving here for future debugging.
@Nonnull
static String debugConvertToJavaRegex(String regex) {
AsPathRegex parser = Parboiled.createParser(AsPathRegex.class);
TracingParseRunner<String> runner =
new TracingParseRunner<String>(parser.TopLevel()).withLog(new StringBuilderSink());
ParsingResult<String> result = runner.run(regex);
if (!result.matched) {
throw new IllegalArgumentException("Unhandled input: " + regex + "\n" + runner.getLog());
}
return result.resultValue;
}
示例4
TestBase() {
parser = Parboiled.createParser(CfgPropsParboiled.class);
tracingRunner = new TracingParseRunner(parser.cfgProps());
reportingRunner = new ReportingParseRunner(parser.cfgProps());
}
示例5
private TracingParseRunner<J> getTracingParseRunner() {
Rule parserRootRule = getParserRootRule();
TracingParseRunner<J> runner = new TracingParseRunner<>(parserRootRule);
return runner;
}