code: def loadGrammar(self, grammar, searchpaths=None):
          
          self.grammar = self._load(grammar, searchpaths=searchpaths)
          self.refs = {}
          for ref in self.grammar.getElementsByTagName("ref"):
              self.refs[ref.attributes["id"].value] = ref
docs: load context-free grammar