def get_info(StateIndexList): """ NOTE: At least a 'dummy' state router is always equired so that 'goto QUEX_STATE_ROUTER;' does not reference a non-existing label. Then, we return an empty text array. <fschaef9/13y10m15d: "Still true with current dial_db implementation?"> """ if len(StateIndexList) == 0: return [] # Make sure, that for every state the 'drop-out' state is also mentioned result = [None] * len(StateIndexList) for i, index in enumerate(StateIndexList): assert type(index) != str if index >= 0: # Transition to state entry label = dial_db.get_label_by_address(index) else: assert False, "Is this still an issue?" # Transition to a templates 'drop-out' door_id = DoorID.drop_out(- index) label = dial_db.get_label_by_door_id(door_id) result[i] = (index, "goto %s; " % label) dial_db.mark_label_as_gotoed(label) return result
def get_info(StateIndexList, dial_db): """ NOTE: At least a 'dummy' state router is always equired so that 'goto QUEX_STATE_ROUTER;' does not reference a non-existing label. Then, we return an empty text array. <fschaef9/13y10m15d: "Still true with current dial_db implementation?"> """ if len(StateIndexList) == 0: return [] # Make sure, that for every state the 'drop-out' state is also mentioned result = [None] * len(StateIndexList) for i, index in enumerate(StateIndexList): assert type(index) != str if index >= 0: # Transition to state entry adr = index else: assert False, "Is this still an issue?" # Transition to a templates 'drop-out' adr = DoorID.drop_out(-index, dial_db).related_address result[i] = (index, Lng.GOTO_ADDRESS(adr, dial_db)) return result
def get_info(StateIndexList): """ NOTE: At least a 'dummy' state router is always equired so that 'goto QUEX_STATE_ROUTER;' does not reference a non-existing label. Then, we return an empty text array. <fschaef9/13y10m15d: "Still true with current dial_db implementation?"> """ if len(StateIndexList) == 0: return [] # Make sure, that for every state the 'drop-out' state is also mentioned result = [None] * len(StateIndexList) for i, index in enumerate(StateIndexList): assert type(index) != str if index >= 0: # Transition to state entry label = dial_db.get_label_by_address(index) else: assert False, "Is this still an issue?" # Transition to a templates 'drop-out' door_id = DoorID.drop_out(-index) label = dial_db.get_label_by_door_id(door_id) result[i] = (index, "goto %s; " % label) dial_db.mark_label_as_gotoed(label) return result
def get_main_function(tm0, TranstionTxt, Codec): def indent(Txt, N): return (" " * N) + (Txt.replace("\n", "\n" + (" " * N))) input_preperation = get_read_preparation(codec) entry_list = [(0 if interval.begin < 0 else interval.begin, target) for interval, target in tm0] entry_list.append((tm0[-1][0].begin, -1)) entry_list.append((0x1FFFF, -1)) expected_array = [ " { 0x%06X, %s },\n" % (begin, target) for begin, target in entry_list ] txt = main_template.replace("$$ENTRY_LIST$$", "".join(expected_array)) txt = txt.replace("$$TRANSITION$$", indent(TranstionTxt, 4)) txt = txt.replace("$$PREPARE_INPUT$$", input_preperation) door_id = DoorID.incidence(E_IncidenceIDs.BAD_LEXATOM, dial_db) txt = txt.replace("$$ON_BAD_LEXATOM$$", Lng.LABEL_STR(door_id, dial_db)) txt = txt.replace("$$DROP_OUT_MINUS_1$$", Lng.LABEL_STR(DoorID.drop_out(-1, dial_db))) txt = txt.replace("MATCH_FAILURE", "((int)-1)") return txt
def get_transition_function(iid_map, Codec): if Codec == "UTF8": Setup.buffer_codec_prepare("utf8", Module=utf8_state_split) else: Setup.buffer_codec_prepare("unicode") cssm = CharacterSetStateMachine(iid_map, MaintainLexemeF=False) analyzer = analyzer_generator.do(cssm.sm, engine.CHARACTER_COUNTER) tm_txt = do_analyzer(analyzer) tm_txt = Lng.GET_PLAIN_STRINGS(tm_txt) tm_txt.append("\n") label = dial_db.get_label_by_door_id(DoorID.incidence(E_IncidenceIDs.MATCH_FAILURE)) for character_set, iid in iid_map: tm_txt.append("%s return (int)%s;\n" % (Lng.LABEL(DoorID.incidence(iid)), iid)) tm_txt.append("%s return (int)-1;\n" % Lng.LABEL(DoorID.drop_out(-1))) return "".join(tm_txt)
def get_transition_function(iid_map, Codec): if Codec == "UTF8": Setup.buffer_codec_set(bc_factory.do("utf8"), 1) else: Setup.buffer_codec_set(bc_factory.do("unicode"), -1) sm = StateMachine.from_IncidenceIdMap(iid_map) dummy, sm = Setup.buffer_codec.do_state_machine(sm, beautifier) analyzer = analyzer_generator.do(sm, engine.CHARACTER_COUNTER) tm_txt = do_analyzer(analyzer) tm_txt = Lng.GET_PLAIN_STRINGS(tm_txt) tm_txt.append("\n") #label = dial_db.get_label_by_door_id(DoorID.incidence(E_IncidenceIDs.MATCH_FAILURE)) for character_set, iid in iid_map: tm_txt.append("%s return (int)%s;\n" % (Lng.LABEL(DoorID.incidence(iid)), iid)) tm_txt.append("%s return (int)-1;\n" % Lng.LABEL(DoorID.drop_out(-1))) return "".join(tm_txt)
def get_transition_function(iid_map, Codec): if Codec == "UTF8": Setup.buffer_codec_prepare("utf8", Module=utf8_state_split) else: Setup.buffer_codec_prepare("unicode") cssm = CharacterSetStateMachine(iid_map, MaintainLexemeF=False) analyzer = analyzer_generator.do(cssm.sm, engine.CHARACTER_COUNTER) tm_txt = do_analyzer(analyzer) tm_txt = Lng.GET_PLAIN_STRINGS(tm_txt) tm_txt.append("\n") label = dial_db.get_label_by_door_id( DoorID.incidence(E_IncidenceIDs.MATCH_FAILURE)) for character_set, iid in iid_map: tm_txt.append("%s return (int)%s;\n" % (Lng.LABEL(DoorID.incidence(iid)), iid)) tm_txt.append("%s return (int)-1;\n" % Lng.LABEL(DoorID.drop_out(-1))) return "".join(tm_txt)
def get_transition_function(iid_map, Codec): global dial_db if Codec == "UTF8": Setup.buffer_setup("uint8_t", 1, "utf8") else: Setup.buffer_setup("uint32_t", 4, "none") Setup.bad_lexatom_detection_f = False sm = DFA.from_IncidenceIdMap(iid_map) analyzer = analyzer_generator.do(sm, engine.CHARACTER_COUNTER, dial_db=dial_db, CutF=False) tm_txt = do_analyzer(analyzer) tm_txt = Lng.GET_PLAIN_STRINGS(tm_txt, dial_db=dial_db) tm_txt.append("\n") #label = dial_db.get_label_by_door_id(DoorID.incidence(E_IncidenceIDs.MATCH_FAILURE)) for character_set, iid in iid_map: tm_txt.append("%s return (int)%s;\n" % (Lng.LABEL(DoorID.incidence(iid, dial_db)), iid)) tm_txt.append("%s return (int)-1;\n" % Lng.LABEL(DoorID.drop_out(-1, dial_db))) return "".join(tm_txt)