def p_instanceDeclaration(p):
    # pylint: disable=line-too-long
    """instanceDeclaration : INSTANCE OF className '{' valueInitializerList '}' ';'
                           | INSTANCE OF className alias '{' valueInitializerList '}' ';'
                           | qualifierList INSTANCE OF className '{' valueInitializerList '}' ';'
                           | qualifierList INSTANCE OF className alias '{' valueInitializerList '}' ';'
                           """  # noqa: E501
    # pylint: disable=too-many-locals,too-many-branches,too-many-statements
    alias = None
    quals = OrderedDict()
    ns = p.parser.handle.default_namespace
    if isinstance(p[1], six.string_types):  # no qualifiers
        cname = p[3]
        if p[4] == '{':
            props = p[5]
        else:
            props = p[6]
            alias = p[4]
    else:
        cname = p[4]
        # quals = p[1]  # qualifiers on instances are deprecated -- rightly so.
        if p[5] == '{':
            props = p[6]
        else:
            props = p[7]
            alias = p[5]

    try:
        cc = p.parser.handle.GetClass(cname, LocalOnly=False,
                                      IncludeQualifiers=True)
        p.parser.classnames[ns].append(cc.classname.lower())
    except CIMError as ce:
        ce.file_line = (p.parser.file, p.lexer.lineno)
        if ce.status_code == CIM_ERR_NOT_FOUND:
            file_ = p.parser.mofcomp.find_mof(cname)
            if p.parser.verbose:
                p.parser.log(
                    _format("Class {0!A} does not exist", cname))
            if file_:
                p.parser.mofcomp.compile_file(file_, ns)
                cc = p.parser.handle.GetClass(cname, LocalOnly=False,
                                              IncludeQualifiers=True)
            else:
                if p.parser.verbose:
                    p.parser.log("Can't find file to satisfy class")
                ce = CIMError(CIM_ERR_INVALID_CLASS, cname)
                ce.file_line = (p.parser.file, p.lexer.lineno)
                raise ce
        else:
            raise
    path = CIMInstanceName(cname, namespace=ns)
    inst = CIMInstance(cname, qualifiers=quals, path=path)
    keybindings = NocaseDict()   # dictionary to build kb if alias exists

    for prop in props:
        pname = prop[1]
        pval = prop[2]
        try:
            cprop = cc.properties[pname]
        except KeyError:
            ce = CIMError(
                CIM_ERR_INVALID_PARAMETER,
                _format("Invalid property. Not in class: {0!A}", pname))
            ce.file_line = (p.parser.file, p.lexer.lineno)
            raise ce

        # confirm property name not duplicated.
        if pname in inst.properties:
            ce = CIMError(
                CIM_ERR_INVALID_PARAMETER,
                _format("Duplicate property: {0!A}", pname))
            ce.file_line = (p.parser.file, p.lexer.lineno)
            raise ce

        try:
            # build instance property from class property but without
            # qualifiers, default value,
            pprop = cprop.copy()
            pprop.qualifiers = NocaseDict(None)
            pprop.value = cimvalue(pval, cprop.type)
            inst.properties[pname] = pprop
            # if alias and this is key property, add keybinding
            if alias and 'key' in cprop.qualifiers:
                keybindings[pname] = pprop.value

        except ValueError as ve:
            ce = CIMError(
                CIM_ERR_INVALID_PARAMETER,
                _format("Invalid value for property {0!A}: {1}", pname, ve))
            ce.file_line = (p.parser.file, p.lexer.lineno)
            raise ce

    if alias:
        if keybindings:
            inst.path.keybindings = keybindings
        p.parser.aliases[alias] = inst.path

    p[0] = inst
instanceDeclaration : INSTANCE OF className '{' valueInitializerList '}' ';'
                           | INSTANCE OF className alias '{' valueInitializerList '}' ';'
                           | qualifierList INSTANCE OF className '{' valueInitializerList '}' ';'
                           | qualifierList INSTANCE OF className alias '{' valueInitializerList '}' ';'