def do_pre_context(SM, PreContextSmIdList): """Pre-context detecting state machine (backward). --------------------------------------------------------------------------- Micro actions are: pre-context fullfilled_f DropOut --> Begin of 'main' state machine. BLC --> ReloadStateBackward EndOfStream --> 'error' Variables (potentially) required: pre_context_fulfilled_f[N] --> Array of flags for pre-context indication. RETURNS: [0] generated code text [1] reload state BACKWARD, to be generated later. """ if SM is None: return [], None txt, analyzer = do_state_machine(SM, engine.BACKWARD_PRE_CONTEXT) txt.append("\n%s:" % dial_db.get_label_by_door_id(DoorID.global_end_of_pre_context_check())) # -- set the input stream back to the real current position. # during backward lexing the analyzer went backwards, so it needs to be reset. txt.append(" %s\n" % Lng.INPUT_P_TO_LEXEME_START()) for sm_id in PreContextSmIdList: variable_db.require("pre_context_%i_fulfilled_f", Index = sm_id) variable_db.require("input") return txt, analyzer
def _get_pre_context_epilog_definition(dial_db): backup_position = Lng.REGISTER_NAME(E_R.BackupStreamPositionOfLexemeStartP) txt = [ Lng.LABEL(DoorID.global_end_of_pre_context_check(dial_db)), #------------------- Lng.IF(backup_position, "!=", "((QUEX_TYPE_STREAM_POSITION)-1)"), # "QUEX_NAME(Buffer_print_content)(&me->buffer);\n", # "std::cout << std::endl;\n", Lng.IF("false", "==", Lng.BUFFER_SEEK(backup_position)), Lng.RAISE_ERROR_FLAG("E_Error_File_SeekFailed"), Lng.RETURN, Lng.END_IF, Lng.LEXEME_START_SET(PositionStorage=None), # use '_read_p' # "std::cout << \"lexst \" << me->buffer._lexeme_start_p[0] << std::endl;", # "std::cout << \"readp \" << me->buffer._read_p[0] << std::endl;", # "QUEX_NAME(Buffer_print_content)(&me->buffer);\n", # "std::cout << std::endl;\n", Lng.ASSIGN(backup_position, "((QUEX_TYPE_STREAM_POSITION)-1)"), Lng.ELSE_FOLLOWS, #----------------------- # -- set the input stream back to the real current position. # during backward lexing the analyzer went backwards, so it needs to be reset. Lng.INPUT_P_TO_LEXEME_START(), Lng.END_IF, ] return [ "%s\n" % line for line in txt ]
def do_pre_context(SM, PreContextSmIdList): """Pre-context detecting state machine (backward). --------------------------------------------------------------------------- Micro actions are: pre-context fullfilled_f DropOut --> Begin of 'main' state machine. BLC --> ReloadStateBackward EndOfStream --> 'error' Variables (potentially) required: pre_context_fulfilled_f[N] --> Array of flags for pre-context indication. RETURNS: [0] generated code text [1] reload state BACKWARD, to be generated later. """ if SM is None: return [], None txt, analyzer = do_state_machine(SM, engine.BACKWARD_PRE_CONTEXT) txt.append( "\n%s:" % dial_db.get_label_by_door_id(DoorID.global_end_of_pre_context_check())) # -- set the input stream back to the real current position. # during backward lexing the analyzer went backwards, so it needs to be reset. txt.append(" %s\n" % Lng.INPUT_P_TO_LEXEME_START()) for sm_id in PreContextSmIdList: variable_db.require("pre_context_%i_fulfilled_f", Index=sm_id) variable_db.require("input") return txt, analyzer
def create_DropOut(self, SM_State): return OpList(Op.GotoDoorId(DoorID.global_end_of_pre_context_check()))