Add state and rules to machine.

def add_state(self, string):
        """Add state and rules to machine."""
        parsed_string = string.split()
        if len(parsed_string) > 0:
            state, rules = parsed_string[0], parsed_string[1:]

            if len(rules) != len(self.alphabet):
                raise SyntaxError('Wrong count of rules ({cur}/{exp}): {string}'
                                  .format(cur=len(rules), exp=len(self.alphabet),
                                          string=string))

            if state in self.states or state == self.TERM_STATE:
                raise SyntaxError('Double definition of state: ' + state)
            else:
                self.states[state] = []

            for rule in rules:
                try:
                    self._add_rule(state, rule)
                except SyntaxError as err:
                    self.states.pop(state)
                    raise err