![JAR search and dependency download from the Maven repository](/logo.png)
com.github.dakusui.jcunit.regex.Printer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcunit Show documentation
Show all versions of jcunit Show documentation
Automated combinatorial testing framework on top of JUnit
package com.github.dakusui.jcunit.regex;
import java.io.PrintStream;
public class Printer implements Expr.Visitor {
private final PrintStream ps;
public Printer(PrintStream ps) {
this.ps = ps;
}
@Override
public void visit(Expr.Alt exp) {
ps.print("(");
try {
boolean first = true;
for (Expr each : exp.getChildren()) {
if (!first) {
ps.print("|");
}
each.accept(this);
first = false;
}
} finally {
ps.print(")");
}
}
@Override
public void visit(Expr.Cat exp) {
boolean first = true;
for (Expr each : exp.getChildren()) {
if (!first) {
ps.print(" ");
}
each.accept(this);
first = false;
}
}
@Override
public void visit(Expr.Leaf leaf) {
ps.print(leaf.value());
}
@Override
public void visit(Expr.Empty empty) {
ps.print(empty);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy