Permalink
Browse files

Added support for IF statement to interpreter.

  • Loading branch information...
1 parent 188ee28 commit a8d4b416fa9fc57c9e609038ea84d4070bde39b8 @ioquatix ioquatix committed Apr 4, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 pl1_interpreter.py
View
@@ -92,6 +92,15 @@ def accept_while(self, node):
self.evaluate(loop)
+ def accept_if(self, node):
+ condition = node[1]
+ body = node[2]
+
+ block, result = self.evaluate(condition)
+
+ if result:
+ self.evaluate(body)
+
def accept_condition(self, node):
operator = node[2]
lhs = self.evaluate(node[1])

0 comments on commit a8d4b41

Please sign in to comment.