def METHOD_NAME(self):
    self.modules = []
    while True:
        if self.nexttok is None:
            break
        elif self._accept_keyword('module'):
            m = Module()
            self.modules.append(m)
            self._expect('NAME')
            m.nm = self.tok.value
            m.parameters = self.parse_possibly_empty_comma_separated_list( self.parse_name)
            self._expect('SEMI')                            
            while True:
                if self._accept_keyword( 'input') or self._accept_keyword( 'output'):
                    ty = self.tok.value
                    nms = self.parse_comma_separated_list( self.parse_name)
                    if ty == 'input':
                        m.inputs += nms
                    elif ty == 'output':
                        m.outputs += nms
                    else:
                        assert False, ty
                    self._expect('SEMI')
                elif self._accept_keyword( 'endmodule'):
                    m.prnt()
                    break
                else:
                    inst = Instance()
                    m.instances.append(inst)
                    inst.template_name = self.parse_name()
                    inst.instance_name = self.parse_hier_name()
                    inst.fa_list = self.parse_possibly_empty_comma_separated_list( self.parse_fa_pair)
                    self._expect('SEMI')                            
        else:
            raise SyntaxError( f'Expected module, got {self.nexttok}')