tree schema BUGFIX store YANG string quote style

Refs #3252
diff --git a/src/parser_yang.c b/src/parser_yang.c
index a6d1d79..4423950 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -3,7 +3,7 @@
  * @author Michal Vasko <mvasko@cesnet.cz>
  * @brief YANG parser
  *
- * Copyright (c) 2018 - 2022 CESNET, z.s.p.o.
+ * Copyright (c) 2018 - 2024 CESNET, z.s.p.o.
  *
  * This source code is licensed under BSD 3-Clause License (the "License").
  * You may not use this file except in compliance with the License.
@@ -562,13 +562,13 @@
 /**
  * @brief Get another YANG string from the raw data.
  *
- * @param[in] ctx yang parser context for logging.
+ * @param[in] ctx Yang parser context for logging.
  * @param[in] arg Type of YANG keyword argument expected.
- * @param[out] flags optional output argument to get flag of the argument's quoting (LYS_*QUOTED - see
+ * @param[out] flags Optional output argument to get flag of the argument's quoting (LYS_*QUOTED - see
  * [schema node flags](@ref snodeflags))
- * @param[out] word_p Pointer to the read string. Can return NULL if \p arg is #Y_MAYBE_STR_ARG.
+ * @param[out] word_p Pointer to the read string. Can return NULL if @p arg is #Y_MAYBE_STR_ARG.
  * @param[out] word_b Pointer to a dynamically-allocated buffer holding the read string. If not needed,
- * set to NULL. Otherwise equal to \p word_p.
+ * set to NULL. Otherwise equal to @p word_p.
  * @param[out] word_len Length of the read string.
  * @return LY_ERR values.
  */
@@ -600,7 +600,7 @@
                 goto error;
             }
             if (flags) {
-                (*flags) |= ctx->in->current[0] == '\'' ? LYS_SINGLEQUOTED : LYS_DOUBLEQUOTED;
+                (*flags) |= (ctx->in->current[0] == '\'') ? LYS_SINGLEQUOTED : LYS_DOUBLEQUOTED;
             }
 
             LY_CHECK_GOTO(ret = read_qstring(ctx, arg, word_p, word_b, word_len, &buf_len), error);
@@ -984,12 +984,14 @@
  * @param[in] parent_stmt_index In case of several @p parent_stmt, index of the relevant @p parent statement.
  * @param[in,out] value Place to store the parsed value.
  * @param[in] arg Type of the YANG keyword argument (of the value).
+ * @param[out] flags Optional output argument to get flag of the argument's quoting (LYS_*QUOTED - see
+ * [schema node flags](@ref snodeflags))
  * @param[in,out] exts Extension instances to add to.
  * @return LY_ERR values.
  */
 static LY_ERR
 parse_text_field(struct lysp_yang_ctx *ctx, const void *parent, enum ly_stmt parent_stmt, uint32_t parent_stmt_index,
-        const char **value, enum yang_arg arg, struct lysp_ext_instance **exts)
+        const char **value, enum yang_arg arg, uint16_t *flags, struct lysp_ext_instance **exts)
 {
     LY_ERR ret = LY_SUCCESS;
     char *buf, *word;
@@ -1002,7 +1004,7 @@
     }
 
     /* get value */
-    LY_CHECK_RET(get_argument(ctx, arg, NULL, &word, &buf, &word_len));
+    LY_CHECK_RET(get_argument(ctx, arg, flags, &word, &buf, &word_len));
 
     /* store value and spend buf if allocated */
     INSERT_WORD_GOTO(ctx, buf, *value, word, word_len, ret, cleanup);
@@ -1106,7 +1108,8 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_PREFIX:
-            LY_CHECK_RET(parse_text_field(ctx, submod->prefix, LY_STMT_PREFIX, 0, &submod->prefix, Y_IDENTIF_ARG, &submod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, submod->prefix, LY_STMT_PREFIX, 0, &submod->prefix, Y_IDENTIF_ARG, NULL,
+                    &submod->exts));
             break;
         case LY_STMT_EXTENSION_INSTANCE:
             LY_CHECK_RET(parse_ext(ctx, word, word_len, submod, LY_STMT_BELONGS_TO, 0, &submod->exts));
@@ -1213,11 +1216,11 @@
         switch (kw) {
         case LY_STMT_DESCRIPTION:
             PARSER_CHECK_STMTVER2_RET(ctx, "description", "include");
-            LY_CHECK_RET(parse_text_field(ctx, inc->dsc, LY_STMT_DESCRIPTION, 0, &inc->dsc, Y_STR_ARG, &inc->exts));
+            LY_CHECK_RET(parse_text_field(ctx, inc->dsc, LY_STMT_DESCRIPTION, 0, &inc->dsc, Y_STR_ARG, NULL, &inc->exts));
             break;
         case LY_STMT_REFERENCE:
             PARSER_CHECK_STMTVER2_RET(ctx, "reference", "include");
-            LY_CHECK_RET(parse_text_field(ctx, inc->ref, LY_STMT_REFERENCE, 0, &inc->ref, Y_STR_ARG, &inc->exts));
+            LY_CHECK_RET(parse_text_field(ctx, inc->ref, LY_STMT_REFERENCE, 0, &inc->ref, Y_STR_ARG, NULL, &inc->exts));
             break;
         case LY_STMT_REVISION_DATE:
             LY_CHECK_RET(parse_revisiondate(ctx, inc->rev, &inc->exts));
@@ -1262,16 +1265,16 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_PREFIX:
-            LY_CHECK_RET(parse_text_field(ctx, imp->prefix, LY_STMT_PREFIX, 0, &imp->prefix, Y_IDENTIF_ARG, &imp->exts));
+            LY_CHECK_RET(parse_text_field(ctx, imp->prefix, LY_STMT_PREFIX, 0, &imp->prefix, Y_IDENTIF_ARG, NULL, &imp->exts));
             LY_CHECK_RET(lysp_check_prefix((struct lysp_ctx *)ctx, *imports, module_prefix, &imp->prefix), LY_EVALID);
             break;
         case LY_STMT_DESCRIPTION:
             PARSER_CHECK_STMTVER2_RET(ctx, "description", "import");
-            LY_CHECK_RET(parse_text_field(ctx, imp->dsc, LY_STMT_DESCRIPTION, 0, &imp->dsc, Y_STR_ARG, &imp->exts));
+            LY_CHECK_RET(parse_text_field(ctx, imp->dsc, LY_STMT_DESCRIPTION, 0, &imp->dsc, Y_STR_ARG, NULL, &imp->exts));
             break;
         case LY_STMT_REFERENCE:
             PARSER_CHECK_STMTVER2_RET(ctx, "reference", "import");
-            LY_CHECK_RET(parse_text_field(ctx, imp->ref, LY_STMT_REFERENCE, 0, &imp->ref, Y_STR_ARG, &imp->exts));
+            LY_CHECK_RET(parse_text_field(ctx, imp->ref, LY_STMT_REFERENCE, 0, &imp->ref, Y_STR_ARG, NULL, &imp->exts));
             break;
         case LY_STMT_REVISION_DATE:
             LY_CHECK_RET(parse_revisiondate(ctx, imp->rev, &imp->exts));
@@ -1326,10 +1329,10 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, rev->dsc, LY_STMT_DESCRIPTION, 0, &rev->dsc, Y_STR_ARG, &rev->exts));
+            LY_CHECK_RET(parse_text_field(ctx, rev->dsc, LY_STMT_DESCRIPTION, 0, &rev->dsc, Y_STR_ARG, NULL, &rev->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, rev->ref, LY_STMT_REFERENCE, 0, &rev->ref, Y_STR_ARG, &rev->exts));
+            LY_CHECK_RET(parse_text_field(ctx, rev->ref, LY_STMT_REFERENCE, 0, &rev->ref, Y_STR_ARG, NULL, &rev->exts));
             break;
         case LY_STMT_EXTENSION_INSTANCE:
             LY_CHECK_RET(parse_ext(ctx, word, word_len, rev, LY_STMT_REVISION, 0, &rev->exts));
@@ -1413,7 +1416,7 @@
     LY_ARRAY_NEW_RET(PARSER_CTX(ctx), *qnames, item, LY_EMEM);
 
     /* get value */
-    LY_CHECK_RET(get_argument(ctx, arg, NULL, &word, &buf, &word_len));
+    LY_CHECK_RET(get_argument(ctx, arg, &item->flags, &word, &buf, &word_len));
 
     INSERT_WORD_GOTO(ctx, buf, item->str, word, word_len, ret, cleanup);
     item->mod = PARSER_CUR_PMOD(ctx);
@@ -1552,7 +1555,7 @@
     enum ly_stmt kw;
 
     /* get value */
-    LY_CHECK_RET(get_argument(ctx, Y_STR_ARG, NULL, &word, &buf, &word_len));
+    LY_CHECK_RET(get_argument(ctx, Y_STR_ARG, &restr->arg.flags, &word, &buf, &word_len));
 
     CHECK_NONEMPTY(ctx, word_len, lyplg_ext_stmt2str(restr_kw));
     INSERT_WORD_GOTO(ctx, buf, restr->arg.str, word, word_len, ret, cleanup);
@@ -1560,17 +1563,17 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, restr->dsc, LY_STMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));
+            LY_CHECK_RET(parse_text_field(ctx, restr->dsc, LY_STMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, NULL, &restr->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, restr->ref, LY_STMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));
+            LY_CHECK_RET(parse_text_field(ctx, restr->ref, LY_STMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, NULL, &restr->exts));
             break;
         case LY_STMT_ERROR_APP_TAG:
-            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG,
+            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG, NULL,
                     &restr->exts));
             break;
         case LY_STMT_ERROR_MESSAGE:
-            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, &restr->exts));
+            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, NULL, &restr->exts));
             break;
         case LY_STMT_EXTENSION_INSTANCE:
             LY_CHECK_RET(parse_ext(ctx, word, word_len, restr, restr_kw, 0, &restr->exts));
