Beispiel #1
0
 def get_LexemeEndCheck_appendix(ccfactory, CC_Type):
     if not LexemeEndCheckF:
         return [Op.GotoDoorId(door_id_loop)]
     #
     #       .---------------.        ,----------.   no
     #   --->| Count Op |-------< LexemeEnd? >------> DoorIdOk
     #       '---------------'        '----+-----'
     #                                     | yes
     #                              .---------------.
     #                              |  Lexeme End   |
     #                              | Count Op |----> DoorIdOnLexemeEnd
     #                              '---------------'
     #
     elif ccfactory.requires_reference_p(
     ) and CC_Type == E_CharacterCountType.COLUMN:
         return [
             Op.GotoDoorIdIfInputPNotEqualPointer(door_id_loop,
                                                  E_R.LexemeEnd),
             Op.ColumnCountReferencePDeltaAdd(
                 E_R.InputP, ccfactory.column_count_per_chunk, False),
         ] + AfterBeyond
     else:
         return [
             Op.GotoDoorIdIfInputPNotEqualPointer(door_id_loop,
                                                  E_R.LexemeEnd),
         ] + AfterBeyond
Beispiel #2
0
 def __replace_Lazy_DoorIdLoop(self, cmd, DoorIdLoop):
     if cmd.id == E_Op.GotoDoorId:
         if cmd.content.door_id != self.Lazy_DoorIdLoop: return cmd
         return Op.GotoDoorId(DoorIdLoop)
     elif cmd.id == E_Op.GotoDoorIdIfInputPNotEqualPointer:
         if cmd.content.door_id != self.Lazy_DoorIdLoop: return cmd
         return Op.GotoDoorIdIfInputPNotEqualPointer(
             DoorIdLoop, cmd.content.pointer)
     else:
         return cmd
Beispiel #3
0
    def get_loop_terminal_code(self, TheLoopMapEntry, DoorIdLoop,
                               DoorIdLoopExit):
        """RETURNS: A loop terminal. 

        A terminal: (i)    Counts,
                    (ii)   checks possibly for the lexeme end, and
                    (iii)a either re-enters the loop, or
                    (iii)b transits to an appendix state machine (couple terminal).
        """
        IncidenceId = TheLoopMapEntry.incidence_id
        AppendixSmId = TheLoopMapEntry.appendix_sm_id
        TheCountAction = TheLoopMapEntry.count_action

        code = []
        if TheCountAction is not None:
            code.extend(
                TheCountAction.get_OpList(self.column_number_per_code_unit))

        if AppendixSmId is not None:
            if not lei.appendix_sm_has_transitions_f:
                # If there is no appendix, directly goto to the terminal.
                code.extend([Op.GotoDoorId(DoorID.incidence_id(AppendixSmId))])
            else:
                assert not self.lexeme_end_check_f
                # Couple Terminal: transit to appendix state machine.
                code.extend([
                    Op.Assign(E_R.ReferenceP, E_R.InputP),
                    Op.GotoDoorId(DoorID.state_machine_entry(AppendixSmId))
                ])
        elif not self.lexeme_end_check_f:
            # Loop Terminal: directly re-enter loop.
            code.append(Op.GotoDoorId(DoorIdLoop))
        else:
            # Check Terminal: check against lexeme end before re-entering loop.
            code.append(
                Op.GotoDoorIdIfInputPNotEqualPointer(DoorIdLoop,
                                                     E_R.LexemeEnd))
            if     self.column_number_per_code_unit is not None \
               and TheCountAction is not None \
               and TheCountAction.cc_type == E_CharacterCountType.COLUMN:
                # With reference counting, no column counting while looping.
                # => Do it now, before leaving.
                code.append(
                    Op.ColumnCountReferencePDeltaAdd(
                        E_R.InputP, self.column_number_per_code_unit, False))
            code.append(Op.GotoDoorId(DoorIdLoopExit))

        return Terminal(CodeTerminal(Lng.COMMAND_LIST(code)),
                        "<LOOP TERMINAL %i>" % IncidenceId, IncidenceId)
Beispiel #4
0
 def _cmd_list_CA_LexemeEndCheck_GotoLoopEntry(self, CA):
     # Check Terminal: check against lexeme end before re-entering loop.
     cmd_list = [
         Op.GotoDoorIdIfInputPNotEqualPointer(self.Lazy_DoorIdLoop,
                                              E_R.LexemeEnd)
     ]
     if     self.column_number_per_code_unit is not None \
        and CA is not None and CA.cc_type == E_CharacterCountType.COLUMN:
         # With reference counting, no column counting while looping.
         # => Do it now, before leaving.
         cmd_list.append(
             Op.ColumnCountReferencePDeltaAdd(
                 E_R.InputP, self.column_number_per_code_unit, False))
     target_door_id = self.door_id_on_loop_exit_user_code
     return self._cmd_list_Frame(CA, cmd_list, target_door_id)