code: def parse(self) -> Statement:
          
          self.opt_separator()
          start = self.offset
          res = self.statement()
          if res.keyword not in ["module", "submodule"]:
              self.offset = start
              raise UnexpectedInput(self, "'module' or 'submodule'")
          if self.name is not None and res.argument != self.name:
              raise ModuleNameMismatch(res.argument, self.name)
          if self.rev:
              revst = res.find1("revision")
              if revst is None or revst.argument != self.rev:
                  raise ModuleRevisionMismatch(revst.argument, self.rev)
          try:
              self.opt_separator()
          except EndOfInput:
              return res
          raise UnexpectedInput(self, "end of input")
docs: Parse a complete YANG module or submodule.
  
          Args:
              mtext: YANG module text.
  
          Raises:
              EndOfInput: If past the end of input.
              ModuleNameMismatch: If parsed module name doesn't match `self.name`.
              ModuleRevisionMismatch: If parsed revision date doesn't match `self.rev`.
              UnexpectedInput: If top-level statement isn't ``(sub)module``.