@@ -1689,12 +1692,12 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_GOTO(ret = parse_text_field(ctx, when->dsc, LY_STMT_DESCRIPTION, 0, &when->dsc, Y_STR_ARG, &when->exts),
-                    cleanup);
+            ret = parse_text_field(ctx, when->dsc, LY_STMT_DESCRIPTION, 0, &when->dsc, Y_STR_ARG, NULL, &when->exts);
+            LY_CHECK_GOTO(ret, cleanup);
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_GOTO(ret = parse_text_field(ctx, when->ref, LY_STMT_REFERENCE, 0, &when->ref, Y_STR_ARG, &when->exts),
-                    cleanup);
+            ret = parse_text_field(ctx, when->ref, LY_STMT_REFERENCE, 0, &when->ref, Y_STR_ARG, NULL, &when->exts);
+            LY_CHECK_GOTO(ret, cleanup);
             break;
         case LY_STMT_EXTENSION_INSTANCE:
             LY_CHECK_GOTO(ret = parse_ext(ctx, word, word_len, *when_p, LY_STMT_WHEN, 0, &when->exts), cleanup);
@@ -1752,7 +1755,7 @@
             LY_CHECK_RET(parse_config(ctx, &any->flags, &any->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, any->dsc, LY_STMT_DESCRIPTION, 0, &any->dsc, Y_STR_ARG, &any->exts));
+            LY_CHECK_RET(parse_text_field(ctx, any->dsc, LY_STMT_DESCRIPTION, 0, &any->dsc, Y_STR_ARG, NULL, &any->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &any->iffeatures, Y_STR_ARG, &any->exts));
@@ -1764,7 +1767,7 @@
             LY_CHECK_RET(parse_restrs(ctx, kw, &any->musts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, any->ref, LY_STMT_REFERENCE, 0, &any->ref, Y_STR_ARG, &any->exts));
+            LY_CHECK_RET(parse_text_field(ctx, any->ref, LY_STMT_REFERENCE, 0, &any->ref, Y_STR_ARG, NULL, &any->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &any->flags, &any->exts));
@@ -1904,14 +1907,14 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, enm->dsc, LY_STMT_DESCRIPTION, 0, &enm->dsc, Y_STR_ARG, &enm->exts));
+            LY_CHECK_RET(parse_text_field(ctx, enm->dsc, LY_STMT_DESCRIPTION, 0, &enm->dsc, Y_STR_ARG, NULL, &enm->exts));
             break;
         case LY_STMT_IF_FEATURE:
             PARSER_CHECK_STMTVER2_RET(ctx, "if-feature", lyplg_ext_stmt2str(enum_kw));
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &enm->iffeatures, Y_STR_ARG, &enm->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, enm->ref, LY_STMT_REFERENCE, 0, &enm->ref, Y_STR_ARG, &enm->exts));
+            LY_CHECK_RET(parse_text_field(ctx, enm->ref, LY_STMT_REFERENCE, 0, &enm->ref, Y_STR_ARG, NULL, &enm->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &enm->flags, &enm->exts));
@@ -2131,7 +2134,7 @@
     LY_ARRAY_NEW_RET(PARSER_CTX(ctx), *patterns, restr, LY_EMEM);
 
     /* get value */
-    LY_CHECK_RET(get_argument(ctx, Y_STR_ARG, NULL, &word, &buf, &word_len));
+    LY_CHECK_RET(get_argument(ctx, Y_STR_ARG, &restr->arg.flags, &word, &buf, &word_len));
 
     /* add special meaning first byte */
     if (buf) {
@@ -2152,16 +2155,16 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, restr->dsc, LY_STMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));
+            LY_CHECK_RET(parse_text_field(ctx, restr->dsc, LY_STMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, NULL, &restr->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, restr->ref, LY_STMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));
+            LY_CHECK_RET(parse_text_field(ctx, restr->ref, LY_STMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, NULL, &restr->exts));
             break;
         case LY_STMT_ERROR_APP_TAG:
-            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG, &restr->exts));
+            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG, NULL, &restr->exts));
             break;
         case LY_STMT_ERROR_MESSAGE:
-            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, &restr->exts));
+            LY_CHECK_RET(parse_text_field(ctx, restr, LY_STMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, NULL, &restr->exts));
             break;
         case LY_STMT_MODIFIER:
             PARSER_CHECK_STMTVER2_RET(ctx, "modifier", "pattern");
@@ -2250,7 +2253,7 @@
              * care of removing the parsed value from the dictionary. But in this case, it is not possible
              * to rely on lysp_module_free because the result of the parsing is stored in a local variable.
              */
-            LY_CHECK_ERR_RET(ret = parse_text_field(ctx, type, LY_STMT_PATH, 0, &str_path, Y_STR_ARG, &type->exts),
+            LY_CHECK_ERR_RET(ret = parse_text_field(ctx, type, LY_STMT_PATH, 0, &str_path, Y_STR_ARG, NULL, &type->exts),
                     lydict_remove(PARSER_CTX(ctx), str_path), ret);
             ret = ly_path_parse(PARSER_CTX(ctx), NULL, str_path, 0, 1, LY_PATH_BEGIN_EITHER,
                     LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);
@@ -2329,11 +2332,12 @@
             LY_CHECK_RET(parse_config(ctx, &leaf->flags, &leaf->exts));
             break;
         case LY_STMT_DEFAULT:
-            LY_CHECK_RET(parse_text_field(ctx, &leaf->dflt, LY_STMT_DEFAULT, 0, &leaf->dflt.str, Y_STR_ARG, &leaf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, &leaf->dflt, LY_STMT_DEFAULT, 0, &leaf->dflt.str, Y_STR_ARG,
+                    &leaf->dflt.flags, &leaf->exts));
             leaf->dflt.mod = PARSER_CUR_PMOD(ctx);
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, leaf->dsc, LY_STMT_DESCRIPTION, 0, &leaf->dsc, Y_STR_ARG, &leaf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, leaf->dsc, LY_STMT_DESCRIPTION, 0, &leaf->dsc, Y_STR_ARG, NULL, &leaf->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &leaf->iffeatures, Y_STR_ARG, &leaf->exts));
@@ -2345,7 +2349,7 @@
             LY_CHECK_RET(parse_restrs(ctx, kw, &leaf->musts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, leaf->ref, LY_STMT_REFERENCE, 0, &leaf->ref, Y_STR_ARG, &leaf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, leaf->ref, LY_STMT_REFERENCE, 0, &leaf->ref, Y_STR_ARG, NULL, &leaf->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &leaf->flags, &leaf->exts));
@@ -2354,7 +2358,7 @@
             LY_CHECK_RET(parse_type(ctx, &leaf->type));
             break;
         case LY_STMT_UNITS:
-            LY_CHECK_RET(parse_text_field(ctx, leaf->units, LY_STMT_UNITS, 0, &leaf->units, Y_STR_ARG, &leaf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, leaf->units, LY_STMT_UNITS, 0, &leaf->units, Y_STR_ARG, NULL, &leaf->exts));
             break;
         case LY_STMT_WHEN:
             LY_CHECK_RET(parse_when(ctx, &leaf->when));
@@ -2605,7 +2609,7 @@
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_DEFAULT, &llist->dflts, Y_STR_ARG, &llist->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, llist->dsc, LY_STMT_DESCRIPTION, 0, &llist->dsc, Y_STR_ARG, &llist->exts));
+            LY_CHECK_RET(parse_text_field(ctx, llist->dsc, LY_STMT_DESCRIPTION, 0, &llist->dsc, Y_STR_ARG, NULL, &llist->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &llist->iffeatures, Y_STR_ARG, &llist->exts));
@@ -2623,7 +2627,7 @@
             LY_CHECK_RET(parse_orderedby(ctx, &llist->node));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, llist->ref, LY_STMT_REFERENCE, 0, &llist->ref, Y_STR_ARG, &llist->exts));
+            LY_CHECK_RET(parse_text_field(ctx, llist->ref, LY_STMT_REFERENCE, 0, &llist->ref, Y_STR_ARG, NULL, &llist->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &llist->flags, &llist->exts));
@@ -2632,7 +2636,7 @@
             LY_CHECK_RET(parse_type(ctx, &llist->type));
             break;
         case LY_STMT_UNITS:
-            LY_CHECK_RET(parse_text_field(ctx, llist->units, LY_STMT_UNITS, 0, &llist->units, Y_STR_ARG, &llist->exts));
+            LY_CHECK_RET(parse_text_field(ctx, llist->units, LY_STMT_UNITS, 0, &llist->units, Y_STR_ARG, NULL, &llist->exts));
             break;
         case LY_STMT_WHEN:
             LY_CHECK_RET(parse_when(ctx, &llist->when));
@@ -2689,7 +2693,7 @@
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_DEFAULT, &rf->dflts, Y_STR_ARG, &rf->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, rf->dsc, LY_STMT_DESCRIPTION, 0, &rf->dsc, Y_STR_ARG, &rf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, rf->dsc, LY_STMT_DESCRIPTION, 0, &rf->dsc, Y_STR_ARG, NULL, &rf->exts));
             break;
         case LY_STMT_IF_FEATURE:
             PARSER_CHECK_STMTVER2_RET(ctx, "if-feature", "refine");
@@ -2708,10 +2712,10 @@
             LY_CHECK_RET(parse_mandatory(ctx, &rf->flags, &rf->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, rf->ref, LY_STMT_REFERENCE, 0, &rf->ref, Y_STR_ARG, &rf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, rf->ref, LY_STMT_REFERENCE, 0, &rf->ref, Y_STR_ARG, NULL, &rf->exts));
             break;
         case LY_STMT_PRESENCE:
