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)))
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))
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)
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))
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))