Browse Source

Interprete loop recursively

pull/1/head
Malte Schmitz 9 years ago
parent
commit
bce0129994
1 changed files with 3 additions and 7 deletions
  1. +3
    -7
      src/interpreter/Interpreter.java

+ 3
- 7
src/interpreter/Interpreter.java View File

@@ -49,15 +49,11 @@ public class Interpreter extends ProgramVisitor {
} }
} }


private boolean enterLoop(Loop loop) {
Evaluator evaluator = new Evaluator(loop.condition, valuation);
return evaluator.eval() != 0;
}

@Override @Override
public void visitLoop(Loop loop) { public void visitLoop(Loop loop) {
while(enterLoop(loop)) {
visit(loop.program);
Evaluator evaluator = new Evaluator(loop.condition, valuation);
if (evaluator.eval() != 0) {
visit(new Composition(loop.program, loop));
} }
} }
} }

Loading…
Cancel
Save