예제 #1
0
def check_indentation_setup(isetup):
    """None of the elements 'comment', 'newline', 'newline_suppressor' should 
       not match some subsets of each other. Otherwise, the behavior would be 
       too confusing.
    """
    sm_newline = isetup.sm_newline.get()
    sm_newline_suppressor = isetup.sm_newline_suppressor.get()
    sm_comment = isetup.sm_comment.get()
    candidates = (sm_newline, sm_newline_suppressor, sm_comment)

    def mutually_subset(Sm1, Sm2):
        if Sm1 is None or Sm2 is None: return False
        elif superset_check.do(Sm1, Sm2): return True
        elif superset_check.do(Sm2, Sm1): return True
        return False

    for i, candidate1 in enumerate(candidates):
        if candidate1 is None: continue
        for candidate2 in candidates[i + 1:]:
            if candidate2 is None: continue
            elif not mutually_subset(candidate1, candidate2): continue
            c_error_message(candidate1,
                            candidate2,
                            ThisComment="matches on some common lexemes as",
                            ThatComment="")
예제 #2
0
파일: mode.py 프로젝트: dkopecek/amplify
 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")
예제 #3
0
파일: mode.py 프로젝트: xxyzzzq/quex
 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")
예제 #4
0
파일: mode.py 프로젝트: dkopecek/amplify
 def check_dominated_pattern(self, ErrorCode):
     for high, low in self.unique_pattern_pair_iterable():
         # 'low' comes after 'high' => 'i' has precedence
         # Check for domination.
         if superset_check.do(high, low):
             c_error_message(high, low, 
                             ThisComment  = "matches a superset of what is matched by",
                             EndComment   = "The former has precedence and the latter can never match.",
                             ExitF        = True, 
                             SuppressCode = ErrorCode)
예제 #5
0
파일: mode.py 프로젝트: xxyzzzq/quex
 def check_dominated_pattern(self, ErrorCode):
     for high, low in self.unique_pattern_pair_iterable():
         # 'low' comes after 'high' => 'i' has precedence
         # Check for domination.
         if superset_check.do(high, low):
             c_error_message(high, low, 
                             ThisComment  = "matches a superset of what is matched by",
                             EndComment   = "The former has precedence and the latter can never match.",
                             ExitF        = True, 
                             SuppressCode = ErrorCode)
예제 #6
0
파일: mode.py 프로젝트: dkopecek/amplify
 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)
예제 #7
0
파일: mode.py 프로젝트: xxyzzzq/quex
 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)
예제 #8
0
파일: mode.py 프로젝트: dkopecek/amplify
    def check_higher_priority_matches_subset(self, ErrorCode):
        """Checks whether a higher prioritized pattern matches a common subset
           of the ReferenceSM. For special patterns of skipper, etc. this would
           be highly confusing.
        """
        global special_pattern_list
        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

            if not superset_check.do(high.sm, low.sm):             
                continue

            c_error_message(high, low, ExitF=True, 
                            ThisComment  = "has higher priority and",
                            ThatComment  = "matches a subset of",
                            SuppressCode = ErrorCode)
예제 #9
0
파일: mode.py 프로젝트: xxyzzzq/quex
    def check_higher_priority_matches_subset(self, ErrorCode):
        """Checks whether a higher prioritized pattern matches a common subset
           of the ReferenceSM. For special patterns of skipper, etc. this would
           be highly confusing.
        """
        global special_pattern_list
        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

            if not superset_check.do(high.sm, low.sm):             
                continue

            c_error_message(high, low, ExitF=True, 
                            ThisComment  = "has higher priority and",
                            ThatComment  = "matches a subset of",
                            SuppressCode = ErrorCode)
예제 #10
0
파일: mode.py 프로젝트: dkopecek/amplify
    def check_match_same(self, ErrorCode):
        """Special patterns shall never match on some common lexemes."""
        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

            # A superset of B, or B superset of A => there are common matches.
            if not same_check.do(high.sm, low.sm): continue

            # The 'match what remains' is exempted from check.
            if high.pattern_string() == "." or low.pattern_string() == ".":
                continue

            c_error_message(high, low, 
                            ThisComment  = "matches on some common lexemes as",
                            ThatComment  = "",
                            ExitF        = True,
                            SuppressCode = ErrorCode)
예제 #11
0
파일: mode.py 프로젝트: xxyzzzq/quex
    def check_match_same(self, ErrorCode):
        """Special patterns shall never match on some common lexemes."""
        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

            # A superset of B, or B superset of A => there are common matches.
            if not same_check.do(high.sm, low.sm): continue

            # The 'match what remains' is exempted from check.
            if high.pattern_string() == "." or low.pattern_string() == ".":
                continue

            c_error_message(high, low, 
                            ThisComment  = "matches on some common lexemes as",
                            ThatComment  = "",
                            ExitF        = True,
                            SuppressCode = ErrorCode)
예제 #12
0
def check_indentation_setup(isetup):
    """None of the elements 'comment', 'newline', 'newline_suppressor' should 
       not match some subsets of each other. Otherwise, the behavior would be 
       too confusing.
    """
    sm_newline            = isetup.sm_newline.get()
    sm_newline_suppressor = isetup.sm_newline_suppressor.get()
    sm_comment            = isetup.sm_comment.get()
    candidates            = (sm_newline, sm_newline_suppressor, sm_comment)

    def mutually_subset(Sm1, Sm2):
        if   Sm1 is None or Sm2 is None:                           return False
        elif superset_check.do(sm_newline, sm_newline_suppressor): return True
        elif superset_check.do(sm_newline_suppressor, sm_newline): return True
        return False

    for i, candidate1 in enumerate(candidates):
        if candidate1 is None: continue
        for candidate2 in candidates[i+1:]:
            if candidate2 is None: continue
            elif not mutually_subset(candidate1, candidate2): continue
            c_error_message(candidate1, candidate2,
                            ThisComment="matches on some common lexemes as",
                            ThatComment="")