'Construct the parser for the shape arguments.
Generates the argument-parsing functions dynamically and attaches
them to the instance.
Is supposed to be called in __init__ of a class for each distribution.
If self.shapes is a non-empty string, interprets it as a
comma-separated list of shape parameters.
Otherwise inspects the call signatures of `meths_to_inspect`
and constructs the argument-parsing functions from these.
In this case also sets `shapes` and `numargs`.'

def _construct_argparser(self, meths_to_inspect, locscale_in, locscale_out):

    if self.shapes:
        if (not isinstance(self.shapes, string_types)):
            raise TypeError('shapes    must    be    a    string.')
        shapes = self.shapes.replace(',', '    ').split()
        for field in shapes:
            if keyword.iskeyword(field):
                raise SyntaxError('keywords    cannot    be    used    as    shapes.')
            if (not re.match('^[_a-zA-Z][_a-zA-Z0-9]*$', field)):
                raise SyntaxError('shapes    must    be    valid    python    identifiers')
    else:
        shapes_list = []
        for meth in meths_to_inspect:
            shapes_args = _getargspec(meth)
            args = shapes_args.args[1:]
            if args:
                shapes_list.append(args)
                if (shapes_args.varargs is not None):
                    raise TypeError('*args    are    not    allowed    w/out    explicit    shapes')
                if (shapes_args.keywords is not None):
                    raise TypeError('**kwds    are    not    allowed    w/out    explicit    shapes')
                if (shapes_args.defaults is not None):
                    raise TypeError('defaults    are    not    allowed    for    shapes')
        if shapes_list:
            shapes = shapes_list[0]
            for item in shapes_list:
                if (item != shapes):
                    raise TypeError('Shape    arguments    are    inconsistent.')
        else:
            shapes = []
    shapes_str = ((',    '.join(shapes) + ',    ') if shapes else '')
    dct = dict(shape_arg_str=shapes_str, locscale_in=locscale_in, locscale_out=locscale_out)
    ns = {}
    exec_((parse_arg_template % dct), ns)
    for name in ['_parse_args', '_parse_args_stats', '_parse_args_rvs']:
        setattr(self, name, instancemethod(ns[name], self, self.__class__))
    self.shapes = (',    '.join(shapes) if shapes else None)
    if (not hasattr(self, 'numargs')):
        self.numargs = len(shapes)
