Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running the evaluator from the CLI #308

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public void _exec(ExecOptions options) throws Exception {
}
}
OutputTrace trace = new OutputTrace(quiet || outdir == null ? null : stderr);
Map<CommandInfo, A4Solution> answers = new TreeMap<>();
int n = 0;

int repeat = options.repeat(1);
Expand Down Expand Up @@ -281,9 +280,9 @@ public void _exec(ExecOptions options) throws Exception {
trace.format(" expects=%s", c.expects);
error("'%s' was satisfied against expectation",c);
}

if (options.evaluator() && !answers.isEmpty()) {
evaluator(world, answers);
trace.format("\n");
if (options.evaluator()) {
evaluator(world, solution);
}
}
n++;
Expand Down Expand Up @@ -358,19 +357,15 @@ private String getStem(File file) {
return parts[0];
}

private void evaluator(CompModule world, Map<CommandInfo, A4Solution> answers) throws Exception {
for (Entry<CommandInfo, A4Solution> s : answers.entrySet()) {
A4Solution sol = s.getValue();
if (sol.satisfiable()) {
stdout.println("Evaluator for " + s.getKey().command);
stdout.flush();
Evaluator e = new Evaluator(world, sol, stdin, stdout);
String lastCommand = e.loop();
if (lastCommand.equals("/exit"))
break;
}
private void evaluator(CompModule world, A4Solution sol) throws Exception {
if (sol.satisfiable()) {
stdout.println("Evaluator for latest command");
stdout.flush();
Evaluator e = new Evaluator(world, sol, stdin, stdout);
String lastCommand = e.loop();
if (lastCommand == null || lastCommand.equals("/exit"))
return;
}
stdout.println("bye");
}

@Arguments(arg = "path")
Expand Down