impl loop and add tests for both unary operators and loops

This commit is contained in:
Lukáš Hozda
2017-10-28 16:40:38 +02:00
parent 679f0de6b6
commit caf8a411aa
3 changed files with 72 additions and 0 deletions

View File

@@ -1153,6 +1153,19 @@ impl Engine {
}
}
}
Stmt::Loop(ref body) => {
loop {
match self.eval_stmt(scope, body) {
Err(EvalAltResult::LoopBreak) => {
return Ok(Box::new(()));
}
Err(x) => {
return Err(x);
}
_ => (),
}
}
}
Stmt::Break => Err(EvalAltResult::LoopBreak),
Stmt::Return => Err(EvalAltResult::Return(Box::new(()))),
Stmt::ReturnWithVal(ref a) => {