File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
PascalInterpreter/PascalInterpreter/Interpreter Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ public class Interpreter {
4848 return eval ( ifElse: ifElse)
4949 case let repeatUntil as RepeatUntil :
5050 return eval ( repeatUntil: repeatUntil)
51+ case let whileLoop as While :
52+ return eval ( whileLoop: whileLoop)
5153 case let forLoop as For :
5254 return eval ( forLoop: forLoop)
5355 default :
@@ -182,6 +184,14 @@ public class Interpreter {
182184 return . none
183185 }
184186
187+ func eval( whileLoop: While ) -> Value {
188+ while case . boolean( true ) = eval ( condition: whileLoop. condition) {
189+ eval ( node: whileLoop. statement)
190+ }
191+
192+ return . none
193+ }
194+
185195 func eval( forLoop: For ) -> Value {
186196 guard let currentFrame = callStack. peek ( ) else {
187197 fatalError ( " No call stack frame " )
You can’t perform that action at this time.
0 commit comments