Exemplo n.º 1
0
 def _create_control(self):
     control = FSA()
     control.add_state("0", is_init=True, is_final=False)
     for state in xrange(1, len(self.matchers) + 1):
         control.add_state(str(state),
                           is_init=False,
                           is_final=(state == len(self.matchers)))
         control.add_transition(self.matchers[state - 1], str(state - 1),
                                str(state))
     return control
Exemplo n.º 2
0
    def generate_control(self):
        control = FSA()
        control.add_state("0", is_init=True, is_final=False)

        state_num = 1
        for key in self.avm:
            state_name = str(state_num)
            matcher = self.avm.get_field(key, AVM.TYPE)
            control.add_state(state_name, is_init=False, is_final=True)
            control.add_transition(matcher, "0", state_name)
            state_num += 1
        return control