yin parser CHANGE add support for require-instance element
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 26223be..0d05deb 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -454,6 +454,37 @@
 }
 
 /**
+ * @brief Parse require instance element.
+ *
+ * @param[in,out] ctx Yin parser context for logging and to store current state.
+ * @param[in] attrs [Sized array](@ref sizedarrays) of attributes of current element.
+ * @param[in,out] data Data to read from, always moved to currently handled character.
+ * @prama[out] type Type structure to store value, flag and extensions.
+ *
+ * @return LY_ERR values.
+ */
+static LY_ERR
+yin_pasrse_reqinstance(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs,
+                       const char **data,  struct lysp_type *type)
+{
+    const char *temp_val = NULL;
+    struct yin_subelement subelems[1] = {{YANG_CUSTOM, NULL, 0}};
+
+    type->flags |= LYS_SET_REQINST;
+    LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_REQUIRE_INSTANCE));
+    if (strcmp(temp_val, "true") == 0) {
+        type->require_instance = 1;
+    } else if (strcmp(temp_val, "false") != 0) {
+        LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "require-instance");
+        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_REQUIRE_INSTANCE, NULL, &type->exts);
+}
+
+/**
  * @brief Parse position or value element.
  *
  * @param[in,out] ctx YIN parser context for logging and to store current state.
@@ -478,7 +509,7 @@
     enm->flags |= LYS_SET_VALUE;
 
     /* get attribute value */
-    yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, kw);
+    LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, kw));
     if (!temp_val || (temp_val[0] == '+') || ((temp_val[0] == '0') && (temp_val[0] != '\0')) || ((kw == YANG_VALUE) && !strcmp(temp_val, "-0"))) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL, strlen(temp_val), temp_val, ly_stmt2str(kw));
         goto error;
@@ -529,7 +560,7 @@
  * text element as child
  *
  * @param[in,out] ctx Yin parser context for logging and to store current state.
- * @param[in,out] data Data to read from.
+ * @param[in,out] data Data to read from, always moved to currently handled character.
  * @param[in] Type of element can be set to YANG_ORGANIZATION or YANG_CONTACT or YANG_DESCRIPTION or YANG_REFERENCE.
  * @param[out] value Where the content of meta element should be stored.
  * @param[in,out] exts Extension instance to add to.
@@ -865,6 +896,7 @@
                 case YANG_REFINE:
                     break;
                 case YANG_REQUIRE_INSTANCE:
+                    ret = yin_pasrse_reqinstance(ctx, subelem_attrs, data, (struct lysp_type *)subelem_info_rec->dest);
                     break;
                 case YANG_REVISION:
                     break;
diff --git a/tests/src/test_parser_yin.c b/tests/src/test_parser_yin.c
index 180dc4b..7512726 100644
--- a/tests/src/test_parser_yin.c
+++ b/tests/src/test_parser_yin.c
@@ -676,6 +676,7 @@
                             "<default value=\"default-value\"/>"
                             "<position value=\"25\"></position>"
                             "<value value=\"-5\"/>"
+                            "<require-instance value=\"true\"></require-instance>"
                         "</prefix>";
     struct lysp_ext_instance *exts = NULL;
     const char **if_features = NULL;
@@ -683,25 +684,27 @@
     const char *value, *err_msg, *app_tag, *units, *def;
     struct lysp_ext *ext_def = NULL;
     struct lysp_when *when_p = NULL;
-    struct lysp_type_enum pos_enum = {.flags = 0}, val_enum = {.flags = 0};
+    struct lysp_type_enum pos_enum = {}, val_enum = {};
+    struct lysp_type req_type = {};
     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[12] = {{YANG_CONFIG, &config, 0},
+    struct yin_subelement subelems[13] = {{YANG_CONFIG, &config, 0},
                                          {YANG_DEFAULT, &def, 0},
                                          {YANG_ERROR_APP_TAG, &app_tag, 0},
                                          {YANG_ERROR_MESSAGE, &err_msg, 0},
                                          {YANG_EXTENSION, &ext_def, 0},
                                          {YANG_IF_FEATURE, &if_features, 0},
                                          {YANG_POSITION, &pos_enum, 0},
+                                         {YANG_REQUIRE_INSTANCE, &req_type, 0},
                                          {YANG_UNITS, &units, 0},
                                          {YANG_VALUE, &val_enum, 0},
                                          {YANG_WHEN, &when_p, 0},
                                          {YANG_CUSTOM, NULL, 0},
                                          {YIN_TEXT, &value, 0}};
-    ret = yin_parse_content(st->yin_ctx, subelems, 12, &data, YANG_PREFIX, NULL, &exts);
+    ret = yin_parse_content(st->yin_ctx, subelems, 13, &data, YANG_PREFIX, NULL, &exts);
     assert_int_equal(ret, LY_SUCCESS);
     assert_int_equal(st->yin_ctx->xml_ctx.status, LYXML_END);
     /* check parsed values */
@@ -718,6 +721,8 @@
     assert_true(pos_enum.flags | LYS_SET_VALUE);
     assert_int_equal(val_enum.value, -5);
     assert_true(val_enum.flags | LYS_SET_VALUE);
+    assert_int_equal(req_type.require_instance, 1);
+    assert_true(req_type.flags |= LYS_SET_REQINST);
     assert_string_equal(err_msg, "error-msg");
     assert_string_equal(app_tag, "err-app-tag");
     /* cleanup */