-            LY_CHECK_RET(parse_text_field(ctx, rf->presence, LY_STMT_PRESENCE, 0, &rf->presence, Y_STR_ARG, &rf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, rf->presence, LY_STMT_PRESENCE, 0, &rf->presence, Y_STR_ARG, NULL, &rf->exts));
             break;
         case LY_STMT_EXTENSION_INSTANCE:
             LY_CHECK_RET(parse_ext(ctx, word, word_len, rf, LY_STMT_REFINE, 0, &rf->exts));
@@ -2753,14 +2757,15 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DEFAULT:
-            LY_CHECK_RET(parse_text_field(ctx, &tpdf->dflt, LY_STMT_DEFAULT, 0, &tpdf->dflt.str, Y_STR_ARG, &tpdf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, &tpdf->dflt, LY_STMT_DEFAULT, 0, &tpdf->dflt.str, Y_STR_ARG,
+                    &tpdf->dflt.flags, &tpdf->exts));
             tpdf->dflt.mod = PARSER_CUR_PMOD(ctx);
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, tpdf->dsc, LY_STMT_DESCRIPTION, 0, &tpdf->dsc, Y_STR_ARG, &tpdf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, tpdf->dsc, LY_STMT_DESCRIPTION, 0, &tpdf->dsc, Y_STR_ARG, NULL, &tpdf->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, tpdf->ref, LY_STMT_REFERENCE, 0, &tpdf->ref, Y_STR_ARG, &tpdf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, tpdf->ref, LY_STMT_REFERENCE, 0, &tpdf->ref, Y_STR_ARG, NULL, &tpdf->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &tpdf->flags, &tpdf->exts));
@@ -2769,7 +2774,7 @@
             LY_CHECK_RET(parse_type(ctx, &tpdf->type));
             break;
         case LY_STMT_UNITS:
-            LY_CHECK_RET(parse_text_field(ctx, tpdf->units, LY_STMT_UNITS, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));
+            LY_CHECK_RET(parse_text_field(ctx, tpdf->units, LY_STMT_UNITS, 0, &tpdf->units, Y_STR_ARG, NULL, &tpdf->exts));
             break;
         case LY_STMT_EXTENSION_INSTANCE:
             LY_CHECK_RET(parse_ext(ctx, word, word_len, tpdf, LY_STMT_TYPEDEF, 0, &tpdf->exts));
@@ -2903,13 +2908,13 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, act->dsc, LY_STMT_DESCRIPTION, 0, &act->dsc, Y_STR_ARG, &act->exts));
+            LY_CHECK_RET(parse_text_field(ctx, act->dsc, LY_STMT_DESCRIPTION, 0, &act->dsc, Y_STR_ARG, NULL, &act->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &act->iffeatures, Y_STR_ARG, &act->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, act->ref, LY_STMT_REFERENCE, 0, &act->ref, Y_STR_ARG, &act->exts));
+            LY_CHECK_RET(parse_text_field(ctx, act->ref, LY_STMT_REFERENCE, 0, &act->ref, Y_STR_ARG, NULL, &act->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &act->flags, &act->exts));
@@ -2981,13 +2986,15 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, notif->dsc, LY_STMT_DESCRIPTION, 0, &notif->dsc, Y_STR_ARG, &notif->exts));
+            LY_CHECK_RET(parse_text_field(ctx, notif->dsc, LY_STMT_DESCRIPTION, 0, &notif->dsc, Y_STR_ARG, NULL,
+                    &notif->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &notif->iffeatures, Y_STR_ARG, &notif->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, notif->ref, LY_STMT_REFERENCE, 0, &notif->ref, Y_STR_ARG, &notif->exts));
+            LY_CHECK_RET(parse_text_field(ctx, notif->ref, LY_STMT_REFERENCE, 0, &notif->ref, Y_STR_ARG, NULL,
+                    &notif->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &notif->flags, &notif->exts));
@@ -3069,10 +3076,10 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, grp->dsc, LY_STMT_DESCRIPTION, 0, &grp->dsc, Y_STR_ARG, &grp->exts));
+            LY_CHECK_RET(parse_text_field(ctx, grp->dsc, LY_STMT_DESCRIPTION, 0, &grp->dsc, Y_STR_ARG, NULL, &grp->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, grp->ref, LY_STMT_REFERENCE, 0, &grp->ref, Y_STR_ARG, &grp->exts));
+            LY_CHECK_RET(parse_text_field(ctx, grp->ref, LY_STMT_REFERENCE, 0, &grp->ref, Y_STR_ARG, NULL, &grp->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &grp->flags, &grp->exts));
@@ -3165,13 +3172,13 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, aug->dsc, LY_STMT_DESCRIPTION, 0, &aug->dsc, Y_STR_ARG, &aug->exts));
+            LY_CHECK_RET(parse_text_field(ctx, aug->dsc, LY_STMT_DESCRIPTION, 0, &aug->dsc, Y_STR_ARG, NULL, &aug->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &aug->iffeatures, Y_STR_ARG, &aug->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, aug->ref, LY_STMT_REFERENCE, 0, &aug->ref, Y_STR_ARG, &aug->exts));
+            LY_CHECK_RET(parse_text_field(ctx, aug->ref, LY_STMT_REFERENCE, 0, &aug->ref, Y_STR_ARG, NULL, &aug->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &aug->flags, &aug->exts));
@@ -3259,13 +3266,13 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, uses->dsc, LY_STMT_DESCRIPTION, 0, &uses->dsc, Y_STR_ARG, &uses->exts));
+            LY_CHECK_RET(parse_text_field(ctx, uses->dsc, LY_STMT_DESCRIPTION, 0, &uses->dsc, Y_STR_ARG, NULL, &uses->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &uses->iffeatures, Y_STR_ARG, &uses->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, uses->ref, LY_STMT_REFERENCE, 0, &uses->ref, Y_STR_ARG, &uses->exts));
+            LY_CHECK_RET(parse_text_field(ctx, uses->ref, LY_STMT_REFERENCE, 0, &uses->ref, Y_STR_ARG, NULL, &uses->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &uses->flags, &uses->exts));
@@ -3323,13 +3330,13 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, cas->dsc, LY_STMT_DESCRIPTION, 0, &cas->dsc, Y_STR_ARG, &cas->exts));
+            LY_CHECK_RET(parse_text_field(ctx, cas->dsc, LY_STMT_DESCRIPTION, 0, &cas->dsc, Y_STR_ARG, NULL, &cas->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &cas->iffeatures, Y_STR_ARG, &cas->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, cas->ref, LY_STMT_REFERENCE, 0, &cas->ref, Y_STR_ARG, &cas->exts));
+            LY_CHECK_RET(parse_text_field(ctx, cas->ref, LY_STMT_REFERENCE, 0, &cas->ref, Y_STR_ARG, NULL, &cas->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &cas->flags, &cas->exts));
@@ -3408,7 +3415,8 @@
             LY_CHECK_RET(parse_config(ctx, &choice->flags, &choice->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, choice->dsc, LY_STMT_DESCRIPTION, 0, &choice->dsc, Y_STR_ARG, &choice->exts));
+            LY_CHECK_RET(parse_text_field(ctx, choice->dsc, LY_STMT_DESCRIPTION, 0, &choice->dsc, Y_STR_ARG, NULL,
+                    &choice->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &choice->iffeatures, Y_STR_ARG, &choice->exts));
@@ -3417,7 +3425,8 @@
             LY_CHECK_RET(parse_mandatory(ctx, &choice->flags, &choice->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, choice->ref, LY_STMT_REFERENCE, 0, &choice->ref, Y_STR_ARG, &choice->exts));
+            LY_CHECK_RET(parse_text_field(ctx, choice->ref, LY_STMT_REFERENCE, 0, &choice->ref, Y_STR_ARG, NULL,
+                    &choice->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &choice->flags, &choice->exts));
@@ -3427,7 +3436,7 @@
             break;
         case LY_STMT_DEFAULT:
             LY_CHECK_RET(parse_text_field(ctx, &choice->dflt, LY_STMT_DEFAULT, 0, &choice->dflt.str, Y_PREF_IDENTIF_ARG,
-                    &choice->exts));
+                    &choice->dflt.flags, &choice->exts));
             choice->dflt.mod = PARSER_CUR_PMOD(ctx);
             break;
 
@@ -3502,13 +3511,13 @@
             LY_CHECK_RET(parse_config(ctx, &cont->flags, &cont->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, cont->dsc, LY_STMT_DESCRIPTION, 0, &cont->dsc, Y_STR_ARG, &cont->exts));
+            LY_CHECK_RET(parse_text_field(ctx, cont->dsc, LY_STMT_DESCRIPTION, 0, &cont->dsc, Y_STR_ARG, NULL, &cont->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &cont->iffeatures, Y_STR_ARG, &cont->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, cont->ref, LY_STMT_REFERENCE, 0, &cont->ref, Y_STR_ARG, &cont->exts));
+            LY_CHECK_RET(parse_text_field(ctx, cont->ref, LY_STMT_REFERENCE, 0, &cont->ref, Y_STR_ARG, NULL, &cont->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &cont->flags, &cont->exts));
@@ -3517,7 +3526,8 @@
             LY_CHECK_RET(parse_when(ctx, &cont->when));
             break;
         case LY_STMT_PRESENCE:
-            LY_CHECK_RET(parse_text_field(ctx, cont->presence, LY_STMT_PRESENCE, 0, &cont->presence, Y_STR_ARG, &cont->exts));
+            LY_CHECK_RET(parse_text_field(ctx, cont->presence, LY_STMT_PRESENCE, 0, &cont->presence, Y_STR_ARG, NULL,
+                    &cont->exts));
             break;
 
         case LY_STMT_ANYDATA:
@@ -3608,13 +3618,13 @@
             LY_CHECK_RET(parse_config(ctx, &list->flags, &list->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, list->dsc, LY_STMT_DESCRIPTION, 0, &list->dsc, Y_STR_ARG, &list->exts));
