<s> """<STR_LIT>""" <EOL> __author__ = """<STR_LIT>""" <EOL> IS_MAIN = True if __name__ == '<STR_LIT:__main__>' else False <EOL> if IS_MAIN : <EOL> from os import getcwd <EOL> from os import sys <EOL> sys . path . append ( getcwd ( ) ) <EOL> import time <EOL> from MOAL . helpers . display import Section <EOL> class JITCompiler : <EOL> """<STR_LIT>""" <EOL> class BASICLanguageInterpreter : <EOL> """<STR_LIT>""" <EOL> def tokenize ( self , code ) : <EOL> return code . split ( '<STR_LIT:\n>' ) <EOL> def interpret ( self , code ) : <EOL> for token in self . tokenize ( code ) : <EOL> if token : <EOL> yield token . strip ( ) . split ( '<STR_LIT:U+0020>' ) <EOL> class BASICBytecodeInterpreter : <EOL> """<STR_LIT>""" <EOL> def interpret ( self , code ) : <EOL> for token in code : <EOL> if len ( token ) > <NUM_LIT:1> : <EOL> func , arg = token <EOL> if func and arg : <EOL> signature = '<STR_LIT>' . format ( func , arg ) <EOL> yield func , arg , signature <EOL> class PythonVirtualMachineInterpreter : <EOL> """<STR_LIT>""" <EOL> def interpret ( self , code ) : <EOL> def _print ( arg ) : <EOL> print ( arg ) <EOL> def cls ( * args ) : <EOL> print ( '<STR_LIT>' ) <EOL> def sleep ( arg ) : <EOL> return time . sleep ( int ( args ) ) <EOL> control_table = dict ( <EOL> _print = _print , <EOL> sleep = sleep , <EOL> cls = cls , <EOL> ) <EOL> for token in code : <EOL> if len ( token ) > <NUM_LIT:2> : <EOL> func , args , signature = token <EOL> print ( '<STR_LIT>' . format ( signature ) ) <EOL> if func == '<STR_LIT>' : <EOL> print ( args ) <EOL> else : <EOL> if func in control_table : <EOL> yield control_table [ func ] ( args ) <EOL> def run ( self , prog ) : <EOL> for val in prog : <EOL> print ( val ) <EOL> if IS_MAIN : <EOL> with Section ( '<STR_LIT>' ) : <EOL> code = """<STR_LIT>""" <EOL> langint = BASICLanguageInterpreter ( ) <EOL> byteint = BASICBytecodeInterpreter ( ) <EOL> vm = PythonVirtualMachineInterpreter ( ) <EOL> code = langint . interpret ( code ) <EOL> code = byteint . interpret ( code ) <EOL> code = vm . interpret ( code ) <EOL> vm . run ( code ) </s>
