yin parser CHANGE add support for notification element
diff --git a/src/parser_yin.c b/src/parser_yin.c
index d57579a..a0d356f 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -1528,6 +1528,7 @@
/* parse list content */
struct tree_node_meta new_node_meta = {(struct lysp_node *)list, &list->child};
struct typedef_meta typedef_meta = {(struct lysp_node *)list, &list->typedefs};
+ struct notif_meta notif_meta = {(struct lysp_node *)list, &list->notifs};
struct yin_subelement subelems[25] = {
/* TODO action */
{YANG_ACTION, NULL, 0},
@@ -1549,8 +1550,7 @@
{YANG_MAX_ELEMENTS, list, YIN_SUBELEM_UNIQUE},
{YANG_MIN_ELEMENTS, list, YIN_SUBELEM_UNIQUE},
{YANG_MUST, &list->musts, 0},
- /* TODO notification */
- {YANG_NOTIFICATION, NULL, 0},
+ {YANG_NOTIFICATION, ¬if_meta, 0},
{YANG_ORDERED_BY, &list->flags, YIN_SUBELEM_UNIQUE},
{YANG_REFERENCE, &list->ref, YIN_SUBELEM_UNIQUE},
{YANG_STATUS, &list->flags, YIN_SUBELEM_UNIQUE},
@@ -1576,6 +1576,62 @@
}
/**
+ * @brief Parse notification 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,out] notif_meta Meta information about node parent and notifications to add to.
+ *
+ * @return LY_ERR values.
+ */
+static LY_ERR
+yin_parse_notification(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
+ struct notif_meta *notif_meta)
+{
+ struct lysp_notif *notif;
+
+ /* allocate new notification */
+ LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *notif_meta->notifs, notif, LY_EMEM);
+ notif->nodetype = LYS_NOTIF;
+ notif->parent = notif_meta->parent;
+
+ /* parse argument */
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, ¬if->name, Y_IDENTIF_ARG, YANG_NOTIFICATION));
+
+ /* parse notification content */
+ struct tree_node_meta node_meta = {(struct lysp_node *)notif, ¬if->data};
+ struct typedef_meta typedef_meta = {(struct lysp_node *)notif, ¬if->typedefs};
+ struct yin_subelement subelems[16] = {
+ {YANG_ANYDATA, &node_meta, 0},
+ {YANG_ANYXML, &node_meta, 0},
+ /* TODO choice */
+ {YANG_CHOICE, NULL, 0},
+ /* TODO container */
+ {YANG_CONTAINER, NULL, 0},
+ {YANG_DESCRIPTION, ¬if->dsc, YIN_SUBELEM_UNIQUE},
+ /* TODO grouping */
+ {YANG_GROUPING, NULL, 0},
+ {YANG_IF_FEATURE, ¬if->iffeatures, 0},
+ {YANG_LEAF, &node_meta, 0},
+ {YANG_LEAF_LIST, &node_meta, 0},
+ {YANG_LIST, &node_meta, 0},
+ {YANG_MUST, ¬if->musts, YIN_SUBELEM_VER2},
+ {YANG_REFERENCE, ¬if->ref, YIN_SUBELEM_UNIQUE},
+ {YANG_STATUS, ¬if->flags, YIN_SUBELEM_UNIQUE},
+ {YANG_TYPEDEF, &typedef_meta, 0},
+ {YANG_USES, &node_meta, 0},
+ {YANG_CUSTOM, NULL, 0},
+ };
+ LY_CHECK_RET(yin_parse_content(ctx, subelems, 16, data, YANG_NOTIFICATION, NULL, ¬if->exts));
+
+ /* finalize parent pointers to the reallocated items */
+ LY_CHECK_RET(lysp_parse_finalize_reallocated((struct lys_parser_ctx *)ctx, notif->groupings, NULL, NULL, NULL));
+
+ return LY_SUCCESS;
+}
+
+/**
* @brief Map keyword type to substatement info.
*
* @param[in] kw Keyword type.
@@ -1879,6 +1935,7 @@
YIN_ARG_URI, Y_STR_ARG, exts);
break;
case YANG_NOTIFICATION:
+ ret = yin_parse_notification(ctx, attrs, data, (struct notif_meta *)subelem->dest);
break;
case YANG_ORDERED_BY:
ret = yin_parse_orderedby(ctx, attrs, data, (uint16_t *)subelem->dest, exts);
diff --git a/src/parser_yin.h b/src/parser_yin.h
index 2fcae20..e21dd55 100644
--- a/src/parser_yin.h
+++ b/src/parser_yin.h
@@ -115,6 +115,11 @@
struct lysp_include **includes; /**< [Sized array](@ref sizedarrays) of parsed includes to add to */
};
+struct notif_meta {
+ struct lysp_node *parent; /**< parent node */
+ struct lysp_notif **notifs; /**< [Sized array](@ref sizedarrays) of notifications to add to */
+};
+
/**
* @brief Match argument name.
*