code: def remove_rules(self, doc):
          
          # remove blanks lines and comment lines, e.g. lines starting with "#"
          doc = os.linesep.join([s for s in doc.splitlines() if s and not re.match("^\s*#", s)])
  
          rules = doc.split()
          index = []
          for i in range(len(rules)):
              if rules[i] == '::=':
                  index.append(i-1)
          index.append(len(rules))
          for i in range(len(index)-1):
              lhs = rules[index[i]]
              rhs = rules[index[i]+2:index[i+1]]
              rule = (lhs, tuple(rhs))
  
              if lhs not in self.rules:
                  return
  
              if rule in self.rules[lhs]:
                  self.rules[lhs].remove(rule)
                  del self.rule2func[rule]
                  del self.rule2name[rule]
                  self.ruleschanged = True
  
                  # If we are profiling, remove this rule from that as well
                  if self.profile_info is not None and len(rule[1]) > 0:
                      rule_str = self.reduce_string(rule)
                      if rule_str and rule_str in self.profile_info:
                          del self.profile_info[rule_str]
                          pass
                      pass
                  pass
  
          return
docs: Remove a grammar rules from  _self.rules_, _self.rule2func_,
              and _self.rule2name_