Exemplo n.º 1
0
def __end_state_router(PathWalker, SMD):
    """After the last transition of the path, transit into the 'end state',
       i.e. the first state after the path. If the pathwalker contains multiple
       path, this might include state routing.  
    """
    assert PathWalker.uniform_state_entries_f()

    PathList     = PathWalker.path_list()
    PathN        = len(PathList)

    txt = []
    txt.append("        ")
    txt.append(LanguageDB["$input/decrement"] + "\n")
    txt.append("\n        ")

    # -- Transition to the first state after the path:
    if PathN == 1:
        # (i) There is only one path for the pathwalker, then there is only
        #     one terminal and it is determined at compilation time.
        txt.append(transition.get_transition_to_state(PathList[0].end_state_index()))
    else:
        # (ii) There are multiple paths for the pathwalker, then the terminal
        #      must be determined at run time.
        #   -- At the end of the path, path_iterator == path_end, thus we can identify
        #      the path by comparing simply against all path_ends.
        
        get_label("$state-router", U=True) # Make sure, that state router is referenced
        txt.append("QUEX_GOTO_STATE(path_end_state);")

    txt.append("\n")
    txt.append("    ")
    return txt
Exemplo n.º 2
0
def __switch_case_state_router(txt, SMD, PathWalker, StateIndexList=None):
    PathWalkerID = PathWalker.core().state_index
    
    txt.append("            ")
    value_txt = "(int)(path_iterator - path_walker_%i_base)" % PathWalkerID
    memory_index = 0
    case_code_list = []
    for path in PathWalker.path_list():
        for info in path.sequence():
            if StateIndexList == None or info[0] in StateIndexList:
                case_code_list.append((memory_index, 
                                       transition.get_transition_to_state(info[0], SMD)))
            memory_index += 1

    txt.extend(LanguageDB["$switch-block"](value_txt, case_code_list))
    txt.append("QUEX_ERROR_EXIT(\"Pathwalker: path_iterator on inadmissible position.\");\n")
Exemplo n.º 3
0
 def get_code(self):
     return [transition.get_transition_to_state(self.__target_state_index)]
Exemplo n.º 4
0
 def get_code(self):
     return [ transition.get_transition_to_state(self.__target_state_index) ]