+            LY_CHECK_RET(parse_text_field(ctx, list->dsc, LY_STMT_DESCRIPTION, 0, &list->dsc, Y_STR_ARG, NULL, &list->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &list->iffeatures, Y_STR_ARG, &list->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, list->ref, LY_STMT_REFERENCE, 0, &list->ref, Y_STR_ARG, &list->exts));
+            LY_CHECK_RET(parse_text_field(ctx, list->ref, LY_STMT_REFERENCE, 0, &list->ref, Y_STR_ARG, NULL, &list->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &list->flags, &list->exts));
@@ -3623,7 +3633,7 @@
             LY_CHECK_RET(parse_when(ctx, &list->when));
             break;
         case LY_STMT_KEY:
-            LY_CHECK_RET(parse_text_field(ctx, list, LY_STMT_KEY, 0, &list->key, Y_STR_ARG, &list->exts));
+            LY_CHECK_RET(parse_text_field(ctx, list, LY_STMT_KEY, 0, &list->key, Y_STR_ARG, NULL, &list->exts));
             break;
         case LY_STMT_MAX_ELEMENTS:
             LY_CHECK_RET(parse_maxelements(ctx, &list->max, &list->flags, &list->exts));
@@ -3813,10 +3823,10 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, ex->dsc, LY_STMT_DESCRIPTION, 0, &ex->dsc, Y_STR_ARG, &ex->exts));
+            LY_CHECK_RET(parse_text_field(ctx, ex->dsc, LY_STMT_DESCRIPTION, 0, &ex->dsc, Y_STR_ARG, NULL, &ex->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, ex->ref, LY_STMT_REFERENCE, 0, &ex->ref, Y_STR_ARG, &ex->exts));
+            LY_CHECK_RET(parse_text_field(ctx, ex->ref, LY_STMT_REFERENCE, 0, &ex->ref, Y_STR_ARG, NULL, &ex->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &ex->flags, &ex->exts));
@@ -3945,7 +3955,8 @@
                 ret = LY_EVALID;
                 goto cleanup;
             case LYS_DEV_REPLACE:
-                ret = parse_text_field(ctx, &d_rpl->dflt, LY_STMT_DEFAULT, 0, &d_rpl->dflt.str, Y_STR_ARG, &d->exts);
+                ret = parse_text_field(ctx, &d_rpl->dflt, LY_STMT_DEFAULT, 0, &d_rpl->dflt.str, Y_STR_ARG,
+                        &d_rpl->dflt.flags, &d->exts);
                 LY_CHECK_GOTO(ret, cleanup);
                 d_rpl->dflt.mod = PARSER_CUR_PMOD(ctx);
                 break;
@@ -4041,7 +4052,8 @@
                 ret = LY_EVALID;
                 goto cleanup;
             default:
-                LY_CHECK_GOTO(ret = parse_text_field(ctx, *d_units, LY_STMT_UNITS, 0, d_units, Y_STR_ARG, &d->exts), cleanup);
+                ret = parse_text_field(ctx, *d_units, LY_STMT_UNITS, 0, d_units, Y_STR_ARG, NULL, &d->exts);
+                LY_CHECK_GOTO(ret, cleanup);
                 break;
             }
             break;
@@ -4095,13 +4107,15 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_GOTO(ret = parse_text_field(ctx, dev->dsc, LY_STMT_DESCRIPTION, 0, &dev->dsc, Y_STR_ARG, &dev->exts), cleanup);
+            ret = parse_text_field(ctx, dev->dsc, LY_STMT_DESCRIPTION, 0, &dev->dsc, Y_STR_ARG, NULL, &dev->exts);
+            LY_CHECK_GOTO(ret, cleanup);
             break;
         case LY_STMT_DEVIATE:
             LY_CHECK_GOTO(ret = parse_deviate(ctx, &dev->deviates), cleanup);
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_GOTO(ret = parse_text_field(ctx, dev->ref, LY_STMT_REFERENCE, 0, &dev->ref, Y_STR_ARG, &dev->exts), cleanup);
+            ret = parse_text_field(ctx, dev->ref, LY_STMT_REFERENCE, 0, &dev->ref, Y_STR_ARG, NULL, &dev->exts);
+            LY_CHECK_GOTO(ret, cleanup);
             break;
         case LY_STMT_EXTENSION_INSTANCE:
             LY_CHECK_GOTO(ret = parse_ext(ctx, word, word_len, dev, LY_STMT_DEVIATION, 0, &dev->exts), cleanup);
@@ -4154,13 +4168,13 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, feat->dsc, LY_STMT_DESCRIPTION, 0, &feat->dsc, Y_STR_ARG, &feat->exts));
+            LY_CHECK_RET(parse_text_field(ctx, feat->dsc, LY_STMT_DESCRIPTION, 0, &feat->dsc, Y_STR_ARG, NULL, &feat->exts));
             break;
         case LY_STMT_IF_FEATURE:
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &feat->iffeatures, Y_STR_ARG, &feat->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, feat->ref, LY_STMT_REFERENCE, 0, &feat->ref, Y_STR_ARG, &feat->exts));
+            LY_CHECK_RET(parse_text_field(ctx, feat->ref, LY_STMT_REFERENCE, 0, &feat->ref, Y_STR_ARG, NULL, &feat->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &feat->flags, &feat->exts));
@@ -4204,21 +4218,22 @@
     YANG_READ_SUBSTMT_FOR_GOTO(ctx, kw, word, word_len, ret, cleanup) {
         switch (kw) {
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, ident->dsc, LY_STMT_DESCRIPTION, 0, &ident->dsc, Y_STR_ARG, &ident->exts));
+            LY_CHECK_RET(parse_text_field(ctx, ident->dsc, LY_STMT_DESCRIPTION, 0, &ident->dsc, Y_STR_ARG, NULL, &ident->exts));
             break;
         case LY_STMT_IF_FEATURE:
             PARSER_CHECK_STMTVER2_RET(ctx, "if-feature", "identity");
             LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &ident->iffeatures, Y_STR_ARG, &ident->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, ident->ref, LY_STMT_REFERENCE, 0, &ident->ref, Y_STR_ARG, &ident->exts));
+            LY_CHECK_RET(parse_text_field(ctx, ident->ref, LY_STMT_REFERENCE, 0, &ident->ref, Y_STR_ARG, NULL, &ident->exts));
             break;
         case LY_STMT_STATUS:
             LY_CHECK_RET(parse_status(ctx, &ident->flags, &ident->exts));
             break;
         case LY_STMT_BASE:
             if (ident->bases && (PARSER_CUR_PMOD(ctx)->version < LYS_VERSION_1_1)) {
-                LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Identity can be derived from multiple base identities only in YANG 1.1 modules");
+                LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG,
+                        "Identity can be derived from multiple base identities only in YANG 1.1 modules");
                 return LY_EVALID;
             }
             LY_CHECK_RET(parse_text_fields(ctx, LY_STMT_BASE, &ident->bases, Y_PREF_IDENTIF_ARG, &ident->exts));
@@ -4329,10 +4344,11 @@
             LY_CHECK_RET(parse_yangversion(ctx, mod));
             break;
         case LY_STMT_NAMESPACE:
-            LY_CHECK_RET(parse_text_field(ctx, mod, LY_STMT_NAMESPACE, 0, &mod->mod->ns, Y_STR_ARG, &mod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, mod, LY_STMT_NAMESPACE, 0, &mod->mod->ns, Y_STR_ARG, NULL, &mod->exts));
             break;
         case LY_STMT_PREFIX:
-            LY_CHECK_RET(parse_text_field(ctx, mod->mod->prefix, LY_STMT_PREFIX, 0, &mod->mod->prefix, Y_IDENTIF_ARG, &mod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, mod->mod->prefix, LY_STMT_PREFIX, 0, &mod->mod->prefix, Y_IDENTIF_ARG,
+                    NULL, &mod->exts));
             break;
 
         /* linkage */
@@ -4345,16 +4361,18 @@
 
         /* meta */
         case LY_STMT_ORGANIZATION:
-            LY_CHECK_RET(parse_text_field(ctx, mod, LY_STMT_ORGANIZATION, 0, &mod->mod->org, Y_STR_ARG, &mod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, mod, LY_STMT_ORGANIZATION, 0, &mod->mod->org, Y_STR_ARG, NULL, &mod->exts));
             break;
         case LY_STMT_CONTACT:
-            LY_CHECK_RET(parse_text_field(ctx, mod, LY_STMT_CONTACT, 0, &mod->mod->contact, Y_STR_ARG, &mod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, mod, LY_STMT_CONTACT, 0, &mod->mod->contact, Y_STR_ARG, NULL, &mod->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, mod->mod->dsc, LY_STMT_DESCRIPTION, 0, &mod->mod->dsc, Y_STR_ARG, &mod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, mod->mod->dsc, LY_STMT_DESCRIPTION, 0, &mod->mod->dsc, Y_STR_ARG, NULL,
+                    &mod->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, mod->mod->ref, LY_STMT_REFERENCE, 0, &mod->mod->ref, Y_STR_ARG, &mod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, mod->mod->ref, LY_STMT_REFERENCE, 0, &mod->mod->ref, Y_STR_ARG, NULL,
+                    &mod->exts));
             break;
 
         /* revision */
@@ -4554,16 +4572,16 @@
 
         /* meta */
         case LY_STMT_ORGANIZATION:
-            LY_CHECK_RET(parse_text_field(ctx, submod, LY_STMT_ORGANIZATION, 0, &submod->org, Y_STR_ARG, &submod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, submod, LY_STMT_ORGANIZATION, 0, &submod->org, Y_STR_ARG, NULL, &submod->exts));
             break;
         case LY_STMT_CONTACT:
