Example #1
0
    def __init__(self, SM_State, StateIndex, InitStateF, EngineType,
                 FromStateIndexList):
        assert isinstance(SM_State, State)
        assert isinstance(StateIndex, (int, long))
        assert type(InitStateF) is bool
        assert EngineType in E_EngineTypes
        assert isinstance(FromStateIndexList, set)

        self.__index = StateIndex
        self.__init_state_f = InitStateF
        self.__engine_type = EngineType

        if self.__init_state_f:
            if E_StateIndices.NONE not in FromStateIndexList:
                FromStateIndexList.add(E_StateIndices.NONE)

        # Test "quex/engine/analyzer/mega_state/template/TEST/best_matching_pair.py" would not work!
        # assert len(FromStateIndexList) != 0

        # (*) Entry Action
        if EngineType == E_EngineTypes.FORWARD:
            self.entry = Entry(self.__index, FromStateIndexList)
        elif EngineType == E_EngineTypes.BACKWARD_PRE_CONTEXT:
            pre_context_id_fulfilled_list = [ origin.pattern_id() for origin in SM_State.origins() \
                                                                  if origin.is_acceptance() ]
            self.entry = Entry(self.__index, FromStateIndexList,
                               pre_context_id_fulfilled_list)
        elif EngineType == E_EngineTypes.BACKWARD_INPUT_POSITION:
            self.entry = Entry(self.__index, FromStateIndexList)
        else:
            assert False

        # (*) Transition
        if EngineType == E_EngineTypes.BACKWARD_INPUT_POSITION:
            # During backward input detection, an acceptance SM_State triggers a
            # return from the searcher, thus no further transitions are necessary.
            # (orphaned states, also, need to be deleted).
            ## if SM_State.is_acceptance(): assert state.transitions().is_empty()
            pass

        self.transition_map = SM_State.transitions().get_trigger_map()
        self.__target_index_list = SM_State.transitions().get_map().keys()
        # Currently, the following is only used for path compression. If the alternative
        # is implemented, then the following is no longer necessary.
        self.map_target_index_to_character_set = SM_State.transitions(
        ).get_map()

        # (*) Drop Out
        if EngineType == E_EngineTypes.FORWARD:
            # DropOut and Entry interact and require sophisticated analysis
            # => See "Analyzer.get_drop_out_object(...)"
            self.drop_out = None

        elif EngineType == E_EngineTypes.BACKWARD_PRE_CONTEXT:
            self.drop_out = DropOutBackward()
        elif EngineType == E_EngineTypes.BACKWARD_INPUT_POSITION:
            self.drop_out = DropOutBackwardInputPositionDetection(
                SM_State.is_acceptance())

        self._origin_list = SM_State.origins().get_list()
Example #2
0
    def __init__(self):
        Entry.__init__(self)

        # Some transitions into a MegaState_Entry do not require a
        # 'SetStateKey' command. This is true, for example, for the recursive
        # transition in TemplateState-s or the 'on-path-transition' in
        # PathWalkerState-s. 
        #
        # If a transition shared a DoorID with another one which does not
        # contain a 'SetStateKey' command, then this is no longer the case
        # and the transition needs a new DoorID. The relation between the
        # new and the old DoorID is stored in 'self.transition_reassignment_db'.
        
        self.transition_reassignment_candidate_list = []
        self.__transition_reassignment_db           = None
Example #3
0
    def __init__(self):
        Entry.__init__(self)

        # Some transitions into a MegaState_Entry do not require a
        # 'SetStateKey' command. This is true, for example, for the recursive
        # transition in TemplateState-s or the 'on-path-transition' in
        # PathWalkerState-s. 
        #
        # If a transition shared a DoorID with another one which does not
        # contain a 'SetStateKey' command, then this is no longer the case
        # and the transition needs a new DoorID. The relation between the
        # new and the old DoorID is stored in 'self.transition_reassignment_db'.
        
        self.transition_reassignment_candidate_list = []
        self.__transition_reassignment_db           = None
Example #4
0
 def __init__(self, EngineType, InitStateIndex, dial_db):
     self.__engine_type = EngineType
     self.__init_state_index = InitStateIndex
     self.__state_db = {}
     self.dial_db = dial_db
     self.drop_out = Processor(E_StateIndices.DROP_OUT, Entry(self.dial_db))
     self.__state_machine_id = None
Example #5
0
 def __init__(self, StateIndex, TheTransitionMap):
     # Empty transition maps are reported as 'None'
     Processor.__init__(self, StateIndex, Entry())
     self.map_target_index_to_character_set = None
     self.transition_map                    = TheTransitionMap
Example #6
0
 def __init__(self, EngineType):
     if EngineType.is_FORWARD(): index = E_StateIndices.RELOAD_FORWARD
     else:                       index = E_StateIndices.RELOAD_BACKWARD
     Processor.__init__(self, index, Entry())
Example #7
0
 def __init__(self, MegaStateIndex):
     Entry.__init__(self, MegaStateIndex, FromStateIndexList=[])
Example #8
0
 def __init__(self, StateIndex, TransitionDB, DoorDB):
     Entry.__init__(self, StateIndex, FromStateIndexList=[])
     self.set_transition_db(TransitionDB)
     self.set_door_db(DoorDB)
Example #9
0
 def __init__(self, Code, Name=""):
     Processor.__init__(self, index.get(), Entry())
     self.__incidence_id = None
     self.__code = Code
     self.__name = Name
Example #10
0
 def __init__(self, Code, Name, IncidenceId=None):
     Processor.__init__(self, index.get(), Entry())
     self.__incidence_id = IncidenceId
     self.__code = Code
     self.__name = Name
     self.__requires_goto_loop_entry_f = False
Example #11
0
 def __init__(self, EngineType, dial_db):
     if EngineType.is_FORWARD(): index = E_StateIndices.RELOAD_FORWARD
     else:                       index = E_StateIndices.RELOAD_BACKWARD
     Processor.__init__(self, index, Entry(dial_db))
     self.engine_type = EngineType
     self.dial_db     = dial_db
Example #12
0
 def __init__(self, MegaStateIndex):
     Entry.__init__(self, MegaStateIndex, FromStateIndexList=[])
Example #13
0
 def __init__(self, StateIndex, TransitionDB, DoorDB):
     Entry.__init__(self, StateIndex, FromStateIndexList=[])
     self.set_transition_db(TransitionDB)
     self.set_door_db(DoorDB)