def _extract_trigger_set(sr, Keyword, Pattern):
    if (Pattern is None):
        return None
    elif isinstance(Pattern, NumberSet):
        return Pattern

    def check_can_be_matched_by_single_character(SM):
        bad_f = False
        init_state = SM.get_init_state()
        if SM.get_init_state().is_acceptance():
            bad_f = True
        elif (len(SM.states) != 2):
            bad_f = True
        elif (len(init_state.target_map.get_target_state_index_list()) != 1):
            bad_f = True
        else:
            tmp = set(SM.states.keys())
            tmp.remove(SM.init_state_index)
            other_state_index = next(iter(tmp))
            if (len(SM.states[other_state_index].target_map.get_target_state_index_list()) != 0):
                bad_f = True
        if bad_f:
            error.log((("For '%s' only patterns are addmissible which\n" % Keyword) + 'can be matched by a single character, e.g. " " or [a-z].'), sr)
    sm = Pattern.extract_sm()
    check_can_be_matched_by_single_character(sm)
    transition_map = sm.get_init_state().target_map.get_map()
    assert (len(transition_map) == 1)
    return list(transition_map.values())[0]
def _extract_trigger_set(sr, Keyword, Pattern):
    if (Pattern is None):
        return None
    elif isinstance(Pattern, NumberSet):
        return Pattern

    def check_can_be_matched_by_single_character(SM):
        bad_f = False
        init_state = SM.get_init_state()
        if SM.get_init_state().is_acceptance():
            bad_f = True
        elif (len(SM.states) != 2):
            bad_f = True
        elif (len(init_state.target_map.get_target_state_index_list()) != 1):
            bad_f = True
        else:
            tmp = set(SM.states.keys())
            tmp.remove(SM.init_state_index)
            other_state_index = next(iter(tmp))
            if (len(SM.states[other_state_index].target_map.get_target_state_index_list()) != 0):
                bad_f = True
        if bad_f:
            error.log((("For '%s' only patterns are addmissible which\n" % Keyword) + 'can be matched by a single character, e.g. " " or [a-z].'), sr)
    sm = Pattern.extract_sm()
    check_can_be_matched_by_single_character(sm)
    transition_map = sm.get_init_state().target_map.get_map()
    assert (len(transition_map) == 1)
    return list(transition_map.values())[0]