code: def validate(cls, grammar):
          # type: (_MetaRule, Grammar) -> None
          
          # check if the rule is not defined multiple times
          defined = set(dir(cls))
          if 'rules' in defined and len(defined & {'rule', 'left', 'right', 'toSymbol', 'fromSymbol'}) > 0 or \
                  'rule' in defined and len(defined & {'left', 'right', 'toSymbol', 'fromSymbol'}) > 0 or \
                  'left' in defined and 'fromSymbol' in defined or \
                  'right' in defined and 'toSymbol' in defined:
              raise MultipleDefinitionException(cls, 'Rule is defined multiple times')
          # check if the rule is defined properly
          all = cls.rules
          if not isinstance(all, list):
              raise RuleSyntaxException(cls, 'Rules property is not enclose in list')
          for rule in all:
              if not isinstance(rule, tuple):
                  raise RuleSyntaxException(cls, 'One of the rules is not enclose in tuple', rule)
              if len(rule) != 2:
                  raise RuleSyntaxException(cls, 'One of the rules does not have define left and right part', rule)
              left = rule[0]
              right = rule[1]
              cls._controlSide(left, grammar)
              cls._controlSide(right, grammar)
              if left == [EPS] and right == [EPS]:
                  raise UselessEpsilonException(cls)
docs: Perform rules validation of the class.
          :param grammar: Grammar on which to validate.
          :raise RuleSyntaxException: If invalid syntax is used.
          :raise UselessEpsilonException: If epsilon used in rules in useless.
          :raise TerminalDoesNotExistsException: If terminal does not exists in the grammar.
          :raise NonterminalDoesNotExistsException: If nonterminal does not exists in the grammar.