Example #1
0
def do(txt, TheState, TheAnalyzer):
    specific = Handler(TheState)

    specific.debug_info_map_state_key_to_state_index(txt)

    # (*) Entry _______________________________________________________________
    entry_coder.do(txt, TheState, TheAnalyzer) 

    # (*) Access input character etc. _________________________________________
    specific.framework(txt, TheState, TheAnalyzer)

    # (*) Transition Map ______________________________________________________
    prepare_transition_map(TheState, TheAnalyzer, specific.state_key_str)
    transition_block.do(txt, 
                        TheState.transition_map, 
                        TheState.index, 
                        TheAnalyzer.engine_type, 
                        TheState.init_state_f, 
                        TheAnalyzer = TheAnalyzer) 

    # (*) Drop Out ____________________________________________________________
    drop_out_scheme_implementation(txt, TheState, TheAnalyzer, 
                                   specific.state_key_str, 
                                   specific.debug_drop_out_str)

    # (*) Request necessary variable definition _______________________________
    specific.require_data(TheState, TheAnalyzer)

    specific.debug_info_undo_map_state_key_to_state_index(txt)
    return
Example #2
0
def init_state_forward_epilog(txt, TheState, TheAnalyzer):
    assert TheState.init_state_forward_f
    global LanguageDB

    entry.do(txt, TheState, TheAnalyzer)
    txt.extend([
        "\n", 
        "    %s\n" % LanguageDB.INPUT_P_INCREMENT(),
        "    %s\n" % LanguageDB.GOTO(E_StateIndices.INIT_STATE_TRANSITION_BLOCK),
    ])
    return txt
Example #3
0
def do(code, TheState, TheAnalyzer):
    global LanguageDB
    assert isinstance(TheState, AnalyzerState)
    assert isinstance(TheAnalyzer, Analyzer)

    LanguageDB = Setup.language_db
    txt        = []

    # (*) Entry _______________________________________________________________
    if not TheState.init_state_forward_f:
        entry.do(txt, TheState, TheAnalyzer)
    else:
        # There is something special about the init state in forward direction:
        # It does not increment the input pointer initially. But when it is entered
        # from other states, is has to do so. Solution: Implement init state entry
        # as 'prologue' here (without increment) and epilogue (with increment) after 
        # the state. 
        txt.append(LanguageDB.LABEL_INIT_STATE_TRANSITION_BLOCK())

    # (*) Access the triggering character _____________________________________
    input_do(txt, TheState, TheAnalyzer)
    LanguageDB.STATE_DEBUG_INFO(txt, TheState)

    # (*) Transition Map ______________________________________________________
    transition_block.do(txt, 
                        TheState.transition_map, 
                        TheState.index, 
                        TheState.engine_type, 
                        TheState.init_state_f, 
                        TheAnalyzer=TheAnalyzer)

    # (*) Drop Out ____________________________________________________________
    drop_out.do(txt, TheState, TheAnalyzer)

    # ( ) Init state prologue (if necessary)
    if TheState.init_state_forward_f:
        init_state_forward_epilog(txt, TheState, TheAnalyzer)

    # (*) Cleaning Up _________________________________________________________
    for i, x in enumerate(txt):
        assert not isinstance(x, list), repr(txt[i-2:i+2])
        assert not x is None, txt[i-2:i+2]

    code.extend(txt)
Example #4
0
def do(TheReloadState):
    assert TheReloadState.index in (E_StateIndices.RELOAD_FORWARD, \
                                    E_StateIndices.RELOAD_BACKWARD)
    assert TheReloadState.entry.size() != 0

    txt, post_txt = entry.do(TheReloadState)
    txt.extend(
        Lng.RELOAD_PROCEDURE(ForwardF=(TheReloadState.index == E_StateIndices.RELOAD_FORWARD))
    )
    txt.extend(post_txt)
    return txt
Example #5
0
def do(code, TheState, TheAnalyzer):
    assert isinstance(TheState, AnalyzerState)
    assert isinstance(TheAnalyzer, Analyzer)

    # (*) Entry _______________________________________________________________
    txt, post_txt = entry.do(TheState)

    # (*) Transition Map ______________________________________________________
    tm = relate_to_TransitionCode(TheState.transition_map)
    transition_block.do(txt, tm)

    # (*) Post-state entry to init state (if necessary)
    txt.extend(post_txt) 

    # (*) Consistency check ___________________________________________________
    assert none_isinstance(txt, list)
    assert none_is_None(txt)
    code.extend(txt)
Example #6
0
def code_drop_out_catcher(txt, TheAnalyzer):
    pre_txt, post_txt = entry.do(TheAnalyzer.drop_out)
    txt.extend(pre_txt)
    txt.extend(post_txt)
Example #7
0
def code_drop_out_catcher(txt, TheAnalyzer):
    pre_txt, post_txt = entry.do(TheAnalyzer.drop_out)
    txt.extend(pre_txt)
    txt.extend(post_txt)