-            LY_CHECK_RET(parse_text_field(ctx, submod, LY_STMT_CONTACT, 0, &submod->contact, Y_STR_ARG, &submod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, submod, LY_STMT_CONTACT, 0, &submod->contact, Y_STR_ARG, NULL, &submod->exts));
             break;
         case LY_STMT_DESCRIPTION:
-            LY_CHECK_RET(parse_text_field(ctx, submod->dsc, LY_STMT_DESCRIPTION, 0, &submod->dsc, Y_STR_ARG, &submod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, submod->dsc, LY_STMT_DESCRIPTION, 0, &submod->dsc, Y_STR_ARG, NULL, &submod->exts));
             break;
         case LY_STMT_REFERENCE:
-            LY_CHECK_RET(parse_text_field(ctx, submod->ref, LY_STMT_REFERENCE, 0, &submod->ref, Y_STR_ARG, &submod->exts));
+            LY_CHECK_RET(parse_text_field(ctx, submod->ref, LY_STMT_REFERENCE, 0, &submod->ref, Y_STR_ARG, NULL, &submod->exts));
             break;
 
         /* revision */
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 9dd95a8..e60417c 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -46,6 +46,11 @@
     LYS_YPR_COMPILED  /**< YANG printer of the compiled schema */
 };
 
+enum lys_ypr_text_flags {
+    LYS_YPR_TEXT_SINGLELINE = 0x01,     /**< print 'text' on the same line as 'name' */
+    LYS_YPR_TEXT_SINGLEQUOTED = 0x02    /**< do not encode 'text' and print it in single quotes */
+};
+
 #define YPR_CTX_FLAG_EXTRA_LINE 0x01 /**< Flag for ::ypr_ctx::flags to print extra line in schema */
 
 #define YPR_EXTRA_LINE(COND, PCTX) if (COND) { (PCTX)->flags |= YPR_CTX_FLAG_EXTRA_LINE; }
@@ -57,6 +62,8 @@
         } \
     }
 
+#define YPR_IS_LYS_SINGLEQUOTED(FLAGS) (((FLAGS) & LYS_SINGLEQUOTED) ? 1 : 0)
+
 /**
  * @brief Compiled YANG printer context
  *
@@ -167,35 +174,48 @@
 }
 
 static void
-ypr_text(struct lys_ypr_ctx *pctx, const char *name, const char *text, ly_bool singleline, ly_bool closed)
+ypr_text(struct lys_ypr_ctx *pctx, const char *name, const char *text, enum lys_ypr_text_flags flags)
 {
     const char *s, *t;
+    char quot;
 
-    if (singleline) {
-        ly_print_(pctx->out, "%*s%s \"", INDENT, name);
+    if (flags & LYS_YPR_TEXT_SINGLEQUOTED) {
+        quot = '\'';
+    } else {
+        quot = '\"';
+    }
+
+    if (flags & LYS_YPR_TEXT_SINGLELINE) {
+        ly_print_(pctx->out, "%*s%s %c", INDENT, name, quot);
     } else {
         ly_print_(pctx->out, "%*s%s\n", INDENT, name);
         LEVEL++;
 
-        ly_print_(pctx->out, "%*s\"", INDENT);
+        ly_print_(pctx->out, "%*s%c", INDENT, quot);
     }
+
     t = text;
     while ((s = strchr(t, '\n'))) {
-        ypr_encode(pctx->out, t, s - t);
+        if (flags & LYS_YPR_TEXT_SINGLEQUOTED) {
+            ly_print_(pctx->out, "%.*s", (int)(s - t), t);
+        } else {
+            ypr_encode(pctx->out, t, s - t);
+        }
         ly_print_(pctx->out, "\n");
+
         t = s + 1;
         if (*t != '\n') {
             ly_print_(pctx->out, "%*s ", INDENT);
         }
     }
 
-    ypr_encode(pctx->out, t, strlen(t));
-    if (closed) {
-        ly_print_(pctx->out, "\";\n");
+    if (flags & LYS_YPR_TEXT_SINGLEQUOTED) {
+        ly_print_(pctx->out, "%s", t);
     } else {
-        ly_print_(pctx->out, "\"");
+        ypr_encode(pctx->out, t, strlen(t));
     }
-    if (!singleline) {
+    ly_print_(pctx->out, "%c", quot);
+    if (!(flags & LYS_YPR_TEXT_SINGLELINE)) {
         LEVEL--;
     }
 }
@@ -204,25 +224,15 @@
 yprp_stmt(struct lys_ypr_ctx *pctx, struct lysp_stmt *stmt)
 {
     struct lysp_stmt *childstmt;
-    const char *s, *t;
+    uint16_t tflags = 0;
 
     if (stmt->arg) {
         if (stmt->flags) {
-            ly_print_(pctx->out, "%*s%s\n", INDENT, stmt->stmt);
-            LEVEL++;
-            ly_print_(pctx->out, "%*s%c", INDENT, (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'');
-            t = stmt->arg;
-            while ((s = strchr(t, '\n'))) {
-                ypr_encode(pctx->out, t, s - t);
-                ly_print_(pctx->out, "\n");
-                t = s + 1;
-                if (*t != '\n') {
-                    ly_print_(pctx->out, "%*s ", INDENT);
-                }
+            if (stmt->flags & LYS_SINGLEQUOTED) {
+                tflags |= LYS_YPR_TEXT_SINGLEQUOTED;
             }
-            LEVEL--;
-            ypr_encode(pctx->out, t, strlen(t));
-            ly_print_(pctx->out, "%c%s", (stmt->flags & LYS_DOUBLEQUOTED) ? '\"' : '\'', stmt->child ? " {\n" : ";\n");
+            ypr_text(pctx, stmt->stmt, stmt->arg, tflags);
+            ly_print_(pctx->out, "%s", stmt->child ? " {\n" : ";\n");
         } else {
             ly_print_(pctx->out, "%*s%s %s%s", INDENT, stmt->stmt, stmt->arg, stmt->child ? " {\n" : ";\n");
         }
@@ -344,9 +354,11 @@
 }
 
 static void
-ypr_substmt(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text, void *exts)
+ypr_substmt(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text,
+        ly_bool singlequoted, void *exts)
 {
     ly_bool extflag = 0;
+    uint16_t flags = 0;
 
     if (!text) {
         /* nothing to print */
@@ -356,7 +368,13 @@
     if (lys_stmt_flags(substmt) & LY_STMT_FLAG_ID) {
         ly_print_(pctx->out, "%*s%s %s", INDENT, lys_stmt_str(substmt), text);
     } else {
-        ypr_text(pctx, lys_stmt_str(substmt), text, (lys_stmt_flags(substmt) & LY_STMT_FLAG_YIN) ? 0 : 1, 0);
+        if (!(lys_stmt_flags(substmt) & LY_STMT_FLAG_YIN)) {
+            flags |= LYS_YPR_TEXT_SINGLELINE;
+        }
+        if (singlequoted) {
+            flags |= LYS_YPR_TEXT_SINGLEQUOTED;
+        }
+        ypr_text(pctx, lys_stmt_str(substmt), text, flags);
     }
 
     LEVEL++;
@@ -380,7 +398,7 @@
         return;
     }
     ypr_open(pctx->out, flag);
-    ypr_substmt(pctx, substmt, substmt_index, str, exts);
+    ypr_substmt(pctx, substmt, substmt_index, str, 0, exts);
     free(str);
 }
 
@@ -395,7 +413,7 @@
         return;
     }
     ypr_open(pctx->out, flag);
-    ypr_substmt(pctx, substmt, substmt_index, str, exts);
+    ypr_substmt(pctx, substmt, substmt_index, str, 0, exts);
     free(str);
 }
 
@@ -406,8 +424,8 @@
         ly_print_(pctx->out, "%*srevision %s {\n", INDENT, rev->date);
         LEVEL++;
         yprp_extension_instances(pctx, LY_STMT_REVISION, 0, rev->exts, NULL);
-        ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);
-        ypr_substmt(pctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);
+        ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, rev->dsc, 0, rev->exts);
+        ypr_substmt(pctx, LY_STMT_REFERENCE, 0, rev->ref, 0, rev->exts);
         LEVEL--;
         ly_print_(pctx->out, "%*s}\n", INDENT);
     } else {
@@ -420,7 +438,7 @@
 {
     if (flags & LYS_MAND_MASK) {
         ypr_open(pctx->out, flag);
-        ypr_substmt(pctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);
+        ypr_substmt(pctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", 0, exts);
     }
 }
 
@@ -429,7 +447,7 @@
 {
     if (flags & LYS_CONFIG_MASK) {
         ypr_open(pctx->out, flag);
-        ypr_substmt(pctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);
+        ypr_substmt(pctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", 0, exts);
     }
 }
 
@@ -449,7 +467,7 @@
         status = "obsolete";
     }
 
-    ypr_substmt(pctx, LY_STMT_STATUS, 0, status, exts);
+    ypr_substmt(pctx, LY_STMT_STATUS, 0, status, 0, exts);
 }
 
 static void
@@ -457,7 +475,7 @@
 {
     if (dsc) {
         ypr_open(pctx->out, flag);
-        ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, dsc, exts);
+        ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, dsc, 0, exts);
     }
 }
 
@@ -466,7 +484,7 @@
 {
     if (ref) {
         ypr_open(pctx->out, flag);
-        ypr_substmt(pctx, LY_STMT_REFERENCE, 0, ref, exts);
+        ypr_substmt(pctx, LY_STMT_REFERENCE, 0, ref, 0, exts);
     }
 }
 
