Logical ops work.

pull/15/head
Jussi Pakkanen 11 years ago
parent 9a19effb0f
commit 5266171487
  1. 9
      interpreter.py

@ -718,9 +718,9 @@ class Interpreter():
elif isinstance(cur, mparser2.MethodNode): elif isinstance(cur, mparser2.MethodNode):
return self.method_call(cur) return self.method_call(cur)
elif isinstance(cur, mparser2.StringNode): elif isinstance(cur, mparser2.StringNode):
return cur return cur.value
elif isinstance(cur, mparser2.BooleanNode): elif isinstance(cur, mparser2.BooleanNode):
return cur return cur.value
elif isinstance(cur, mparser2.IfClauseNode): elif isinstance(cur, mparser2.IfClauseNode):
return self.evaluate_if(cur) return self.evaluate_if(cur)
elif isinstance(cur, mparser2.IdNode): elif isinstance(cur, mparser2.IdNode):
@ -1296,6 +1296,7 @@ class Interpreter():
assert(isinstance(node, mparser2.IfClauseNode)) assert(isinstance(node, mparser2.IfClauseNode))
for i in node.ifs: for i in node.ifs:
result = self.evaluate_statement(i.condition) result = self.evaluate_statement(i.condition)
print(result)
if not(isinstance(result, bool)): if not(isinstance(result, bool)):
raise InvalidCode('If clause does not evaluate to true or false.') raise InvalidCode('If clause does not evaluate to true or false.')
if result: if result:
@ -1361,9 +1362,9 @@ class Interpreter():
return r return r
def evaluate_notstatement(self, cur): def evaluate_notstatement(self, cur):
v = self.evaluate_statement(cur.val) v = self.evaluate_statement(cur.value)
if isinstance(v, mparser2.BooleanNode): if isinstance(v, mparser2.BooleanNode):
v = v.get_value() v = v.value
if not isinstance(v, bool): if not isinstance(v, bool):
raise InterpreterException('Argument to "not" is not a boolean.') raise InterpreterException('Argument to "not" is not a boolean.')
return not v return not v

Loading…
Cancel
Save