示例#1
0
文件: loop.py 项目: mplucinski/quex
def _get_source_code(CcFactory, analyzer, terminal_list):
    """RETURNS: String containing source code for the 'loop'. 

       -- The source code for the (looping) state machine.
       -- The terminals which contain counting actions.

    Also, it requests variable definitions as they are required.
    """
    txt = []
    txt.extend(
        generator.do_analyzer(analyzer)
    )
    txt.extend(
        generator.do_terminals(terminal_list, analyzer)
    )
    if analyzer.engine_type.subject_to_reload():
        txt.extend(
            generator.do_reload_procedure(analyzer)
        )

    if CcFactory.requires_reference_p():   
        variable_db.require("reference_p", Condition="QUEX_OPTION_COLUMN_NUMBER_COUNTING")
    if Setup.buffer_codec.variable_character_sizes_f(): 
        variable_db.require("character_begin_p")
    return txt
示例#2
0
文件: loop.py 项目: xxyzzzq/quex
def _get_source_code(analyzer_list, terminal_list, ColumnNPerChunk, 
                     AppendixSmExistF):
    """RETURNS: String containing source code for the 'loop'. 

       -- The source code for the (looping) state machine.
       -- The terminals which contain counting actions.

    Also, it requests variable definitions as they are required.
    """
    txt = flatten_list_of_lists(
        generator.do_analyzer(analyzer) for analyzer in analyzer_list
    )
    txt.extend(
        generator.do_terminals(terminal_list, TheAnalyzer=None)
    )
    loop_analyzer = analyzer_list[0]
    if loop_analyzer.engine_type.subject_to_reload():
        txt.extend(
            generator.do_reload_procedure(loop_analyzer)
        )

    if AppendixSmExistF or ColumnNPerChunk is not None:
        variable_db.require("reference_p", 
                            Condition="QUEX_OPTION_COLUMN_NUMBER_COUNTING")
    if Setup.buffer_codec.variable_character_sizes_f():
        variable_db.require("lexatom_begin_p")

    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)
示例#5
0
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)
示例#7
0
文件: loop.py 项目: nyulacska/gpr
def _get_source_code(CcFactory, analyzer, terminal_list):
    """RETURNS: String containing source code for the 'loop'. 

       -- The source code for the (looping) state machine.
       -- The terminals which contain counting actions.

    Also, it requests variable definitions as they are required.
    """
    txt = []
    txt.extend(generator.do_analyzer(analyzer))
    txt.extend(generator.do_terminals(terminal_list, analyzer))
    if analyzer.engine_type.subject_to_reload():
        txt.extend(generator.do_reload_procedure(analyzer))

    if CcFactory.requires_reference_p():
        variable_db.require("reference_p",
                            Condition="QUEX_OPTION_COLUMN_NUMBER_COUNTING")
    if Setup.buffer_codec.variable_character_sizes_f():
        variable_db.require("character_begin_p")
    return 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)
示例#9
0
def _get_source_code(analyzer_list, terminal_list, ColumnNPerChunk,
                     AppendixSmExistF):
    """RETURNS: String containing source code for the 'loop'. 

       -- The source code for the (looping) state machine.
       -- The terminals which contain counting actions.

    Also, it requests variable definitions as they are required.
    """
    txt = flatten_list_of_lists(
        generator.do_analyzer(analyzer) for analyzer in analyzer_list)
    txt.extend(generator.do_terminals(terminal_list, TheAnalyzer=None))
    loop_analyzer = analyzer_list[0]
    if loop_analyzer.engine_type.subject_to_reload():
        txt.extend(generator.do_reload_procedure(loop_analyzer))

    if AppendixSmExistF or ColumnNPerChunk is not None:
        variable_db.require("reference_p",
                            Condition="QUEX_OPTION_COLUMN_NUMBER_COUNTING")
    if Setup.buffer_codec.variable_character_sizes_f():
        variable_db.require("lexatom_begin_p")

    return txt