def do_endloop(): DataProvider.set_peek_values_stack(DataProvider.peek_values_stack() - 1) if DataProvider.peek_values_stack() == 0: DataProvider.pop_command_stack() DataProvider.pop_values_stack() DataProvider.inc_current_line() # stepping over loop's goto
def parse_file(self, filename): filename = copy.deepcopy(filename) ModuleManager.download_default_modules() Logger.log("Compiling...") try: filename = self.__preproccessor.preprocess_file(filename) except Preprocessor.ParseException as exception: raise Interpreter.CompilationError("Compilation error: " + str(exception)) Logger.log("Compilation succeed. Running...") with open(filename) as f: lines = [line.rstrip() for line in f] while True: idx = DataProvider.get_current_line() try: line = lines[idx] except IndexError: break if len(line) == 0: DataProvider.inc_current_line() continue try: self.__parse_line(line) except Interpreter.RunTimeError as exception: raise Interpreter.RunTimeError( f"Runtime error. Line: {idx + 1}. " + str(exception)) DataProvider.inc_current_line() Logger.log("Program finished.")