schema compile CHANGE basic implementation of applying groupings into uses
Refine and uses-augment not yet implemented.
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 82a9ba3..6c7253b 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -2822,6 +2822,8 @@
size_t word_len;
struct lysp_action_inout *inout;
enum yang_keyword kw;
+ unsigned int u;
+ struct lysp_node *child;
if (*inout_p) {
LOGVAL_YANG(ctx, LY_VCODE_DUPSTMT, ly_stmt2str(inout_kw));
@@ -2880,6 +2882,12 @@
return LY_EVALID;
}
}
+ /* finalize parent pointers to the reallocated items */
+ LY_ARRAY_FOR(inout->groupings, u) {
+ LY_LIST_FOR(inout->groupings[u].data, child) {
+ child->parent = (struct lysp_node*)&inout->groupings[u];
+ }
+ }
return ret;
}
@@ -2900,6 +2908,8 @@
size_t word_len;
enum yang_keyword kw;
struct lysp_action *act;
+ struct lysp_node *child;
+ unsigned int u;
LY_ARRAY_NEW_RET(ctx->ctx, *actions, act, LY_EMEM);
@@ -2945,6 +2955,12 @@
return LY_EVALID;
}
}
+ /* finalize parent pointers to the reallocated items */
+ LY_ARRAY_FOR(act->groupings, u) {
+ LY_LIST_FOR(act->groupings[u].data, child) {
+ child->parent = (struct lysp_node*)&act->groupings[u];
+ }
+ }
return ret;
}
@@ -2965,6 +2981,8 @@
size_t word_len;
enum yang_keyword kw;
struct lysp_notif *notif;
+ struct lysp_node *child;
+ unsigned int u;
LY_ARRAY_NEW_RET(ctx->ctx, *notifs, notif, LY_EMEM);
@@ -3032,6 +3050,12 @@
return LY_EVALID;
}
}
+ /* finalize parent pointers to the reallocated items */
+ LY_ARRAY_FOR(notif->groupings, u) {
+ LY_LIST_FOR(notif->groupings[u].data, child) {
+ child->parent = (struct lysp_node*)¬if->groupings[u];
+ }
+ }
return ret;
}
@@ -3052,6 +3076,8 @@
size_t word_len;
enum yang_keyword kw;
struct lysp_grp *grp;
+ struct lysp_node *child;
+ unsigned int u;
LY_ARRAY_NEW_RET(ctx->ctx, *groupings, grp, LY_EMEM);
@@ -3120,6 +3146,12 @@
return LY_EVALID;
}
}
+ /* finalize parent pointers to the reallocated items */
+ LY_ARRAY_FOR(grp->groupings, u) {
+ LY_LIST_FOR(grp->groupings[u].data, child) {
+ child->parent = (struct lysp_node*)&grp->groupings[u];
+ }
+ }
return ret;
}
@@ -3503,6 +3535,7 @@
enum yang_keyword kw;
struct lysp_node *iter;
struct lysp_node_container *cont;
+ unsigned int u;
/* create structure */
cont = calloc(1, sizeof *cont);
@@ -3597,6 +3630,12 @@
return LY_EVALID;
}
}
+ /* finalize parent pointers to the reallocated items */
+ LY_ARRAY_FOR(cont->groupings, u) {
+ LY_LIST_FOR(cont->groupings[u].data, iter) {
+ iter->parent = (struct lysp_node*)&cont->groupings[u];
+ }
+ }
return ret;
}
@@ -3618,6 +3657,7 @@
enum yang_keyword kw;
struct lysp_node *iter;
struct lysp_node_list *list;
+ unsigned int u;
/* create structure */
list = calloc(1, sizeof *list);
@@ -3725,6 +3765,12 @@
}
}
LY_CHECK_RET(ret);
+ /* finalize parent pointers to the reallocated items */
+ LY_ARRAY_FOR(list->groupings, u) {
+ LY_LIST_FOR(list->groupings[u].data, iter) {
+ iter->parent = (struct lysp_node*)&list->groupings[u];
+ }
+ }
checks:
if (list->max && list->min > list->max) {
LOGVAL_YANG(ctx, LYVE_SEMANTICS,
@@ -4271,6 +4317,8 @@
enum yang_keyword kw, prev_kw = 0;
enum yang_module_stmt mod_stmt = Y_MOD_MODULE_HEADER;
struct lysp_module *dup;
+ struct lysp_node *child;
+ unsigned int u;
/* (sub)module name */
LY_CHECK_RET(get_argument(ctx, data, Y_IDENTIF_ARG, &word, &buf, &word_len));
@@ -4452,6 +4500,14 @@
}
}
LY_CHECK_RET(ret);
+
+ /* finalize parent pointers to the reallocated items */
+ LY_ARRAY_FOR(mod->groupings, u) {
+ LY_LIST_FOR(mod->groupings[u].data, child) {
+ child->parent = (struct lysp_node*)&mod->groupings[u];
+ }
+ }
+
checks:
/* mandatory substatements */
if (mod->submodule) {