def check_low_priority_outruns_high_priority_pattern(self): """Warn when low priority patterns may outrun high priority patterns. Assume that the pattern list is sorted by priority! """ for high, low in self.unique_pattern_pair_iterable(): if outrun_checker.do(high.sm, low.sm): c_error_message(low, high, ExitF=False, ThisComment="may outrun")
def check_low_priority_outruns_high_priority_pattern(self): """Warn when low priority patterns may outrun high priority patterns. Assume that the pattern list is sorted by priority! """ for high, low in self.unique_pattern_pair_iterable(): if outrun_checker.do(high.sm, low.sm): c_error_message(low, high, ExitF=False, ThisComment="may outrun")
def __core(Pattern0, Pattern1): print("Pattern A = " + Pattern0).replace("\n", "\\n").replace("\t", "\\t") print("Pattern B = " + Pattern1).replace("\n", "\\n").replace("\t", "\\t") sm0 = regex.do(Pattern0, {}).extract_sm() sm1 = regex.do(Pattern1, {}).extract_sm() print "claim = ", outrun_check.do(sm0, sm1)
def check_special_incidence_outrun(self, ErrorCode): for high, low in self.unique_pattern_pair_iterable(): if high.pattern_string() not in Mode.focus \ and low.pattern_string() not in Mode.focus: continue elif not outrun_checker.do(high.sm, low.sm): continue c_error_message(high, low, ExitF=True, ThisComment = "has lower priority but", ThatComment = "may outrun", SuppressCode = ErrorCode)
def check_special_incidence_outrun(self, ErrorCode): for high, low in self.unique_pattern_pair_iterable(): if high.pattern_string() not in Mode.focus \ and low.pattern_string() not in Mode.focus: continue elif not outrun_checker.do(high.sm, low.sm): continue c_error_message(high, low, ExitF=True, ThisComment = "has lower priority but", ThatComment = "may outrun", SuppressCode = ErrorCode)
def __outrun_check(mode, PAP): ReferenceSM = PAP.pattern().sm for other_pap in mode.get_pattern_action_pair_list(): sm = other_pap.pattern().sm # No 'commonalities' between self and self shall be checked if ReferenceSM.get_id() >= sm.get_id(): continue if outrun_checker.do(ReferenceSM, sm): __error_message(other_pap, PAP, ExitF=True, ThisComment="has lower priority but", ThatComment="may outrun")
def __outrun_investigation(mode): pattern_action_pair_list = mode.get_pattern_action_pair_list() # Sort by pattern_id pattern_action_pair_list.sort(key=lambda x: x.pattern().sm.get_id()) for i, pap_i in enumerate(pattern_action_pair_list): sm_high = pap_i.pattern().sm for pap_k in islice(pattern_action_pair_list, i+1, None): # 'pap_k' has a higher id than 'pap_i'. Thus, it has a lower # priority. Check for outrun. sm_low = pap_k.pattern().sm if outrun_checker.do(sm_high, sm_low): file_name, line_n = pap_i.get_action_location() __error_message(pap_k, pap_i, ExitF=False, ThisComment="may outrun")
def __outrun_check(mode, PAP): ReferenceSM = PAP.pattern().sm for other_pap in mode.get_pattern_action_pair_list(): sm = other_pap.pattern().sm # No 'commonalities' between self and self shall be checked if ReferenceSM.get_id() >= sm.get_id(): continue if outrun_checker.do(ReferenceSM, sm): __error_message(other_pap, PAP, ExitF=True, ThisComment="has lower priority but", ThatComment="may outrun")
def __outrun_investigation(mode): pattern_action_pair_list = mode.get_pattern_action_pair_list() # Sort by pattern_id pattern_action_pair_list.sort(key=lambda x: x.pattern().sm.get_id()) for i, pap_i in enumerate(pattern_action_pair_list): sm_high = pap_i.pattern().sm for pap_k in islice(pattern_action_pair_list, i + 1, None): # 'pap_k' has a higher id than 'pap_i'. Thus, it has a lower # priority. Check for outrun. sm_low = pap_k.pattern().sm if outrun_checker.do(sm_high, sm_low): file_name, line_n = pap_i.get_action_location() __error_message(pap_k, pap_i, ExitF=False, ThisComment="may outrun")
def __core(Pattern0, Pattern1): print ("Pattern A = " + Pattern0).replace("\n", "\\n").replace("\t", "\\t") print ("Pattern B = " + Pattern1).replace("\n", "\\n").replace("\t", "\\t") sm0 = regex.do(Pattern0, {}).sm sm1 = regex.do(Pattern1, {}).sm print "claim = ", outrun_check.do(sm0, sm1)