diff --git a/code.txt b/code.txt index a360497..631e2de 100755 --- a/code.txt +++ b/code.txt @@ -12,5 +12,10 @@ Set Name To System Read EndSet BeginNote Reads an entire line EndNote Set Prefix To BeginText Hi there, EndText EndSet Set Greeting To Prefix Append Name EndSet -System Print Greeting Done + +If Name Equals BeginText Jookia EndText +Then System Print BeginText Hi creator! EndText +Else System Print Greeting +EndIf + System Exit Done diff --git a/interp.py b/interp.py index c899b2c..757904d 100644 --- a/interp.py +++ b/interp.py @@ -103,7 +103,14 @@ return self.env[ast.subject] def run_conditional(self, ast): - raise InterpreterError("Conditionals are unimplemented") + test = self.run_statement(ast.test) + if test.__class__ != Bool: + raise InterpreterError("Test condition didn't return a boolean") + if test.value(): + ret = self.run_statement(ast.success) + else: + ret = self.run_statement(ast.failure) + return ret def run_command(self, ast): if ast.__class__ == ast_types.Statement: