Ejemplo n.º 1
0
 def _validate_final_states(self):
     """Raise an error if any final states are invalid."""
     invalid_states = self.final_states - self.states
     if invalid_states:
         raise exceptions.InvalidStateError(
             'final states are not valid ({})'.format(
                 ', '.join(invalid_states)))
Ejemplo n.º 2
0
 def _validate_transition_end_states(self, start_state, paths):
     """Raise an error if transition end states are invalid."""
     for end_state in paths.values():
         if end_state not in self.states:
             raise exceptions.InvalidStateError(
                 'end state {} for transition on {} is not valid'.format(
                     end_state, start_state))
Ejemplo n.º 3
0
 def _validate_transition_result(self, result):
     result_state, result_symbol, result_direction = result
     if result_state not in self.states:
         raise exceptions.InvalidStateError(
             'result state is not valid ({})'.format(result_state))
     if result_symbol not in self.tape_symbols:
         raise exceptions.InvalidSymbolError(
             'result symbol is not valid ({})'.format(result_symbol))
     self._validate_transition_result_direction(result_direction)
Ejemplo n.º 4
0
 def _validate_transition_state(self, transition_state):
     if transition_state not in self.states:
         raise exceptions.InvalidStateError(
             'transition state is not valid ({})'.format(transition_state))
Ejemplo n.º 5
0
 def _validate_initial_state(self):
     """Raise an error if the initial state is invalid."""
     if self.initial_state not in self.states:
         raise exceptions.InvalidStateError(
             '{} is not a valid initial state'.format(self.initial_state))