public static <A extends Appendable> A render(RENode re, A appendable) throws IOException, NullPointerException { if (re == null) { throw new NullPointerException("No null disjunction accepted"); } if (appendable == null) { throw new NullPointerException("No null appendable accepted"); } // RERenderer renderer = new RERenderer(appendable); // re.accept(renderer); // return appendable; }
public static <A extends Appendable> A render(RENode re, A appendable) throws IOException, NullPointerException { if (re == null) { throw new NullPointerException("No null disjunction accepted"); } if (appendable == null) { throw new NullPointerException("No null appendable accepted"); } // RERenderer renderer = new RERenderer(appendable); // re.accept(renderer); // return appendable; }
@Override protected void visit(RENode.Group expr) throws RuntimeException { if (expr.getType() == GroupType.CAPTURING_GROUP) { try { RERenderer renderer = new RERenderer(current.resolvingExpression); expr.accept(renderer); } catch (IOException e) { // Should not happen throw new AssertionError(e); } try { RERenderer renderer = new RERenderer(current.valueMatcher); expr.accept(renderer); } catch (IOException e) { // Should not happen throw new AssertionError(e); } current.prefix = current.buffer.toString(); current.buffer.setLength(0); } else { super.visit(expr); } }
@Override protected void visit(RENode.Group expr) throws RuntimeException { if (expr.getType() == GroupType.CAPTURING_GROUP) { try { RERenderer renderer = new RERenderer(current.resolvingExpression); expr.accept(renderer); } catch (IOException e) { // Should not happen throw new AssertionError(e); } try { RERenderer renderer = new RERenderer(current.valueMatcher); expr.accept(renderer); } catch (IOException e) { // Should not happen throw new AssertionError(e); } current.prefix = current.buffer.toString(); current.buffer.setLength(0); } else { super.visit(expr); } }
private void assertTransform(String test, String expected, boolean capturing) throws SyntaxException, IOException { RENode node = new REParser(test).parse(); REVisitor<RuntimeException> transformer = capturing ? new CaptureGroupTransformation() : new NonCaptureGroupTransformation(); node.accept(transformer); StringBuilder sb = new StringBuilder(); RERenderer renderer = new RERenderer(sb); node.accept(renderer); assertEquals(expected, sb.toString()); } }
private void assertTransform(String test, String expected, boolean capturing) throws SyntaxException, IOException { RENode node = new REParser(test).parse(); REVisitor<RuntimeException> transformer = capturing ? new CaptureGroupTransformation() : new NonCaptureGroupTransformation(); node.accept(transformer); StringBuilder sb = new StringBuilder(); RERenderer renderer = new RERenderer(sb); node.accept(renderer); assertEquals(expected, sb.toString()); } }