Пример #1
0
 def implement_prototype(StateIndices, TheAnalyzer):
     # There **must** be at least one element, at this point in time
     assert len(StateIndices) != 0
     prototype_i = StateIndices.__iter__().next()
     prototype = TheAnalyzer.state_db[prototype_i]
     result = []
     drop_out_coder.do(result, prototype, TheAnalyzer, DefineLabelF=False, MentionStateIndexF=False)
     return result
Пример #2
0
 def implement_prototype(StateIndices, TheAnalyzer):
     # There **must** be at least one element, at this point in time
     assert len(StateIndices) != 0
     prototype_i = StateIndices.__iter__().next()
     prototype   = TheAnalyzer.state_db[prototype_i]
     result      = []
     drop_out_coder.do(result, prototype, TheAnalyzer, \
                       DefineLabelF=False, MentionStateIndexF=False)
     return result
Пример #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)
Пример #4
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)