yin parser CHANGE add support for bit element
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 237edf9..0622bf4 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -32,26 +32,6 @@
 #include "tree_schema_internal.h"
 
 /**
- * @brief Try to find object with MEMBER string matching the IDENT in the given ARRAY.
- * Macro logs an error message and returns LY_EVALID in case of existence of a matching object.
- *
- * @param[in] CTX yang parser context for logging.
- * @param[in] ARRAY [sized array](@ref sizedarrays) of a generic objects with member named MEMBER to search.
- * @param[in] MEMBER Name of the member of the objects in the ARRAY to compare.
- * @param[in] STMT Name of the compared YANG statements for logging.
- * @param[in] IDENT String trying to find in the ARRAY's objects inside the MEMBER member.
- */
-#define CHECK_UNIQUENESS(CTX, ARRAY, MEMBER, STMT, IDENT) \
-    if (ARRAY) { \
-        for (unsigned int u = 0; u < LY_ARRAY_SIZE(ARRAY) - 1; ++u) { \
-            if (!strcmp((ARRAY)[u].MEMBER, IDENT)) { \
-                LOGVAL_PARSER(CTX, LY_VCODE_DUPIDENT, IDENT, STMT); \
-                return LY_EVALID; \
-            } \
-        } \
-    }
-
-/**
  * @brief Insert WORD into the libyang context's dictionary and store as TARGET.
  * @param[in] CTX yang parser context to access libyang context.
  * @param[in] BUF buffer in case the word is not a constant and can be inserted directly (zero-copy)
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 84f5b1b..e8ec242 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -470,6 +470,27 @@
     return yin_parse_content(ctx, subelems, 6, data, YANG_PATTERN, NULL, &restr->exts);
 }
 
+static LY_ERR
+yin_parse_bit(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
+              struct lysp_type *type)
+{
+    struct lysp_type_enum *bit;
+    LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, type->bits, bit, LY_EMEM);
+    LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &bit->name, Y_IDENTIF_ARG, YANG_BIT));
+    type->flags |= LYS_SET_BIT;
+    CHECK_UNIQUENESS((struct lys_parser_ctx *)ctx, type->bits, name, "bit", bit->name);
+
+    struct yin_subelement subelems[6] = {
+                                            {YANG_DESCRIPTION, &bit->dsc, YIN_SUBELEM_UNIQUE},
+                                            {YANG_IF_FEATURE, &bit->iffeatures, 0},
+                                            {YANG_POSITION, &bit->value, YIN_SUBELEM_UNIQUE},
+                                            {YANG_REFERENCE, &bit->ref, YIN_SUBELEM_UNIQUE},
+                                            {YANG_STATUS, &bit->flags, YIN_SUBELEM_UNIQUE},
+                                            {YANG_CUSTOM, NULL, 0}
+                                        };
+    return yin_parse_content(ctx, subelems, 6, data, YANG_BIT, NULL, &bit->exts);
+}
+
 /**
  * @brief Parse simple element without any special constraints and argument mapped to yin attribute, that can have
  * more instances, such as base or if-feature.
@@ -937,6 +958,7 @@
                     ret = yin_parse_belongs_to(ctx, subelem_attrs, data, (struct lysp_submodule *)subelem_info_rec->dest, exts);
                     break;
                 case YANG_BIT:
+                    ret = yin_parse_bit(ctx, subelem_attrs, data, (struct lysp_type *)subelem_info_rec->dest);
                     break;
                 case YANG_CASE:
                     break;
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 813dede..2d03115 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -40,6 +40,26 @@
                             (c >= 0xf0000 && c <= 0xffffd) || (c >= 0x100000 && c <= 0x10fffd))
 
 /**
+ * @brief Try to find object with MEMBER string matching the IDENT in the given ARRAY.
+ * Macro logs an error message and returns LY_EVALID in case of existence of a matching object.
+ *
+ * @param[in] CTX yang parser context for logging.
+ * @param[in] ARRAY [sized array](@ref sizedarrays) of a generic objects with member named MEMBER to search.
+ * @param[in] MEMBER Name of the member of the objects in the ARRAY to compare.
+ * @param[in] STMT Name of the compared YANG statements for logging.
+ * @param[in] IDENT String trying to find in the ARRAY's objects inside the MEMBER member.
+ */
+#define CHECK_UNIQUENESS(CTX, ARRAY, MEMBER, STMT, IDENT) \
+    if (ARRAY) { \
+        for (unsigned int u = 0; u < LY_ARRAY_SIZE(ARRAY) - 1; ++u) { \
+            if (!strcmp((ARRAY)[u].MEMBER, IDENT)) { \
+                LOGVAL_PARSER(CTX, LY_VCODE_DUPIDENT, IDENT, STMT); \
+                return LY_EVALID; \
+            } \
+        } \
+    }
+
+/**
  * @brief List of YANG statement groups - the (sub)module's substatements
  */
 enum yang_module_stmt {