Skip to content

Commit

Permalink
write preprocessed program to stdout using -- as path
Browse files Browse the repository at this point in the history
  • Loading branch information
madmike200590 committed Aug 24, 2020
1 parent 9878287 commit e31e3bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/main/java/at/ac/tuwien/kr/alpha/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,22 @@ private static void writeComponentGraph(ComponentGraph cg, String path) {
*/
private static void writeInternalProgram(InternalProgram prg, String path) {
LOGGER.debug("Writing preprocessed program to {}", path);
try (PrintStream ps = new PrintStream(new File(path))) {
PrintStream ps = null;
try {
if (path.equals(InputConfig.PREPROC_STDOUT_PATH)) {
ps = System.out;
} else {
ps = new PrintStream(new File(path));
}
ps.println(prg.toString());
} catch (IOException ex) {
LOGGER.error("Failed writing preprocessed program file", ex);
Main.bailOut("Failed writing preprocessed program file " + ex.getMessage());
}
}

private static void computeAndConsumeAnswerSets(Alpha alpha, InputConfig inputCfg, InternalProgram program) {
private static void computeAndConsumeAnswerSets(Alpha alpha, InputConfig inputCfg,
InternalProgram program) {
Solver solver = alpha.prepareSolverFor(program, inputCfg.getFilter());
Stream<AnswerSet> stream = solver.stream();
if (alpha.getConfig().isSortAnswerSets()) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/at/ac/tuwien/kr/alpha/config/InputConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import at.ac.tuwien.kr.alpha.common.fixedinterpretations.PredicateInterpretation;

public class InputConfig {

public static final java.util.function.Predicate<Predicate> DEFAULT_FILTER = p -> true;
public static final boolean DEFAULT_LITERATE = false;
public static final int DEFAULT_NUM_ANSWER_SETS = 0;
Expand All @@ -21,6 +21,7 @@ public class InputConfig {
public static final String DEFAULT_COMPGRAPH_TARGET_FILE = "compgraph.dot";
public static final boolean DEFAULT_WRITE_PREPROCESSED_PROG = false;
public static final String DEFAULT_PREPROC_TARGET_FILE = "input.preproc.asp";
public static final String PREPROC_STDOUT_PATH = "--"; // indicator preprocessed program should be written to stdout
public static final boolean DEFAULT_WRITE_XLSX = false;
public static final String DEFAULT_XLSX_OUTFILE_PATH = "alphaAnswerSet"; // current directory, files named "alphaAnswerSet.{num}.{ext}"

Expand Down

0 comments on commit e31e3bb

Please sign in to comment.