yin parser CHANGE add support for input and output element
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 74c7b32..a15bc20 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -786,6 +786,31 @@
         return LY_EVALID;
 }
 
+
+/**
+ * @brief Parse belongs-to element.
+ *
+ * @param[in] 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.
+ * @param[out] submod Structure of submodule that is being parsed.
+ * @param[in,out] exts Extension instances to add to.
+ *
+ * @return LY_ERR values
+ */
+static LY_ERR
+yin_parse_belongs_to(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
+                     struct lysp_submodule *submod, struct lysp_ext_instance **exts)
+{
+    struct yin_subelement subelems[2] = {
+                                            {YANG_PREFIX, &submod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE},
+                                            {YANG_CUSTOM, NULL, 0}
+                                        };
+    LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &submod->belongsto, Y_IDENTIF_ARG, YANG_BELONGS_TO));
+
+    return yin_parse_content(ctx, subelems, 2, data, YANG_BELONGS_TO, NULL, exts);
+}
+
 /**
  * @brief Function to parse meta tags (description, contact, ...) eg. elements with
  * text element as child
@@ -1053,7 +1078,7 @@
  * @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.
  * @param[in] any_kw Identification of current element, can be set to YANG_ANY_DATA or YANG_ANY_XML
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1101,7 +1126,7 @@
  * @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.
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1143,7 +1168,7 @@
                                             {YANG_UNITS, &leaf->units, YIN_SUBELEM_UNIQUE},
                                             {YANG_WHEN, &leaf->when, YIN_SUBELEM_UNIQUE},
                                             {YANG_CUSTOM, NULL, 0},
-                                        };
+                                         };
     return yin_parse_content(ctx, subelems, 12, data, YANG_LEAF, NULL, &leaf->exts);
 }
 
@@ -1153,7 +1178,7 @@
  * @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.
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1220,7 +1245,7 @@
  * @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.
- * @param[in] typedef_meta Meta information about node parent and typedefs to add to.
+ * @param[in] typedef_meta Meta information about parent node and typedefs to add to.
  *
  * @return LY_ERR values.
  */
@@ -1300,7 +1325,7 @@
  * @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.
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1498,7 +1523,7 @@
  * @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.
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1580,7 +1605,7 @@
  * @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.
- * @param[in,out] notif_meta Meta information about node parent and notifications to add to.
+ * @param[in,out] notif_meta Meta information about parent node and notifications to add to.
  *
  * @return LY_ERR values.
  */
@@ -1634,7 +1659,7 @@
  * @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.
- * @param[in,out] notif_meta Meta information about node parent and notifications to add to.
+ * @param[in,out] notif_meta Meta information about parent node and notifications to add to.
  *
  * @return LY_ERR values.
  */
@@ -1689,7 +1714,7 @@
  * @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.
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1758,7 +1783,7 @@
  * @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.
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1808,12 +1833,12 @@
 }
 
 /**
- * @brief Parse case element.
+ * @brief Parse choice 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.
- * @param[in] node_meta Meta information about node parent and siblings.
+ * @param[in] node_meta Meta information about parent node and siblings.
  *
  * @return LY_ERR values.
  */
