org.parboiled.parserunners.TracingParseRunner Java Examples

The following examples show how to use org.parboiled.parserunners.TracingParseRunner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapSelectionExpressionParserTest.java    From jtwig-core with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: GroupWildcard.java    From batfish with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example #3
Source File: AsPathRegex.java    From batfish with Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example #4
Source File: TestBase.java    From nb-springboot with Apache License 2.0 4 votes vote down vote up
TestBase() {
    parser = Parboiled.createParser(CfgPropsParboiled.class);
    tracingRunner = new TracingParseRunner(parser.cfgProps());
    reportingRunner = new ReportingParseRunner(parser.cfgProps());
}
 
Example #5
Source File: JidCorpusParser.java    From jxmpp with Apache License 2.0 4 votes vote down vote up
private TracingParseRunner<J> getTracingParseRunner() {
	Rule parserRootRule = getParserRootRule();
	TracingParseRunner<J> runner = new TracingParseRunner<>(parserRootRule);
	return runner;
}