コード例 #1
0
ファイル: CharClass.py プロジェクト: UniGrammar/CoCoPy
 def WriteClasses():
     for c in CharClass.classes:
         Trace.Write(str(c.name), -10)
         Trace.Write(': ')
         c.WriteSet()
         Trace.WriteLine()
     Trace.WriteLine()
コード例 #2
0
 def WriteSet(self):
     i = 0
     mx = max(self.set) + 1
     while i < mx:
         while i < mx and (i not in self.set):
             i += 1
         if i == mx:
             break
         j = i
         while i < mx and (i in self.set):
             i += 1
         if j < (i - 1):
             Trace.Write(
                 str(CharClass.Ch(j)) + ".." + str(CharClass.Ch(i - 1)) +
                 " ")
         else:
             Trace.Write(str(CharClass.Ch(j) + " "))
コード例 #3
0
ファイル: CharClass.py プロジェクト: UniGrammar/CoCoPy
    def WriteSet(self):
        s = self.set.copy()
        try:
            s.remove('ANYCHAR')
        except KeyError:
            pass

        i = 0
        mx = max(s) + 1
        while i < mx:
            while i < mx and (i not in s):
                i += 1
            if i == mx:
                break
            j = i
            while i < mx and (i in s):
                i += 1
            if j < (i - 1):
                Trace.Write(
                    str(CharClass.Ch(j)) + ".." + str(CharClass.Ch(i - 1)) +
                    " ")
            else:
                Trace.Write(str(CharClass.Ch(j) + " "))