schema tree REFACTOR pass only new mod set when parsing modules

Parsing and compilation being strictly separate,
pass only new mod set (creating) from unres to
parsing functions to make the distinction explicit.
diff --git a/tests/utests/schema/test_parser_yang.c b/tests/utests/schema/test_parser_yang.c
index d226bc3..3190d40 100644
--- a/tests/utests/schema/test_parser_yang.c
+++ b/tests/utests/schema/test_parser_yang.c
@@ -589,7 +589,7 @@
     struct lysp_module *mod = NULL;
     struct lysp_submodule *submod = NULL;
     struct lys_module *m;
-    struct lys_glob_unres unres = {0};
+    struct ly_set new_mods = {0};
     struct lys_yang_parser_ctx *ctx_p;
 
     mod = mod_renew(YCTX);
@@ -761,7 +761,7 @@
     in.current = "module " SCHEMA_BEGINNING "} module q {namespace urn:q;prefixq;}";
     m = calloc(1, sizeof *m);
     m->ctx = YCTX->parsed_mod->mod->ctx;
-    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &unres));
+    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &new_mods));
     CHECK_LOG_CTX("Trailing garbage \"module q {names...\" after module, expected end-of-input.", "Line number 1.");
     yang_parser_ctx_free(ctx_p);
     lys_module_free(m);
@@ -769,7 +769,7 @@
     in.current = "prefix " SCHEMA_BEGINNING "}";
     m = calloc(1, sizeof *m);
     m->ctx = YCTX->parsed_mod->mod->ctx;
-    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &unres));
+    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &new_mods));
     CHECK_LOG_CTX("Invalid keyword \"prefix\", expected \"module\" or \"submodule\".", "Line number 1.");
     yang_parser_ctx_free(ctx_p);
     lys_module_free(m);
@@ -777,7 +777,7 @@
     in.current = "module " SCHEMA_BEGINNING "leaf enum {type enumeration {enum seven { position 7;}}}}";
     m = calloc(1, sizeof *m);
     m->ctx = YCTX->parsed_mod->mod->ctx;
-    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &unres));
+    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &new_mods));
     CHECK_LOG_CTX("Invalid keyword \"position\" as a child of \"enum\".", "Line number 1.");
     yang_parser_ctx_free(ctx_p);
     lys_module_free(m);
diff --git a/tests/utests/schema/test_parser_yin.c b/tests/utests/schema/test_parser_yin.c
index d492591..66b454d 100644
--- a/tests/utests/schema/test_parser_yin.c
+++ b/tests/utests/schema/test_parser_yin.c
@@ -3681,7 +3681,7 @@
     struct lys_module *mod;
     struct lys_yin_parser_ctx *yin_ctx = NULL;
     struct ly_in *in = NULL;
-    struct lys_glob_unres unres = {0};
+    struct ly_set new_mods = {0};
 
     mod = calloc(1, sizeof *mod);
     mod->ctx = UTEST_LYCTX;
@@ -3707,10 +3707,10 @@
             "    </md:annotation>\n"
             "</module>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_SUCCESS);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_SUCCESS);
     assert_null(mod->parsed->exts->child->next->child);
     assert_string_equal(mod->parsed->exts->child->next->arg, "test");
-    lys_compile_unres_glob_erase(UTEST_LYCTX, &unres);
+    ly_set_erase(&new_mods, NULL);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3748,8 +3748,8 @@
             "    </list>\n"
             "</module>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_SUCCESS);
-    lys_compile_unres_glob_erase(UTEST_LYCTX, &unres);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_SUCCESS);
+    ly_set_erase(&new_mods, NULL);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3764,8 +3764,8 @@
             "    <prefix value=\"foo\"/>\n"
             "</module>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_SUCCESS);
-    lys_compile_unres_glob_erase(UTEST_LYCTX, &unres);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_SUCCESS);
+    ly_set_erase(&new_mods, NULL);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3777,7 +3777,7 @@
     data = "<submodule name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
             "</submodule>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_EINVAL);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_EINVAL);
     CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
@@ -3792,7 +3792,7 @@
             "</module>\n"
             "<module>";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_EVALID);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_EVALID);
     CHECK_LOG_CTX("Trailing garbage \"<module>\" after module, expected end-of-input.", "Line number 6.");
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index 3ab7ccd..b8c70cc 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -76,16 +76,14 @@
 
     str = "module test {namespace urn:test; prefix t;"
             "feature f1;feature f2 {if-feature f1;}}";
-    assert_int_equal(LY_EINVAL, lys_compile(NULL, 0, 0, NULL));
+    assert_int_equal(LY_EINVAL, lys_compile(NULL, 0, NULL));
     CHECK_LOG("Invalid argument mod (lys_compile()).", NULL);
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
-    assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres, &mod));
-    assert_int_equal(LY_SUCCESS, lys_compile_unres_glob(UTEST_LYCTX, &unres));
     lys_compile_unres_glob_erase(UTEST_LYCTX, &unres);
+    assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod));
     ly_in_free(in, 0);
     assert_int_equal(0, mod->implemented);
-    mod->implemented = 1;
-    assert_int_equal(LY_SUCCESS, lys_compile(mod, 0, 0, &unres));
+    assert_int_equal(LY_SUCCESS, lys_implement(mod, NULL, &unres));
     assert_int_equal(LY_SUCCESS, lys_compile_unres_glob(UTEST_LYCTX, &unres));
     lys_compile_unres_glob_erase(UTEST_LYCTX, &unres);
     assert_non_null(mod->compiled);
@@ -107,15 +105,15 @@
     /* submodules cannot be compiled directly */
     str = "submodule test {belongs-to xxx {prefix x;}}";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
-    assert_int_equal(LY_EINVAL, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres, NULL));
     lys_compile_unres_glob_erase(UTEST_LYCTX, &unres);
+    assert_int_equal(LY_EINVAL, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, NULL));
     ly_in_free(in, 0);
     CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL);
 
     /* data definition name collision in top level */
     str = "module aa {namespace urn:aa;prefix aa; leaf a {type string;} container a{presence x;}}";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
-    assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres, &mod));
+    assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod));
     assert_int_equal(LY_EEXIST, lys_implement(mod, NULL, &unres));
     CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "/aa:a");
     lys_compile_unres_glob_erase(UTEST_LYCTX, &unres);