def __prepare(Language): global dial_db end_str = ' printf("end\\n");\n' end_str += "# define self (*me)\n" end_str += " self.send(&self, QUEX_TKN_TERMINATION);\n" end_str += " return;\n" end_str += "# undef self\n" __Setup_init_language_database(Language) dial_db = DialDB() variable_db.init() return end_str
def do_with_counter(Mode, ModeNameList): txt = [] Lng.debug_unit_name_set("Counter:%s" % Mode.name) if Mode.run_time_counter_db is not None: variable_db.init() txt.append( run_time_counter.get(Mode.run_time_counter_db, Mode.name) ) analyzer_txt = do(Mode, ModeNameList) assert isinstance(analyzer_txt, list) txt.extend(analyzer_txt) return txt
def do(Mode, ModeNameList): """RETURNS: The analyzer code for a mode defined in 'Mode'. """ variable_db.init() function_body, \ variable_definitions = do_core(Mode.pattern_list, Mode.terminal_db, Mode.on_after_match_code) function_txt = wrap_up(Mode.name, function_body, variable_definitions, ModeNameList) return function_txt
def do(Mode, ModeNameList): """RETURNS: The analyzer code for a mode defined in 'Mode'. """ variable_db.init() Lng.debug_unit_name_set("Mode:%s" % Mode.name) function_body, \ variable_definitions = do_core(Mode) function_txt = wrap_up(Mode.name, function_body, variable_definitions, ModeNameList, Mode.dial_db) return function_txt
def __prepare(Language, TokenQueueF=False): end_str = ' printf("end\\n");\n' if not TokenQueueF: end_str += ' return false;\n' else: end_str += "# define self (*me)\n" end_str += " self_send(QUEX_TKN_TERMINATION);\n" end_str += " return;\n" end_str += "# undef self\n" __Setup_init_language_database(Language) dial_db.clear() variable_db.init() return end_str
def do_default_counter(Mode): if not Mode.default_character_counter_required_f: return [] dial_db.clear() ccfactory = CountOpFactory.from_ParserDataLineColumn( Mode.counter_db, Setup.buffer_codec.source_set, Lng.INPUT_P()) variable_db.init() # May be, the default counter is the same as for another mode. In that # case call the default counter of the other mode with the same one and # only macro. default_character_counter_function_name, \ default_character_counter_function_code = counter.get(ccfactory, Mode.name) txt = [Lng.DEFAULT_COUNTER_PROLOG(default_character_counter_function_name)] if default_character_counter_function_code is not None: txt.append(default_character_counter_function_code) return txt
def do_default_counter(Mode): if not Mode.default_character_counter_required_f: return [] dial_db.clear() ci_map = CountInfoMap.from_LineColumnCount(Mode.counter_db, Setup.buffer_codec.source_set, Lng.INPUT_P()) variable_db.init() # May be, the default counter is the same as for another mode. In that # case call the default counter of the other mode with the same one and # only macro. default_character_counter_function_name, \ default_character_counter_function_code = counter.get(ci_map, Mode.name) txt = [ Lng.DEFAULT_COUNTER_PROLOG(default_character_counter_function_name) ] if default_character_counter_function_code is not None: txt.append(default_character_counter_function_code) return txt
def create_indentation_handler_code(Language, TestStr, ISetup, BufferSize): end_str = __prepare(Language) class MiniIncidenceDb(dict): def __init__(self): self[E_IncidenceIDs.INDENTATION_BAD] = "" def default_indentation_handler_f(self): return True mini_incidence_db = MiniIncidenceDb() ca_map = LineColumnCount_Default() counter_code = run_time_counter.get(ca_map, "M") code = [ ] # [ "%s\n" % Lng.LABEL(DoorID.incidence(E_IncidenceIDs.INDENTATION_HANDLER, dial_db)) ] variable_db.init() analyzer_list, \ terminal_list, \ required_register_set, \ run_time_counter_f = indentation_counter.do("M", ca_map, ISetup, mini_incidence_db, FSM.reload_state, dial_db) loop_code = generator.do_analyzer_list(analyzer_list) loop_code.extend( generator.do_terminals(terminal_list, TheAnalyzer=None, dial_db=dial_db)) if not run_time_counter_f: counter_code = None code.extend(loop_code) __require_variables(required_register_set) main_txt = create_customized_analyzer_function( Language, TestStr, code, QuexBufferSize=BufferSize, CommentTestStrF="", ShowPositionF=True, EndStr=end_str, SkipUntilMarkerSet="behind newline", LocalVariableDB=deepcopy(variable_db.get()), IndentationSupportF=True, ReloadF=True, CounterPrintF=False, BeforeCode=counter_code) on_indentation_txt = indentation_handler.do( AuxMode(), ["M", "M2"]).replace("$on_indentation", "QUEX_NAME(M_on_indentation)") Setup.analyzer_class_name = "TestAnalyzer" Setup.analyzer_name_safe = "TestAnalyzer" result = adapt.do(main_txt + on_indentation_txt, test_analyzer_dir(Language)) result = language_defines + result result = result.replace("$$TEST_ANALYZER_DIR$$", test_analyzer_dir(Language)) result = result.replace("$$COMPUTED_GOTOS_CHECK$$", computed_gotos_check_str()) return result