@@ -475,12 +493,14 @@
 {
     LY_ARRAY_COUNT_TYPE u;
     ly_bool extflag;
+    uint16_t flags;
 
     LY_ARRAY_FOR(iffs, u) {
         ypr_open(pctx->out, flag);
         extflag = 0;
 
-        ly_print_(pctx->out, "%*sif-feature \"%s\"", INDENT, iffs[u].str);
+        flags = LYS_YPR_TEXT_SINGLELINE | (iffs[u].flags & LYS_SINGLEQUOTED) ? LYS_YPR_TEXT_SINGLEQUOTED : 0;
+        ypr_text(pctx, "if-feature", iffs[u].str, flags);
 
         /* extensions */
         LEVEL++;
@@ -514,7 +534,7 @@
         if ((ext->flags & LYS_YINELEM_MASK) ||
                 (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LY_STMT_YIN_ELEMENT) != LY_ARRAY_COUNT(ext->exts)))) {
             ypr_open(pctx->out, &flag2);
-            ypr_substmt(pctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
+            ypr_substmt(pctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", 0, ext->exts);
         }
         LEVEL--;
         ypr_close(pctx, flag2);
@@ -558,7 +578,7 @@
 
     LY_ARRAY_FOR(ident->bases, u) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_BASE, u, ident->bases[u], ident->exts);
+        ypr_substmt(pctx, LY_STMT_BASE, u, ident->bases[u], 0, ident->exts);
     }
 
     ypr_status(pctx, ident->flags, ident->exts, &flag);
@@ -604,8 +624,9 @@
 static void
 yprp_restr(struct lys_ypr_ctx *pctx, const struct lysp_restr *restr, enum ly_stmt stmt, ly_bool *flag)
 {
-    ly_bool inner_flag = 0, singleline;
+    ly_bool inner_flag = 0;
     const char *text;
+    uint16_t flags = 0;
 
     if (!restr) {
         return;
@@ -614,23 +635,28 @@
     ypr_open(pctx->out, flag);
     text = ((restr->arg.str[0] != LYSP_RESTR_PATTERN_NACK) && (restr->arg.str[0] != LYSP_RESTR_PATTERN_ACK)) ?
             restr->arg.str : restr->arg.str + 1;
-    singleline = strchr(text, '\n') ? 0 : 1;
-    ypr_text(pctx, lyplg_ext_stmt2str(stmt), text, singleline, 0);
+    if (!strchr(text, '\n')) {
+        flags |= LYS_YPR_TEXT_SINGLELINE;
+    }
+    if (restr->arg.flags & LYS_SINGLEQUOTED) {
+        flags |= LYS_YPR_TEXT_SINGLEQUOTED;
+    }
+    ypr_text(pctx, lyplg_ext_stmt2str(stmt), text, flags);
 
     LEVEL++;
     yprp_extension_instances(pctx, stmt, 0, restr->exts, &inner_flag);
     if (restr->arg.str[0] == LYSP_RESTR_PATTERN_NACK) {
         /* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_MODIFIER, 0, "invert-match", restr->exts);
+        ypr_substmt(pctx, LY_STMT_MODIFIER, 0, "invert-match", 0, restr->exts);
     }
     if (restr->emsg) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, 0, restr->exts);
     }
     if (restr->eapptag) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, 0, restr->exts);
     }
     ypr_description(pctx, restr->dsc, restr->exts, &inner_flag);
     ypr_reference(pctx, restr->ref, restr->exts, &inner_flag);
@@ -645,17 +671,17 @@
     ly_bool inner_flag = 0;
 
     ypr_open(pctx->out, flag);
-    ypr_text(pctx, "must", must->cond->expr, 1, 0);
+    ypr_text(pctx, "must", must->cond->expr, LYS_YPR_TEXT_SINGLELINE);
 
     LEVEL++;
     yprc_extension_instances(pctx, LY_STMT_MUST, 0, must->exts, &inner_flag);
     if (must->emsg) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, must->emsg, must->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, must->emsg, 0, must->exts);
     }
     if (must->eapptag) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, must->eapptag, must->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, must->eapptag, 0, must->exts);
     }
     ypr_description(pctx, must->dsc, must->exts, &inner_flag);
     ypr_reference(pctx, must->ref, must->exts, &inner_flag);
@@ -700,11 +726,11 @@
     yprc_extension_instances(pctx, LY_STMT_RANGE, 0, range->exts, &inner_flag);
     if (range->emsg) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, range->emsg, range->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, range->emsg, 0, range->exts);
     }
     if (range->eapptag) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, range->eapptag, range->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, range->eapptag, 0, range->exts);
     }
     ypr_description(pctx, range->dsc, range->exts, &inner_flag);
     ypr_reference(pctx, range->ref, range->exts, &inner_flag);
@@ -728,15 +754,15 @@
     if (pattern->inverted) {
         /* special byte value in pattern's expression: 0x15 - invert-match, 0x06 - match */
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_MODIFIER, 0, "invert-match", pattern->exts);
+        ypr_substmt(pctx, LY_STMT_MODIFIER, 0, "invert-match", 0, pattern->exts);
     }
     if (pattern->emsg) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, pattern->emsg, pattern->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_MESSAGE, 0, pattern->emsg, 0, pattern->exts);
     }
     if (pattern->eapptag) {
         ypr_open(pctx->out, &inner_flag);
-        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, pattern->eapptag, pattern->exts);
+        ypr_substmt(pctx, LY_STMT_ERROR_APP_TAG, 0, pattern->eapptag, 0, pattern->exts);
     }
     ypr_description(pctx, pattern->dsc, pattern->exts, &inner_flag);
     ypr_reference(pctx, pattern->ref, pattern->exts, &inner_flag);
@@ -788,7 +814,7 @@
     }
     ypr_open(pctx->out, flag);
 
-    ypr_text(pctx, "when", when->cond, 1, 0);
+    ypr_text(pctx, "when", when->cond, LYS_YPR_TEXT_SINGLELINE);
 
     LEVEL++;
     yprp_extension_instances(pctx, LY_STMT_WHEN, 0, when->exts, &inner_flag);
@@ -808,7 +834,7 @@
     }
     ypr_open(pctx->out, flag);
 
-    ypr_text(pctx, "when", when->cond->expr, 1, 0);
+    ypr_text(pctx, "when", when->cond->expr, LYS_YPR_TEXT_SINGLELINE);
 
     LEVEL++;
     yprc_extension_instances(pctx, LY_STMT_WHEN, 0, when->exts, &inner_flag);
@@ -873,18 +899,18 @@
 
     if (type->path) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_PATH, 0, type->path->expr, type->exts);
+        ypr_substmt(pctx, LY_STMT_PATH, 0, type->path->expr, 0, type->exts);
     }
     if (type->flags & LYS_SET_REQINST) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);
+        ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", 0, type->exts);
     }
     if (type->flags & LYS_SET_FRDIGITS) {
         ypr_unsigned(pctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits, &flag);
     }
     LY_ARRAY_FOR(type->bases, u) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_BASE, u, type->bases[u], type->exts);
+        ypr_substmt(pctx, LY_STMT_BASE, u, type->bases[u], 0, type->exts);
     }
     LY_ARRAY_FOR(type->types, u) {
         ypr_open(pctx->out, &flag);
@@ -903,7 +929,7 @@
     const char *str;
 
     str = value->realtype->plugin->print(ly_pctx, value, LY_VALUE_JSON, NULL, &dynamic, NULL);
-    ypr_substmt(pctx, LY_STMT_DEFAULT, 0, str, exts);
+    ypr_substmt(pctx, LY_STMT_DEFAULT, 0, str, 0, exts);
     if (dynamic) {
         free((void *)str);
     }
@@ -974,7 +1000,7 @@
 
         LY_ARRAY_FOR(ident->bases, u) {
             ypr_open(pctx->out, &flag);
-            ypr_substmt(pctx, LY_STMT_BASE, u, ident->bases[u]->name, type->exts);
+            ypr_substmt(pctx, LY_STMT_BASE, u, ident->bases[u]->name, 0, type->exts);
         }
         break;
     }
@@ -982,15 +1008,15 @@
         struct lysc_type_instanceid *inst = (struct lysc_type_instanceid *)type;
 
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, inst->require_instance ? "true" : "false", inst->exts);
+        ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, inst->require_instance ? "true" : "false", 0, inst->exts);
         break;
     }
     case LY_TYPE_LEAFREF: {
         struct lysc_type_leafref *lr = (struct lysc_type_leafref *)type;
 
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_PATH, 0, lr->path->expr, lr->exts);
-        ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, lr->require_instance ? "true" : "false", lr->exts);
+        ypr_substmt(pctx, LY_STMT_PATH, 0, lr->path->expr, 0, lr->exts);
+        ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, lr->require_instance ? "true" : "false", 0, lr->exts);
         yprc_type(pctx, lr->realtype);
         break;
     }
@@ -1022,10 +1048,10 @@
     yprp_type(pctx, &tpdf->type);
 
     if (tpdf->units) {
-        ypr_substmt(pctx, LY_STMT_UNITS, 0, tpdf->units, tpdf->exts);
+        ypr_substmt(pctx, LY_STMT_UNITS, 0, tpdf->units, 0, tpdf->exts);
     }
     if (tpdf->dflt.str) {
-        ypr_substmt(pctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);
+        ypr_substmt(pctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, YPR_IS_LYS_SINGLEQUOTED(tpdf->dflt.flags), tpdf->exts);
     }
 
     ypr_status(pctx, tpdf->flags, tpdf->exts, NULL);
@@ -1355,7 +1381,7 @@
     }
     if (cont->presence) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_PRESENCE, 0, cont->presence, cont->exts);
+        ypr_substmt(pctx, LY_STMT_PRESENCE, 0, cont->presence, 0, cont->exts);
     }
 
     yprp_node_common2(pctx, node, &flag);
@@ -1406,7 +1432,7 @@
     }
     if (cont->flags & LYS_PRESENCE) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_PRESENCE, 0, "true", cont->exts);
+        ypr_substmt(pctx, LY_STMT_PRESENCE, 0, "true", 0, cont->exts);
     }
 
     yprc_node_common2(pctx, node, &flag);
