Source:
public int run(CompiledDefinition compiledDef, KRunOptions options, Function<Module, Rewriter> rewriterGenerator, ExecutionMode executionMode) { String pgmFileName = options.configurationCreation.pgm(); K program; if (options.configurationCreation.term()) { program = externalParse(options.configurationCreation.parser(compiledDef.executionModule().name()), pgmFileName, compiledDef.programStartSymbol, Source.apply("<parameters>"), compiledDef); } else { program = parseConfigVars(options, compiledDef); } Rewriter rewriter = rewriterGenerator.apply(compiledDef.executionModule()); Object result = executionMode.execute(program, rewriter, compiledDef); if (result instanceof K) { prettyPrint(compiledDef, options.output, s -> outputFile(s, options), (K) result); } else if (result instanceof Tuple2) { Tuple2<?, ?> tuple = (Tuple2<?, ?>) result; if (tuple._1() instanceof K && tuple._2() instanceof Integer) { prettyPrint(compiledDef, options.output, s -> outputFile(s, options), (K) tuple._1()); return (Integer) tuple._2(); } } else if (result instanceof SearchResult) { List<? extends Map<? extends KVariable, ? extends K>> searchResult = ((SearchResult) result).getSearchList(); if (searchResult == null || searchResult.isEmpty()) { outputFile("No Search Results \n", options); return 0; } int i = 0; for (Map<? extends KVariable, ? extends K> substitution : searchResult) { outputFile("Solution: " + (i++) + "\n", options); prettyPrintSubstitution(substitution, ((SearchResult) result).getParsedRule(), compiledDef, options.output, s -> outputFile(s, options)); } return 0; } return 0; }

Target:
public int run(CompiledDefinition compiledDef, KRunOptions options, Function<Module, Rewriter> rewriterGenerator, ExecutionMode executionMode) { String pgmFileName = options.configurationCreation.pgm(); K program; if (options.configurationCreation.term()) { program = externalParse(options.configurationCreation.parser(compiledDef.executionModule().name()), pgmFileName, compiledDef.programStartSymbol, Source.apply("<parameters>"), compiledDef); } else { program = parseConfigVars(options, compiledDef); } Rewriter rewriter = rewriterGenerator.apply(compiledDef.executionModule()); Object result = executionMode.execute(program, rewriter, compiledDef); if (result instanceof K) { prettyPrint(compiledDef, options.output, s -> outputFile(s, options), (K) result); if (options.exitCodePattern != null) { Rule exitCodePattern = compilePattern(files, kem, options.exitCodePattern, options, compiledDef, Source.apply("<command line: --exit-code>")); List<? extends Map<? extends KVariable, ? extends K>> res = rewriter.match((K) result, exitCodePattern); return getExitCode(kem, res); } } else if (result instanceof Tuple2) { Tuple2<?, ?> tuple = (Tuple2<?, ?>) result; if (tuple._1() instanceof K && tuple._2() instanceof Integer) { prettyPrint(compiledDef, options.output, s -> outputFile(s, options), (K) tuple._1()); return (Integer) tuple._2(); } if (tuple._1() instanceof SearchResult && tuple._2() instanceof Integer) { printSearchResult((SearchResult) tuple._1(), options, compiledDef); return (Integer) tuple._2(); } } else if (result instanceof SearchResult) { printSearchResult((SearchResult) result, options, compiledDef); return 0; } else if (options.experimental.prove != null) { if (((List) result).isEmpty()) { System.out.println("true"); } } return 0; }