示例#1
0
 def get_all_clourse(self):
     queue = Queue()
     all_clourse = self.all_clourse
     queue.enqueue(
         self.get_clourse([
             Item(self.expression[0].leftside, self.expression[0].rightside,
                  0, "#")
         ]))
     i = 0
     while not queue.is_empty():
         current = queue.dequeue()
         all_clourse.append(current)
         current_index = len(all_clourse) - 1
         self.map_of_clourses[current_index] = {}
         for x in sorted(list(self.terminators | self.variable)):
             next = self.Go(current, x)
             if next != set(
             ) and next not in self.all_clourse and not queue.In(
                     next):  #next不为空,并且不在队列中,也不在all_clourse中
                 queue.enqueue(next)
                 i += 1
             if next in self.all_clourse:
                 self.map_of_clourses[current_index][
                     x] = self.all_clourse.index(next)
             elif queue.In(next):
                 self.map_of_clourses[current_index][x] = len(
                     self.all_clourse) + queue.index(next)