String prologGrammarPath = outputDir + File.separator + baseName + ".pl";
AGEvaluatorSwipl.writeFile(prologGrammarPath, prologGrammar);
if (verbose) System.out.println("=== PL GRAMMAR: === \n " + prologGrammar);
ages.runGrammar(resourceDir, prologGrammarPath);
Schedule sched = ages.generateVisits(isFixedChildOrder, isExhaustive, false, maxLen, grammar.alegEval, grammar.ast);
HashMap<String, String> exprPrinter = genExprPrinter(sched._aleg, grammar.ast.condsTop, sched);
HashMap<String, String> exprToCall = genExprToCall(sched._aleg, grammar.ast.condsTop, sched, exprPrinter);
////////////////////////////////////////////////////////////////
Hashtable<Variable, Term> binding = null;
int round = 0;
(new File(outputDir + File.separator + "variants")).mkdir();
String fHeaders = functionHeaders(grammar.ast);
long queryTime = -System.currentTimeMillis();
System.err.println("Start time: " + queryTime + "ms");
long timeSinceLastQuery = -System.currentTimeMillis();
int found = 0;
int cumQTime = 0;
while (sched.hasNext()) {
found++;
binding = sched.moveNext();
//if (!sched.isAllParallel()) continue;
long qTime = timeSinceLastQuery + System.currentTimeMillis();
cumQTime += qTime;
String seq = "";
for (Term visit : sched.binding.get("P").toTermArray()) {
seq += " " + visit.arg(2).arg(1).toString().replace("tdLtrU", "inorder");
}
System.err.println("sched: " + seq);
System.err.println("find time: " + qTime + "ms");
System.err.println("Running average: " + (cumQTime / found) + "ms/query (over " + found + " queries)");
long compeTime = -System.currentTimeMillis();
(new File(outputDir + File.separator + "variants/variant" + round)).mkdir();
backend.generateParseFiles(grammar.ast, sched, outputDir + File.separator + "variants/variant" + round + File.separator, verbose, fHeaders);
LoopRecoverer ir = new LoopRecoverer(sched);
String visitOut =
backend.preVisits(grammar.alegEval, sched)
+ visits(sched._aleg, ir, binding, sched.computeVisitOrders(), sched.classMap, exprToCall, exprPrinter, sched)
+ backend.postVisits(grammar.alegEval, sched);
String visitDispatches = visitDispatchers(sched.numVisits(), grammar.alegEval, sched.buSubInorderBuIn, sched.buSubInorderBus);
backend.output(baseName, visitOut, visitDispatches, outputDir + File.separator + "variants/variant" + round + File.separator, true, verbose, grammar.ast, sched, fHeaders, binding, grammar.alegEval);
AGEvaluatorSwipl.writeFile(outputDir + File.separator + "variants/variant" + round + File.separator + "schedule", seq);
round++;
//if (!isExhaustive) {