def load_std(self): """ Adds the core libraries to the environment """ for i in env.standard_env: libs = env.include_lib(i) for lib in libs: if lib[0] == "py": self.vm.env.update(lib[1]) elif lib[0] == "pyl": file_parse = FileParser(lib[1], self.vm) file_parse.run()
def main(): """ The main function called when the program is run. Will either start the interpreter or run a file if a filename is provided """ if len(sys.argv) == 1: from interpreter import Interpreter # Main loop which prompts user for input and print the response of the input handed to the rep function interpreter = Interpreter() interpreter.load_std() interpreter.cmdloop() else: from fileparser import FileParser from virtualmachine import VirtualMachine parser = FileParser(sys.argv[1], VirtualMachine({})) parser.load_std() parser.run()