schema CHANGE always store extension's parent statement
So far the parent statement of extension instances was stored only in
case the extension was not stored directly in the extension list of
parent structure. But there is no reason to distinguish these cases, so
the patch makes libyang to store the extension's parent statement type
always.
diff --git a/src/parser_stmt.c b/src/parser_stmt.c
index 3f6cf96..f5118aa 100644
--- a/src/parser_stmt.c
+++ b/src/parser_stmt.c
@@ -301,7 +301,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &when->ref, Y_STR_ARG, &when->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &when->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_WHEN, 0, &when->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "when");
@@ -432,7 +432,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &restr->emsg, Y_STR_ARG, &restr->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &restr->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw, 0, &restr->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));
@@ -512,7 +512,7 @@
LY_CHECK_RET(lysp_stmt_when(ctx, child, &any->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &any->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw, 0, &any->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw),
@@ -655,7 +655,7 @@
LY_CHECK_RET(lysp_stmt_type_enum_value_pos(ctx, child, &enm->value, &enm->flags, &enm->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &enm->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw, 0, &enm->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));
@@ -864,7 +864,7 @@
LY_CHECK_RET(lysp_stmt_type_pattern_modifier(ctx, child, &restr->arg.str, &restr->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &restr->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_PATTERN, 0, &restr->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "pattern");
@@ -961,7 +961,7 @@
type->flags |= LYS_SET_TYPE;
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &type->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_TYPE, 0, &type->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "type");
@@ -1034,7 +1034,7 @@
LY_CHECK_RET(lysp_stmt_when(ctx, child, &leaf->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &leaf->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_LEAF, 0, &leaf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "leaf");
@@ -1294,7 +1294,7 @@
LY_CHECK_RET(lysp_stmt_when(ctx, child, &llist->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &llist->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_LEAF_LIST, 0, &llist->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "llist");
@@ -1365,7 +1365,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &rf->presence, Y_STR_ARG, &rf->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &rf->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_REFINE, 0, &rf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "refine");
@@ -1420,7 +1420,7 @@
LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &tpdf->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_TYPEDEF, 0, &tpdf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "typedef");
@@ -1504,7 +1504,7 @@
LY_CHECK_RET(lysp_stmt_grouping(ctx, child, &inout_p->node, &inout_p->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &inout_p->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw, 0, &inout_p->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));
@@ -1572,7 +1572,7 @@
LY_CHECK_RET(lysp_stmt_grouping(ctx, child, &act->node, &act->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &act->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, parent ? LY_STMT_ACTION : LY_STMT_RPC, 0, &act->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), parent ? "action" : "rpc");
@@ -1669,7 +1669,7 @@
LY_CHECK_RET(lysp_stmt_grouping(ctx, child, ¬if->node, ¬if->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, ¬if->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NOTIFICATION, 0, ¬if->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "notification");
@@ -1755,7 +1755,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &grp->node, &grp->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &grp->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_GROUPING, 0, &grp->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "grouping");
@@ -1844,7 +1844,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &aug->node, &aug->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &aug->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_AUGMENT, 0, &aug->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "augment");
@@ -1905,7 +1905,7 @@
LY_CHECK_RET(lysp_stmt_augment(ctx, child, &uses->node, &uses->augments));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &uses->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_USES, 0, &uses->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "uses");
@@ -1984,7 +1984,7 @@
LY_CHECK_RET(lysp_stmt_uses(ctx, child, &cas->node, &cas->child));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &cas->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_CASE, 0, &cas->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "case");
@@ -2072,7 +2072,7 @@
LY_CHECK_RET(lysp_stmt_list(ctx, child, &choice->node, &choice->child));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &choice->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_CHOICE, 0, &choice->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "choice");
@@ -2173,7 +2173,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &cont->node, &cont->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &cont->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_CONTAINER, 0, &cont->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "container");
@@ -2288,7 +2288,7 @@
LY_CHECK_RET(lysp_stmt_notif(ctx, child, &list->node, &list->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &list->exts));
+ LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_LIST, 0, &list->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "list");
@@ -2360,7 +2360,7 @@
ret = lysp_stmt_qnames(&pctx, stmt, (struct lysp_qname **)result, Y_STR_ARG, exts);
break;
case LY_STMT_EXTENSION_INSTANCE:
- ret = lysp_stmt_ext(&pctx, stmt, LY_STMT_NONE, 0, exts);
+ ret = lysp_stmt_ext(&pctx, stmt, LY_STMT_EXTENSION_INSTANCE, 0, exts);
break;
case LY_STMT_FRACTION_DIGITS:
ret = lysp_stmt_type_fracdigits(&pctx, stmt, *(uint8_t **)result, exts);
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 47f437c..cae5398 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -1115,7 +1115,7 @@
LY_CHECK_RET(parse_revisiondate(ctx, inc->rev, &inc->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &inc->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_INCLUDE, 0, &inc->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "include");
@@ -1167,7 +1167,7 @@
LY_CHECK_RET(parse_revisiondate(ctx, imp->rev, &imp->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &imp->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_IMPORT, 0, &imp->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "import");
@@ -1222,7 +1222,7 @@
LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &rev->ref, Y_STR_ARG, &rev->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &rev->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_REVISION, 0, &rev->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "revision");
@@ -1451,7 +1451,7 @@
LY_CHECK_RET(parse_text_field(ctx, LY_STMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, &restr->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &restr->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, restr_kw, 0, &restr->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(restr_kw));
@@ -1570,7 +1570,7 @@
LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &when->ref, Y_STR_ARG, &when->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &when->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_WHEN, 0, &when->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "when");
@@ -1584,23 +1584,24 @@
* @brief Parse the anydata or anyxml statement.
*
* @param[in] ctx yang parser context for logging.
- * @param[in] kw Type of this particular keyword.
+ * @param[in] any_kw Type of this particular keyword.
* @param[in,out] siblings Siblings to add to.
*
* @return LY_ERR values.
*/
LY_ERR
-parse_any(struct lys_yang_parser_ctx *ctx, enum ly_stmt kw, struct lysp_node *parent, struct lysp_node **siblings)
+parse_any(struct lys_yang_parser_ctx *ctx, enum ly_stmt any_kw, struct lysp_node *parent, struct lysp_node **siblings)
{
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
struct lysp_node_anydata *any;
+ enum ly_stmt kw;
/* create new structure and insert into siblings */
LY_LIST_NEW_RET(PARSER_CTX(ctx), siblings, any, next, LY_EMEM);
- any->nodetype = kw == LY_STMT_ANYDATA ? LYS_ANYDATA : LYS_ANYXML;
+ any->nodetype = any_kw == LY_STMT_ANYDATA ? LYS_ANYDATA : LYS_ANYXML;
any->parent = parent;
/* get name */
@@ -1635,11 +1636,10 @@
LY_CHECK_RET(parse_when(ctx, &any->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &any->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, any_kw, 0, &any->exts));
break;
default:
- LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
- (any->nodetype & LYS_ANYDATA) == LYS_ANYDATA ? ly_stmt2str(LY_STMT_ANYDATA) : ly_stmt2str(LY_STMT_ANYXML));
+ LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(any_kw));
return LY_EVALID;
}
}
@@ -1785,7 +1785,7 @@
LY_CHECK_RET(parse_type_enum_value_pos(ctx, kw, &enm->value, &enm->flags, &enm->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &enm->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, enum_kw, 0, &enm->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(enum_kw));
@@ -2016,7 +2016,7 @@
LY_CHECK_RET(parse_type_pattern_modifier(ctx, &restr->arg.str, &restr->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &restr->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_PATTERN, 0, &restr->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "pattern");
@@ -2123,7 +2123,7 @@
type->flags |= LYS_SET_TYPE;
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &type->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_TYPE, 0, &type->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "type");
@@ -2197,7 +2197,7 @@
LY_CHECK_RET(parse_when(ctx, &leaf->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &leaf->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_LEAF, 0, &leaf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "leaf");
@@ -2466,7 +2466,7 @@
LY_CHECK_RET(parse_when(ctx, &llist->when));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &llist->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_LEAF_LIST, 0, &llist->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "llist");
@@ -2542,7 +2542,7 @@
LY_CHECK_RET(parse_text_field(ctx, LY_STMT_PRESENCE, 0, &rf->presence, Y_STR_ARG, &rf->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &rf->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_REFINE, 0, &rf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "refine");
@@ -2598,7 +2598,7 @@
LY_CHECK_RET(parse_text_field(ctx, LY_STMT_UNITS, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &tpdf->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_TYPEDEF, 0, &tpdf->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "typedef");
@@ -2688,7 +2688,7 @@
LY_CHECK_RET(parse_grouping(ctx, (struct lysp_node *)inout_p, &inout_p->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &inout_p->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, inout_kw, 0, &inout_p->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(inout_kw));
@@ -2760,7 +2760,7 @@
LY_CHECK_RET(parse_grouping(ctx, (struct lysp_node *)act, &act->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &act->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, parent ? LY_STMT_ACTION : LY_STMT_RPC, 0, &act->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), parent ? "action" : "rpc");
@@ -2861,7 +2861,7 @@
LY_CHECK_RET(parse_grouping(ctx, (struct lysp_node *)notif, ¬if->groupings));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, ¬if->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NOTIFICATION, 0, ¬if->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "notification");
@@ -2949,7 +2949,7 @@
LY_CHECK_RET(parse_notif(ctx, &grp->node, &grp->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &grp->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_GROUPING, 0, &grp->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "grouping");
@@ -3041,7 +3041,7 @@
LY_CHECK_RET(parse_notif(ctx, (struct lysp_node *)aug, &aug->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &aug->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_AUGMENT, 0, &aug->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "augment");
@@ -3104,7 +3104,7 @@
LY_CHECK_RET(parse_augment(ctx, (struct lysp_node *)uses, &uses->augments));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &uses->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_USES, 0, &uses->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "uses");
@@ -3185,7 +3185,7 @@
LY_CHECK_RET(parse_uses(ctx, (struct lysp_node *)cas, &cas->child));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &cas->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_CASE, 0, &cas->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "case");
@@ -3277,7 +3277,7 @@
LY_CHECK_RET(parse_list(ctx, (struct lysp_node *)choice, &choice->child));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &choice->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_CHOICE, 0, &choice->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "choice");
@@ -3381,7 +3381,7 @@
LY_CHECK_RET(parse_notif(ctx, (struct lysp_node *)cont, &cont->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &cont->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_CONTAINER, 0, &cont->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "container");
@@ -3498,7 +3498,7 @@
LY_CHECK_RET(parse_notif(ctx, (struct lysp_node *)list, &list->notifs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &list->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_LIST, 0, &list->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "list");
@@ -3640,7 +3640,7 @@
LY_CHECK_RET(parse_argument(ctx, &ex->argument, &ex->flags, &ex->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &ex->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_EXTENSION, 0, &ex->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "extension");
@@ -3849,7 +3849,7 @@
}
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &d->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_DEVIATE, 0, &d->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "deviate");
@@ -3895,7 +3895,7 @@
LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &dev->ref, Y_STR_ARG, &dev->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &dev->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_DEVIATION, 0, &dev->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "deviation");
@@ -3951,7 +3951,7 @@
LY_CHECK_RET(parse_status(ctx, &feat->flags, &feat->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &feat->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_FEATURE, 0, &feat->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "feature");
@@ -4007,7 +4007,7 @@
LY_CHECK_RET(parse_text_fields(ctx, LY_STMT_BASE, &ident->bases, Y_PREF_IDENTIF_ARG, &ident->exts));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &ident->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_IDENTITY, 0, &ident->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "identity");
@@ -4193,7 +4193,7 @@
LY_CHECK_RET(parse_typedef(ctx, NULL, &mod->typedefs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &mod->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_MODULE, 0, &mod->exts));
break;
default:
@@ -4400,7 +4400,7 @@
LY_CHECK_RET(parse_typedef(ctx, NULL, &submod->typedefs));
break;
case LY_STMT_EXTENSION_INSTANCE:
- LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &submod->exts));
+ LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_SUBMODULE, 0, &submod->exts));
break;
default:
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 90fbf78..24ed410 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -2530,6 +2530,7 @@
LY_ERR ret = LY_SUCCESS;
struct yin_subelement *subelems = NULL;
size_t subelems_size;
+ enum ly_stmt kw = act_meta->parent ? LY_STMT_ACTION : LY_STMT_RPC;
/* create new action */
LY_LIST_NEW_RET(ctx->xmlctx->ctx, acts, act, next, LY_EMEM);
@@ -2538,7 +2539,7 @@
/* parse argument */
LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
- LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_NAME, &act->name, Y_IDENTIF_ARG, LY_STMT_ACTION));
+ LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_NAME, &act->name, Y_IDENTIF_ARG, kw));
/* parse content */
LY_CHECK_RET(subelems_allocator(ctx, subelems_size = 9, (struct lysp_node *)act, &subelems,
@@ -2551,7 +2552,7 @@
LY_STMT_STATUS, &act->flags, YIN_SUBELEM_UNIQUE,
LY_STMT_TYPEDEF, &act->typedefs, 0,
LY_STMT_EXTENSION_INSTANCE, NULL, 0));
- ret = (yin_parse_content(ctx, subelems, subelems_size, LY_STMT_ACTION, NULL, &act->exts));
+ ret = (yin_parse_content(ctx, subelems, subelems_size, kw, NULL, &act->exts));
subelems_deallocator(subelems_size, subelems);
LY_CHECK_RET(ret);
@@ -2763,86 +2764,6 @@
}
/**
- * @brief Map keyword type to substatement info.
- *
- * @param[in] kw Keyword type.
- *
- * @return correct LYEXT_SUBSTMT information.
- */
-static enum ly_stmt
-kw2lyext_substmt(enum ly_stmt kw)
-{
- switch (kw) {
- case LY_STMT_ARGUMENT:
- return LY_STMT_ARGUMENT;
- case LY_STMT_BASE:
- return LY_STMT_BASE;
- case LY_STMT_BELONGS_TO:
- return LY_STMT_BELONGS_TO;
- case LY_STMT_CONTACT:
- return LY_STMT_CONTACT;
- case LY_STMT_DEFAULT:
- return LY_STMT_DEFAULT;
- case LY_STMT_DESCRIPTION:
- return LY_STMT_DESCRIPTION;
- case LY_STMT_ERROR_APP_TAG:
- return LY_STMT_ERROR_APP_TAG;
- case LY_STMT_ERROR_MESSAGE:
- return LY_STMT_ERROR_MESSAGE;
- case LY_STMT_KEY:
- return LY_STMT_KEY;
- case LY_STMT_NAMESPACE:
- return LY_STMT_NAMESPACE;
- case LY_STMT_ORGANIZATION:
- return LY_STMT_ORGANIZATION;
- case LY_STMT_PATH:
- return LY_STMT_PATH;
- case LY_STMT_PREFIX:
- return LY_STMT_PREFIX;
- case LY_STMT_PRESENCE:
- return LY_STMT_PRESENCE;
- case LY_STMT_REFERENCE:
- return LY_STMT_REFERENCE;
- case LY_STMT_REVISION_DATE:
- return LY_STMT_REVISION_DATE;
- case LY_STMT_UNITS:
- return LY_STMT_UNITS;
- case LY_STMT_VALUE:
- return LY_STMT_VALUE;
- case LY_STMT_YANG_VERSION:
- return LY_STMT_YANG_VERSION;
- case LY_STMT_MODIFIER:
- return LY_STMT_MODIFIER;
- case LY_STMT_REQUIRE_INSTANCE:
- return LY_STMT_REQUIRE_INSTANCE;
- case LY_STMT_YIN_ELEMENT:
- return LY_STMT_YIN_ELEMENT;
- case LY_STMT_CONFIG:
- return LY_STMT_CONFIG;
- case LY_STMT_MANDATORY:
- return LY_STMT_MANDATORY;
- case LY_STMT_ORDERED_BY:
- return LY_STMT_ORDERED_BY;
- case LY_STMT_STATUS:
- return LY_STMT_STATUS;
- case LY_STMT_FRACTION_DIGITS:
- return LY_STMT_FRACTION_DIGITS;
- case LY_STMT_MAX_ELEMENTS:
- return LY_STMT_MAX_ELEMENTS;
- case LY_STMT_MIN_ELEMENTS:
- return LY_STMT_MIN_ELEMENTS;
- case LY_STMT_POSITION:
- return LY_STMT_POSITION;
- case LY_STMT_UNIQUE:
- return LY_STMT_UNIQUE;
- case LY_STMT_IF_FEATURE:
- return LY_STMT_IF_FEATURE;
- default:
- return LY_STMT_NONE;
- }
-}
-
-/**
* @brief map keyword to keyword-group.
*
* @param[in] ctx YIN parser context used for logging.
@@ -3399,7 +3320,7 @@
switch (kw) {
/* call responsible function */
case LY_STMT_EXTENSION_INSTANCE:
- ret = yin_parse_extension_instance(ctx, kw2lyext_substmt(current_element),
+ ret = yin_parse_extension_instance(ctx, current_element,
(subelem->dest) ? *((LY_ARRAY_COUNT_TYPE *)subelem->dest) : 0, exts);
break;
case LY_STMT_ACTION:
diff --git a/src/printer_yang.c b/src/printer_yang.c
index c08da2f..bf1c8a6 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -330,7 +330,7 @@
if (rev->dsc || rev->ref || rev->exts) {
ly_print_(ctx->out, "%*srevision %s {\n", INDENT, rev->date);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, rev->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_REVISION, 0, rev->exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);
ypr_substmt(ctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);
LEVEL--;
@@ -427,7 +427,7 @@
LEVEL++;
if (ext->exts) {
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, ext->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
}
if (ext->argument) {
@@ -464,7 +464,7 @@
ly_print_(ctx->out, "\n%*sfeature %s", INDENT, feat->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, feat->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_FEATURE, 0, feat->exts, &flag, 0);
yprp_iffeatures(ctx, feat->iffeatures, feat->exts, &flag);
ypr_status(ctx, feat->flags, feat->exts, &flag);
ypr_description(ctx, feat->dsc, feat->exts, &flag);
@@ -482,7 +482,7 @@
ly_print_(ctx->out, "\n%*sidentity %s", INDENT, ident->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, ident->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
yprp_iffeatures(ctx, ident->iffeatures, ident->exts, &flag);
LY_ARRAY_FOR(ident->bases, u) {
@@ -507,7 +507,7 @@
ly_print_(ctx->out, "\n%*sidentity %s", INDENT, ident->name);
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, ident->exts, &flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
LY_ARRAY_FOR(ident->derived, u) {
ypr_open(ctx->out, &flag);
@@ -527,7 +527,7 @@
}
static void
-yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, const char *name, ly_bool *flag)
+yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, enum ly_stmt stmt, ly_bool *flag)
{
ly_bool inner_flag = 0;
@@ -536,14 +536,14 @@
}
ypr_open(ctx->out, flag);
- ly_print_(ctx->out, "%*s%s \"", INDENT, name);
+ ly_print_(ctx->out, "%*s%s \"", INDENT, ly_stmt2str(stmt));
ypr_encode(ctx->out,
(restr->arg.str[0] != LYSP_RESTR_PATTERN_NACK && restr->arg.str[0] != LYSP_RESTR_PATTERN_ACK) ?
restr->arg.str : &restr->arg.str[1], -1);
ly_print_(ctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, restr->exts, &inner_flag, 0);
+ yprp_extension_instances(ctx, stmt, 0, restr->exts, &inner_flag, 0);
if (restr->arg.str[0] == LYSP_RESTR_PATTERN_NACK) {
/* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
ypr_open(ctx->out, &inner_flag);
@@ -575,7 +575,7 @@
ly_print_(ctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, must->exts, &inner_flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_MUST, 0, must->exts, &inner_flag, 0);
if (must->emsg) {
ypr_open(ctx->out, &inner_flag);
ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, must->emsg, must->exts);
@@ -624,7 +624,7 @@
ly_print_(ctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, range->exts, &inner_flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_RANGE, 0, range->exts, &inner_flag, 0);
if (range->emsg) {
ypr_open(ctx->out, &inner_flag);
ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, range->emsg, range->exts);
@@ -651,7 +651,7 @@
ly_print_(ctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, pattern->exts, &inner_flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_PATTERN, 0, pattern->exts, &inner_flag, 0);
if (pattern->inverted) {
/* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
ypr_open(ctx->out, &inner_flag);
@@ -687,7 +687,7 @@
ly_print_(ctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, when->exts, &inner_flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
ypr_description(ctx, when->dsc, when->exts, &inner_flag);
ypr_reference(ctx, when->ref, when->exts, &inner_flag);
LEVEL--;
@@ -709,7 +709,7 @@
ly_print_(ctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, when->exts, &inner_flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
ypr_description(ctx, when->dsc, when->exts, &inner_flag);
ypr_reference(ctx, when->ref, when->exts, &inner_flag);
LEVEL--;
@@ -733,7 +733,7 @@
}
inner_flag = 0;
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, items[u].exts, &inner_flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_ENUM, 0, items[u].exts, &inner_flag, 0);
yprp_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag);
if (items[u].flags & LYS_SET_VALUE) {
if (type == LY_TYPE_BITS) {
@@ -759,12 +759,12 @@
ly_print_(ctx->out, "%*stype %s", INDENT, type->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, type->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
- yprp_restr(ctx, type->range, "range", &flag);
- yprp_restr(ctx, type->length, "length", &flag);
+ yprp_restr(ctx, type->range, LY_STMT_RANGE, &flag);
+ yprp_restr(ctx, type->length, LY_STMT_LENGTH, &flag);
LY_ARRAY_FOR(type->patterns, u) {
- yprp_restr(ctx, &type->patterns[u], "pattern", &flag);
+ yprp_restr(ctx, &type->patterns[u], LY_STMT_PATTERN, &flag);
}
yprp_enum(ctx, type->bits, LY_TYPE_BITS, &flag);
yprp_enum(ctx, type->enums, LY_TYPE_ENUM, &flag);
@@ -815,7 +815,7 @@
ly_print_(ctx->out, "%*stype %s", INDENT, lys_datatype2str(type->basetype));
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, type->exts, &flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
switch (type->basetype) {
case LY_TYPE_BINARY: {
@@ -856,10 +856,11 @@
ypr_encode(ctx->out, item->name, -1);
ly_print_(ctx->out, "\"");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, item->exts, &inner_flag, 0);
if (type->basetype == LY_TYPE_BITS) {
+ yprc_extension_instances(ctx, LY_STMT_BIT, 0, item->exts, &inner_flag, 0);
ypr_unsigned(ctx, LY_STMT_POSITION, 0, item->exts, item->position, &inner_flag);
} else { /* LY_TYPE_ENUM */
+ yprc_extension_instances(ctx, LY_STMT_ENUM, 0, item->exts, &inner_flag, 0);
ypr_signed(ctx, LY_STMT_VALUE, 0, item->exts, item->value, &inner_flag);
}
ypr_status(ctx, item->flags, item->exts, &inner_flag);
@@ -925,7 +926,7 @@
ly_print_(ctx->out, "\n%*stypedef %s {\n", INDENT, tpdf->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, tpdf->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_TYPEDEF, 0, tpdf->exts, NULL, 0);
yprp_type(ctx, &tpdf->type);
@@ -962,7 +963,7 @@
ly_print_(ctx->out, "\n%*sgrouping %s", INDENT, grp->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, grp->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_GROUPING, 0, grp->exts, &flag, 0);
ypr_status(ctx, grp->flags, grp->exts, &flag);
ypr_description(ctx, grp->dsc, grp->exts, &flag);
ypr_reference(ctx, grp->ref, grp->exts, &flag);
@@ -1012,9 +1013,9 @@
ly_print_(ctx->out, "\n%*s%s {\n", INDENT, inout->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, inout->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_MUST, 0, inout->exts, NULL, 0);
LY_ARRAY_FOR(inout->musts, u) {
- yprp_restr(ctx, &inout->musts[u], "must", NULL);
+ yprp_restr(ctx, &inout->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(inout->typedefs, u) {
yprp_typedef(ctx, &inout->typedefs[u]);
@@ -1046,7 +1047,7 @@
ly_print_(ctx->out, "\n%*s%s {\n", INDENT, inout->name);
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, inout->exts, NULL, 0);
+ yprc_extension_instances(ctx, lys_nodetype2stmt(inout->nodetype), 0, inout->exts, NULL, 0);
LY_ARRAY_FOR(inout->musts, u) {
yprc_must(ctx, &inout->musts[u], NULL);
}
@@ -1072,11 +1073,11 @@
ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, notif->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
yprp_iffeatures(ctx, notif->iffeatures, notif->exts, &flag);
LY_ARRAY_FOR(notif->musts, u) {
- yprp_restr(ctx, ¬if->musts[u], "must", &flag);
+ yprp_restr(ctx, ¬if->musts[u], LY_STMT_MUST, &flag);
}
ypr_status(ctx, notif->flags, notif->exts, &flag);
ypr_description(ctx, notif->dsc, notif->exts, &flag);
@@ -1111,7 +1112,7 @@
ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, notif->exts, &flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
LY_ARRAY_FOR(notif->musts, u) {
yprc_must(ctx, ¬if->musts[u], &flag);
@@ -1141,7 +1142,7 @@
ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, action->exts, &flag, 0);
+ yprp_extension_instances(ctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
yprp_iffeatures(ctx, action->iffeatures, action->exts, &flag);
ypr_status(ctx, action->flags, action->exts, &flag);
ypr_description(ctx, action->dsc, action->exts, &flag);
@@ -1172,7 +1173,7 @@
ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, action->exts, &flag, 0);
+ yprc_extension_instances(ctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
ypr_status(ctx, action->flags, action->exts, &flag);
ypr_description(ctx, action->dsc, action->exts, &flag);
ypr_reference(ctx, action->ref, action->exts, &flag);
@@ -1190,7 +1191,7 @@
ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, node->exts, flag, 0);
+ yprp_extension_instances(ctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
yprp_when(ctx, lysp_node_when(node), flag);
yprp_iffeatures(ctx, node->iffeatures, node->exts, flag);
}
@@ -1204,7 +1205,7 @@
ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, node->exts, flag, 0);
+ yprc_extension_instances(ctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
when = lysc_node_when(node);
LY_ARRAY_FOR(when, u) {
@@ -1250,7 +1251,7 @@
yprp_node_common1(ctx, node, &flag);
LY_ARRAY_FOR(cont->musts, u) {
- yprp_restr(ctx, &cont->musts[u], "must", &flag);
+ yprp_restr(ctx, &cont->musts[u], LY_STMT_MUST, &flag);
}
if (cont->presence) {
ypr_open(ctx->out, &flag);
@@ -1431,7 +1432,7 @@
yprp_type(ctx, &leaf->type);
ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
LY_ARRAY_FOR(leaf->musts, u) {
- yprp_restr(ctx, &leaf->musts[u], "must", NULL);
+ yprp_restr(ctx, &leaf->musts[u], LY_STMT_MUST, NULL);
}
ypr_substmt(ctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);
@@ -1476,7 +1477,7 @@
yprp_type(ctx, &llist->type);
ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
LY_ARRAY_FOR(llist->musts, u) {
- yprp_restr(ctx, &llist->musts[u], "must", NULL);
+ yprp_restr(ctx, &llist->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(llist->dflts, u) {
ypr_substmt(ctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);
@@ -1557,7 +1558,7 @@
yprp_node_common1(ctx, node, &flag);
LY_ARRAY_FOR(list->musts, u) {
- yprp_restr(ctx, &list->musts[u], "must", &flag);
+ yprp_restr(ctx, &list->musts[u], LY_STMT_MUST, &flag);
}
if (list->key) {
ypr_open(ctx->out, &flag);
@@ -1692,12 +1693,12 @@
ly_print_(ctx->out, "%*srefine \"%s\"", INDENT, refine->nodeid);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, refine->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_REFINE, 0, refine->exts, &flag, 0);
yprp_iffeatures(ctx, refine->iffeatures, refine->exts, &flag);
LY_ARRAY_FOR(refine->musts, u) {
ypr_open(ctx->out, &flag);
- yprp_restr(ctx, &refine->musts[u], "must", NULL);
+ yprp_restr(ctx, &refine->musts[u], LY_STMT_MUST, NULL);
}
if (refine->presence) {
@@ -1743,7 +1744,7 @@
ly_print_(ctx->out, "%*saugment \"%s\" {\n", INDENT, aug->nodeid);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, aug->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_AUGMENT, 0, aug->exts, NULL, 0);
yprp_when(ctx, aug->when, NULL);
yprp_iffeatures(ctx, aug->iffeatures, aug->exts, NULL);
ypr_status(ctx, aug->flags, aug->exts, NULL);
@@ -1802,7 +1803,7 @@
LY_ARRAY_FOR(any->musts, u) {
ypr_open(ctx->out, &flag);
- yprp_restr(ctx, &any->musts[u], "must", NULL);
+ yprp_restr(ctx, &any->musts[u], LY_STMT_MUST, NULL);
}
yprp_node_common2(ctx, node, &flag);
@@ -1905,7 +1906,7 @@
ly_print_(ctx->out, "%*sdeviation \"%s\" {\n", INDENT, deviation->nodeid);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, deviation->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATION, 0, deviation->exts, NULL, 0);
ypr_description(ctx, deviation->dsc, deviation->exts, NULL);
ypr_reference(ctx, deviation->ref, deviation->exts, NULL);
@@ -1916,7 +1917,7 @@
ly_print_(ctx->out, "not-supported {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, elem->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, elem->exts, NULL, 0);
} else {
ly_print_(ctx->out, "not-supported;\n");
continue;
@@ -1926,10 +1927,10 @@
ly_print_(ctx->out, "add {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, add->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, add->exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_UNITS, 0, add->units, add->exts);
LY_ARRAY_FOR(add->musts, u) {
- yprp_restr(ctx, &add->musts[u], "must", NULL);
+ yprp_restr(ctx, &add->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(add->uniques, u) {
ypr_substmt(ctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);
@@ -1954,7 +1955,7 @@
ly_print_(ctx->out, "replace {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, rpl->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, rpl->exts, NULL, 0);
if (rpl->type) {
yprp_type(ctx, rpl->type);
}
@@ -1977,10 +1978,10 @@
ly_print_(ctx->out, "delete {\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, del->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, del->exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_UNITS, 0, del->units, del->exts);
LY_ARRAY_FOR(del->musts, u) {
- yprp_restr(ctx, &del->musts[u], "must", NULL);
+ yprp_restr(ctx, &del->musts[u], LY_STMT_MUST, NULL);
}
LY_ARRAY_FOR(del->uniques, u) {
ypr_substmt(ctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);
@@ -2010,7 +2011,7 @@
ly_print_(ctx->out, "%s%*simport %s {\n", u ? "" : "\n", INDENT, modp->imports[u].name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->imports[u].exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_IMPORT, 0, modp->imports[u].exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);
if (modp->imports[u].rev[0]) {
ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);
@@ -2028,7 +2029,7 @@
if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) {
ly_print_(ctx->out, "%s%*sinclude %s {\n", u ? "" : "\n", INDENT, modp->includes[u].name);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->includes[u].exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_INCLUDE, 0, modp->includes[u].exts, NULL, 0);
if (modp->includes[u].rev[0]) {
ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);
}
@@ -2058,7 +2059,7 @@
}
if (modp->exts) {
ly_print_(ctx->out, "\n");
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_MODULE, 0, modp->exts, NULL, 0);
}
LY_ARRAY_FOR(modp->features, u) {
@@ -2248,7 +2249,7 @@
/* body-stmts */
if (modc->exts) {
ly_print_(out, "\n");
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, module->compiled->exts, NULL, 0);
+ yprc_extension_instances(ctx, LY_STMT_MODULE, 0, module->compiled->exts, NULL, 0);
}
LY_ARRAY_FOR(module->identities, u) {
@@ -2314,7 +2315,7 @@
}
LEVEL++;
- yprc_extension_instances(ctx, LY_STMT_NONE, 0, ext[u].exts, &inner_flag, 0);
+ yprc_extension_instances(ctx, LY_STMT_EXTENSION_INSTANCE, 0, ext[u].exts, &inner_flag, 0);
if (ext[u].def->plugin->sprinter) {
ext[u].def->plugin->sprinter(ctx, &ext[u], &inner_flag);
diff --git a/src/printer_yin.c b/src/printer_yin.c
index 8cbe8cc..1531f65 100644
--- a/src/printer_yin.c
+++ b/src/printer_yin.c
@@ -156,7 +156,7 @@
if (rev->dsc || rev->ref || rev->exts) {
ypr_open(ctx, "revision", "date", rev->date, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, rev->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_REVISION, 0, rev->exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);
ypr_substmt(ctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);
LEVEL--;
@@ -254,7 +254,7 @@
if (ext->exts) {
ypr_close_parent(ctx, &flag);
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, ext->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_EXTENSION, 0, ext->exts, &flag, 0);
}
if (ext->argument) {
@@ -293,7 +293,7 @@
ypr_open(ctx, "feature", "name", feat->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, feat->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_FEATURE, 0, feat->exts, &flag, 0);
yprp_iffeatures(ctx, feat->iffeatures, feat->exts, &flag);
ypr_status(ctx, feat->flags, feat->exts, &flag);
ypr_description(ctx, feat->dsc, feat->exts, &flag);
@@ -311,7 +311,7 @@
ypr_open(ctx, "identity", "name", ident->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, ident->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_IDENTITY, 0, ident->exts, &flag, 0);
yprp_iffeatures(ctx, ident->iffeatures, ident->exts, &flag);
LY_ARRAY_FOR(ident->bases, u) {
@@ -328,7 +328,7 @@
}
static void
-yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, const char *name, const char *attr, int8_t *flag)
+yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, enum ly_stmt stmt, const char *attr, int8_t *flag)
{
(void)flag;
int8_t inner_flag = 0;
@@ -337,14 +337,14 @@
return;
}
- ly_print_(ctx->out, "%*s<%s %s=\"", INDENT, name, attr);
+ ly_print_(ctx->out, "%*s<%s %s=\"", INDENT, ly_stmt2str(stmt), attr);
lyxml_dump_text(ctx->out,
(restr->arg.str[0] != LYSP_RESTR_PATTERN_NACK && restr->arg.str[0] != LYSP_RESTR_PATTERN_ACK) ?
restr->arg.str : &restr->arg.str[1], 1);
ly_print_(ctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, restr->exts, &inner_flag, 0);
+ yprp_extension_instances(ctx, stmt, 0, restr->exts, &inner_flag, 0);
if (restr->arg.str[0] == LYSP_RESTR_PATTERN_NACK) {
ypr_close_parent(ctx, &inner_flag);
/* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
@@ -362,7 +362,7 @@
ypr_reference(ctx, restr->ref, restr->exts, &inner_flag);
LEVEL--;
- ypr_close(ctx, name, inner_flag);
+ ypr_close(ctx, ly_stmt2str(stmt), inner_flag);
}
static void
@@ -381,7 +381,7 @@
ly_print_(ctx->out, "\"");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, when->exts, &inner_flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_WHEN, 0, when->exts, &inner_flag, 0);
ypr_description(ctx, when->dsc, when->exts, &inner_flag);
ypr_reference(ctx, when->ref, when->exts, &inner_flag);
LEVEL--;
@@ -408,7 +408,7 @@
}
inner_flag = 0;
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, items[u].exts, &inner_flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_ENUM, 0, items[u].exts, &inner_flag, 0);
yprp_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag);
if (items[u].flags & LYS_SET_VALUE) {
if (type == LY_TYPE_BITS) {
@@ -440,15 +440,15 @@
ypr_open(ctx, "type", "name", type->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, type->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_TYPE, 0, type->exts, &flag, 0);
if (type->range || type->length || type->patterns || type->bits || type->enums) {
ypr_close_parent(ctx, &flag);
}
- yprp_restr(ctx, type->range, "range", "value", &flag);
- yprp_restr(ctx, type->length, "length", "value", &flag);
+ yprp_restr(ctx, type->range, LY_STMT_RANGE, "value", &flag);
+ yprp_restr(ctx, type->length, LY_STMT_LENGTH, "value", &flag);
LY_ARRAY_FOR(type->patterns, u) {
- yprp_restr(ctx, &type->patterns[u], "pattern", "value", &flag);
+ yprp_restr(ctx, &type->patterns[u], LY_STMT_PATTERN, "value", &flag);
}
yprp_enum(ctx, type->bits, LY_TYPE_BITS, &flag);
yprp_enum(ctx, type->enums, LY_TYPE_ENUM, &flag);
@@ -484,7 +484,7 @@
ypr_open(ctx, "typedef", "name", tpdf->name, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, tpdf->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_TYPEDEF, 0, tpdf->exts, NULL, 0);
yprp_type(ctx, &tpdf->type);
@@ -520,7 +520,7 @@
ypr_open(ctx, "grouping", "name", grp->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, grp->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_GROUPING, 0, grp->exts, &flag, 0);
ypr_status(ctx, grp->flags, grp->exts, &flag);
ypr_description(ctx, grp->dsc, grp->exts, &flag);
ypr_reference(ctx, grp->ref, grp->exts, &flag);
@@ -570,9 +570,9 @@
ypr_open(ctx, inout->name, NULL, NULL, *flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, inout->exts, NULL, 0);
+ yprp_extension_instances(ctx, lys_nodetype2stmt(inout->nodetype), 0, inout->exts, NULL, 0);
LY_ARRAY_FOR(inout->musts, u) {
- yprp_restr(ctx, &inout->musts[u], "must", "condition", NULL);
+ yprp_restr(ctx, &inout->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(inout->typedefs, u) {
yprp_typedef(ctx, &inout->typedefs[u]);
@@ -600,12 +600,12 @@
ypr_open(ctx, "notification", "name", notif->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, notif->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_NOTIFICATION, 0, notif->exts, &flag, 0);
yprp_iffeatures(ctx, notif->iffeatures, notif->exts, &flag);
LY_ARRAY_FOR(notif->musts, u) {
ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, ¬if->musts[u], "must", "condition", &flag);
+ yprp_restr(ctx, ¬if->musts[u], LY_STMT_MUST, "condition", &flag);
}
ypr_status(ctx, notif->flags, notif->exts, &flag);
ypr_description(ctx, notif->dsc, notif->exts, &flag);
@@ -640,7 +640,7 @@
ypr_open(ctx, action->parent ? "action" : "rpc", "name", action->name, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, action->exts, &flag, 0);
+ yprp_extension_instances(ctx, lys_nodetype2stmt(action->nodetype), 0, action->exts, &flag, 0);
yprp_iffeatures(ctx, action->iffeatures, action->exts, &flag);
ypr_status(ctx, action->flags, action->exts, &flag);
ypr_description(ctx, action->dsc, action->exts, &flag);
@@ -669,7 +669,7 @@
ypr_open(ctx, lys_nodetype2str(node->nodetype), "name", node->name, *flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, node->exts, flag, 0);
+ yprp_extension_instances(ctx, lys_nodetype2stmt(node->nodetype), 0, node->exts, flag, 0);
yprp_when(ctx, lysp_node_when(node), flag);
yprp_iffeatures(ctx, node->iffeatures, node->exts, flag);
}
@@ -701,7 +701,7 @@
LY_ARRAY_FOR(cont->musts, u) {
ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &cont->musts[u], "must", "condition", &flag);
+ yprp_restr(ctx, &cont->musts[u], LY_STMT_MUST, "condition", &flag);
}
if (cont->presence) {
ypr_close_parent(ctx, &flag);
@@ -796,7 +796,7 @@
yprp_type(ctx, &leaf->type);
ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
LY_ARRAY_FOR(leaf->musts, u) {
- yprp_restr(ctx, &leaf->musts[u], "must", "condition", &flag);
+ yprp_restr(ctx, &leaf->musts[u], LY_STMT_MUST, "condition", &flag);
}
ypr_substmt(ctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);
@@ -818,7 +818,7 @@
yprp_type(ctx, &llist->type);
ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
LY_ARRAY_FOR(llist->musts, u) {
- yprp_restr(ctx, &llist->musts[u], "must", "condition", NULL);
+ yprp_restr(ctx, &llist->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(llist->dflts, u) {
ypr_substmt(ctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);
@@ -864,7 +864,7 @@
LY_ARRAY_FOR(list->musts, u) {
ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &list->musts[u], "must", "condition", &flag);
+ yprp_restr(ctx, &list->musts[u], LY_STMT_MUST, "condition", &flag);
}
if (list->key) {
ypr_close_parent(ctx, &flag);
@@ -935,12 +935,12 @@
ypr_open(ctx, "refine", "target-node", refine->nodeid, flag);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, refine->exts, &flag, 0);
+ yprp_extension_instances(ctx, LY_STMT_REFINE, 0, refine->exts, &flag, 0);
yprp_iffeatures(ctx, refine->iffeatures, refine->exts, &flag);
LY_ARRAY_FOR(refine->musts, u) {
ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &refine->musts[u], "must", "condition", &flag);
+ yprp_restr(ctx, &refine->musts[u], LY_STMT_MUST, "condition", &flag);
}
if (refine->presence) {
@@ -986,7 +986,7 @@
ypr_open(ctx, "augment", "target-node", aug->nodeid, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, aug->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_AUGMENT, 0, aug->exts, NULL, 0);
yprp_when(ctx, aug->when, NULL);
yprp_iffeatures(ctx, aug->iffeatures, aug->exts, NULL);
ypr_status(ctx, aug->flags, aug->exts, NULL);
@@ -1045,7 +1045,7 @@
LY_ARRAY_FOR(any->musts, u) {
ypr_close_parent(ctx, &flag);
- yprp_restr(ctx, &any->musts[u], "must", "condition", &flag);
+ yprp_restr(ctx, &any->musts[u], LY_STMT_MUST, "condition", &flag);
}
yprp_node_common2(ctx, node, &flag);
@@ -1100,7 +1100,7 @@
ypr_open(ctx, "deviation", "target-node", deviation->nodeid, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, deviation->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATION, 0, deviation->exts, NULL, 0);
ypr_description(ctx, deviation->dsc, deviation->exts, NULL);
ypr_reference(ctx, deviation->ref, deviation->exts, NULL);
@@ -1111,7 +1111,7 @@
ly_print_(ctx->out, "not-supported\"/>\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, elem->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, elem->exts, NULL, 0);
} else {
ly_print_(ctx->out, "not-supported\"/>\n");
continue;
@@ -1121,10 +1121,10 @@
ly_print_(ctx->out, "add\">\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, add->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, add->exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_UNITS, 0, add->units, add->exts);
LY_ARRAY_FOR(add->musts, u) {
- yprp_restr(ctx, &add->musts[u], "must", "condition", NULL);
+ yprp_restr(ctx, &add->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(add->uniques, u) {
ypr_substmt(ctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);
@@ -1149,7 +1149,7 @@
ly_print_(ctx->out, "replace\">\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, rpl->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, rpl->exts, NULL, 0);
if (rpl->type) {
yprp_type(ctx, rpl->type);
}
@@ -1172,10 +1172,10 @@
ly_print_(ctx->out, "delete\">\n");
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, del->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_DEVIATE, 0, del->exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_UNITS, 0, del->units, del->exts);
LY_ARRAY_FOR(del->musts, u) {
- yprp_restr(ctx, &del->musts[u], "must", "condition", NULL);
+ yprp_restr(ctx, &del->musts[u], LY_STMT_MUST, "condition", NULL);
}
LY_ARRAY_FOR(del->uniques, u) {
ypr_substmt(ctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);
@@ -1300,7 +1300,7 @@
ypr_open(ctx, "import", "module", modp->imports[u].name, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->imports[u].exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_IMPORT, 0, modp->imports[u].exts, NULL, 0);
ypr_substmt(ctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);
if (modp->imports[u].rev[0]) {
ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);
@@ -1318,7 +1318,7 @@
if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) {
ypr_open(ctx, "include", "module", modp->includes[u].name, 1);
LEVEL++;
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->includes[u].exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_INCLUDE, 0, modp->includes[u].exts, NULL, 0);
if (modp->includes[u].rev[0]) {
ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);
}
@@ -1348,7 +1348,7 @@
}
if (modp->exts) {
ly_print_(ctx->out, "\n");
- yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->exts, NULL, 0);
+ yprp_extension_instances(ctx, LY_STMT_MODULE, 0, modp->exts, NULL, 0);
}
LY_ARRAY_FOR(modp->features, u) {
diff --git a/src/tree_schema.h b/src/tree_schema.h
index cf825d1..142a33d 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -442,6 +442,13 @@
const char *lyext_parent2str(LYEXT_PARENT type);
/**
+ * @brief Convert nodetype to statement identifier
+ * @param[in] nodetype Nodetype to convert.
+ * @return Statement identifier representing the given @p nodetype.
+ */
+enum ly_stmt lys_nodetype2stmt(uint16_t nodetype);
+
+/**
* @brief YANG import-stmt
*/
struct lysp_import {
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 717f2b9..ab5b0d0 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1073,6 +1073,43 @@
}
}
+API enum ly_stmt
+lys_nodetype2stmt(uint16_t nodetype)
+{
+ switch (nodetype) {
+ case LYS_CONTAINER:
+ return LY_STMT_CONTAINER;
+ case LYS_CHOICE:
+ return LY_STMT_CHOICE;
+ case LYS_LEAF:
+ return LY_STMT_LEAF;
+ case LYS_LEAFLIST:
+ return LY_STMT_LEAF_LIST;
+ case LYS_LIST:
+ return LY_STMT_LIST;
+ case LYS_ANYXML:
+ return LY_STMT_ANYXML;
+ case LYS_ANYDATA:
+ return LY_STMT_ANYDATA;
+ case LYS_CASE:
+ return LY_STMT_CASE;
+ case LYS_RPC:
+ return LY_STMT_RPC;
+ case LYS_ACTION:
+ return LY_STMT_ACTION;
+ case LYS_NOTIF:
+ return LY_STMT_NOTIFICATION;
+ case LYS_USES:
+ return LY_STMT_USES;
+ case LYS_INPUT:
+ return LY_STMT_INPUT;
+ case LYS_OUTPUT:
+ return LY_STMT_OUTPUT;
+ default:
+ return LY_STMT_NONE;
+ }
+}
+
const char *
lys_datatype2str(LY_DATA_TYPE basetype)
{