@@ -1866,6 +1891,54 @@
 }
 
 /**
+ * @brief Parse input or output 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.
+ * @param[in] inout_meta Meta information about parent node and siblings and input/output pointer to write to.
+ *
+ * @return LY_ERR values.
+ */
+static LY_ERR
+yin_parse_inout(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum yang_keyword inout_kw,
+                struct inout_meta *inout_meta)
+{
+    /* initiate structure */
+    inout_meta->inout_p->nodetype = (inout_kw == YANG_INPUT) ? LYS_INPUT : LYS_OUTPUT;
+    inout_meta->inout_p->parent = inout_meta->parent;
+
+    /* check attributes */
+    LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NONE, NULL, Y_MAYBE_STR_ARG, inout_kw));
+
+    /* parser input/output content */
+    struct tree_node_meta node_meta = {(struct lysp_node *)inout_meta->inout_p, &inout_meta->inout_p->data};
+    struct grouping_meta grp_meta = {(struct lysp_node *)inout_meta->inout_p, &inout_meta->inout_p->groupings};
+    struct typedef_meta typedef_meta = {(struct lysp_node *)inout_meta->inout_p, &inout_meta->inout_p->typedefs};
+    struct yin_subelement subelems[12] = {
+                                            {YANG_ANYDATA, &node_meta, YIN_SUBELEM_VER2},
+                                            {YANG_ANYXML, &node_meta, 0},
+                                            {YANG_CHOICE, &node_meta, 0},
+                                            {YANG_CONTAINER, &node_meta, 0},
+                                            {YANG_GROUPING, &grp_meta, 0},
+                                            {YANG_LEAF, &node_meta, 0},
+                                            {YANG_LEAF_LIST, &node_meta, 0},
+                                            {YANG_LIST, &node_meta, 0},
+                                            {YANG_MUST, &inout_meta->inout_p->musts, YIN_SUBELEM_VER2},
+                                            {YANG_TYPEDEF, &typedef_meta, 0},
+                                            {YANG_USES, &node_meta, 0},
+                                            {YANG_CUSTOM, NULL, 0},
+                                         };
+    LY_CHECK_RET(yin_parse_content(ctx, subelems, 12, data, inout_kw, NULL, &inout_meta->inout_p->exts));
+
+    /* finalize parent pointers to the reallocated items */
+    LY_CHECK_RET(lysp_parse_finalize_reallocated((struct lys_parser_ctx *)ctx, inout_meta->inout_p->groupings,
+                                                  NULL, NULL, NULL));
+
+    return LY_SUCCESS;
+}
+
+/**
  * @brief Map keyword type to substatement info.
  *
  * @param[in] kw Keyword type.
@@ -1945,30 +2018,6 @@
     }
 }
 
-/**
- * @brief Parse belongs-to element.
- *
- * @param[in] 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.
- * @param[out] submod Structure of submodule that is being parsed.
- * @param[in,out] exts Extension instances to add to.
- *
- * @return LY_ERR values
- */
-static LY_ERR
-yin_parse_belongs_to(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
-                     struct lysp_submodule *submod, struct lysp_ext_instance **exts)
-{
-    struct yin_subelement subelems[2] = {
-                                            {YANG_PREFIX, &submod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE},
-                                            {YANG_CUSTOM, NULL, 0}
-                                        };
-    LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &submod->belongsto, Y_IDENTIF_ARG, YANG_BELONGS_TO));
-
-    return yin_parse_content(ctx, subelems, 2, data, YANG_BELONGS_TO, NULL, exts);
-}
-
 LY_ERR
 yin_parse_content(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info, signed char subelem_info_size,
                   const char **data, enum yang_keyword current_element, const char **text_content, struct lysp_ext_instance **exts)
@@ -2132,6 +2181,8 @@
                     ret = yin_parse_include(ctx, attrs, data, (struct include_meta *)subelem->dest);
                     break;
                 case YANG_INPUT:
+                case YANG_OUTPUT:
+                    ret = yin_parse_inout(ctx, attrs, data, kw, (struct inout_meta *)subelem->dest);
                     break;
                 case YANG_KEY:
                     ret = yin_parse_simple_element(ctx, attrs, data, kw, (const char **)subelem->dest, YIN_ARG_VALUE,
@@ -2178,8 +2229,6 @@
                 case YANG_ORDERED_BY:
                     ret = yin_parse_orderedby(ctx, attrs, data, (uint16_t *)subelem->dest, exts);
                     break;
-                case YANG_OUTPUT:
-                    break;
                 case YANG_PATH:
                     type = (struct lysp_type *)subelem->dest;
                     ret = yin_parse_simple_element(ctx, attrs, data, kw, &type->path,