def analyzer_functions_get(ModeDB): code = [] # (*) Get list of modes that are actually implemented # (abstract modes only serve as common base) mode_name_list = ModeDB.keys() for name, mode_descr in ModeDB.iteritems(): dial_db.clear() # -- Generate 'Mode' from 'ModeDescriptions' mode = Mode(mode_descr) blackboard.mode_db[name] = mode if not mode.is_implemented(): continue txt_analyzer = cpp_generator.do(mode, mode_name_list) txt_counter = cpp_generator.do_default_counter(mode) code.extend(txt_counter) code.extend(txt_analyzer) code.append( do_comment_pattern_action_pairs(blackboard.mode_db.itervalues())) if not Setup.token_class_only_f: determine_start_mode(blackboard.mode_db) # (*) perform consistency check on newly generated mode_db consistency_check.do(blackboard.mode_db) # generate frame for analyser code return cpp_generator.frame_this("".join(code)), blackboard.mode_db
def analyzer_functions_get(ModeDB): code = [] # (*) Get list of modes that are actually implemented # (abstract modes only serve as common base) mode_name_list = ModeDB.keys() for name, mode_descr in ModeDB.iteritems(): dial_db.clear() # -- Generate 'Mode' from 'ModeDescriptions' mode = Mode(mode_descr) blackboard.mode_db[name] = mode if not mode.is_implemented(): continue txt_analyzer = cpp_generator.do(mode, mode_name_list) txt_counter = cpp_generator.do_default_counter(mode) code.extend(txt_counter) code.extend(txt_analyzer) code.append(do_comment_pattern_action_pairs(blackboard.mode_db.itervalues())) if not Setup.token_class_only_f: determine_start_mode(blackboard.mode_db) # (*) perform consistency check on newly generated mode_db consistency_check.do(blackboard.mode_db) # generate frame for analyser code return cpp_generator.frame_this("".join(code)), blackboard.mode_db
def finalize(): """After all modes have been defined, the mode descriptions can now be translated into 'real' modes. """ global mode_description_db # (*) Translate each mode description int a 'real' mode for name, mode_descr in mode_description_db.iteritems(): blackboard.mode_db[name] = Mode(mode_descr) # (*) perform consistency check consistency_check.do(blackboard.mode_db)
def finalize(): """After all modes have been defined, the mode descriptions can now be translated into 'real' modes. """ global mode_description_db # (*) Translate each mode description int a 'real' mode for name, mode_descr in mode_description_db.iteritems(): blackboard.mode_db[name] = Mode(mode_descr) # (*) perform consistency check consistency_check.do(blackboard.mode_db)
def blackboard_mode_db_setup(ModeDescrDb): """Takes all ModeDescription-s from ModeDescrDb and generates Mode objects out of them. RESULT: blackboard.mode_db containing appropriate Mode objects. """ def enter(Name, ModeDescr): mode = Mode(mode_descr) # -- Generate 'Mode' from 'ModeDescriptions' blackboard.mode_db[name] = mode return mode for name, mode_descr in ModeDescrDb.iteritems(): enter(name, mode_descr) if not Setup.token_class_only_f: determine_start_mode(blackboard.mode_db) # (*) perform consistency check on newly generated mode_db consistency_check.do(blackboard.mode_db) return
def blackboard_mode_db_setup(ModeDescrDb): """Takes all ModeDescription-s from ModeDescrDb and generates Mode objects out of them. RESULT: blackboard.mode_db containing appropriate Mode objects. """ def enter(Name, ModeDescr): mode = Mode(mode_descr) # -- Generate 'Mode' from 'ModeDescriptions' blackboard.mode_db[name] = mode return mode for name, mode_descr in ModeDescrDb.iteritems(): enter(name, mode_descr) if not Setup.token_class_only_f: determine_start_mode(blackboard.mode_db) # (*) perform consistency check on newly generated mode_db consistency_check.do(blackboard.mode_db) return
def __finalize_modes_prep(ModePrepPrepDb): assert not Setup.token_class_only_f assert not Setup.converter_only_f assert all( isinstance(x, Mode_PrepPrep) for x in ModePrepPrepDb.itervalues()) # (BEFORE) Parsing --> Mode_PrepPrep # (*) Mode_PrepPrep --> Mode_Prep # * collection of options_db from base modes # * collection of incidence_db from base modes # * finalize all mentioned patterns in a mode # (patterns are not yet collected from base modes) mode_prep_db = dict( (mode_prep_prep.name, mode_prep_prep.finalize(ModePrepPrepDb)) for mode_prep_prep in ModePrepPrepDb.itervalues()) # (*) Mode_Prep: pre finalize # All patterns of all modes have been finalized # => collect all patterns and loopers from base modes # => generate pattern list / terminal configuration for mode_prep in mode_prep_db.itervalues(): mode_prep.pre_finalize(mode_prep_db) consistency_check.do_pre(mode_prep_db.values()) __determine_initial_mode(mode_prep_db) # (*) Mode_Prep --> Mode # Pattern lists are determined for each mode # => Each mode is determined whether mode is implemented or not. # => Determine the concerned mode names for mode handlers consistency_check.do(mode_prep_db.values()) return mode_prep_db