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.")
def do_label(label): DataProvider.set_label_line(label, DataProvider.get_current_line())