@@ -1482,7 +1508,7 @@
 
     if (choice->dflt.str) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_DEFAULT, 0, choice->dflt.str, choice->exts);
+        ypr_substmt(pctx, LY_STMT_DEFAULT, 0, choice->dflt.str, YPR_IS_LYS_SINGLEQUOTED(choice->dflt.flags), choice->exts);
     }
 
     yprp_node_common2(pctx, node, &flag);
@@ -1507,7 +1533,7 @@
 
     if (choice->dflt) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_DEFAULT, 0, choice->dflt->name, choice->exts);
+        ypr_substmt(pctx, LY_STMT_DEFAULT, 0, choice->dflt->name, 0, choice->exts);
     }
 
     yprc_node_common2(pctx, node, &flag);
@@ -1530,11 +1556,11 @@
     yprp_node_common1(pctx, node, NULL);
 
     yprp_type(pctx, &leaf->type);
-    ypr_substmt(pctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
+    ypr_substmt(pctx, LY_STMT_UNITS, 0, leaf->units, 0, leaf->exts);
     LY_ARRAY_FOR(leaf->musts, u) {
         yprp_restr(pctx, &leaf->musts[u], LY_STMT_MUST, NULL);
     }
-    ypr_substmt(pctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);
+    ypr_substmt(pctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, YPR_IS_LYS_SINGLEQUOTED(leaf->dflt.flags), leaf->exts);
 
     yprp_node_common2(pctx, node, NULL);
 
@@ -1551,7 +1577,7 @@
     yprc_node_common1(pctx, node, NULL);
 
     yprc_type(pctx, leaf->type);
-    ypr_substmt(pctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);
+    ypr_substmt(pctx, LY_STMT_UNITS, 0, leaf->units, 0, leaf->exts);
     LY_ARRAY_FOR(leaf->musts, u) {
         yprc_must(pctx, &leaf->musts[u], NULL);
     }
@@ -1575,12 +1601,13 @@
     yprp_node_common1(pctx, node, NULL);
 
     yprp_type(pctx, &llist->type);
-    ypr_substmt(pctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
+    ypr_substmt(pctx, LY_STMT_UNITS, 0, llist->units, 0, llist->exts);
     LY_ARRAY_FOR(llist->musts, u) {
         yprp_restr(pctx, &llist->musts[u], LY_STMT_MUST, NULL);
     }
     LY_ARRAY_FOR(llist->dflts, u) {
-        ypr_substmt(pctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);
+        ypr_substmt(pctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, YPR_IS_LYS_SINGLEQUOTED(llist->dflts[u].flags),
+                llist->exts);
     }
 
     ypr_config(pctx, node->flags, node->exts, NULL);
@@ -1592,12 +1619,12 @@
         if (llist->max) {
             ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);
         } else {
-            ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
+            ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, llist->exts);
         }
     }
 
     if (llist->flags & LYS_ORDBY_MASK) {
-        ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
+        ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", 0, llist->exts);
     }
 
     ypr_status(pctx, node->flags, node->exts, NULL);
@@ -1617,7 +1644,7 @@
     yprc_node_common1(pctx, node, NULL);
 
     yprc_type(pctx, llist->type);
-    ypr_substmt(pctx, LY_STMT_UNITS, 0, llist->units, llist->exts);
+    ypr_substmt(pctx, LY_STMT_UNITS, 0, llist->units, 0, llist->exts);
     LY_ARRAY_FOR(llist->musts, u) {
         yprc_must(pctx, &llist->musts[u], NULL);
     }
@@ -1631,10 +1658,10 @@
     if (llist->max) {
         ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);
     } else {
-        ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);
+        ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, llist->exts);
     }
 
-    ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);
+    ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", 0, llist->exts);
 
     ypr_status(pctx, node->flags, node->exts, NULL);
     ypr_description(pctx, node->dsc, node->exts, NULL);
@@ -1662,11 +1689,12 @@
     }
     if (list->key) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_KEY, 0, list->key, list->exts);
+        ypr_substmt(pctx, LY_STMT_KEY, 0, list->key, 0, list->exts);
     }
     LY_ARRAY_FOR(list->uniques, u) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_UNIQUE, u, list->uniques[u].str, list->exts);
+        ypr_substmt(pctx, LY_STMT_UNIQUE, u, list->uniques[u].str, YPR_IS_LYS_SINGLEQUOTED(list->uniques[u].flags),
+                list->exts);
     }
 
     ypr_config(pctx, node->flags, node->exts, &flag);
@@ -1679,13 +1707,13 @@
             ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, &flag);
         } else {
             ypr_open(pctx->out, &flag);
-            ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
+            ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, list->exts);
         }
     }
 
     if (list->flags & LYS_ORDBY_MASK) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
+        ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", 0, list->exts);
     }
 
     ypr_status(pctx, node->flags, node->exts, &flag);
@@ -1753,10 +1781,10 @@
     if (list->max) {
         ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, NULL);
     } else {
-        ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);
+        ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, list->exts);
     }
 
-    ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);
+    ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", 0, list->exts);
 
     ypr_status(pctx, node->flags, node->exts, NULL);
     ypr_description(pctx, node->dsc, node->exts, NULL);
@@ -1803,12 +1831,13 @@
 
     if (refine->presence) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_PRESENCE, 0, refine->presence, refine->exts);
+        ypr_substmt(pctx, LY_STMT_PRESENCE, 0, refine->presence, 0, refine->exts);
     }
 
     LY_ARRAY_FOR(refine->dflts, u) {
         ypr_open(pctx->out, &flag);
-        ypr_substmt(pctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, refine->exts);
+        ypr_substmt(pctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, YPR_IS_LYS_SINGLEQUOTED(refine->dflts[u].flags),
+                refine->exts);
     }
 
     ypr_config(pctx, refine->flags, refine->exts, &flag);
@@ -1823,7 +1852,7 @@
         if (refine->max) {
             ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, refine->exts, refine->max, NULL);
         } else {
-            ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);
+            ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, refine->exts);
         }
     }
 
@@ -2028,15 +2057,17 @@
             LEVEL++;
 
             yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, add->exts, NULL);
-            ypr_substmt(pctx, LY_STMT_UNITS, 0, add->units, add->exts);
+            ypr_substmt(pctx, LY_STMT_UNITS, 0, add->units, 0, add->exts);
             LY_ARRAY_FOR(add->musts, u) {
                 yprp_restr(pctx, &add->musts[u], LY_STMT_MUST, NULL);
             }
             LY_ARRAY_FOR(add->uniques, u) {
-                ypr_substmt(pctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);
+                ypr_substmt(pctx, LY_STMT_UNIQUE, u, add->uniques[u].str, YPR_IS_LYS_SINGLEQUOTED(add->uniques[u].flags),
+                        add->exts);
             }
             LY_ARRAY_FOR(add->dflts, u) {
-                ypr_substmt(pctx, LY_STMT_DEFAULT, u, add->dflts[u].str, add->exts);
+                ypr_substmt(pctx, LY_STMT_DEFAULT, u, add->dflts[u].str, YPR_IS_LYS_SINGLEQUOTED(add->dflts[u].flags),
+                        add->exts);
             }
             ypr_config(pctx, add->flags, add->exts, NULL);
             ypr_mandatory(pctx, add->flags, add->exts, NULL);
@@ -2047,7 +2078,7 @@
                 if (add->max) {
                     ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, add->exts, add->max, NULL);
                 } else {
-                    ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", add->exts);
+                    ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, add->exts);
                 }
             }
         } else if (elem->mod == LYS_DEV_REPLACE) {
@@ -2059,8 +2090,8 @@
             if (rpl->type) {
                 yprp_type(pctx, rpl->type);
             }
-            ypr_substmt(pctx, LY_STMT_UNITS, 0, rpl->units, rpl->exts);
-            ypr_substmt(pctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);
+            ypr_substmt(pctx, LY_STMT_UNITS, 0, rpl->units, 0, rpl->exts);
+            ypr_substmt(pctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, YPR_IS_LYS_SINGLEQUOTED(rpl->dflt.flags), rpl->exts);
             ypr_config(pctx, rpl->flags, rpl->exts, NULL);
             ypr_mandatory(pctx, rpl->flags, rpl->exts, NULL);
             if (rpl->flags & LYS_SET_MIN) {
@@ -2070,7 +2101,7 @@
                 if (rpl->max) {
                     ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max, NULL);
                 } else {
-                    ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);
+                    ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, rpl->exts);
                 }
             }
         } else if (elem->mod == LYS_DEV_DELETE) {
@@ -2079,15 +2110,17 @@
             LEVEL++;
 
             yprp_extension_instances(pctx, LY_STMT_DEVIATE, 0, del->exts, NULL);
-            ypr_substmt(pctx, LY_STMT_UNITS, 0, del->units, del->exts);
+            ypr_substmt(pctx, LY_STMT_UNITS, 0, del->units, 0, del->exts);
             LY_ARRAY_FOR(del->musts, u) {
                 yprp_restr(pctx, &del->musts[u], LY_STMT_MUST, NULL);
             }
             LY_ARRAY_FOR(del->uniques, u) {
-                ypr_substmt(pctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);
+                ypr_substmt(pctx, LY_STMT_UNIQUE, u, del->uniques[u].str, YPR_IS_LYS_SINGLEQUOTED(del->uniques[u].flags),
+                        del->exts);
             }
             LY_ARRAY_FOR(del->dflts, u) {
-                ypr_substmt(pctx, LY_STMT_DEFAULT, u, del->dflts[u].str, del->exts);
+                ypr_substmt(pctx, LY_STMT_DEFAULT, u, del->dflts[u].str, YPR_IS_LYS_SINGLEQUOTED(del->dflts[u].flags),
+                        del->exts);
             }
         }
 
@@ -2113,12 +2146,12 @@
         ly_print_(pctx->out, "%*simport %s {\n", INDENT, modp->imports[u].name);
         LEVEL++;
         yprp_extension_instances(pctx, LY_STMT_IMPORT, 0, modp->imports[u].exts, NULL);
