yin parser CHANGE add support for config element
diff --git a/src/parser_yin.c b/src/parser_yin.c
index dfbba27..13927aa 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -36,6 +36,10 @@
  */
 #define IS_YIN_NS(ns) (strcmp(ns, YIN_NS_URI) == 0)
 
+static LY_ERR
+yin_parse_config(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, uint16_t *flags,
+                 struct lysp_ext_instance **exts);
+
 const char *const yin_attr_list[] = {
     [YIN_ARG_NAME] = "name",
     [YIN_ARG_TARGET_NODE] = "target-node",
@@ -352,7 +356,8 @@
  */
 static LY_ERR
 yin_check_subelem_first_constraint(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info,
-                                   signed char subelem_info_size, enum yang_keyword current_element, struct yin_subelement *exp_first)
+                                   signed char subelem_info_size, enum yang_keyword current_element,
+                                   struct yin_subelement *exp_first)
 {
     for (signed char i = 0; i < subelem_info_size; ++i) {
         if (subelem_info[i].flags & YIN_SUBELEM_PARSED) {
@@ -662,6 +667,7 @@
                 case YANG_CHOICE:
                     break;
                 case YANG_CONFIG:
+                    ret = yin_parse_config(ctx, subelem_attrs, data, (uint16_t *)subelem_info_rec->dest, exts);
                     break;
                 case YANG_CONTACT:
                 case YANG_DESCRIPTION:
@@ -851,6 +857,39 @@
     return yin_parse_content(ctx, subelems, 1, data, YANG_REVISION_DATE, NULL, exts);
 }
 
+/**
+ * @brief Parse config element.
+ *
+ * @param[in] ctx Yin parser context for logging and to store current state.
+ * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of import element.
+ * @param[in,out] data Data to read from, always moved to currently handled character.
+ * @param[in,out] flags Flags to add to.
+ * @param[in,out] exts Extension instances to add to.
+ *
+ * @return LY_ERR values.
+ */
+static LY_ERR
+yin_parse_config(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, uint16_t *flags,
+                 struct lysp_ext_instance **exts)
+{
+    const char *temp_val = NULL;
+    struct yin_subelement subelems[1] = {{YANG_CUSTOM, NULL, 0}};
+
+    LY_CHECK_RET(yin_parse_attribute(ctx, &attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_CONFIG));
+    if (strcmp(temp_val, "true") == 0) {
+        *flags |= LYS_CONFIG_W;
+    } else if (strcmp(temp_val, "false") == 0) {
+        *flags |= LYS_CONFIG_R;
+    } else {
+        LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "config");
+        FREE_STRING(ctx->xml_ctx.ctx, temp_val);
+        return LY_EVALID;
+    }
+    FREE_STRING(ctx->xml_ctx.ctx, temp_val);
+
+    return yin_parse_content(ctx, subelems, 1, data, YANG_CONFIG, NULL, exts);
+}
+
 LY_ERR
 yin_parse_yangversion(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, uint8_t *version,
                       struct lysp_ext_instance **exts)
diff --git a/src/parser_yin.h b/src/parser_yin.h
index d4e22bf..3c4ee1a 100644
--- a/src/parser_yin.h
+++ b/src/parser_yin.h
@@ -64,7 +64,7 @@
 /* flags to encode cardinality of subelement */
 #define YIN_SUBELEM_MANDATORY   0x01    /**< is set when subelement is mandatory */
 #define YIN_SUBELEM_UNIQUE      0x02    /**< is set when subelement is unique */
-#define YIN_SUBELEM_FIRST       0x08    /**< is set when subelement is actually yang argument mapped to yin element */
+#define YIN_SUBELEM_FIRST       0x04    /**< is set when subelement is actually yang argument mapped to yin element */
 
 #define YIN_SUBELEM_PARSED      0x80    /**< is set during parsing when given subelement is encountered for the first
                                              time to simply check validity of given constraints */
diff --git a/tests/src/test_parser_yin.c b/tests/src/test_parser_yin.c
index e27744d..3511681 100644
--- a/tests/src/test_parser_yin.c
+++ b/tests/src/test_parser_yin.c
@@ -667,6 +667,7 @@
                                 "<reference><text>when_ref</text></reference>"
                                 "<description><text>when_desc</text></description>"
                             "</when>"
+                            "<config value=\"true\"/>"
                         "</prefix>";
     struct lysp_ext_instance *exts = NULL;
     const char **if_features = NULL;
@@ -674,16 +675,18 @@
     const char *value;
     struct lysp_ext *ext_def = NULL;
     struct lysp_when *when_p = NULL;
+    uint8_t config = 0;
 
     lyxml_get_element(&st->yin_ctx->xml_ctx, &data, &prefix.value, &prefix.len, &name.value, &name.len);
     yin_load_attributes(st->yin_ctx, &data, &attrs);
 
-    struct yin_subelement subelems[5] = {{YANG_EXTENSION, &ext_def, 0},
+    struct yin_subelement subelems[6] = {{YANG_CONFIG, &config, 0},
+                                         {YANG_EXTENSION, &ext_def, 0},
                                          {YANG_IF_FEATURE, &if_features, 0},
                                          {YANG_WHEN, &when_p, 0},
                                          {YANG_CUSTOM, NULL, 0},
                                          {YIN_TEXT, &value, 0}};
-    ret = yin_parse_content(st->yin_ctx, subelems, 5, &data, YANG_PREFIX, NULL, &exts);
+    ret = yin_parse_content(st->yin_ctx, subelems, 6, &data, YANG_PREFIX, NULL, &exts);
     assert_int_equal(ret, LY_SUCCESS);
     assert_int_equal(st->yin_ctx->xml_ctx.status, LYXML_END);
     assert_string_equal(exts->name, "custom");
@@ -692,6 +695,7 @@
     assert_string_equal(when_p->cond, "condition...");
     assert_string_equal(when_p->dsc, "when_desc");
     assert_string_equal(when_p->ref, "when_ref");
+    assert_int_equal(config, LYS_CONFIG_W);
     lysp_ext_instance_free(st->ctx, exts);
     lysp_when_free(st->ctx, when_p);
     lysp_ext_free(st->ctx, ext_def);