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 __preprocess_line(self, line, w): # comments line = line.split('#')[0] parts = line.strip().split() # no action in this string if len(parts) == 0: w.write('\n') return command, *params = parts if ModuleManager.module_was_loaded('CORE'): try: CommonValidator.check_if_variable_exists(command) leading_spaces = self.__get_leading_spaces(line) line = " ".join([ ' ' * leading_spaces, Semantic.get_symbol('var'), line.lstrip() ]) parts = line.strip().split() command, *params = parts except Exception as ignored: pass try: self.__validator.validate('command', (command, params)) except Validator.ValidationError as exception: raise Preprocessor.ParseException(f"Command: `{command}`. " + str(exception)) if command == Semantic.get_symbol('var'): DataProvider.set_variable_value(params[0], None) elif DataProvider.is_opening_command(command): DataProvider.append_command_stack(command) elif DataProvider.is_closing_command(command): DataProvider.pop_command_stack() try: self.__command_to_func[command](line, w) except KeyError: w.write(line + '\n')