-        ypr_substmt(pctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);
+        ypr_substmt(pctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, 0, modp->imports[u].exts);
         if (modp->imports[u].rev[0]) {
-            ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);
+            ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, 0, modp->imports[u].exts);
         }
-        ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);
-        ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);
+        ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, 0, modp->imports[u].exts);
+        ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, 0, modp->imports[u].exts);
         LEVEL--;
         ly_print_(pctx->out, "%*s}\n", INDENT);
     }
@@ -2135,10 +2168,10 @@
             LEVEL++;
             yprp_extension_instances(pctx, LY_STMT_INCLUDE, 0, modp->includes[u].exts, NULL);
             if (modp->includes[u].rev[0]) {
-                ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);
+                ypr_substmt(pctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, 0, modp->includes[u].exts);
             }
-            ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);
-            ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);
+            ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, 0, modp->includes[u].exts);
+            ypr_substmt(pctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, 0, modp->includes[u].exts);
             LEVEL--;
             ly_print_(pctx->out, "%*s}\n", INDENT);
         } else {
@@ -2258,10 +2291,10 @@
 
     /* module-header-stmts */
     if (modp->version) {
-        ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);
+        ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", 0, modp->exts);
     }
-    ypr_substmt(pctx, LY_STMT_NAMESPACE, 0, module->ns, modp->exts);
-    ypr_substmt(pctx, LY_STMT_PREFIX, 0, module->prefix, modp->exts);
+    ypr_substmt(pctx, LY_STMT_NAMESPACE, 0, module->ns, 0, modp->exts);
+    ypr_substmt(pctx, LY_STMT_PREFIX, 0, module->prefix, 0, modp->exts);
 
     YPR_EXTRA_LINE(1, pctx);
 
@@ -2272,10 +2305,10 @@
     if (module->org || module->contact || module->dsc || module->ref) {
         YPR_EXTRA_LINE_PRINT(pctx);
     }
-    ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, module->org, modp->exts);
-    ypr_substmt(pctx, LY_STMT_CONTACT, 0, module->contact, modp->exts);
-    ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, module->dsc, modp->exts);
-    ypr_substmt(pctx, LY_STMT_REFERENCE, 0, module->ref, modp->exts);
+    ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, module->org, 0, modp->exts);
+    ypr_substmt(pctx, LY_STMT_CONTACT, 0, module->contact, 0, modp->exts);
+    ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, module->dsc, 0, modp->exts);
+    ypr_substmt(pctx, LY_STMT_REFERENCE, 0, module->ref, 0, modp->exts);
 
     YPR_EXTRA_LINE(module->org || module->contact || module->dsc || module->ref, pctx);
 
@@ -2303,7 +2336,7 @@
     ly_print_(pctx->out, "%*sbelongs-to %s {\n", INDENT, submodp->mod->name);
     LEVEL++;
     yprp_extension_instances(pctx, LY_STMT_BELONGS_TO, 0, submodp->exts, NULL);
-    ypr_substmt(pctx, LY_STMT_PREFIX, 0, submodp->prefix, submodp->exts);
+    ypr_substmt(pctx, LY_STMT_PREFIX, 0, submodp->prefix, 0, submodp->exts);
     LEVEL--;
     ly_print_(pctx->out, "%*s}\n", INDENT);
 }
@@ -2325,7 +2358,7 @@
 
     /* submodule-header-stmts */
     if (submodp->version) {
-        ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);
+        ypr_substmt(pctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", 0, submodp->exts);
     }
 
     yprp_belongsto(pctx, submodp);
@@ -2339,10 +2372,10 @@
     if (submodp->org || submodp->contact || submodp->dsc || submodp->ref) {
         YPR_EXTRA_LINE_PRINT(pctx);
     }
-    ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, submodp->org, submodp->exts);
-    ypr_substmt(pctx, LY_STMT_CONTACT, 0, submodp->contact, submodp->exts);
-    ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);
-    ypr_substmt(pctx, LY_STMT_REFERENCE, 0, submodp->ref, submodp->exts);
+    ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, submodp->org, 0, submodp->exts);
+    ypr_substmt(pctx, LY_STMT_CONTACT, 0, submodp->contact, 0, submodp->exts);
+    ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, 0, submodp->exts);
+    ypr_substmt(pctx, LY_STMT_REFERENCE, 0, submodp->ref, 0, submodp->exts);
 
     YPR_EXTRA_LINE(submodp->org || submodp->contact || submodp->dsc || submodp->ref, pctx);
 
@@ -2398,8 +2431,8 @@
     LEVEL++;
 
     /* module-header-stmts */
-    ypr_substmt(pctx, LY_STMT_NAMESPACE, 0, module->ns, modc->exts);
-    ypr_substmt(pctx, LY_STMT_PREFIX, 0, module->prefix, modc->exts);
+    ypr_substmt(pctx, LY_STMT_NAMESPACE, 0, module->ns, 0, modc->exts);
+    ypr_substmt(pctx, LY_STMT_PREFIX, 0, module->prefix, 0, modc->exts);
 
     YPR_EXTRA_LINE(1, pctx);
 
@@ -2409,10 +2442,10 @@
     if (module->org || module->contact || module->dsc || module->ref) {
         YPR_EXTRA_LINE_PRINT(pctx);
     }
-    ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, module->org, modc->exts);
-    ypr_substmt(pctx, LY_STMT_CONTACT, 0, module->contact, modc->exts);
-    ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, module->dsc, modc->exts);
-    ypr_substmt(pctx, LY_STMT_REFERENCE, 0, module->ref, modc->exts);
+    ypr_substmt(pctx, LY_STMT_ORGANIZATION, 0, module->org, 0, modc->exts);
+    ypr_substmt(pctx, LY_STMT_CONTACT, 0, module->contact, 0, modc->exts);
+    ypr_substmt(pctx, LY_STMT_DESCRIPTION, 0, module->dsc, 0, modc->exts);
+    ypr_substmt(pctx, LY_STMT_REFERENCE, 0, module->ref, 0, modc->exts);
 
     YPR_EXTRA_LINE(module->org || module->contact || module->dsc || module->ref, pctx);
 
@@ -2530,7 +2563,7 @@
         case LY_STMT_UNITS:
             if (*(const char **)ext->substmts[u].storage) {
                 ypr_open(pctx->out, flag);
-                ypr_substmt(pctx, ext->substmts[u].stmt, 0, *(const char **)ext->substmts[u].storage, ext->exts);
+                ypr_substmt(pctx, ext->substmts[u].stmt, 0, *(const char **)ext->substmts[u].storage, 0, ext->exts);
             }
             break;
         case LY_STMT_BIT:
@@ -2575,7 +2608,7 @@
                 ypr_unsigned(pctx, LY_STMT_MAX_ELEMENTS, 0, ext->exts, max, flag);
             } else {
                 ypr_open(pctx->out, flag);
-                ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", ext->exts);
+                ypr_substmt(pctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", 0, ext->exts);
             }
             break;
         }
@@ -2585,7 +2618,7 @@
         case LY_STMT_ORDERED_BY:
             ypr_open(pctx->out, flag);
             ypr_substmt(pctx, LY_STMT_ORDERED_BY, 0,
-                    (*(uint16_t *)ext->substmts[u].storage & LYS_ORDBY_USER) ? "user" : "system", ext->exts);
+                    (*(uint16_t *)ext->substmts[u].storage & LYS_ORDBY_USER) ? "user" : "system", 0, ext->exts);
             break;
         case LY_STMT_MUST: {
             const struct lysc_must *musts = *(struct lysc_must **)ext->substmts[u].storage;
@@ -2621,7 +2654,7 @@
         case LY_STMT_REQUIRE_INSTANCE:
             ypr_open(pctx->out, flag);
             ypr_substmt(pctx, LY_STMT_REQUIRE_INSTANCE, 0, *(uint8_t *)ext->substmts[u].storage ? "true" : "false",
-                    ext->exts);
+                    0, ext->exts);
             break;
         case LY_STMT_STATUS:
             ypr_status(pctx, *(uint16_t *)ext->substmts[u].storage, ext->exts, flag);
diff --git a/src/tree_schema.h b/src/tree_schema.h
index e9528b9..0181bc6 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -338,6 +338,8 @@
     const char *str;                 /**< qualified name string */
     const struct lysp_module *mod;   /**< module to resolve any prefixes found in the string, it must be
                                           stored explicitly because of deviations/refines */
+    uint16_t flags;                  /**< [schema node flags](@ref snodeflags) - only LYS_SINGLEQUOTED and
+                                          LYS_DOUBLEQUOTED values allowed */
 };
 
 /**
@@ -705,8 +707,10 @@
 #define LYS_SET_UNITS    0x0400      /**< flag to know if the leaf's/leaflist's units are their own (flag set) or it is taken from the type. */
 #define LYS_SET_CONFIG   0x0800      /**< flag to know if the config property was set explicitly (flag set) or it is inherited. */
 
-#define LYS_SINGLEQUOTED 0x0100      /**< flag for single-quoted argument of an extension instance's substatement, only when the source is YANG */
-#define LYS_DOUBLEQUOTED 0x0200      /**< flag for double-quoted argument of an extension instance's substatement, only when the source is YANG */
+#define LYS_SINGLEQUOTED 0x0100      /**< flag for single-quoted string (argument of an extension instance's substatement),
+                                          only when the source is YANG */
+#define LYS_DOUBLEQUOTED 0x0200      /**< flag for double-quoted string (argument of an extension instance's substatement),
+                                          only when the source is YANG */
 
 #define LYS_YIN_ATTR     0x0400      /**< flag to identify YIN attribute parsed as extension's substatement, only when the source is YIN */
 #define LYS_YIN_ARGUMENT 0x0800      /**< flag to identify statement representing extension's argument, only when the source is YIN */