extensions CHANGE base for substatements support in extension instances
Proof of concept on Metadata annotation implementation. So far just some
of the structures, function stubs and the process framework. functions to
convert extension's substatements to lysp structures are still missing.
diff --git a/src/common.c b/src/common.c
index a59d5af..69245d4 100644
--- a/src/common.c
+++ b/src/common.c
@@ -29,80 +29,80 @@
#include "tree_schema_internal.h"
const char *const ly_stmt_list[] = {
- [YANG_ACTION] = "action",
- [YANG_ANYDATA] = "anydata",
- [YANG_ANYXML] = "anyxml",
- [YANG_ARGUMENT] = "argument",
- [YANG_AUGMENT] = "augment",
- [YANG_BASE] = "base",
- [YANG_BELONGS_TO] = "belongs-to",
- [YANG_BIT] = "bit",
- [YANG_CASE] = "case",
- [YANG_CHOICE] = "choice",
- [YANG_CONFIG] = "config",
- [YANG_CONTACT] = "contact",
- [YANG_CONTAINER] = "container",
- [YANG_CUSTOM] = "<extension-instance>",
- [YANG_DEFAULT] = "default",
- [YANG_DESCRIPTION] = "description",
- [YANG_DEVIATE] = "deviate",
- [YANG_DEVIATION] = "deviation",
- [YANG_ENUM] = "enum",
- [YANG_ERROR_APP_TAG] = "error-app-tag",
- [YANG_ERROR_MESSAGE] = "error-message",
- [YANG_EXTENSION] = "extension",
- [YANG_FEATURE] = "feature",
- [YANG_FRACTION_DIGITS] = "fraction-digits",
- [YANG_GROUPING] = "grouping",
- [YANG_IDENTITY] = "identity",
- [YANG_IF_FEATURE] = "if-feature",
- [YANG_IMPORT] = "import",
- [YANG_INCLUDE] = "include",
- [YANG_INPUT] = "input",
- [YANG_KEY] = "key",
- [YANG_LEAF] = "leaf",
- [YANG_LEAF_LIST] = "leaf-list",
- [YANG_LENGTH] = "length",
- [YANG_LIST] = "list",
- [YANG_MANDATORY] = "mandatory",
- [YANG_MAX_ELEMENTS] = "max-elements",
- [YANG_MIN_ELEMENTS] = "min-elements",
- [YANG_MODIFIER] = "modifier",
- [YANG_MODULE] = "module",
- [YANG_MUST] = "must",
- [YANG_NAMESPACE] = "namespace",
- [YANG_NOTIFICATION] = "notification",
- [YANG_ORDERED_BY] = "ordered-by",
- [YANG_ORGANIZATION] = "organization",
- [YANG_OUTPUT] = "output",
- [YANG_PATH] = "path",
- [YANG_PATTERN] = "pattern",
- [YANG_POSITION] = "position",
- [YANG_PREFIX] = "prefix",
- [YANG_PRESENCE] = "presence",
- [YANG_RANGE] = "range",
- [YANG_REFERENCE] = "reference",
- [YANG_REFINE] = "refine",
- [YANG_REQUIRE_INSTANCE] = "require-instance",
- [YANG_REVISION] = "revision",
- [YANG_REVISION_DATE] = "revision-date",
- [YANG_RPC] = "rpc",
- [YANG_STATUS] = "status",
- [YANG_SUBMODULE] = "submodule",
- [YANG_TYPE] = "type",
- [YANG_TYPEDEF] = "typedef",
- [YANG_UNIQUE] = "unique",
- [YANG_UNITS] = "units",
- [YANG_USES] = "uses",
- [YANG_VALUE] = "value",
- [YANG_WHEN] = "when",
- [YANG_YANG_VERSION] = "yang-version",
- [YANG_YIN_ELEMENT] = "yin-element",
- [YANG_SEMICOLON] = ";",
- [YANG_LEFT_BRACE] = "{",
- [YANG_RIGHT_BRACE] = "}",
- [YIN_TEXT] = "text",
- [YIN_VALUE] = "value",
+ [LY_STMT_ACTION] = "action",
+ [LY_STMT_ANYDATA] = "anydata",
+ [LY_STMT_ANYXML] = "anyxml",
+ [LY_STMT_ARGUMENT] = "argument",
+ [LY_STMT_AUGMENT] = "augment",
+ [LY_STMT_BASE] = "base",
+ [LY_STMT_BELONGS_TO] = "belongs-to",
+ [LY_STMT_BIT] = "bit",
+ [LY_STMT_CASE] = "case",
+ [LY_STMT_CHOICE] = "choice",
+ [LY_STMT_CONFIG] = "config",
+ [LY_STMT_CONTACT] = "contact",
+ [LY_STMT_CONTAINER] = "container",
+ [LY_STMT_EXTENSION_INSTANCE] = "<extension-instance>",
+ [LY_STMT_DEFAULT] = "default",
+ [LY_STMT_DESCRIPTION] = "description",
+ [LY_STMT_DEVIATE] = "deviate",
+ [LY_STMT_DEVIATION] = "deviation",
+ [LY_STMT_ENUM] = "enum",
+ [LY_STMT_ERROR_APP_TAG] = "error-app-tag",
+ [LY_STMT_ERROR_MESSAGE] = "error-message",
+ [LY_STMT_EXTENSION] = "extension",
+ [LY_STMT_FEATURE] = "feature",
+ [LY_STMT_FRACTION_DIGITS] = "fraction-digits",
+ [LY_STMT_GROUPING] = "grouping",
+ [LY_STMT_IDENTITY] = "identity",
+ [LY_STMT_IF_FEATURE] = "if-feature",
+ [LY_STMT_IMPORT] = "import",
+ [LY_STMT_INCLUDE] = "include",
+ [LY_STMT_INPUT] = "input",
+ [LY_STMT_KEY] = "key",
+ [LY_STMT_LEAF] = "leaf",
+ [LY_STMT_LEAF_LIST] = "leaf-list",
+ [LY_STMT_LENGTH] = "length",
+ [LY_STMT_LIST] = "list",
+ [LY_STMT_MANDATORY] = "mandatory",
+ [LY_STMT_MAX_ELEMENTS] = "max-elements",
+ [LY_STMT_MIN_ELEMENTS] = "min-elements",
+ [LY_STMT_MODIFIER] = "modifier",
+ [LY_STMT_MODULE] = "module",
+ [LY_STMT_MUST] = "must",
+ [LY_STMT_NAMESPACE] = "namespace",
+ [LY_STMT_NOTIFICATION] = "notification",
+ [LY_STMT_ORDERED_BY] = "ordered-by",
+ [LY_STMT_ORGANIZATION] = "organization",
+ [LY_STMT_OUTPUT] = "output",
+ [LY_STMT_PATH] = "path",
+ [LY_STMT_PATTERN] = "pattern",
+ [LY_STMT_POSITION] = "position",
+ [LY_STMT_PREFIX] = "prefix",
+ [LY_STMT_PRESENCE] = "presence",
+ [LY_STMT_RANGE] = "range",
+ [LY_STMT_REFERENCE] = "reference",
+ [LY_STMT_REFINE] = "refine",
+ [LY_STMT_REQUIRE_INSTANCE] = "require-instance",
+ [LY_STMT_REVISION] = "revision",
+ [LY_STMT_REVISION_DATE] = "revision-date",
+ [LY_STMT_RPC] = "rpc",
+ [LY_STMT_STATUS] = "status",
+ [LY_STMT_SUBMODULE] = "submodule",
+ [LY_STMT_TYPE] = "type",
+ [LY_STMT_TYPEDEF] = "typedef",
+ [LY_STMT_UNIQUE] = "unique",
+ [LY_STMT_UNITS] = "units",
+ [LY_STMT_USES] = "uses",
+ [LY_STMT_VALUE] = "value",
+ [LY_STMT_WHEN] = "when",
+ [LY_STMT_YANG_VERSION] = "yang-version",
+ [LY_STMT_YIN_ELEMENT] = "yin-element",
+ [LY_STMT_SYNTAX_SEMICOLON] = ";",
+ [LY_STMT_SYNTAX_LEFT_BRACE] = "{",
+ [LY_STMT_SYNTAX_RIGHT_BRACE] = "}",
+ [LY_STMT_ARG_TEXT] = "text",
+ [LY_STMT_ARG_VALUE] = "value",
};
const char *const lyext_substmt_list[] = {
diff --git a/src/common.h b/src/common.h
index 10637ee..d04dbc2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -268,86 +268,6 @@
* Parsers
*****************************************************************************/
-enum yang_keyword {
- YANG_NONE = 0,
- YANG_ACTION,
- YANG_ANYDATA,
- YANG_ANYXML,
- YANG_ARGUMENT,
- YANG_AUGMENT,
- YANG_BASE,
- YANG_BELONGS_TO,
- YANG_BIT,
- YANG_CASE,
- YANG_CHOICE,
- YANG_CONFIG,
- YANG_CONTACT,
- YANG_CONTAINER,
- YANG_DEFAULT,
- YANG_DESCRIPTION,
- YANG_DEVIATE,
- YANG_DEVIATION,
- YANG_ENUM,
- YANG_ERROR_APP_TAG,
- YANG_ERROR_MESSAGE,
- YANG_EXTENSION,
- YANG_FEATURE,
- YANG_FRACTION_DIGITS,
- YANG_GROUPING,
- YANG_IDENTITY,
- YANG_IF_FEATURE,
- YANG_IMPORT,
- YANG_INCLUDE,
- YANG_INPUT,
- YANG_KEY,
- YANG_LEAF,
- YANG_LEAF_LIST,
- YANG_LENGTH,
- YANG_LIST,
- YANG_MANDATORY,
- YANG_MAX_ELEMENTS,
- YANG_MIN_ELEMENTS,
- YANG_MODIFIER,
- YANG_MODULE,
- YANG_MUST,
- YANG_NAMESPACE,
- YANG_NOTIFICATION,
- YANG_ORDERED_BY,
- YANG_ORGANIZATION,
- YANG_OUTPUT,
- YANG_PATH,
- YANG_PATTERN,
- YANG_POSITION,
- YANG_PREFIX,
- YANG_PRESENCE,
- YANG_RANGE,
- YANG_REFERENCE,
- YANG_REFINE,
- YANG_REQUIRE_INSTANCE,
- YANG_REVISION,
- YANG_REVISION_DATE,
- YANG_RPC,
- YANG_STATUS,
- YANG_SUBMODULE,
- YANG_TYPE,
- YANG_TYPEDEF,
- YANG_UNIQUE,
- YANG_UNITS,
- YANG_USES,
- YANG_VALUE,
- YANG_WHEN,
- YANG_YANG_VERSION,
- YANG_YIN_ELEMENT,
-
- YANG_SEMICOLON,
- YANG_LEFT_BRACE,
- YANG_RIGHT_BRACE,
- YANG_CUSTOM,
-
- YIN_TEXT,
- YIN_VALUE
-};
-
/* list of the YANG statements strings */
extern const char *const ly_stmt_list[];
#define ly_stmt2str(STMT) ly_stmt_list[STMT]
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 3949b4a..612d19f 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -65,16 +65,16 @@
*/
#define YANG_READ_SUBSTMT_FOR(CTX, DATA, KW, WORD, WORD_LEN, ERR, CHECKGOTO) \
LY_CHECK_RET(get_keyword(CTX, DATA, &KW, &WORD, &WORD_LEN)); \
- if (KW == YANG_SEMICOLON) { \
+ if (KW == LY_STMT_SYNTAX_SEMICOLON) { \
CHECKGOTO; \
return LY_SUCCESS; \
} \
- if (KW != YANG_LEFT_BRACE) { \
+ if (KW != LY_STMT_SYNTAX_LEFT_BRACE) { \
LOGVAL_PARSER(CTX, LYVE_SYNTAX_YANG, "Invalid keyword \"%s\", expected \";\" or \"{\".", ly_stmt2str(KW)); \
return LY_EVALID; \
} \
for (ERR = get_keyword(CTX, DATA, &KW, &WORD, &WORD_LEN); \
- !ERR && (KW != YANG_RIGHT_BRACE); \
+ !ERR && (KW != LY_STMT_SYNTAX_RIGHT_BRACE); \
ERR = get_keyword(CTX, DATA, &KW, &WORD, &WORD_LEN))
/**
@@ -622,7 +622,7 @@
* @return LY_ERR values.
*/
LY_ERR
-get_keyword(struct lys_parser_ctx *ctx, const char **data, enum yang_keyword *kw, char **word_p, size_t *word_len)
+get_keyword(struct lys_parser_ctx *ctx, const char **data, enum ly_stmt *kw, char **word_p, size_t *word_len)
{
int prefix;
const char *word_start;
@@ -677,11 +677,11 @@
word_start = *data;
*kw = lysp_match_kw(ctx, data);
- if (*kw == YANG_SEMICOLON || *kw == YANG_LEFT_BRACE || *kw == YANG_RIGHT_BRACE) {
+ if (*kw == LY_STMT_SYNTAX_SEMICOLON || *kw == LY_STMT_SYNTAX_LEFT_BRACE || *kw == LY_STMT_SYNTAX_RIGHT_BRACE) {
goto success;
}
- if (*kw != YANG_NONE) {
+ if (*kw != LY_STMT_NONE) {
/* make sure we have the whole keyword */
switch (**data) {
case '\n':
@@ -698,7 +698,7 @@
goto extension;
case '{':
/* allowed only for input and output statements which can be without arguments */
- if (*kw == YANG_INPUT || *kw == YANG_OUTPUT) {
+ if (*kw == LY_STMT_INPUT || *kw == LY_STMT_OUTPUT) {
break;
}
/* fallthrough */
@@ -730,7 +730,7 @@
return LY_EVALID;
}
- *kw = YANG_CUSTOM;
+ *kw = LY_STMT_EXTENSION_INSTANCE;
}
success:
if (word_p) {
@@ -758,7 +758,7 @@
{
char *buf;
LY_ERR ret = LY_SUCCESS;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_stmt *stmt, *par_child;
stmt = calloc(1, sizeof *stmt);
@@ -812,7 +812,7 @@
char *buf, *word;
size_t word_len;
struct lysp_ext_instance *e;
- enum yang_keyword kw;
+ enum ly_stmt kw;
LY_ARRAY_NEW_RET(ctx->ctx, *exts, e, LY_EMEM);
@@ -855,7 +855,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*value) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, lyext_substmt2str(substmt));
@@ -870,7 +870,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, substmt, substmt_index, exts));
break;
default:
@@ -897,7 +897,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*version) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "yang-version");
@@ -920,7 +920,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_VERSION, 0, exts));
break;
default:
@@ -948,7 +948,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*belongsto) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "belongs-to");
@@ -962,10 +962,10 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_PREFIX:
+ case LY_STMT_PREFIX:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_PREFIX, 0, prefix, Y_IDENTIF_ARG, exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_BELONGSTO, 0, exts));
break;
default:
@@ -999,7 +999,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (rev[0]) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "revision-date");
@@ -1021,7 +1021,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_REVISIONDATE, 0, exts));
break;
default:
@@ -1048,7 +1048,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_include *inc;
LY_ARRAY_NEW_RET(ctx->ctx, *includes, inc, LY_EMEM);
@@ -1067,18 +1067,18 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
YANG_CHECK_STMTVER2_RET(ctx, "description", "include");
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &inc->dsc, Y_STR_ARG, &inc->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
YANG_CHECK_STMTVER2_RET(ctx, "reference", "include");
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &inc->ref, Y_STR_ARG, &inc->exts));
break;
- case YANG_REVISION_DATE:
+ case LY_STMT_REVISION_DATE:
LY_CHECK_RET(parse_revisiondate(ctx, data, inc->rev, &inc->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &inc->exts));
break;
default:
@@ -1105,7 +1105,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_import *imp;
LY_ARRAY_NEW_RET(ctx->ctx, *imports, imp, LY_EVALID);
@@ -1116,22 +1116,22 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_PREFIX:
+ case LY_STMT_PREFIX:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_PREFIX, 0, &imp->prefix, Y_IDENTIF_ARG, &imp->exts));
LY_CHECK_RET(lysp_check_prefix(ctx, *imports, module_prefix, &imp->prefix), LY_EVALID);
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
YANG_CHECK_STMTVER2_RET(ctx, "description", "import");
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &imp->dsc, Y_STR_ARG, &imp->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
YANG_CHECK_STMTVER2_RET(ctx, "reference", "import");
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &imp->ref, Y_STR_ARG, &imp->exts));
break;
- case YANG_REVISION_DATE:
+ case LY_STMT_REVISION_DATE:
LY_CHECK_RET(parse_revisiondate(ctx, data, imp->rev, &imp->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &imp->exts));
break;
default:
@@ -1162,7 +1162,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_revision *rev;
LY_ARRAY_NEW_RET(ctx->ctx, *revs, rev, LY_EMEM);
@@ -1181,13 +1181,13 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &rev->dsc, Y_STR_ARG, &rev->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &rev->ref, Y_STR_ARG, &rev->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &rev->exts));
break;
default:
@@ -1218,7 +1218,7 @@
char *buf, *word;
const char **item;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
/* allocate new pointer */
LY_ARRAY_NEW_RET(ctx->ctx, *texts, item, LY_EMEM);
@@ -1229,7 +1229,7 @@
INSERT_WORD(ctx, buf, *item, word, word_len);
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, substmt, LY_ARRAY_SIZE(*texts) - 1, exts));
break;
default:
@@ -1256,7 +1256,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_CONFIG_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "config");
@@ -1279,7 +1279,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_CONFIG, 0, exts));
break;
default:
@@ -1306,7 +1306,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_MAND_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "mandatory");
@@ -1329,7 +1329,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_MANDATORY, 0, exts));
break;
default:
@@ -1351,12 +1351,12 @@
* @return LY_ERR values.
*/
static LY_ERR
-parse_restr(struct lys_parser_ctx *ctx, const char **data, enum yang_keyword restr_kw, struct lysp_restr *restr)
+parse_restr(struct lys_parser_ctx *ctx, const char **data, enum ly_stmt restr_kw, struct lysp_restr *restr)
{
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
/* get value */
LY_CHECK_RET(get_argument(ctx, data, Y_STR_ARG, NULL, &word, &buf, &word_len));
@@ -1365,19 +1365,19 @@
INSERT_WORD(ctx, buf, restr->arg, word, word_len);
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));
break;
- case YANG_ERROR_APP_TAG:
+ case LY_STMT_ERROR_APP_TAG:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_ERRTAG, 0, &restr->eapptag, Y_STR_ARG, &restr->exts));
break;
- case YANG_ERROR_MESSAGE:
+ case LY_STMT_ERROR_MESSAGE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_ERRMSG, 0, &restr->emsg, Y_STR_ARG, &restr->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &restr->exts));
break;
default:
@@ -1399,7 +1399,7 @@
* @return LY_ERR values.
*/
static LY_ERR
-parse_restrs(struct lys_parser_ctx *ctx, const char **data, enum yang_keyword restr_kw, struct lysp_restr **restrs)
+parse_restrs(struct lys_parser_ctx *ctx, const char **data, enum ly_stmt restr_kw, struct lysp_restr **restrs)
{
struct lysp_restr *restr;
@@ -1423,7 +1423,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_STATUS_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "status");
@@ -1448,7 +1448,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_STATUS, 0, exts));
break;
default:
@@ -1474,7 +1474,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_when *when;
if (*when_p) {
@@ -1494,13 +1494,13 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &when->dsc, Y_STR_ARG, &when->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &when->ref, Y_STR_ARG, &when->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &when->exts));
break;
default:
@@ -1522,7 +1522,7 @@
* @return LY_ERR values.
*/
LY_ERR
-parse_any(struct lys_parser_ctx *ctx, const char **data, enum yang_keyword kw, struct lysp_node *parent, struct lysp_node **siblings)
+parse_any(struct lys_parser_ctx *ctx, const char **data, enum ly_stmt kw, struct lysp_node *parent, struct lysp_node **siblings)
{
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
@@ -1532,7 +1532,7 @@
/* create new structure and insert into siblings */
LY_LIST_NEW_RET(ctx->ctx, siblings, any, next);
- any->nodetype = kw == YANG_ANYDATA ? LYS_ANYDATA : LYS_ANYXML;
+ any->nodetype = kw == LY_STMT_ANYDATA ? LYS_ANYDATA : LYS_ANYXML;
any->parent = parent;
/* get name */
@@ -1542,36 +1542,36 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
LY_CHECK_RET(parse_config(ctx, data, &any->flags, &any->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &any->dsc, Y_STR_ARG, &any->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &any->iffeatures, Y_STR_ARG, &any->exts));
break;
- case YANG_MANDATORY:
+ case LY_STMT_MANDATORY:
LY_CHECK_RET(parse_mandatory(ctx, data, &any->flags, &any->exts));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
LY_CHECK_RET(parse_restrs(ctx, data, kw, &any->musts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &any->ref, Y_STR_ARG, &any->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &any->flags, &any->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &any->when));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &any->exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
- (any->nodetype & LYS_ANYDATA) == LYS_ANYDATA ? ly_stmt2str(YANG_ANYDATA) : ly_stmt2str(YANG_ANYXML));
+ (any->nodetype & LYS_ANYDATA) == LYS_ANYDATA ? ly_stmt2str(LY_STMT_ANYDATA) : ly_stmt2str(LY_STMT_ANYXML));
return LY_EVALID;
}
}
@@ -1591,7 +1591,7 @@
* @return LY_ERR values.
*/
LY_ERR
-parse_type_enum_value_pos(struct lys_parser_ctx *ctx, const char **data, enum yang_keyword val_kw, int64_t *value, uint16_t *flags,
+parse_type_enum_value_pos(struct lys_parser_ctx *ctx, const char **data, enum ly_stmt val_kw, int64_t *value, uint16_t *flags,
struct lysp_ext_instance **exts)
{
LY_ERR ret = LY_SUCCESS;
@@ -1599,7 +1599,7 @@
size_t word_len;
long int num = 0;
unsigned long int unum = 0;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_SET_VALUE) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, ly_stmt2str(val_kw));
@@ -1610,13 +1610,13 @@
/* get value */
LY_CHECK_RET(get_argument(ctx, data, Y_STR_ARG, NULL, &word, &buf, &word_len));
- if (!word_len || (word[0] == '+') || ((word[0] == '0') && (word_len > 1)) || ((val_kw == YANG_POSITION) && !strncmp(word, "-0", 2))) {
+ if (!word_len || (word[0] == '+') || ((word[0] == '0') && (word_len > 1)) || ((val_kw == LY_STMT_POSITION) && !strncmp(word, "-0", 2))) {
LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, ly_stmt2str(val_kw));
goto error;
}
errno = 0;
- if (val_kw == YANG_VALUE) {
+ if (val_kw == LY_STMT_VALUE) {
num = strtol(word, &ptr, 10);
if (num < INT64_C(-2147483648) || num > INT64_C(2147483647)) {
LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, ly_stmt2str(val_kw));
@@ -1638,7 +1638,7 @@
LOGVAL_PARSER(ctx, LY_VCODE_OOB, word_len, word, ly_stmt2str(val_kw));
goto error;
}
- if (val_kw == YANG_VALUE) {
+ if (val_kw == LY_STMT_VALUE) {
*value = num;
} else {
*value = unum;
@@ -1647,8 +1647,8 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
- LY_CHECK_RET(parse_ext(ctx, data, word, word_len, val_kw == YANG_VALUE ? LYEXT_SUBSTMT_VALUE : LYEXT_SUBSTMT_POSITION, 0, exts));
+ case LY_STMT_EXTENSION_INSTANCE:
+ LY_CHECK_RET(parse_ext(ctx, data, word, word_len, val_kw == LY_STMT_VALUE ? LYEXT_SUBSTMT_VALUE : LYEXT_SUBSTMT_POSITION, 0, exts));
break;
default:
LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(val_kw));
@@ -1673,25 +1673,25 @@
* @return LY_ERR values.
*/
static LY_ERR
-parse_type_enum(struct lys_parser_ctx *ctx, const char **data, enum yang_keyword enum_kw, struct lysp_type_enum **enums)
+parse_type_enum(struct lys_parser_ctx *ctx, const char **data, enum ly_stmt enum_kw, struct lysp_type_enum **enums)
{
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_type_enum *enm;
LY_ARRAY_NEW_RET(ctx->ctx, *enums, enm, LY_EMEM);
/* get value */
- LY_CHECK_RET(get_argument(ctx, data, enum_kw == YANG_ENUM ? Y_STR_ARG : Y_IDENTIF_ARG, NULL, &word, &buf, &word_len));
- if (enum_kw == YANG_ENUM) {
+ LY_CHECK_RET(get_argument(ctx, data, enum_kw == LY_STMT_ENUM ? Y_STR_ARG : Y_IDENTIF_ARG, NULL, &word, &buf, &word_len));
+ if (enum_kw == LY_STMT_ENUM) {
ret = lysp_check_enum_name(ctx, (const char *)word, word_len);
LY_CHECK_ERR_RET(ret, free(buf), ret);
} else { /* YANG_BIT */
}
- if (enum_kw == YANG_ENUM) {
+ if (enum_kw == LY_STMT_ENUM) {
YANG_CHECK_NONEMPTY(ctx, word_len, "enum");
}
INSERT_WORD(ctx, buf, enm->name, word, word_len);
@@ -1699,30 +1699,30 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &enm->dsc, Y_STR_ARG, &enm->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
YANG_CHECK_STMTVER2_RET(ctx, "if-feature", ly_stmt2str(enum_kw));
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &enm->iffeatures, Y_STR_ARG, &enm->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &enm->ref, Y_STR_ARG, &enm->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &enm->flags, &enm->exts));
break;
- case YANG_VALUE:
- LY_CHECK_ERR_RET(enum_kw == YANG_BIT, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
+ case LY_STMT_VALUE:
+ LY_CHECK_ERR_RET(enum_kw == LY_STMT_BIT, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
ly_stmt2str(enum_kw)), LY_EVALID);
LY_CHECK_RET(parse_type_enum_value_pos(ctx, data, kw, &enm->value, &enm->flags, &enm->exts));
break;
- case YANG_POSITION:
- LY_CHECK_ERR_RET(enum_kw == YANG_ENUM, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
+ case LY_STMT_POSITION:
+ LY_CHECK_ERR_RET(enum_kw == LY_STMT_ENUM, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
ly_stmt2str(enum_kw)), LY_EVALID);
LY_CHECK_RET(parse_type_enum_value_pos(ctx, data, kw, &enm->value, &enm->flags, &enm->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &enm->exts));
break;
default:
@@ -1750,7 +1750,7 @@
char *buf, *word, *ptr;
size_t word_len;
unsigned long int num;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*fracdig) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "fraction-digits");
@@ -1784,7 +1784,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_FRACDIGITS, 0, exts));
break;
default:
@@ -1813,7 +1813,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_SET_REQINST) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "require-instance");
@@ -1835,7 +1835,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_REQINSTANCE, 0, exts));
break;
default:
@@ -1862,7 +1862,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if ((*pat)[0] == 0x15) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "modifier");
@@ -1891,7 +1891,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_MODIFIER, 0, exts));
break;
default:
@@ -1917,7 +1917,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_restr *restr;
LY_ARRAY_NEW_RET(ctx->ctx, *patterns, restr, LY_EMEM);
@@ -1940,23 +1940,23 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));
break;
- case YANG_ERROR_APP_TAG:
+ case LY_STMT_ERROR_APP_TAG:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_ERRTAG, 0, &restr->eapptag, Y_STR_ARG, &restr->exts));
break;
- case YANG_ERROR_MESSAGE:
+ case LY_STMT_ERROR_MESSAGE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_ERRMSG, 0, &restr->emsg, Y_STR_ARG, &restr->exts));
break;
- case YANG_MODIFIER:
+ case LY_STMT_MODIFIER:
YANG_CHECK_STMTVER2_RET(ctx, "modifier", "pattern");
LY_CHECK_RET(parse_type_pattern_modifier(ctx, data, &restr->arg, &restr->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &restr->exts));
break;
default:
@@ -1982,7 +1982,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_type *nest_type;
if (type->name) {
@@ -1996,23 +1996,23 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_BASE:
+ case LY_STMT_BASE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_BASE, &type->bases, Y_PREF_IDENTIF_ARG, &type->exts));
type->flags |= LYS_SET_BASE;
break;
- case YANG_BIT:
+ case LY_STMT_BIT:
LY_CHECK_RET(parse_type_enum(ctx, data, kw, &type->bits));
type->flags |= LYS_SET_BIT;
break;
- case YANG_ENUM:
+ case LY_STMT_ENUM:
LY_CHECK_RET(parse_type_enum(ctx, data, kw, &type->enums));
type->flags |= LYS_SET_ENUM;
break;
- case YANG_FRACTION_DIGITS:
+ case LY_STMT_FRACTION_DIGITS:
LY_CHECK_RET(parse_type_fracdigits(ctx, data, &type->fraction_digits, &type->exts));
type->flags |= LYS_SET_FRDIGITS;
break;
- case YANG_LENGTH:
+ case LY_STMT_LENGTH:
if (type->length) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, ly_stmt2str(kw));
return LY_EVALID;
@@ -2023,15 +2023,15 @@
LY_CHECK_RET(parse_restr(ctx, data, kw, type->length));
type->flags |= LYS_SET_LENGTH;
break;
- case YANG_PATH:
+ case LY_STMT_PATH:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_PATH, 0, &type->path, Y_STR_ARG, &type->exts));
type->flags |= LYS_SET_PATH;
break;
- case YANG_PATTERN:
+ case LY_STMT_PATTERN:
LY_CHECK_RET(parse_type_pattern(ctx, data, &type->patterns));
type->flags |= LYS_SET_PATTERN;
break;
- case YANG_RANGE:
+ case LY_STMT_RANGE:
if (type->range) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, ly_stmt2str(kw));
return LY_EVALID;
@@ -2042,16 +2042,16 @@
LY_CHECK_RET(parse_restr(ctx, data, kw, type->range));
type->flags |= LYS_SET_RANGE;
break;
- case YANG_REQUIRE_INSTANCE:
+ case LY_STMT_REQUIRE_INSTANCE:
LY_CHECK_RET(parse_type_reqinstance(ctx, data, &type->require_instance, &type->flags, &type->exts));
/* LYS_SET_REQINST checked and set inside parse_type_reqinstance() */
break;
- case YANG_TYPE:
+ case LY_STMT_TYPE:
LY_ARRAY_NEW_RET(ctx->ctx, type->types, nest_type, LY_EMEM);
LY_CHECK_RET(parse_type(ctx, data, nest_type));
type->flags |= LYS_SET_TYPE;
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &type->exts));
break;
default:
@@ -2077,7 +2077,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_node_leaf *leaf;
/* create new leaf structure */
@@ -2092,40 +2092,40 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
LY_CHECK_RET(parse_config(ctx, data, &leaf->flags, &leaf->exts));
break;
- case YANG_DEFAULT:
+ case LY_STMT_DEFAULT:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DEFAULT, 0, &leaf->dflt, Y_STR_ARG, &leaf->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &leaf->dsc, Y_STR_ARG, &leaf->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &leaf->iffeatures, Y_STR_ARG, &leaf->exts));
break;
- case YANG_MANDATORY:
+ case LY_STMT_MANDATORY:
LY_CHECK_RET(parse_mandatory(ctx, data, &leaf->flags, &leaf->exts));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
LY_CHECK_RET(parse_restrs(ctx, data, kw, &leaf->musts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &leaf->ref, Y_STR_ARG, &leaf->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &leaf->flags, &leaf->exts));
break;
- case YANG_TYPE:
+ case LY_STMT_TYPE:
LY_CHECK_RET(parse_type(ctx, data, &leaf->type));
break;
- case YANG_UNITS:
+ case LY_STMT_UNITS:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_UNITS, 0, &leaf->units, Y_STR_ARG, &leaf->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &leaf->when));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &leaf->exts));
break;
default:
@@ -2166,7 +2166,7 @@
char *buf, *word, *ptr;
size_t word_len;
unsigned long int num;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_SET_MAX) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "max-elements");
@@ -2204,7 +2204,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_MAX, 0, exts));
break;
default:
@@ -2233,7 +2233,7 @@
char *buf, *word, *ptr;
size_t word_len;
unsigned long int num;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_SET_MIN) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "min-elements");
@@ -2268,7 +2268,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_MIN, 0, exts));
break;
default:
@@ -2295,7 +2295,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_ORDBY_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "ordered-by");
@@ -2318,7 +2318,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_ORDEREDBY, 0, exts));
break;
default:
@@ -2344,7 +2344,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_node_leaflist *llist;
/* create new leaf-list structure */
@@ -2359,47 +2359,47 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
LY_CHECK_RET(parse_config(ctx, data, &llist->flags, &llist->exts));
break;
- case YANG_DEFAULT:
+ case LY_STMT_DEFAULT:
YANG_CHECK_STMTVER2_RET(ctx, "default", "leaf-list");
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_DEFAULT, &llist->dflts, Y_STR_ARG, &llist->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &llist->dsc, Y_STR_ARG, &llist->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &llist->iffeatures, Y_STR_ARG, &llist->exts));
break;
- case YANG_MAX_ELEMENTS:
+ case LY_STMT_MAX_ELEMENTS:
LY_CHECK_RET(parse_maxelements(ctx, data, &llist->max, &llist->flags, &llist->exts));
break;
- case YANG_MIN_ELEMENTS:
+ case LY_STMT_MIN_ELEMENTS:
LY_CHECK_RET(parse_minelements(ctx, data, &llist->min, &llist->flags, &llist->exts));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
LY_CHECK_RET(parse_restrs(ctx, data, kw, &llist->musts));
break;
- case YANG_ORDERED_BY:
+ case LY_STMT_ORDERED_BY:
LY_CHECK_RET(parse_orderedby(ctx, data, &llist->flags, &llist->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &llist->ref, Y_STR_ARG, &llist->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &llist->flags, &llist->exts));
break;
- case YANG_TYPE:
+ case LY_STMT_TYPE:
LY_CHECK_RET(parse_type(ctx, data, &llist->type));
break;
- case YANG_UNITS:
+ case LY_STMT_UNITS:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_UNITS, 0, &llist->units, Y_STR_ARG, &llist->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &llist->when));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &llist->exts));
break;
default:
@@ -2443,7 +2443,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_refine *rf;
LY_ARRAY_NEW_RET(ctx->ctx, *refines, rf, LY_EMEM);
@@ -2455,38 +2455,38 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
LY_CHECK_RET(parse_config(ctx, data, &rf->flags, &rf->exts));
break;
- case YANG_DEFAULT:
+ case LY_STMT_DEFAULT:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_DEFAULT, &rf->dflts, Y_STR_ARG, &rf->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &rf->dsc, Y_STR_ARG, &rf->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
YANG_CHECK_STMTVER2_RET(ctx, "if-feature", "refine");
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &rf->iffeatures, Y_STR_ARG, &rf->exts));
break;
- case YANG_MAX_ELEMENTS:
+ case LY_STMT_MAX_ELEMENTS:
LY_CHECK_RET(parse_maxelements(ctx, data, &rf->max, &rf->flags, &rf->exts));
break;
- case YANG_MIN_ELEMENTS:
+ case LY_STMT_MIN_ELEMENTS:
LY_CHECK_RET(parse_minelements(ctx, data, &rf->min, &rf->flags, &rf->exts));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
LY_CHECK_RET(parse_restrs(ctx, data, kw, &rf->musts));
break;
- case YANG_MANDATORY:
+ case LY_STMT_MANDATORY:
LY_CHECK_RET(parse_mandatory(ctx, data, &rf->flags, &rf->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &rf->ref, Y_STR_ARG, &rf->exts));
break;
- case YANG_PRESENCE:
+ case LY_STMT_PRESENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_PRESENCE, 0, &rf->presence, Y_STR_ARG, &rf->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &rf->exts));
break;
default:
@@ -2512,7 +2512,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_tpdf *tpdf;
LY_ARRAY_NEW_RET(ctx->ctx, *typedefs, tpdf, LY_EMEM);
@@ -2524,25 +2524,25 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_DEFAULT:
+ case LY_STMT_DEFAULT:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DEFAULT, 0, &tpdf->dflt, Y_STR_ARG, &tpdf->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &tpdf->dsc, Y_STR_ARG, &tpdf->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &tpdf->ref, Y_STR_ARG, &tpdf->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &tpdf->flags, &tpdf->exts));
break;
- case YANG_TYPE:
+ case LY_STMT_TYPE:
LY_CHECK_RET(parse_type(ctx, data, &tpdf->type));
break;
- case YANG_UNITS:
+ case LY_STMT_UNITS:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_UNITS, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &tpdf->exts));
break;
default:
@@ -2577,12 +2577,12 @@
* @return LY_ERR values.
*/
static LY_ERR
-parse_inout(struct lys_parser_ctx *ctx, const char **data, enum yang_keyword inout_kw, struct lysp_node *parent, struct lysp_action_inout *inout_p)
+parse_inout(struct lys_parser_ctx *ctx, const char **data, enum ly_stmt inout_kw, struct lysp_node *parent, struct lysp_action_inout *inout_p)
{
LY_ERR ret = LY_SUCCESS;
char *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (inout_p->nodetype) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, ly_stmt2str(inout_kw));
@@ -2596,41 +2596,41 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", ly_stmt2str(inout_kw));
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)inout_p, &inout_p->data));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, (struct lysp_node*)inout_p, &inout_p->data));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)inout_p, &inout_p->data));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)inout_p, &inout_p->data));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)inout_p, &inout_p->data));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)inout_p, &inout_p->data));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, (struct lysp_node*)inout_p, &inout_p->data));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, (struct lysp_node*)inout_p, data, &inout_p->typedefs));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
YANG_CHECK_STMTVER2_RET(ctx, "must", ly_stmt2str(inout_kw));
LY_CHECK_RET(parse_restrs(ctx, data, kw, &inout_p->musts));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, (struct lysp_node*)inout_p, &inout_p->groupings));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &inout_p->exts));
break;
default:
@@ -2661,7 +2661,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_action *act;
LY_ARRAY_NEW_RET(ctx->ctx, *actions, act, LY_EMEM);
@@ -2674,33 +2674,33 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &act->dsc, Y_STR_ARG, &act->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &act->iffeatures, Y_STR_ARG, &act->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &act->ref, Y_STR_ARG, &act->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &act->flags, &act->exts));
break;
- case YANG_INPUT:
+ case LY_STMT_INPUT:
LY_CHECK_RET(parse_inout(ctx, data, kw, (struct lysp_node*)act, &act->input));
break;
- case YANG_OUTPUT:
+ case LY_STMT_OUTPUT:
LY_CHECK_RET(parse_inout(ctx, data, kw, (struct lysp_node*)act, &act->output));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, (struct lysp_node*)act, data, &act->typedefs));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, (struct lysp_node*)act, &act->groupings));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &act->exts));
break;
default:
@@ -2731,7 +2731,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_notif *notif;
LY_ARRAY_NEW_RET(ctx->ctx, *notifs, notif, LY_EMEM);
@@ -2744,55 +2744,55 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, ¬if->dsc, Y_STR_ARG, ¬if->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, ¬if->iffeatures, Y_STR_ARG, ¬if->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, ¬if->ref, Y_STR_ARG, ¬if->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, ¬if->flags, ¬if->exts));
break;
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "notification");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)notif, ¬if->data));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_case(ctx, data, (struct lysp_node*)notif, ¬if->data));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)notif, ¬if->data));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)notif, ¬if->data));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)notif, ¬if->data));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)notif, ¬if->data));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, (struct lysp_node*)notif, ¬if->data));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
YANG_CHECK_STMTVER2_RET(ctx, "must", "notification");
LY_CHECK_RET(parse_restrs(ctx, data, kw, ¬if->musts));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, (struct lysp_node*)notif, data, ¬if->typedefs));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, (struct lysp_node*)notif, ¬if->groupings));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, ¬if->exts));
break;
default:
@@ -2823,7 +2823,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_grp *grp;
LY_ARRAY_NEW_RET(ctx->ctx, *groupings, grp, LY_EMEM);
@@ -2836,56 +2836,56 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &grp->dsc, Y_STR_ARG, &grp->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &grp->ref, Y_STR_ARG, &grp->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &grp->flags, &grp->exts));
break;
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "grouping");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)grp, &grp->data));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, (struct lysp_node*)grp, &grp->data));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)grp, &grp->data));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)grp, &grp->data));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)grp, &grp->data));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)grp, &grp->data));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, (struct lysp_node*)grp, &grp->data));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, (struct lysp_node*)grp, data, &grp->typedefs));
break;
- case YANG_ACTION:
+ case LY_STMT_ACTION:
YANG_CHECK_STMTVER2_RET(ctx, "action", "grouping");
LY_CHECK_RET(parse_action(ctx, data, (struct lysp_node*)grp, &grp->actions));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, (struct lysp_node*)grp, &grp->groupings));
break;
- case YANG_NOTIFICATION:
+ case LY_STMT_NOTIFICATION:
YANG_CHECK_STMTVER2_RET(ctx, "notification", "grouping");
LY_CHECK_RET(parse_notif(ctx, data, (struct lysp_node*)grp, &grp->notifs));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &grp->exts));
break;
default:
@@ -2916,7 +2916,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_augment *aug;
LY_ARRAY_NEW_RET(ctx->ctx, *augments, aug, LY_EMEM);
@@ -2930,59 +2930,59 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &aug->dsc, Y_STR_ARG, &aug->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &aug->iffeatures, Y_STR_ARG, &aug->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &aug->ref, Y_STR_ARG, &aug->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &aug->flags, &aug->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &aug->when));
break;
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "augment");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_CASE:
+ case LY_STMT_CASE:
LY_CHECK_RET(parse_case(ctx, data, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, (struct lysp_node*)aug, &aug->child));
break;
- case YANG_ACTION:
+ case LY_STMT_ACTION:
YANG_CHECK_STMTVER2_RET(ctx, "action", "augment");
LY_CHECK_RET(parse_action(ctx, data, (struct lysp_node*)aug, &aug->actions));
break;
- case YANG_NOTIFICATION:
+ case LY_STMT_NOTIFICATION:
YANG_CHECK_STMTVER2_RET(ctx, "notification", "augment");
LY_CHECK_RET(parse_notif(ctx, data, (struct lysp_node*)aug, &aug->notifs));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &aug->exts));
break;
default:
@@ -3013,7 +3013,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_node_uses *uses;
/* create uses structure */
@@ -3028,29 +3028,29 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &uses->dsc, Y_STR_ARG, &uses->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &uses->iffeatures, Y_STR_ARG, &uses->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &uses->ref, Y_STR_ARG, &uses->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &uses->flags, &uses->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &uses->when));
break;
- case YANG_REFINE:
+ case LY_STMT_REFINE:
LY_CHECK_RET(parse_refine(ctx, data, &uses->refines));
break;
- case YANG_AUGMENT:
+ case LY_STMT_AUGMENT:
LY_CHECK_RET(parse_augment(ctx, data, (struct lysp_node*)uses, &uses->augments));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &uses->exts));
break;
default:
@@ -3080,7 +3080,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_node_case *cas;
/* create new case structure */
@@ -3095,47 +3095,47 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &cas->dsc, Y_STR_ARG, &cas->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &cas->iffeatures, Y_STR_ARG, &cas->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &cas->ref, Y_STR_ARG, &cas->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &cas->flags, &cas->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &cas->when));
break;
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "case");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)cas, &cas->child));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, (struct lysp_node*)cas, &cas->child));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)cas, &cas->child));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)cas, &cas->child));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)cas, &cas->child));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)cas, &cas->child));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, (struct lysp_node*)cas, &cas->child));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &cas->exts));
break;
default:
@@ -3161,7 +3161,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_node_choice *choice;
/* create new choice structure */
@@ -3176,57 +3176,57 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
LY_CHECK_RET(parse_config(ctx, data, &choice->flags, &choice->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &choice->dsc, Y_STR_ARG, &choice->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &choice->iffeatures, Y_STR_ARG, &choice->exts));
break;
- case YANG_MANDATORY:
+ case LY_STMT_MANDATORY:
LY_CHECK_RET(parse_mandatory(ctx, data, &choice->flags, &choice->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &choice->ref, Y_STR_ARG, &choice->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &choice->flags, &choice->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &choice->when));
break;
- case YANG_DEFAULT:
+ case LY_STMT_DEFAULT:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DEFAULT, 0, &choice->dflt, Y_PREF_IDENTIF_ARG, &choice->exts));
break;
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "choice");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)choice, &choice->child));
break;
- case YANG_CASE:
+ case LY_STMT_CASE:
LY_CHECK_RET(parse_case(ctx, data, (struct lysp_node*)choice, &choice->child));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
YANG_CHECK_STMTVER2_RET(ctx, "choice", "choice");
LY_CHECK_RET(parse_choice(ctx, data, (struct lysp_node*)choice, &choice->child));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)choice, &choice->child));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)choice, &choice->child));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)choice, &choice->child));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)choice, &choice->child));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &choice->exts));
break;
default:
@@ -3258,7 +3258,7 @@
LY_ERR ret = 0;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_node_container *cont;
/* create new container structure */
@@ -3273,71 +3273,71 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
LY_CHECK_RET(parse_config(ctx, data, &cont->flags, &cont->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &cont->dsc, Y_STR_ARG, &cont->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &cont->iffeatures, Y_STR_ARG, &cont->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &cont->ref, Y_STR_ARG, &cont->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &cont->flags, &cont->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &cont->when));
break;
- case YANG_PRESENCE:
+ case LY_STMT_PRESENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_PRESENCE, 0, &cont->presence, Y_STR_ARG, &cont->exts));
break;
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "container");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)cont, &cont->child));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, (struct lysp_node*)cont, &cont->child));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)cont, &cont->child));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)cont, &cont->child));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)cont, &cont->child));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)cont, &cont->child));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, (struct lysp_node*)cont, &cont->child));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, (struct lysp_node*)cont, data, &cont->typedefs));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
LY_CHECK_RET(parse_restrs(ctx, data, kw, &cont->musts));
break;
- case YANG_ACTION:
+ case LY_STMT_ACTION:
YANG_CHECK_STMTVER2_RET(ctx, "action", "container");
LY_CHECK_RET(parse_action(ctx, data, (struct lysp_node*)cont, &cont->actions));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, (struct lysp_node*)cont, &cont->groupings));
break;
- case YANG_NOTIFICATION:
+ case LY_STMT_NOTIFICATION:
YANG_CHECK_STMTVER2_RET(ctx, "notification", "container");
LY_CHECK_RET(parse_notif(ctx, data, (struct lysp_node*)cont, &cont->notifs));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &cont->exts));
break;
default:
@@ -3366,7 +3366,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_node_list *list;
/* create new list structure */
@@ -3381,83 +3381,83 @@
/* parse substatements */
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
LY_CHECK_RET(parse_config(ctx, data, &list->flags, &list->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &list->dsc, Y_STR_ARG, &list->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &list->iffeatures, Y_STR_ARG, &list->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &list->ref, Y_STR_ARG, &list->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &list->flags, &list->exts));
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
LY_CHECK_RET(parse_when(ctx, data, &list->when));
break;
- case YANG_KEY:
+ case LY_STMT_KEY:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_KEY, 0, &list->key, Y_STR_ARG, &list->exts));
break;
- case YANG_MAX_ELEMENTS:
+ case LY_STMT_MAX_ELEMENTS:
LY_CHECK_RET(parse_maxelements(ctx, data, &list->max, &list->flags, &list->exts));
break;
- case YANG_MIN_ELEMENTS:
+ case LY_STMT_MIN_ELEMENTS:
LY_CHECK_RET(parse_minelements(ctx, data, &list->min, &list->flags, &list->exts));
break;
- case YANG_ORDERED_BY:
+ case LY_STMT_ORDERED_BY:
LY_CHECK_RET(parse_orderedby(ctx, data, &list->flags, &list->exts));
break;
- case YANG_UNIQUE:
+ case LY_STMT_UNIQUE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_UNIQUE, &list->uniques, Y_STR_ARG, &list->exts));
break;
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "list");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, (struct lysp_node*)list, &list->child));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, (struct lysp_node*)list, &list->child));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, (struct lysp_node*)list, &list->child));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, (struct lysp_node*)list, &list->child));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, (struct lysp_node*)list, &list->child));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, (struct lysp_node*)list, &list->child));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, (struct lysp_node*)list, &list->child));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, (struct lysp_node*)list, data, &list->typedefs));
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
LY_CHECK_RET(parse_restrs(ctx, data, kw, &list->musts));
break;
- case YANG_ACTION:
+ case LY_STMT_ACTION:
YANG_CHECK_STMTVER2_RET(ctx, "action", "list");
LY_CHECK_RET(parse_action(ctx, data, (struct lysp_node*)list, &list->actions));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, (struct lysp_node*)list, &list->groupings));
break;
- case YANG_NOTIFICATION:
+ case LY_STMT_NOTIFICATION:
YANG_CHECK_STMTVER2_RET(ctx, "notification", "list");
LY_CHECK_RET(parse_notif(ctx, data, (struct lysp_node*)list, &list->notifs));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &list->exts));
break;
default:
@@ -3496,7 +3496,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*flags & LYS_YINELEM_MASK) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "yin-element");
@@ -3519,7 +3519,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_YINELEM, 0, exts));
LY_CHECK_RET(ret); break;
default:
@@ -3547,7 +3547,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
if (*argument) {
LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, "argument");
@@ -3560,10 +3560,10 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_YIN_ELEMENT:
+ case LY_STMT_YIN_ELEMENT:
LY_CHECK_RET(parse_yinelement(ctx, data, flags, exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_ARGUMENT, 0, exts));
break;
default:
@@ -3589,7 +3589,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_ext *ex;
LY_ARRAY_NEW_RET(ctx->ctx, *extensions, ex, LY_EMEM);
@@ -3600,19 +3600,19 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &ex->dsc, Y_STR_ARG, &ex->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &ex->ref, Y_STR_ARG, &ex->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &ex->flags, &ex->exts));
break;
- case YANG_ARGUMENT:
+ case LY_STMT_ARGUMENT:
LY_CHECK_RET(parse_argument(ctx, data, &ex->argument, &ex->flags, &ex->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &ex->exts));
break;
default:
@@ -3638,7 +3638,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len, dev_mod;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_deviate *d;
struct lysp_deviate_add *d_add = NULL;
struct lysp_deviate_rpl *d_rpl = NULL;
@@ -3713,7 +3713,7 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
case LYS_DEV_DELETE:
@@ -3724,7 +3724,7 @@
break;
}
break;
- case YANG_DEFAULT:
+ case LY_STMT_DEFAULT:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
LOGVAL_PARSER(ctx, LY_VCODE_INDEV, ly_devmod2str(dev_mod), ly_stmt2str(kw));
@@ -3737,7 +3737,7 @@
break;
}
break;
- case YANG_MANDATORY:
+ case LY_STMT_MANDATORY:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
case LYS_DEV_DELETE:
@@ -3748,7 +3748,7 @@
break;
}
break;
- case YANG_MAX_ELEMENTS:
+ case LY_STMT_MAX_ELEMENTS:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
case LYS_DEV_DELETE:
@@ -3759,7 +3759,7 @@
break;
}
break;
- case YANG_MIN_ELEMENTS:
+ case LY_STMT_MIN_ELEMENTS:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
case LYS_DEV_DELETE:
@@ -3770,7 +3770,7 @@
break;
}
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
case LYS_DEV_REPLACE:
@@ -3781,7 +3781,7 @@
break;
}
break;
- case YANG_TYPE:
+ case LY_STMT_TYPE:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
case LYS_DEV_ADD:
@@ -3799,7 +3799,7 @@
break;
}
break;
- case YANG_UNIQUE:
+ case LY_STMT_UNIQUE:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
case LYS_DEV_REPLACE:
@@ -3810,7 +3810,7 @@
break;
}
break;
- case YANG_UNITS:
+ case LY_STMT_UNITS:
switch (dev_mod) {
case LYS_DEV_NOT_SUPPORTED:
LOGVAL_PARSER(ctx, LY_VCODE_INDEV, ly_devmod2str(dev_mod), ly_stmt2str(kw));
@@ -3820,7 +3820,7 @@
break;
}
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &d->exts));
break;
default:
@@ -3846,7 +3846,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_deviation *dev;
LY_ARRAY_NEW_RET(ctx->ctx, *deviations, dev, LY_EMEM);
@@ -3858,16 +3858,16 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret, goto checks) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &dev->dsc, Y_STR_ARG, &dev->exts));
break;
- case YANG_DEVIATE:
+ case LY_STMT_DEVIATE:
LY_CHECK_RET(parse_deviate(ctx, data, &dev->deviates));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &dev->ref, Y_STR_ARG, &dev->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &dev->exts));
break;
default:
@@ -3901,7 +3901,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_feature *feat;
LY_ARRAY_NEW_RET(ctx->ctx, *features, feat, LY_EMEM);
@@ -3912,19 +3912,19 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &feat->dsc, Y_STR_ARG, &feat->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &feat->iffeatures, Y_STR_ARG, &feat->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &feat->ref, Y_STR_ARG, &feat->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &feat->flags, &feat->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &feat->exts));
break;
default:
@@ -3950,7 +3950,7 @@
LY_ERR ret = LY_SUCCESS;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_ident *ident;
LY_ARRAY_NEW_RET(ctx->ctx, *identities, ident, LY_EMEM);
@@ -3961,27 +3961,27 @@
YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
switch (kw) {
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &ident->dsc, Y_STR_ARG, &ident->exts));
break;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
YANG_CHECK_STMTVER2_RET(ctx, "if-feature", "identity");
LY_CHECK_RET(parse_text_fields(ctx, data, LYEXT_SUBSTMT_IFFEATURE, &ident->iffeatures, Y_STR_ARG, &ident->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &ident->ref, Y_STR_ARG, &ident->exts));
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
LY_CHECK_RET(parse_status(ctx, data, &ident->flags, &ident->exts));
break;
- case YANG_BASE:
+ case LY_STMT_BASE:
if (ident->bases && ctx->mod_version < 2) {
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, data, LYEXT_SUBSTMT_BASE, &ident->bases, Y_PREF_IDENTIF_ARG, &ident->exts));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &ident->exts));
break;
default:
@@ -4007,7 +4007,7 @@
LY_ERR ret = 0;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw, prev_kw = 0;
+ enum ly_stmt kw, prev_kw = 0;
enum yang_module_stmt mod_stmt = Y_MOD_MODULE_HEADER;
struct lysp_submodule *dup;
@@ -4022,49 +4022,49 @@
switch (kw) {
/* module header */
- case YANG_NAMESPACE:
- case YANG_PREFIX:
+ case LY_STMT_NAMESPACE:
+ case LY_STMT_PREFIX:
CHECK_ORDER(Y_MOD_MODULE_HEADER);
break;
- case YANG_YANG_VERSION:
+ case LY_STMT_YANG_VERSION:
CHECK_ORDER(Y_MOD_MODULE_HEADER);
break;
/* linkage */
- case YANG_INCLUDE:
- case YANG_IMPORT:
+ case LY_STMT_INCLUDE:
+ case LY_STMT_IMPORT:
CHECK_ORDER(Y_MOD_LINKAGE);
break;
/* meta */
- case YANG_ORGANIZATION:
- case YANG_CONTACT:
- case YANG_DESCRIPTION:
- case YANG_REFERENCE:
+ case LY_STMT_ORGANIZATION:
+ case LY_STMT_CONTACT:
+ case LY_STMT_DESCRIPTION:
+ case LY_STMT_REFERENCE:
CHECK_ORDER(Y_MOD_META);
break;
/* revision */
- case YANG_REVISION:
+ case LY_STMT_REVISION:
CHECK_ORDER(Y_MOD_REVISION);
break;
/* body */
- case YANG_ANYDATA:
- case YANG_ANYXML:
- case YANG_AUGMENT:
- case YANG_CHOICE:
- case YANG_CONTAINER:
- case YANG_DEVIATION:
- case YANG_EXTENSION:
- case YANG_FEATURE:
- case YANG_GROUPING:
- case YANG_IDENTITY:
- case YANG_LEAF:
- case YANG_LEAF_LIST:
- case YANG_LIST:
- case YANG_NOTIFICATION:
- case YANG_RPC:
- case YANG_TYPEDEF:
- case YANG_USES:
- case YANG_CUSTOM:
+ case LY_STMT_ANYDATA:
+ case LY_STMT_ANYXML:
+ case LY_STMT_AUGMENT:
+ case LY_STMT_CHOICE:
+ case LY_STMT_CONTAINER:
+ case LY_STMT_DEVIATION:
+ case LY_STMT_EXTENSION:
+ case LY_STMT_FEATURE:
+ case LY_STMT_GROUPING:
+ case LY_STMT_IDENTITY:
+ case LY_STMT_LEAF:
+ case LY_STMT_LEAF_LIST:
+ case LY_STMT_LIST:
+ case LY_STMT_NOTIFICATION:
+ case LY_STMT_RPC:
+ case LY_STMT_TYPEDEF:
+ case LY_STMT_USES:
+ case LY_STMT_EXTENSION_INSTANCE:
mod_stmt = Y_MOD_BODY;
break;
default:
@@ -4076,98 +4076,98 @@
prev_kw = kw;
switch (kw) {
/* module header */
- case YANG_YANG_VERSION:
+ case LY_STMT_YANG_VERSION:
LY_CHECK_RET(parse_yangversion(ctx, data, &mod->mod->version, &mod->exts));
ctx->mod_version = mod->mod->version;
break;
- case YANG_NAMESPACE:
+ case LY_STMT_NAMESPACE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_NAMESPACE, 0, &mod->mod->ns, Y_STR_ARG, &mod->exts));
break;
- case YANG_PREFIX:
+ case LY_STMT_PREFIX:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_PREFIX, 0, &mod->mod->prefix, Y_IDENTIF_ARG, &mod->exts));
break;
/* linkage */
- case YANG_INCLUDE:
+ case LY_STMT_INCLUDE:
LY_CHECK_RET(parse_include(ctx, mod->mod->name, data, &mod->includes));
break;
- case YANG_IMPORT:
+ case LY_STMT_IMPORT:
LY_CHECK_RET(parse_import(ctx, mod->mod->prefix, data, &mod->imports));
break;
/* meta */
- case YANG_ORGANIZATION:
+ case LY_STMT_ORGANIZATION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_ORGANIZATION, 0, &mod->mod->org, Y_STR_ARG, &mod->exts));
break;
- case YANG_CONTACT:
+ case LY_STMT_CONTACT:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_CONTACT, 0, &mod->mod->contact, Y_STR_ARG, &mod->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &mod->mod->dsc, Y_STR_ARG, &mod->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &mod->mod->ref, Y_STR_ARG, &mod->exts));
break;
/* revision */
- case YANG_REVISION:
+ case LY_STMT_REVISION:
LY_CHECK_RET(parse_revision(ctx, data, &mod->revs));
break;
/* body */
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "module");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, NULL, &mod->data));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, NULL, &mod->data));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, NULL, &mod->data));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, NULL, &mod->data));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, NULL, &mod->data));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, NULL, &mod->data));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, NULL, &mod->data));
break;
- case YANG_AUGMENT:
+ case LY_STMT_AUGMENT:
LY_CHECK_RET(parse_augment(ctx, data, NULL, &mod->augments));
break;
- case YANG_DEVIATION:
+ case LY_STMT_DEVIATION:
LY_CHECK_RET(parse_deviation(ctx, data, &mod->deviations));
break;
- case YANG_EXTENSION:
+ case LY_STMT_EXTENSION:
LY_CHECK_RET(parse_extension(ctx, data, &mod->extensions));
break;
- case YANG_FEATURE:
+ case LY_STMT_FEATURE:
LY_CHECK_RET(parse_feature(ctx, data, &mod->features));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, NULL, &mod->groupings));
break;
- case YANG_IDENTITY:
+ case LY_STMT_IDENTITY:
LY_CHECK_RET(parse_identity(ctx, data, &mod->identities));
break;
- case YANG_NOTIFICATION:
+ case LY_STMT_NOTIFICATION:
LY_CHECK_RET(parse_notif(ctx, data, NULL, &mod->notifs));
break;
- case YANG_RPC:
+ case LY_STMT_RPC:
LY_CHECK_RET(parse_action(ctx, data, NULL, &mod->rpcs));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, NULL, data, &mod->typedefs));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &mod->exts));
break;
@@ -4217,7 +4217,7 @@
LY_ERR ret = 0;
char *buf, *word;
size_t word_len;
- enum yang_keyword kw, prev_kw = 0;
+ enum ly_stmt kw, prev_kw = 0;
enum yang_module_stmt mod_stmt = Y_MOD_MODULE_HEADER;
struct lysp_submodule *dup;
@@ -4232,48 +4232,48 @@
switch (kw) {
/* module header */
- case YANG_BELONGS_TO:
+ case LY_STMT_BELONGS_TO:
CHECK_ORDER(Y_MOD_MODULE_HEADER);
break;
- case YANG_YANG_VERSION:
+ case LY_STMT_YANG_VERSION:
CHECK_ORDER(Y_MOD_MODULE_HEADER);
break;
/* linkage */
- case YANG_INCLUDE:
- case YANG_IMPORT:
+ case LY_STMT_INCLUDE:
+ case LY_STMT_IMPORT:
CHECK_ORDER(Y_MOD_LINKAGE);
break;
/* meta */
- case YANG_ORGANIZATION:
- case YANG_CONTACT:
- case YANG_DESCRIPTION:
- case YANG_REFERENCE:
+ case LY_STMT_ORGANIZATION:
+ case LY_STMT_CONTACT:
+ case LY_STMT_DESCRIPTION:
+ case LY_STMT_REFERENCE:
CHECK_ORDER(Y_MOD_META);
break;
/* revision */
- case YANG_REVISION:
+ case LY_STMT_REVISION:
CHECK_ORDER(Y_MOD_REVISION);
break;
/* body */
- case YANG_ANYDATA:
- case YANG_ANYXML:
- case YANG_AUGMENT:
- case YANG_CHOICE:
- case YANG_CONTAINER:
- case YANG_DEVIATION:
- case YANG_EXTENSION:
- case YANG_FEATURE:
- case YANG_GROUPING:
- case YANG_IDENTITY:
- case YANG_LEAF:
- case YANG_LEAF_LIST:
- case YANG_LIST:
- case YANG_NOTIFICATION:
- case YANG_RPC:
- case YANG_TYPEDEF:
- case YANG_USES:
- case YANG_CUSTOM:
+ case LY_STMT_ANYDATA:
+ case LY_STMT_ANYXML:
+ case LY_STMT_AUGMENT:
+ case LY_STMT_CHOICE:
+ case LY_STMT_CONTAINER:
+ case LY_STMT_DEVIATION:
+ case LY_STMT_EXTENSION:
+ case LY_STMT_FEATURE:
+ case LY_STMT_GROUPING:
+ case LY_STMT_IDENTITY:
+ case LY_STMT_LEAF:
+ case LY_STMT_LEAF_LIST:
+ case LY_STMT_LIST:
+ case LY_STMT_NOTIFICATION:
+ case LY_STMT_RPC:
+ case LY_STMT_TYPEDEF:
+ case LY_STMT_USES:
+ case LY_STMT_EXTENSION_INSTANCE:
mod_stmt = Y_MOD_BODY;
break;
default:
@@ -4285,95 +4285,95 @@
prev_kw = kw;
switch (kw) {
/* module header */
- case YANG_YANG_VERSION:
+ case LY_STMT_YANG_VERSION:
LY_CHECK_RET(parse_yangversion(ctx, data, &submod->version, &submod->exts));
ctx->mod_version = submod->version;
break;
- case YANG_BELONGS_TO:
+ case LY_STMT_BELONGS_TO:
LY_CHECK_RET(parse_belongsto(ctx, data, &submod->belongsto, &submod->prefix, &submod->exts));
break;
/* linkage */
- case YANG_INCLUDE:
+ case LY_STMT_INCLUDE:
LY_CHECK_RET(parse_include(ctx, submod->name, data, &submod->includes));
break;
- case YANG_IMPORT:
+ case LY_STMT_IMPORT:
LY_CHECK_RET(parse_import(ctx, submod->prefix, data, &submod->imports));
break;
/* meta */
- case YANG_ORGANIZATION:
+ case LY_STMT_ORGANIZATION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_ORGANIZATION, 0, &submod->org, Y_STR_ARG, &submod->exts));
break;
- case YANG_CONTACT:
+ case LY_STMT_CONTACT:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_CONTACT, 0, &submod->contact, Y_STR_ARG, &submod->exts));
break;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_DESCRIPTION, 0, &submod->dsc, Y_STR_ARG, &submod->exts));
break;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
LY_CHECK_RET(parse_text_field(ctx, data, LYEXT_SUBSTMT_REFERENCE, 0, &submod->ref, Y_STR_ARG, &submod->exts));
break;
/* revision */
- case YANG_REVISION:
+ case LY_STMT_REVISION:
LY_CHECK_RET(parse_revision(ctx, data, &submod->revs));
break;
/* body */
- case YANG_ANYDATA:
+ case LY_STMT_ANYDATA:
YANG_CHECK_STMTVER2_RET(ctx, "anydata", "submodule");
/* fall through */
- case YANG_ANYXML:
+ case LY_STMT_ANYXML:
LY_CHECK_RET(parse_any(ctx, data, kw, NULL, &submod->data));
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
LY_CHECK_RET(parse_choice(ctx, data, NULL, &submod->data));
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
LY_CHECK_RET(parse_container(ctx, data, NULL, &submod->data));
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
LY_CHECK_RET(parse_leaf(ctx, data, NULL, &submod->data));
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
LY_CHECK_RET(parse_leaflist(ctx, data, NULL, &submod->data));
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
LY_CHECK_RET(parse_list(ctx, data, NULL, &submod->data));
break;
- case YANG_USES:
+ case LY_STMT_USES:
LY_CHECK_RET(parse_uses(ctx, data, NULL, &submod->data));
break;
- case YANG_AUGMENT:
+ case LY_STMT_AUGMENT:
LY_CHECK_RET(parse_augment(ctx, data, NULL, &submod->augments));
break;
- case YANG_DEVIATION:
+ case LY_STMT_DEVIATION:
LY_CHECK_RET(parse_deviation(ctx, data, &submod->deviations));
break;
- case YANG_EXTENSION:
+ case LY_STMT_EXTENSION:
LY_CHECK_RET(parse_extension(ctx, data, &submod->extensions));
break;
- case YANG_FEATURE:
+ case LY_STMT_FEATURE:
LY_CHECK_RET(parse_feature(ctx, data, &submod->features));
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
LY_CHECK_RET(parse_grouping(ctx, data, NULL, &submod->groupings));
break;
- case YANG_IDENTITY:
+ case LY_STMT_IDENTITY:
LY_CHECK_RET(parse_identity(ctx, data, &submod->identities));
break;
- case YANG_NOTIFICATION:
+ case LY_STMT_NOTIFICATION:
LY_CHECK_RET(parse_notif(ctx, data, NULL, &submod->notifs));
break;
- case YANG_RPC:
+ case LY_STMT_RPC:
LY_CHECK_RET(parse_action(ctx, data, NULL, &submod->rpcs));
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
LY_CHECK_RET(parse_typedef(ctx, NULL, data, &submod->typedefs));
break;
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
LY_CHECK_RET(parse_ext(ctx, data, word, word_len, LYEXT_SUBSTMT_SELF, 0, &submod->exts));
break;
@@ -4411,7 +4411,7 @@
LY_ERR ret = LY_SUCCESS;
char *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_submodule *mod_p = NULL;
/* create context */
@@ -4428,11 +4428,11 @@
ret = get_keyword(*context, &data, &kw, &word, &word_len);
LY_CHECK_GOTO(ret, cleanup);
- if (kw == YANG_MODULE) {
+ if (kw == LY_STMT_MODULE) {
LOGERR((*context)->ctx, LY_EDENIED, "Input data contains module in situation when a submodule is expected.");
ret = LY_EINVAL;
goto cleanup;
- } else if (kw != YANG_SUBMODULE) {
+ } else if (kw != LY_STMT_SUBMODULE) {
LOGVAL_PARSER(*context, LY_VCODE_MOD_SUBOMD, ly_stmt2str(kw));
ret = LY_EVALID;
goto cleanup;
@@ -4475,7 +4475,7 @@
LY_ERR ret = LY_SUCCESS;
char *word;
size_t word_len;
- enum yang_keyword kw;
+ enum ly_stmt kw;
struct lysp_module *mod_p = NULL;
/* create context */
@@ -4488,11 +4488,11 @@
ret = get_keyword(*context, &data, &kw, &word, &word_len);
LY_CHECK_GOTO(ret, cleanup);
- if (kw == YANG_SUBMODULE) {
+ if (kw == LY_STMT_SUBMODULE) {
LOGERR((*context)->ctx, LY_EDENIED, "Input data contains submodule which cannot be parsed directly without its main module.");
ret = LY_EINVAL;
goto cleanup;
- } else if (kw != YANG_MODULE) {
+ } else if (kw != LY_STMT_MODULE) {
LOGVAL_PARSER((*context), LY_VCODE_MOD_SUBOMD, ly_stmt2str(kw));
ret = LY_EVALID;
goto cleanup;
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 2ce5ccc..8bf7748 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -52,26 +52,26 @@
[YIN_ARG_TAG] = "tag",
};
-enum yang_keyword
+enum ly_stmt
yin_match_keyword(struct yin_parser_ctx *ctx, const char *name, size_t name_len,
- const char *prefix, size_t prefix_len, enum yang_keyword parrent)
+ const char *prefix, size_t prefix_len, enum ly_stmt parrent)
{
const char *start = NULL;
- enum yang_keyword kw = YANG_NONE;
+ enum ly_stmt kw = LY_STMT_NONE;
const struct lyxml_ns *ns = NULL;
if (!name || name_len == 0) {
- return YANG_NONE;
+ return LY_STMT_NONE;
}
ns = lyxml_ns_get(&ctx->xml_ctx, prefix, prefix_len);
if (ns) {
if (!IS_YIN_NS(ns->uri)) {
- return YANG_CUSTOM;
+ return LY_STMT_EXTENSION_INSTANCE;
}
} else {
/* elements without namespace are automatically unknown */
- return YANG_NONE;
+ return LY_STMT_NONE;
}
start = name;
@@ -79,15 +79,15 @@
if (name - start == (long int)name_len) {
/* this is done because of collision in yang statement value and yang argument mapped to yin element value */
- if (kw == YANG_VALUE && parrent == YANG_ERROR_MESSAGE) {
- return YIN_VALUE;
+ if (kw == LY_STMT_VALUE && parrent == LY_STMT_ERROR_MESSAGE) {
+ return LY_STMT_ARG_VALUE;
}
return kw;
} else {
if (strncmp(start, "text", name_len) == 0) {
- return YIN_TEXT;
+ return LY_STMT_ARG_TEXT;
} else {
- return YANG_NONE;
+ return LY_STMT_NONE;
}
}
}
@@ -163,12 +163,12 @@
}
}
-#define IS_NODE_ELEM(kw) (kw == YANG_ANYXML || kw == YANG_ANYDATA || kw == YANG_LEAF || kw == YANG_LEAF_LIST || \
- kw == YANG_TYPEDEF || kw == YANG_USES || kw == YANG_LIST || kw == YANG_NOTIFICATION || \
- kw == YANG_GROUPING || kw == YANG_CONTAINER || kw == YANG_CASE || kw == YANG_CHOICE || \
- kw == YANG_ACTION || kw == YANG_RPC || kw == YANG_AUGMENT)
+#define IS_NODE_ELEM(kw) (kw == LY_STMT_ANYXML || kw == LY_STMT_ANYDATA || kw == LY_STMT_LEAF || kw == LY_STMT_LEAF_LIST || \
+ kw == LY_STMT_TYPEDEF || kw == LY_STMT_USES || kw == LY_STMT_LIST || kw == LY_STMT_NOTIFICATION || \
+ kw == LY_STMT_GROUPING || kw == LY_STMT_CONTAINER || kw == LY_STMT_CASE || kw == LY_STMT_CHOICE || \
+ kw == LY_STMT_ACTION || kw == LY_STMT_RPC || kw == LY_STMT_AUGMENT)
-#define HAS_META(kw) (IS_NODE_ELEM(kw) || kw == YANG_IMPORT || kw == YANG_INCLUDE || kw == YANG_INPUT || kw == YANG_OUTPUT)
+#define HAS_META(kw) (IS_NODE_ELEM(kw) || kw == LY_STMT_IMPORT || kw == LY_STMT_INCLUDE || kw == LY_STMT_INPUT || kw == LY_STMT_OUTPUT)
/**
* @brief Free subelems information allocated on heap.
@@ -210,7 +210,7 @@
va_start(ap, result);
for (size_t i = 0; i < count; ++i) {
/* TYPE */
- (*result)[i].type = va_arg(ap, enum yang_keyword);
+ (*result)[i].type = va_arg(ap, enum ly_stmt);
/* DEST */
if (IS_NODE_ELEM((*result)[i].type)) {
struct tree_node_meta *node_meta = NULL;
@@ -219,21 +219,21 @@
node_meta->parent = parent;
node_meta->nodes = va_arg(ap, void *);
(*result)[i].dest = node_meta;
- } else if ((*result)[i].type == YANG_IMPORT) {
+ } else if ((*result)[i].type == LY_STMT_IMPORT) {
struct import_meta *imp_meta = NULL;
imp_meta = calloc(1, sizeof *imp_meta);
LY_CHECK_GOTO(!imp_meta, mem_err);
imp_meta->prefix = va_arg(ap, const char *);
imp_meta->imports = va_arg(ap, struct lysp_import **);
(*result)[i].dest = imp_meta;
- } else if ((*result)[i].type == YANG_INCLUDE) {
+ } else if ((*result)[i].type == LY_STMT_INCLUDE) {
struct include_meta *inc_meta = NULL;
inc_meta = calloc(1, sizeof *inc_meta);
LY_CHECK_GOTO(!inc_meta, mem_err);
inc_meta->name = va_arg(ap, const char *);
inc_meta->includes = va_arg(ap, struct lysp_include **);
(*result)[i].dest = inc_meta;
- } else if ((*result)[i].type == YANG_INPUT || (*result)[i].type == YANG_OUTPUT) {
+ } else if ((*result)[i].type == LY_STMT_INPUT || (*result)[i].type == LY_STMT_OUTPUT) {
struct inout_meta *inout_meta = NULL;
inout_meta = calloc(1, sizeof *inout_meta);
LY_CHECK_GOTO(!inout_meta, mem_err);
@@ -334,7 +334,7 @@
*/
static LY_ERR
yin_parse_attribute(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, enum yin_argument arg_type,
- const char **arg_val, enum yang_arg val_type, enum yang_keyword current_element)
+ const char **arg_val, enum yang_arg val_type, enum ly_stmt current_element)
{
enum yin_argument arg = YIN_ARG_UNKNOWN;
struct yin_arg_record *iter = NULL;
@@ -381,7 +381,7 @@
* @return Pointer to desired record on success, NULL if element is not in the array.
*/
static struct yin_subelement *
-get_record(enum yang_keyword type, signed char array_size, struct yin_subelement *array)
+get_record(enum ly_stmt type, signed char array_size, struct yin_subelement *array)
{
signed char left = 0, right = array_size - 1, middle;
@@ -414,7 +414,7 @@
*/
static LY_ERR
yin_check_subelem_mandatory_constraint(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info,
- signed char subelem_info_size, enum yang_keyword current_element)
+ signed char subelem_info_size, enum ly_stmt current_element)
{
for (signed char i = 0; i < subelem_info_size; ++i) {
/* if there is element that is mandatory and isn't parsed log error and return LY_EVALID */
@@ -441,7 +441,7 @@
*/
static LY_ERR
yin_check_subelem_first_constraint(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info,
- signed char subelem_info_size, enum yang_keyword current_element,
+ signed char subelem_info_size, enum ly_stmt current_element,
struct yin_subelement *exp_first)
{
for (signed char i = 0; i < subelem_info_size; ++i) {
@@ -467,7 +467,7 @@
static bool
is_ordered(struct yin_subelement *subelem_info, signed char subelem_info_size)
{
- enum yang_keyword current = YANG_NONE; /* 0 (minimal value) */
+ enum ly_stmt current = LY_STMT_NONE; /* 0 (minimal value) */
for (signed char i = 0; i < subelem_info_size; ++i) {
if (subelem_info[i].type <= current) {
@@ -496,12 +496,12 @@
* @return LY_ERR values.
*/
static LY_ERR
-yin_parse_simple_element(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum yang_keyword kw,
+yin_parse_simple_element(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum ly_stmt kw,
const char **value, enum yin_argument arg_type, enum yang_arg arg_val_type, struct lysp_ext_instance **exts)
{
LY_CHECK_RET(yin_parse_attribute(ctx, attrs, arg_type, value, arg_val_type, kw));
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
return yin_parse_content(ctx, subelems, 1, data, kw, NULL, exts);
@@ -519,7 +519,7 @@
* @return LY_ERR values.
*/
static LY_ERR
-yin_parse_path(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum yang_keyword kw,
+yin_parse_path(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum ly_stmt kw,
struct lysp_type *type)
{
LY_CHECK_RET(yin_parse_simple_element(ctx, attrs, data, kw, &type->path,
@@ -548,7 +548,7 @@
struct lysp_restr *restr;
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, type->patterns, restr, LY_EMEM);
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &real_value, Y_STR_ARG, YANG_PATTERN));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &real_value, Y_STR_ARG, LY_STMT_PATTERN));
size_t len = strlen(real_value);
saved_value = malloc(len + 2);
@@ -562,14 +562,14 @@
type->flags |= LYS_SET_PATTERN;
struct yin_subelement subelems[6] = {
- {YANG_DESCRIPTION, &restr->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_ERROR_APP_TAG, &restr->eapptag, YIN_SUBELEM_UNIQUE},
- {YANG_ERROR_MESSAGE, &restr->emsg, YIN_SUBELEM_UNIQUE},
- {YANG_MODIFIER, &restr->arg, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &restr->ref, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_DESCRIPTION, &restr->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_ERROR_APP_TAG, &restr->eapptag, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_ERROR_MESSAGE, &restr->emsg, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MODIFIER, &restr->arg, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &restr->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- return yin_parse_content(ctx, subelems, 6, data, YANG_PATTERN, NULL, &restr->exts);
+ return yin_parse_content(ctx, subelems, 6, data, LY_STMT_PATTERN, NULL, &restr->exts);
}
/**
@@ -590,7 +590,7 @@
char *ptr;
unsigned long int num;
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_FRACTION_DIGITS));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_FRACTION_DIGITS));
if (temp_val[0] == '\0' || (temp_val[0] == '0') || !isdigit(temp_val[0])) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "fraction-digits");
@@ -614,9 +614,9 @@
type->fraction_digits = num;
type->flags |= LYS_SET_FRDIGITS;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- return yin_parse_content(ctx, subelems, 1, data, YANG_FRACTION_DIGITS, NULL, &type->exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_FRACTION_DIGITS, NULL, &type->exts);
}
/**
@@ -636,20 +636,20 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, type->enums, en, LY_EMEM);
type->flags |= LYS_SET_ENUM;
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &en->name, Y_IDENTIF_ARG, YANG_ENUM));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &en->name, Y_IDENTIF_ARG, LY_STMT_ENUM));
LY_CHECK_RET(lysp_check_enum_name((struct lys_parser_ctx *)ctx, en->name, strlen(en->name)));
YANG_CHECK_NONEMPTY((struct lys_parser_ctx *)ctx, strlen(en->name), "enum");
CHECK_UNIQUENESS((struct lys_parser_ctx *)ctx, type->enums, name, "enum", en->name);
struct yin_subelement subelems[6] = {
- {YANG_DESCRIPTION, &en->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &en->iffeatures, 0},
- {YANG_REFERENCE, &en->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &en->flags, YIN_SUBELEM_UNIQUE},
- {YANG_VALUE, en, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_DESCRIPTION, &en->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &en->iffeatures, 0},
+ {LY_STMT_REFERENCE, &en->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &en->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_VALUE, en, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- return yin_parse_content(ctx, subelems, 6, data, YANG_ENUM, NULL, &en->exts);
+ return yin_parse_content(ctx, subelems, 6, data, LY_STMT_ENUM, NULL, &en->exts);
}
/**
@@ -670,18 +670,18 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, type->bits, en, LY_EMEM);
type->flags |= LYS_SET_BIT;
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &en->name, Y_IDENTIF_ARG, YANG_BIT));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &en->name, Y_IDENTIF_ARG, LY_STMT_BIT));
CHECK_UNIQUENESS((struct lys_parser_ctx *)ctx, type->enums, name, "bit", en->name);
struct yin_subelement subelems[6] = {
- {YANG_DESCRIPTION, &en->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &en->iffeatures, 0},
- {YANG_POSITION, en, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &en->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &en->flags, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_DESCRIPTION, &en->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &en->iffeatures, 0},
+ {LY_STMT_POSITION, en, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &en->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &en->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- return yin_parse_content(ctx, subelems, 6, data, YANG_BIT, NULL, &en->exts);
+ return yin_parse_content(ctx, subelems, 6, data, LY_STMT_BIT, NULL, &en->exts);
}
/**
@@ -700,14 +700,14 @@
* @return LY_ERR values.
*/
static LY_ERR
-yin_parse_simple_elements(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum yang_keyword kw,
+yin_parse_simple_elements(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum ly_stmt kw,
const char ***values, enum yin_argument arg_type, enum yang_arg arg_val_type, struct lysp_ext_instance **exts)
{
const char **value;
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *values, value, LY_EMEM);
uint32_t index = LY_ARRAY_SIZE(*values) - 1;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, &index, 0}
+ {LY_STMT_EXTENSION_INSTANCE, &index, 0}
};
LY_CHECK_RET(yin_parse_attribute(ctx, attrs, arg_type, value, arg_val_type, kw));
@@ -730,7 +730,7 @@
* @return LY_ERR values.
*/
static LY_ERR
-yin_parse_simple_elem(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum yang_keyword kw,
+yin_parse_simple_elem(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum ly_stmt kw,
struct yin_subelement *subinfo, enum yin_argument arg_type, enum yang_arg arg_val_type, struct lysp_ext_instance **exts)
{
if (subinfo->flags & YIN_SUBELEM_UNIQUE) {
@@ -757,18 +757,18 @@
* @return LY_ERR values.
*/
static LY_ERR
-yin_parse_base(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum yang_keyword parent,
+yin_parse_base(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum ly_stmt parent,
void *dest, struct lysp_ext_instance **exts)
{
struct lysp_type *type = NULL;
- if (parent == YANG_TYPE) {
+ if (parent == LY_STMT_TYPE) {
type = (struct lysp_type *)dest;
- LY_CHECK_RET(yin_parse_simple_elements(ctx, attrs, data, YANG_BASE, &type->bases, YIN_ARG_NAME,
+ LY_CHECK_RET(yin_parse_simple_elements(ctx, attrs, data, LY_STMT_BASE, &type->bases, YIN_ARG_NAME,
Y_PREF_IDENTIF_ARG, exts));
type->flags |= LYS_SET_BASE;
- } else if (parent == YANG_IDENTITY) {
- LY_CHECK_RET(yin_parse_simple_elements(ctx, attrs, data, YANG_BASE, (const char ***)dest,
+ } else if (parent == LY_STMT_IDENTITY) {
+ LY_CHECK_RET(yin_parse_simple_elements(ctx, attrs, data, LY_STMT_BASE, (const char ***)dest,
YIN_ARG_NAME, Y_PREF_IDENTIF_ARG, exts));
} else {
LOGINT(ctx->xml_ctx.ctx);
@@ -794,11 +794,11 @@
{
const char *temp_val = NULL;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
type->flags |= LYS_SET_REQINST;
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_REQUIRE_INSTANCE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_REQUIRE_INSTANCE));
if (strcmp(temp_val, "true") == 0) {
type->require_instance = 1;
} else if (strcmp(temp_val, "false") != 0) {
@@ -809,7 +809,7 @@
}
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_REQUIRE_INSTANCE, NULL, &type->exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_REQUIRE_INSTANCE, NULL, &type->exts);
}
/**
@@ -831,10 +831,10 @@
const char *temp_val;
char *modified_val;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_MODIFIER));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MODIFIER));
if (strcmp(temp_val, "invert-match") != 0) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS1, temp_val, "value",
"modifier", "invert-match");
@@ -853,7 +853,7 @@
modified_val[0] = 0x15;
*pat = lydict_insert_zc(ctx->xml_ctx.ctx, modified_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_MODIFIER, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_MODIFIER, NULL, exts);
}
/**
@@ -862,23 +862,23 @@
* @param[in,out] ctx YIN parser context for logging and to store current state.
* @param[in] attrs [Sized array](@ref sizedarrays) of attributes of current element.
* @param[in,out] data Data to read from, always moved to currently handled character.
- * @param[in] restr_kw Identificaton of element that is being parsed, can be set to YANG_MUST, YANG_LENGTH or YANG_RANGE.
+ * @param[in] restr_kw Identificaton of element that is being parsed, can be set to LY_STMT_MUST, LY_STMT_LENGTH or LY_STMT_RANGE.
* @param[in] restr Value to write to.
*/
static LY_ERR
yin_parse_restriction(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
- enum yang_keyword restr_kw, struct lysp_restr *restr)
+ enum ly_stmt restr_kw, struct lysp_restr *restr)
{
- assert(restr_kw == YANG_MUST || restr_kw == YANG_LENGTH || restr_kw == YANG_RANGE);
+ assert(restr_kw == LY_STMT_MUST || restr_kw == LY_STMT_LENGTH || restr_kw == LY_STMT_RANGE);
struct yin_subelement subelems[5] = {
- {YANG_DESCRIPTION, &restr->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_ERROR_APP_TAG, &restr->eapptag, YIN_SUBELEM_UNIQUE},
- {YANG_ERROR_MESSAGE, &restr->emsg, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &restr->ref, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_DESCRIPTION, &restr->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_ERROR_APP_TAG, &restr->eapptag, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_ERROR_MESSAGE, &restr->emsg, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &restr->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
/* argument of must is called condition, but argument of length and range is called value */
- enum yin_argument arg_type = (restr_kw == YANG_MUST) ? YIN_ARG_CONDITION : YIN_ARG_VALUE;
+ enum yin_argument arg_type = (restr_kw == LY_STMT_MUST) ? YIN_ARG_CONDITION : YIN_ARG_VALUE;
LY_CHECK_RET(yin_parse_attribute(ctx, attrs, arg_type, &restr->arg, Y_STR_ARG, restr_kw));
return yin_parse_content(ctx, subelems, 5, data, restr_kw, NULL, &restr->exts);
@@ -900,7 +900,7 @@
{
type->range = calloc(1, sizeof *type->range);
LY_CHECK_ERR_RET(!type->range, LOGMEM(ctx->xml_ctx.ctx), LY_EMEM);
- LY_CHECK_RET(yin_parse_restriction(ctx, attrs, data, YANG_RANGE, type->range));
+ LY_CHECK_RET(yin_parse_restriction(ctx, attrs, data, LY_STMT_RANGE, type->range));
type->flags |= LYS_SET_RANGE;
return LY_SUCCESS;
@@ -922,7 +922,7 @@
{
type->length = calloc(1, sizeof *type->length);
LY_CHECK_ERR_RET(!type->length, LOGMEM(ctx->xml_ctx.ctx), LY_EMEM);
- LY_CHECK_RET(yin_parse_restriction(ctx, attrs, data, YANG_LENGTH, type->length));
+ LY_CHECK_RET(yin_parse_restriction(ctx, attrs, data, LY_STMT_LENGTH, type->length));
type->flags |= LYS_SET_LENGTH;
return LY_SUCCESS;
@@ -944,7 +944,7 @@
struct lysp_restr *restr;
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *restrs, restr, LY_EMEM);
- return yin_parse_restriction(ctx, attrs, data, YANG_MUST, restr);
+ return yin_parse_restriction(ctx, attrs, data, LY_STMT_MUST, restr);
}
/**
@@ -953,16 +953,16 @@
* @param[in,out] ctx YIN parser context for logging and to store current state.
* @param[in] attrs [Sized array](@ref sizedarrays) of attributes of current element.
* @param[in,out] data Data to read from, always moved to currently handled character.
- * @param[in] kw Type of current element, can be set to YANG_POSITION or YANG_VALUE.
+ * @param[in] kw Type of current element, can be set to LY_STMT_POSITION or LY_STMT_VALUE.
* @param[out] enm Enum structure to save value, flags and extension instances.
*
* @return LY_ERR values.
*/
static LY_ERR
yin_parse_value_pos(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
- enum yang_keyword kw, struct lysp_type_enum *enm)
+ enum ly_stmt kw, struct lysp_type_enum *enm)
{
- assert(kw == YANG_POSITION || kw == YANG_VALUE);
+ assert(kw == LY_STMT_POSITION || kw == LY_STMT_VALUE);
const char *temp_val = NULL;
char *ptr;
long int num;
@@ -974,14 +974,14 @@
/* get attribute value */
LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, kw));
if (!temp_val || temp_val[0] == '\0' || (temp_val[0] == '+') ||
- ((temp_val[0] == '0') && (temp_val[1] != '\0')) || ((kw == YANG_POSITION) && !strcmp(temp_val, "-0"))) {
+ ((temp_val[0] == '0') && (temp_val[1] != '\0')) || ((kw == LY_STMT_POSITION) && !strcmp(temp_val, "-0"))) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", ly_stmt2str(kw));
goto error;
}
/* convert value */
errno = 0;
- if (kw == YANG_VALUE) {
+ if (kw == LY_STMT_VALUE) {
num = strtol(temp_val, &ptr, 10);
if (num < INT64_C(-2147483648) || num > INT64_C(2147483647)) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", ly_stmt2str(kw));
@@ -1004,7 +1004,7 @@
goto error;
}
/* save correctly ternary operator can't be used because num and unum have different signes */
- if (kw == YANG_VALUE) {
+ if (kw == LY_STMT_VALUE) {
enm->value = num;
} else {
enm->value = unum;
@@ -1013,7 +1013,7 @@
/* parse subelements */
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
return yin_parse_content(ctx, subelems, 1, data, kw, NULL, &enm->exts);
@@ -1039,12 +1039,12 @@
struct lysp_submodule *submod, struct lysp_ext_instance **exts)
{
struct yin_subelement subelems[2] = {
- {YANG_PREFIX, &submod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_PREFIX, &submod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &submod->belongsto, Y_IDENTIF_ARG, YANG_BELONGS_TO));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &submod->belongsto, Y_IDENTIF_ARG, LY_STMT_BELONGS_TO));
- return yin_parse_content(ctx, subelems, 2, data, YANG_BELONGS_TO, NULL, exts);
+ return yin_parse_content(ctx, subelems, 2, data, LY_STMT_BELONGS_TO, NULL, exts);
}
/**
@@ -1054,7 +1054,7 @@
* @param[in,out] ctx YIN parser context for logging and to store current state.
* @param[in] attrs [Sized array](@ref sizedarrays) of attributes of current element.
* @param[in,out] data Data to read from, always moved to currently handled character.
- * @param[in] elem_type Type of element can be set to YANG_ORGANIZATION or YANG_CONTACT or YANG_DESCRIPTION or YANG_REFERENCE.
+ * @param[in] elem_type Type of element can be set to LY_STMT_ORGANIZATION or LY_STMT_CONTACT or LY_STMT_DESCRIPTION or LY_STMT_REFERENCE.
* @param[out] value Where the content of meta element should be stored.
* @param[in,out] exts Extension instances to add to.
*
@@ -1062,13 +1062,13 @@
*/
static LY_ERR
yin_parse_meta(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
- enum yang_keyword elem_type, const char **value, struct lysp_ext_instance **exts)
+ enum ly_stmt elem_type, const char **value, struct lysp_ext_instance **exts)
{
- assert(elem_type == YANG_ORGANIZATION || elem_type == YANG_CONTACT || elem_type == YANG_DESCRIPTION || elem_type == YANG_REFERENCE);
+ assert(elem_type == LY_STMT_ORGANIZATION || elem_type == LY_STMT_CONTACT || elem_type == LY_STMT_DESCRIPTION || elem_type == LY_STMT_REFERENCE);
struct yin_subelement subelems[2] = {
- {YANG_CUSTOM, NULL, 0},
- {YIN_TEXT, value, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE | YIN_SUBELEM_FIRST}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
+ {LY_STMT_ARG_TEXT, value, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE | YIN_SUBELEM_FIRST}
};
/* check attributes */
LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NONE, NULL, Y_MAYBE_STR_ARG, elem_type));
@@ -1093,14 +1093,14 @@
const char **value, struct lysp_ext_instance **exts)
{
struct yin_subelement subelems[2] = {
- {YANG_CUSTOM, NULL, 0},
- {YIN_VALUE, value, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE | YIN_SUBELEM_FIRST}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
+ {LY_STMT_ARG_VALUE, value, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE | YIN_SUBELEM_FIRST}
};
/* check attributes */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NONE, NULL, Y_MAYBE_STR_ARG, YANG_ERROR_MESSAGE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NONE, NULL, Y_MAYBE_STR_ARG, LY_STMT_ERROR_MESSAGE));
- return yin_parse_content(ctx, subelems, 2, data, YANG_ERROR_MESSAGE, NULL, exts);
+ return yin_parse_content(ctx, subelems, 2, data, LY_STMT_ERROR_MESSAGE, NULL, exts);
}
/**
@@ -1116,10 +1116,10 @@
*/
static LY_ERR
yin_parse_type(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
- enum yang_keyword parent, struct yin_subelement *subinfo)
+ enum ly_stmt parent, struct yin_subelement *subinfo)
{
struct lysp_type *type = NULL;
- if (parent == YANG_DEVIATE) {
+ if (parent == LY_STMT_DEVIATE) {
*(struct lysp_type **)subinfo->dest = calloc(1, sizeof **(struct lysp_type **)subinfo->dest);
LY_CHECK_ERR_RET(!(*(struct lysp_type **)subinfo->dest), LOGMEM(ctx->xml_ctx.ctx), LY_EMEM);
type = *((struct lysp_type **)subinfo->dest);
@@ -1127,27 +1127,27 @@
type = (struct lysp_type *)subinfo->dest;
}
/* type as child of another type */
- if (parent == YANG_TYPE) {
+ if (parent == LY_STMT_TYPE) {
struct lysp_type *nested_type = NULL;
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, type->types, nested_type, LY_EMEM);
type->flags |= LYS_SET_TYPE;
type = nested_type;
}
struct yin_subelement subelems[11] = {
- {YANG_BASE, type, 0},
- {YANG_BIT, type, 0},
- {YANG_ENUM, type, 0},
- {YANG_FRACTION_DIGITS, type, YIN_SUBELEM_UNIQUE},
- {YANG_LENGTH, type, YIN_SUBELEM_UNIQUE},
- {YANG_PATH, type, YIN_SUBELEM_UNIQUE},
- {YANG_PATTERN, type, 0},
- {YANG_RANGE, type, YIN_SUBELEM_UNIQUE},
- {YANG_REQUIRE_INSTANCE, type, YIN_SUBELEM_UNIQUE},
- {YANG_TYPE, type},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_BASE, type, 0},
+ {LY_STMT_BIT, type, 0},
+ {LY_STMT_ENUM, type, 0},
+ {LY_STMT_FRACTION_DIGITS, type, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_LENGTH, type, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_PATH, type, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_PATTERN, type, 0},
+ {LY_STMT_RANGE, type, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REQUIRE_INSTANCE, type, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_TYPE, type},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &type->name, Y_PREF_IDENTIF_ARG, YANG_TYPE));
- return yin_parse_content(ctx, subelems, 11, data, YANG_TYPE, NULL, &type->exts);
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &type->name, Y_PREF_IDENTIF_ARG, LY_STMT_TYPE));
+ return yin_parse_content(ctx, subelems, 11, data, LY_STMT_TYPE, NULL, &type->exts);
}
/**
@@ -1170,11 +1170,11 @@
char *ptr;
unsigned long int num;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
*flags |= LYS_SET_MAX;
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_MAX_ELEMENTS));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MAX_ELEMENTS));
if (!temp_val || temp_val[0] == '\0' || temp_val[0] == '0' || (temp_val[0] != 'u' && !isdigit(temp_val[0]))) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "max-elements");
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
@@ -1197,7 +1197,7 @@
*max = num;
}
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_MAX_ELEMENTS, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_MAX_ELEMENTS, NULL, exts);
}
/**
@@ -1220,11 +1220,11 @@
char *ptr;
unsigned long int num;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
*flags |= LYS_SET_MIN;
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_MIN_ELEMENTS));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MIN_ELEMENTS));
if (!temp_val || temp_val[0] == '\0' || (temp_val[0] == '0' && temp_val[1] != '\0')) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "min-elements");
@@ -1246,7 +1246,7 @@
}
*min = num;
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_MIN_ELEMENTS, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_MIN_ELEMENTS, NULL, exts);
}
/**
@@ -1263,24 +1263,24 @@
*/
static LY_ERR
yin_parse_minmax(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
- enum yang_keyword parent, enum yang_keyword current, void *dest)
+ enum ly_stmt parent, enum ly_stmt current, void *dest)
{
- assert(current == YANG_MAX_ELEMENTS || current == YANG_MIN_ELEMENTS);
- assert(parent == YANG_LEAF_LIST || parent == YANG_REFINE || parent == YANG_LIST || parent == YANG_DEVIATE);
+ assert(current == LY_STMT_MAX_ELEMENTS || current == LY_STMT_MIN_ELEMENTS);
+ assert(parent == LY_STMT_LEAF_LIST || parent == LY_STMT_REFINE || parent == LY_STMT_LIST || parent == LY_STMT_DEVIATE);
uint32_t *lim;
uint16_t *flags;
struct lysp_ext_instance **exts;
- if (parent == YANG_LEAF_LIST) {
- lim = (current == YANG_MAX_ELEMENTS) ? &((struct lysp_node_leaflist *)dest)->max : &((struct lysp_node_leaflist *)dest)->min;
+ if (parent == LY_STMT_LEAF_LIST) {
+ lim = (current == LY_STMT_MAX_ELEMENTS) ? &((struct lysp_node_leaflist *)dest)->max : &((struct lysp_node_leaflist *)dest)->min;
flags = &((struct lysp_node_leaflist *)dest)->flags;
exts = &((struct lysp_node_leaflist *)dest)->exts;
- } else if (parent == YANG_REFINE) {
- lim = (current == YANG_MAX_ELEMENTS) ? &((struct lysp_refine *)dest)->max : &((struct lysp_refine *)dest)->min;
+ } else if (parent == LY_STMT_REFINE) {
+ lim = (current == LY_STMT_MAX_ELEMENTS) ? &((struct lysp_refine *)dest)->max : &((struct lysp_refine *)dest)->min;
flags = &((struct lysp_refine *)dest)->flags;
exts = &((struct lysp_refine *)dest)->exts;
- } else if (parent == YANG_LIST) {
- lim = (current == YANG_MAX_ELEMENTS) ? &((struct lysp_node_list *)dest)->max : &((struct lysp_node_list *)dest)->min;
+ } else if (parent == LY_STMT_LIST) {
+ lim = (current == LY_STMT_MAX_ELEMENTS) ? &((struct lysp_node_list *)dest)->max : &((struct lysp_node_list *)dest)->min;
flags = &((struct lysp_node_list *)dest)->flags;
exts = &((struct lysp_node_list *)dest)->exts;
} else {
@@ -1289,7 +1289,7 @@
exts = ((struct minmax_dev_meta *)dest)->exts;
}
- if (current == YANG_MAX_ELEMENTS) {
+ if (current == LY_STMT_MAX_ELEMENTS) {
LY_CHECK_RET(yin_parse_maxelements(ctx, attrs, data, lim, flags, exts));
} else {
LY_CHECK_RET(yin_parse_minelements(ctx, attrs, data, lim, flags, exts));
@@ -1315,10 +1315,10 @@
{
const char *temp_val;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_ORDERED_BY));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_ORDERED_BY));
if (strcmp(temp_val, "system") == 0) {
*flags |= LYS_ORDBY_SYSTEM;
} else if (strcmp(temp_val, "user") == 0) {
@@ -1331,7 +1331,7 @@
}
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_ORDERED_BY, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_ORDERED_BY, NULL, exts);
}
/**
@@ -1340,35 +1340,35 @@
* @param[in,out] ctx YIN parser context for logging and to store current state.
* @param[in] attrs [Sized array](@ref sizedarrays) of attributes of current element.
* @param[in,out] data Data to read from, always moved to currently handled character.
- * @param[in] any_kw Identification of current element, can be set to YANG_ANY_DATA or YANG_ANY_XML
+ * @param[in] any_kw Identification of current element, can be set to LY_STMT_ANYDATA or LY_STMT_ANYXML
* @param[in] node_meta Meta information about parent node and siblings to add to.
*
* @return LY_ERR values.
*/
static LY_ERR
yin_parse_any(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data,
- enum yang_keyword any_kw, struct tree_node_meta *node_meta)
+ enum ly_stmt any_kw, struct tree_node_meta *node_meta)
{
struct lysp_node_anydata *any;
/* create new sibling */
LY_LIST_NEW_RET(ctx->xml_ctx.ctx, node_meta->nodes, any, next);
- any->nodetype = (any_kw == YANG_ANYDATA) ? LYS_ANYDATA : LYS_ANYXML;
+ any->nodetype = (any_kw == LY_STMT_ANYDATA) ? LYS_ANYDATA : LYS_ANYXML;
any->parent = node_meta->parent;
/* parse argument */
LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &any->name, Y_IDENTIF_ARG, any_kw));
struct yin_subelement subelems[9] = {
- {YANG_CONFIG, &any->flags, YIN_SUBELEM_UNIQUE},
- {YANG_DESCRIPTION, &any->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &any->iffeatures, 0},
- {YANG_MANDATORY, &any->flags, YIN_SUBELEM_UNIQUE},
- {YANG_MUST, &any->musts, 0},
- {YANG_REFERENCE, &any->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &any->flags, YIN_SUBELEM_UNIQUE},
- {YANG_WHEN, &any->when, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_CONFIG, &any->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DESCRIPTION, &any->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &any->iffeatures, 0},
+ {LY_STMT_MANDATORY, &any->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MUST, &any->musts, 0},
+ {LY_STMT_REFERENCE, &any->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &any->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_WHEN, &any->when, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
return yin_parse_content(ctx, subelems, 9, data, any_kw, NULL, &any->exts);
}
@@ -1395,24 +1395,24 @@
leaf->parent = node_meta->parent;
/* parser argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &leaf->name, Y_IDENTIF_ARG, YANG_LEAF));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &leaf->name, Y_IDENTIF_ARG, LY_STMT_LEAF));
/* parse content */
struct yin_subelement subelems[12] = {
- {YANG_CONFIG, &leaf->flags, YIN_SUBELEM_UNIQUE},
- {YANG_DEFAULT, &leaf->dflt, YIN_SUBELEM_UNIQUE},
- {YANG_DESCRIPTION, &leaf->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &leaf->iffeatures, 0},
- {YANG_MANDATORY, &leaf->flags, YIN_SUBELEM_UNIQUE},
- {YANG_MUST, &leaf->musts, 0},
- {YANG_REFERENCE, &leaf->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &leaf->flags, YIN_SUBELEM_UNIQUE},
- {YANG_TYPE, &leaf->type, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_MANDATORY},
- {YANG_UNITS, &leaf->units, YIN_SUBELEM_UNIQUE},
- {YANG_WHEN, &leaf->when, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_CONFIG, &leaf->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DEFAULT, &leaf->dflt, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DESCRIPTION, &leaf->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &leaf->iffeatures, 0},
+ {LY_STMT_MANDATORY, &leaf->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MUST, &leaf->musts, 0},
+ {LY_STMT_REFERENCE, &leaf->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &leaf->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_TYPE, &leaf->type, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_MANDATORY},
+ {LY_STMT_UNITS, &leaf->units, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_WHEN, &leaf->when, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- return yin_parse_content(ctx, subelems, 12, data, YANG_LEAF, NULL, &leaf->exts);
+ return yin_parse_content(ctx, subelems, 12, data, LY_STMT_LEAF, NULL, &leaf->exts);
}
/**
@@ -1437,26 +1437,26 @@
llist->parent = node_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &llist->name, Y_IDENTIF_ARG, YANG_LEAF_LIST));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &llist->name, Y_IDENTIF_ARG, LY_STMT_LEAF_LIST));
/* parse content */
struct yin_subelement subelems[14] = {
- {YANG_CONFIG, &llist->flags, YIN_SUBELEM_UNIQUE},
- {YANG_DEFAULT, &llist->dflts, 0},
- {YANG_DESCRIPTION, &llist->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &llist->iffeatures, 0},
- {YANG_MAX_ELEMENTS, llist, YIN_SUBELEM_UNIQUE},
- {YANG_MIN_ELEMENTS, llist, YIN_SUBELEM_UNIQUE},
- {YANG_MUST, &llist->musts, 0},
- {YANG_ORDERED_BY, &llist->flags, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &llist->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &llist->flags, YIN_SUBELEM_UNIQUE},
- {YANG_TYPE, &llist->type, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_MANDATORY},
- {YANG_UNITS, &llist->units, YIN_SUBELEM_UNIQUE},
- {YANG_WHEN, &llist->when, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_CONFIG, &llist->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DEFAULT, &llist->dflts, 0},
+ {LY_STMT_DESCRIPTION, &llist->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &llist->iffeatures, 0},
+ {LY_STMT_MAX_ELEMENTS, llist, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MIN_ELEMENTS, llist, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MUST, &llist->musts, 0},
+ {LY_STMT_ORDERED_BY, &llist->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &llist->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &llist->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_TYPE, &llist->type, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_MANDATORY},
+ {LY_STMT_UNITS, &llist->units, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_WHEN, &llist->when, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- LY_CHECK_RET(yin_parse_content(ctx, subelems, 14, data, YANG_LEAF_LIST, NULL, &llist->exts));
+ LY_CHECK_RET(yin_parse_content(ctx, subelems, 14, data, LY_STMT_LEAF_LIST, NULL, &llist->exts));
/* check invalid combination of subelements */
if ((llist->min) && (llist->dflts)) {
@@ -1490,19 +1490,19 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *tpdfs, tpdf, LY_EMEM);
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &tpdf->name, Y_IDENTIF_ARG, YANG_TYPEDEF));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &tpdf->name, Y_IDENTIF_ARG, LY_STMT_TYPEDEF));
/* parse content */
struct yin_subelement subelems[7] = {
- {YANG_DEFAULT, &tpdf->dflt, YIN_SUBELEM_UNIQUE},
- {YANG_DESCRIPTION, &tpdf->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &tpdf->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &tpdf->flags, YIN_SUBELEM_UNIQUE},
- {YANG_TYPE, &tpdf->type, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_MANDATORY},
- {YANG_UNITS, &tpdf->units, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_DEFAULT, &tpdf->dflt, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DESCRIPTION, &tpdf->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &tpdf->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &tpdf->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_TYPE, &tpdf->type, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_MANDATORY},
+ {LY_STMT_UNITS, &tpdf->units, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- LY_CHECK_RET(yin_parse_content(ctx, subelems, 7, data, YANG_TYPEDEF, NULL, &tpdf->exts));
+ LY_CHECK_RET(yin_parse_content(ctx, subelems, 7, data, LY_STMT_TYPEDEF, NULL, &tpdf->exts));
/* store data for collision check */
if (typedef_meta->parent && !(typedef_meta->parent->nodetype & (LYS_GROUPING | LYS_ACTION | LYS_INOUT | LYS_NOTIF))) {
@@ -1532,24 +1532,24 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *refines, rf, LY_EMEM);
/* parse attribute */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_TARGET_NODE, &rf->nodeid, Y_STR_ARG, YANG_REFINE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_TARGET_NODE, &rf->nodeid, Y_STR_ARG, LY_STMT_REFINE));
YANG_CHECK_NONEMPTY((struct lys_parser_ctx *)ctx, strlen(rf->nodeid), "refine");
/* parse content */
struct yin_subelement subelems[11] = {
- {YANG_CONFIG, &rf->flags, YIN_SUBELEM_UNIQUE},
- {YANG_DEFAULT, &rf->dflts, 0},
- {YANG_DESCRIPTION, &rf->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &rf->iffeatures, 0},
- {YANG_MANDATORY, &rf->flags, YIN_SUBELEM_UNIQUE},
- {YANG_MAX_ELEMENTS, rf, YIN_SUBELEM_UNIQUE},
- {YANG_MIN_ELEMENTS, rf, YIN_SUBELEM_UNIQUE},
- {YANG_MUST, &rf->musts, 0},
- {YANG_PRESENCE, &rf->presence, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &rf->ref, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_CONFIG, &rf->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DEFAULT, &rf->dflts, 0},
+ {LY_STMT_DESCRIPTION, &rf->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &rf->iffeatures, 0},
+ {LY_STMT_MANDATORY, &rf->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MAX_ELEMENTS, rf, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MIN_ELEMENTS, rf, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MUST, &rf->musts, 0},
+ {LY_STMT_PRESENCE, &rf->presence, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &rf->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- return yin_parse_content(ctx, subelems, 11, data, YANG_REFINE, NULL, &rf->exts);
+ return yin_parse_content(ctx, subelems, 11, data, LY_STMT_REFINE, NULL, &rf->exts);
}
/**
@@ -1574,21 +1574,21 @@
uses->parent = node_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &uses->name, Y_PREF_IDENTIF_ARG, YANG_USES));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &uses->name, Y_PREF_IDENTIF_ARG, LY_STMT_USES));
/* parse content */
struct tree_node_meta augments = {(struct lysp_node *)uses, (struct lysp_node **)&uses->augments};
struct yin_subelement subelems[8] = {
- {YANG_AUGMENT, &augments, 0},
- {YANG_DESCRIPTION, &uses->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &uses->iffeatures, 0},
- {YANG_REFERENCE, &uses->ref, YIN_SUBELEM_UNIQUE},
- {YANG_REFINE, &uses->refines, 0},
- {YANG_STATUS, &uses->flags, YIN_SUBELEM_UNIQUE},
- {YANG_WHEN, &uses->when, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_AUGMENT, &augments, 0},
+ {LY_STMT_DESCRIPTION, &uses->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &uses->iffeatures, 0},
+ {LY_STMT_REFERENCE, &uses->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFINE, &uses->refines, 0},
+ {LY_STMT_STATUS, &uses->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_WHEN, &uses->when, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- LY_CHECK_RET(yin_parse_content(ctx, subelems, 8, data, YANG_USES, NULL, &uses->exts));
+ LY_CHECK_RET(yin_parse_content(ctx, subelems, 8, data, LY_STMT_USES, NULL, &uses->exts));
LY_CHECK_RET(lysp_parse_finalize_reallocated((struct lys_parser_ctx *)ctx, NULL, uses->augments, NULL, NULL));
return LY_SUCCESS;
@@ -1615,7 +1615,7 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *revs, rev, LY_EMEM);
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_DATE, &temp_date, Y_STR_ARG, YANG_REVISION));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_DATE, &temp_date, Y_STR_ARG, LY_STMT_REVISION));
/* check value */
if (lysp_check_date((struct lys_parser_ctx *)ctx, temp_date, strlen(temp_date), "revision")) {
FREE_STRING(ctx->xml_ctx.ctx, temp_date);
@@ -1626,11 +1626,11 @@
/* parse content */
struct yin_subelement subelems[3] = {
- {YANG_DESCRIPTION, &rev->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &rev->ref, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_DESCRIPTION, &rev->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &rev->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- return yin_parse_content(ctx, subelems, 3, data, YANG_REVISION, NULL, &rev->exts);
+ return yin_parse_content(ctx, subelems, 3, data, LY_STMT_REVISION, NULL, &rev->exts);
}
/**
@@ -1653,7 +1653,7 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *inc_meta->includes, inc, LY_EMEM);
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &inc->name, Y_IDENTIF_ARG, YANG_INCLUDE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &inc->name, Y_IDENTIF_ARG, LY_STMT_INCLUDE));
/* submodules share the namespace with the module names, so there must not be
* a module of the same name in the context, no need for revision matching */
@@ -1664,12 +1664,12 @@
/* parse content */
struct yin_subelement subelems[4] = {
- {YANG_DESCRIPTION, &inc->dsc, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_VER2},
- {YANG_REFERENCE, &inc->ref, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_VER2},
- {YANG_REVISION_DATE, &inc->rev, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_DESCRIPTION, &inc->dsc, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_VER2},
+ {LY_STMT_REFERENCE, &inc->ref, YIN_SUBELEM_UNIQUE | YIN_SUBELEM_VER2},
+ {LY_STMT_REVISION_DATE, &inc->rev, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- return yin_parse_content(ctx, subelems, 4, data, YANG_INCLUDE, NULL, &inc->exts);
+ return yin_parse_content(ctx, subelems, 4, data, LY_STMT_INCLUDE, NULL, &inc->exts);
}
/**
@@ -1689,17 +1689,17 @@
{
const char *temp_rev;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_DATE, &temp_rev, Y_STR_ARG, YANG_REVISION_DATE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_DATE, &temp_rev, Y_STR_ARG, LY_STMT_REVISION_DATE));
LY_CHECK_ERR_RET(lysp_check_date((struct lys_parser_ctx *)ctx, temp_rev, strlen(temp_rev), "revision-date") != LY_SUCCESS,
FREE_STRING(ctx->xml_ctx.ctx, temp_rev), LY_EVALID);
strcpy(rev, temp_rev);
FREE_STRING(ctx->xml_ctx.ctx, temp_rev);
- return yin_parse_content(ctx, subelems, 1, data, YANG_REVISION_DATE, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_REVISION_DATE, NULL, exts);
}
/**
@@ -1719,10 +1719,10 @@
{
const char *temp_val = NULL;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_CONFIG));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_CONFIG));
if (strcmp(temp_val, "true") == 0) {
*flags |= LYS_CONFIG_W;
} else if (strcmp(temp_val, "false") == 0) {
@@ -1735,7 +1735,7 @@
}
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_CONFIG, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_CONFIG, NULL, exts);
}
/**
@@ -1755,10 +1755,10 @@
{
const char *temp_version = NULL;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_version, Y_STR_ARG, YANG_YANG_VERSION));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_version, Y_STR_ARG, LY_STMT_YANG_VERSION));
if (strcmp(temp_version, "1.0") == 0) {
*version = LYS_VERSION_1_0;
} else if (strcmp(temp_version, "1.1") == 0) {
@@ -1772,7 +1772,7 @@
FREE_STRING(ctx->xml_ctx.ctx, temp_version);
ctx->mod_version = *version;
- return yin_parse_content(ctx, subelems, 1, data, YANG_YANG_VERSION, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_YANG_VERSION, NULL, exts);
}
/**
@@ -1793,16 +1793,16 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *imp_meta->imports, imp, LY_EMEM);
struct yin_subelement subelems[5] = {
- {YANG_DESCRIPTION, &imp->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_PREFIX, &imp->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &imp->ref, YIN_SUBELEM_UNIQUE},
- {YANG_REVISION_DATE, imp->rev, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_DESCRIPTION, &imp->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_PREFIX, &imp->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &imp->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REVISION_DATE, imp->rev, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
/* parse import attributes */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &imp->name, Y_IDENTIF_ARG, YANG_IMPORT));
- LY_CHECK_RET(yin_parse_content(ctx, subelems, 5, data, YANG_IMPORT, NULL, &imp->exts));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_MODULE, &imp->name, Y_IDENTIF_ARG, LY_STMT_IMPORT));
+ LY_CHECK_RET(yin_parse_content(ctx, subelems, 5, data, LY_STMT_IMPORT, NULL, &imp->exts));
/* check prefix validity */
LY_CHECK_RET(lysp_check_prefix((struct lys_parser_ctx *)ctx, *imp_meta->imports, imp_meta->prefix, &imp->prefix), LY_EVALID);
@@ -1826,10 +1826,10 @@
{
const char *temp_val = NULL;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_MANDATORY));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MANDATORY));
if (strcmp(temp_val, "true") == 0) {
*flags |= LYS_MAND_TRUE;
} else if (strcmp(temp_val, "false") == 0) {
@@ -1842,7 +1842,7 @@
}
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_MANDATORY, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_MANDATORY, NULL, exts);
}
/**
@@ -1862,10 +1862,10 @@
{
const char *value = NULL;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &value, Y_STR_ARG, YANG_STATUS));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &value, Y_STR_ARG, LY_STMT_STATUS));
if (strcmp(value, "current") == 0) {
*flags |= LYS_STATUS_CURR;
} else if (strcmp(value, "deprecated") == 0) {
@@ -1880,7 +1880,7 @@
}
FREE_STRING(ctx->xml_ctx.ctx, value);
- return yin_parse_content(ctx, subelems, 1, data, YANG_STATUS, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_STATUS, NULL, exts);
}
/**
@@ -1899,17 +1899,17 @@
when = calloc(1, sizeof *when);
LY_CHECK_ERR_RET(!when, LOGMEM(ctx->xml_ctx.ctx), LY_EMEM);
- ret = yin_parse_attribute(ctx, attrs, YIN_ARG_CONDITION, &when->cond, Y_STR_ARG, YANG_WHEN);
+ ret = yin_parse_attribute(ctx, attrs, YIN_ARG_CONDITION, &when->cond, Y_STR_ARG, LY_STMT_WHEN);
LY_CHECK_ERR_RET(ret, free(when), ret);
*when_p = when;
struct yin_subelement subelems[3] = {
- {YANG_DESCRIPTION, &when->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &when->ref, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_DESCRIPTION, &when->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &when->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- return yin_parse_content(ctx, subelems, 3, data, YANG_WHEN, NULL, &when->exts);
+ return yin_parse_content(ctx, subelems, 3, data, LY_STMT_WHEN, NULL, &when->exts);
}
/**
@@ -1929,10 +1929,10 @@
{
const char *temp_val = NULL;
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_YIN_ELEMENT));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_YIN_ELEMENT));
if (strcmp(temp_val, "true") == 0) {
*flags |= LYS_YINELEM_TRUE;
} else if (strcmp(temp_val, "false") == 0) {
@@ -1945,7 +1945,7 @@
}
FREE_STRING(ctx->xml_ctx.ctx, temp_val);
- return yin_parse_content(ctx, subelems, 1, data, YANG_YIN_ELEMENT, NULL, exts);
+ return yin_parse_content(ctx, subelems, 1, data, LY_STMT_YIN_ELEMENT, NULL, exts);
}
/**
@@ -1964,13 +1964,13 @@
struct yin_argument_meta *arg_meta, struct lysp_ext_instance **exts)
{
struct yin_subelement subelems[2] = {
- {YANG_YIN_ELEMENT, arg_meta->flags, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_YIN_ELEMENT, arg_meta->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, arg_meta->argument, Y_IDENTIF_ARG, YANG_ARGUMENT));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, arg_meta->argument, Y_IDENTIF_ARG, LY_STMT_ARGUMENT));
- return yin_parse_content(ctx, subelems, 2, data, YANG_ARGUMENT, NULL, exts);
+ return yin_parse_content(ctx, subelems, 2, data, LY_STMT_ARGUMENT, NULL, exts);
}
/**
@@ -1988,18 +1988,18 @@
{
struct lysp_ext *ex;
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *extensions, ex, LY_EMEM);
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &ex->name, Y_IDENTIF_ARG, YANG_EXTENSION));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &ex->name, Y_IDENTIF_ARG, LY_STMT_EXTENSION));
struct yin_argument_meta arg_info = {&ex->flags, &ex->argument};
struct yin_subelement subelems[5] = {
- {YANG_ARGUMENT, &arg_info, YIN_SUBELEM_UNIQUE},
- {YANG_DESCRIPTION, &ex->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_REFERENCE, &ex->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &ex->flags, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_ARGUMENT, &arg_info, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DESCRIPTION, &ex->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_REFERENCE, &ex->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &ex->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- return yin_parse_content(ctx, subelems, 5, data, YANG_EXTENSION, NULL, &ex->exts);
+ return yin_parse_content(ctx, subelems, 5, data, LY_STMT_EXTENSION, NULL, &ex->exts);
}
/**
@@ -2022,17 +2022,17 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *features, feat, LY_EMEM);
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &feat->name, Y_IDENTIF_ARG, YANG_FEATURE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &feat->name, Y_IDENTIF_ARG, LY_STMT_FEATURE));
/* parse content */
struct yin_subelement subelems[5] = {
- {YANG_DESCRIPTION, &feat->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &feat->iffeatures, 0},
- {YANG_REFERENCE, &feat->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &feat->flags, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_DESCRIPTION, &feat->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &feat->iffeatures, 0},
+ {LY_STMT_REFERENCE, &feat->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &feat->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- return yin_parse_content(ctx, subelems, 5, data, YANG_FEATURE, NULL, &feat->exts);
+ return yin_parse_content(ctx, subelems, 5, data, LY_STMT_FEATURE, NULL, &feat->exts);
}
/**
@@ -2055,18 +2055,18 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *identities, ident, LY_EMEM);
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &ident->name, Y_IDENTIF_ARG, YANG_IDENTITY));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &ident->name, Y_IDENTIF_ARG, LY_STMT_IDENTITY));
/* parse content */
struct yin_subelement subelems[6] = {
- {YANG_BASE, &ident->bases, 0},
- {YANG_DESCRIPTION, &ident->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_IF_FEATURE, &ident->iffeatures, YIN_SUBELEM_VER2},
- {YANG_REFERENCE, &ident->ref, YIN_SUBELEM_UNIQUE},
- {YANG_STATUS, &ident->flags, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_BASE, &ident->bases, 0},
+ {LY_STMT_DESCRIPTION, &ident->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_IF_FEATURE, &ident->iffeatures, YIN_SUBELEM_VER2},
+ {LY_STMT_REFERENCE, &ident->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_STATUS, &ident->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- return yin_parse_content(ctx, subelems, 6, data, YANG_IDENTITY, NULL, &ident->exts);
+ return yin_parse_content(ctx, subelems, 6, data, LY_STMT_IDENTITY, NULL, &ident->exts);
}
/**
@@ -2092,37 +2092,37 @@
list->parent = node_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &list->name, Y_IDENTIF_ARG, YANG_LIST));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &list->name, Y_IDENTIF_ARG, LY_STMT_LIST));
/* parse list content */
LY_CHECK_RET(subelems_allocator(ctx, 25, (struct lysp_node *)list, &subelems,
- YANG_ACTION, &list->actions, 0,
- YANG_ANYDATA, &list->child, 0,
- YANG_ANYXML, &list->child, 0,
- YANG_CHOICE, &list->child, 0,
- YANG_CONFIG, &list->flags, YIN_SUBELEM_UNIQUE,
- YANG_CONTAINER, &list->child, 0,
- YANG_DESCRIPTION, &list->dsc, YIN_SUBELEM_UNIQUE,
- YANG_GROUPING, &list->groupings, 0,
- YANG_IF_FEATURE, &list->iffeatures, 0,
- YANG_KEY, &list->key, YIN_SUBELEM_UNIQUE,
- YANG_LEAF, &list->child, 0,
- YANG_LEAF_LIST, &list->child, 0,
- YANG_LIST, &list->child, 0,
- YANG_MAX_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
- YANG_MIN_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
- YANG_MUST, &list->musts, 0,
- YANG_NOTIFICATION, &list->notifs, 0,
- YANG_ORDERED_BY, &list->flags, YIN_SUBELEM_UNIQUE,
- YANG_REFERENCE, &list->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, &list->flags, YIN_SUBELEM_UNIQUE,
- YANG_TYPEDEF, &list->typedefs, 0,
- YANG_UNIQUE, &list->uniques, 0,
- YANG_USES, &list->child, 0,
- YANG_WHEN, &list->when, YIN_SUBELEM_UNIQUE,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ACTION, &list->actions, 0,
+ LY_STMT_ANYDATA, &list->child, 0,
+ LY_STMT_ANYXML, &list->child, 0,
+ LY_STMT_CHOICE, &list->child, 0,
+ LY_STMT_CONFIG, &list->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_CONTAINER, &list->child, 0,
+ LY_STMT_DESCRIPTION, &list->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_GROUPING, &list->groupings, 0,
+ LY_STMT_IF_FEATURE, &list->iffeatures, 0,
+ LY_STMT_KEY, &list->key, YIN_SUBELEM_UNIQUE,
+ LY_STMT_LEAF, &list->child, 0,
+ LY_STMT_LEAF_LIST, &list->child, 0,
+ LY_STMT_LIST, &list->child, 0,
+ LY_STMT_MAX_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
+ LY_STMT_MIN_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
+ LY_STMT_MUST, &list->musts, 0,
+ LY_STMT_NOTIFICATION, &list->notifs, 0,
+ LY_STMT_ORDERED_BY, &list->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_REFERENCE, &list->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_STATUS, &list->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_TYPEDEF, &list->typedefs, 0,
+ LY_STMT_UNIQUE, &list->uniques, 0,
+ LY_STMT_USES, &list->child, 0,
+ LY_STMT_WHEN, &list->when, YIN_SUBELEM_UNIQUE,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 25, data, YANG_LIST, NULL, &list->exts);
+ ret = yin_parse_content(ctx, subelems, 25, data, LY_STMT_LIST, NULL, &list->exts);
subelems_deallocator(25, subelems);
LY_CHECK_RET(ret);
@@ -2162,29 +2162,29 @@
notif->parent = notif_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, ¬if->name, Y_IDENTIF_ARG, YANG_NOTIFICATION));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, ¬if->name, Y_IDENTIF_ARG, LY_STMT_NOTIFICATION));
/* parse notification content */
LY_CHECK_RET(subelems_allocator(ctx, 16, (struct lysp_node *)notif, &subelems,
- YANG_ANYDATA, ¬if->data, 0,
- YANG_ANYXML, ¬if->data, 0,
- YANG_CHOICE, ¬if->data, 0,
- YANG_CONTAINER, ¬if->data, 0,
- YANG_DESCRIPTION, ¬if->dsc, YIN_SUBELEM_UNIQUE,
- YANG_GROUPING, ¬if->groupings, 0,
- YANG_IF_FEATURE, ¬if->iffeatures, 0,
- YANG_LEAF, ¬if->data, 0,
- YANG_LEAF_LIST, ¬if->data, 0,
- YANG_LIST, ¬if->data, 0,
- YANG_MUST, ¬if->musts, YIN_SUBELEM_VER2,
- YANG_REFERENCE, ¬if->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, ¬if->flags, YIN_SUBELEM_UNIQUE,
- YANG_TYPEDEF, ¬if->typedefs, 0,
- YANG_USES, ¬if->data, 0,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ANYDATA, ¬if->data, 0,
+ LY_STMT_ANYXML, ¬if->data, 0,
+ LY_STMT_CHOICE, ¬if->data, 0,
+ LY_STMT_CONTAINER, ¬if->data, 0,
+ LY_STMT_DESCRIPTION, ¬if->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_GROUPING, ¬if->groupings, 0,
+ LY_STMT_IF_FEATURE, ¬if->iffeatures, 0,
+ LY_STMT_LEAF, ¬if->data, 0,
+ LY_STMT_LEAF_LIST, ¬if->data, 0,
+ LY_STMT_LIST, ¬if->data, 0,
+ LY_STMT_MUST, ¬if->musts, YIN_SUBELEM_VER2,
+ LY_STMT_REFERENCE, ¬if->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_STATUS, ¬if->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_TYPEDEF, ¬if->typedefs, 0,
+ LY_STMT_USES, ¬if->data, 0,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 16, data, YANG_NOTIFICATION, NULL, ¬if->exts);
+ ret = yin_parse_content(ctx, subelems, 16, data, LY_STMT_NOTIFICATION, NULL, ¬if->exts);
subelems_deallocator(16, subelems);
LY_CHECK_RET(ret);
@@ -2219,28 +2219,28 @@
grp->parent = gr_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &grp->name, Y_IDENTIF_ARG, YANG_GROUPING));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &grp->name, Y_IDENTIF_ARG, LY_STMT_GROUPING));
/* parse grouping content */
LY_CHECK_RET(subelems_allocator(ctx, 16, (struct lysp_node *)grp, &subelems,
- YANG_ACTION, &grp->actions, 0,
- YANG_ANYDATA, &grp->data, 0,
- YANG_ANYXML, &grp->data, 0,
- YANG_CHOICE, &grp->data, 0,
- YANG_CONTAINER, &grp->data, 0,
- YANG_DESCRIPTION, &grp->dsc, YIN_SUBELEM_UNIQUE,
- YANG_GROUPING, &grp->groupings, 0,
- YANG_LEAF, &grp->data, 0,
- YANG_LEAF_LIST, &grp->data, 0,
- YANG_LIST, &grp->data, 0,
- YANG_NOTIFICATION, &grp->notifs, 0,
- YANG_REFERENCE, &grp->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, &grp->flags, YIN_SUBELEM_UNIQUE,
- YANG_TYPEDEF, &grp->typedefs, 0,
- YANG_USES, &grp->data, 0,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ACTION, &grp->actions, 0,
+ LY_STMT_ANYDATA, &grp->data, 0,
+ LY_STMT_ANYXML, &grp->data, 0,
+ LY_STMT_CHOICE, &grp->data, 0,
+ LY_STMT_CONTAINER, &grp->data, 0,
+ LY_STMT_DESCRIPTION, &grp->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_GROUPING, &grp->groupings, 0,
+ LY_STMT_LEAF, &grp->data, 0,
+ LY_STMT_LEAF_LIST, &grp->data, 0,
+ LY_STMT_LIST, &grp->data, 0,
+ LY_STMT_NOTIFICATION, &grp->notifs, 0,
+ LY_STMT_REFERENCE, &grp->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_STATUS, &grp->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_TYPEDEF, &grp->typedefs, 0,
+ LY_STMT_USES, &grp->data, 0,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 16, data, YANG_GROUPING, NULL, &grp->exts);
+ ret = yin_parse_content(ctx, subelems, 16, data, LY_STMT_GROUPING, NULL, &grp->exts);
subelems_deallocator(16, subelems);
LY_CHECK_RET(ret);
@@ -2274,33 +2274,33 @@
cont->parent = node_meta->parent;
/* parse aegument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &cont->name, Y_IDENTIF_ARG, YANG_CONTAINER));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &cont->name, Y_IDENTIF_ARG, LY_STMT_CONTAINER));
/* parse container content */
LY_CHECK_RET(subelems_allocator(ctx, 21, (struct lysp_node *)cont, &subelems,
- YANG_ACTION, &cont->actions, YIN_SUBELEM_VER2,
- YANG_ANYDATA, &cont->child, YIN_SUBELEM_VER2,
- YANG_ANYXML, &cont->child, 0,
- YANG_CHOICE, &cont->child, 0,
- YANG_CONFIG, &cont->flags, YIN_SUBELEM_UNIQUE,
- YANG_CONTAINER, &cont->child, 0,
- YANG_DESCRIPTION, &cont->dsc, YIN_SUBELEM_UNIQUE,
- YANG_GROUPING, &cont->groupings, 0,
- YANG_IF_FEATURE, &cont->iffeatures, 0,
- YANG_LEAF, &cont->child, 0,
- YANG_LEAF_LIST, &cont->child, 0,
- YANG_LIST, &cont->child, 0,
- YANG_MUST, &cont->musts, 0,
- YANG_NOTIFICATION, &cont->notifs, YIN_SUBELEM_VER2,
- YANG_PRESENCE, &cont->presence, YIN_SUBELEM_UNIQUE,
- YANG_REFERENCE, &cont->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, &cont->flags, YIN_SUBELEM_UNIQUE,
- YANG_TYPEDEF, &cont->typedefs, 0,
- YANG_USES, &cont->child, 0,
- YANG_WHEN, &cont->when, YIN_SUBELEM_UNIQUE,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ACTION, &cont->actions, YIN_SUBELEM_VER2,
+ LY_STMT_ANYDATA, &cont->child, YIN_SUBELEM_VER2,
+ LY_STMT_ANYXML, &cont->child, 0,
+ LY_STMT_CHOICE, &cont->child, 0,
+ LY_STMT_CONFIG, &cont->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_CONTAINER, &cont->child, 0,
+ LY_STMT_DESCRIPTION, &cont->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_GROUPING, &cont->groupings, 0,
+ LY_STMT_IF_FEATURE, &cont->iffeatures, 0,
+ LY_STMT_LEAF, &cont->child, 0,
+ LY_STMT_LEAF_LIST, &cont->child, 0,
+ LY_STMT_LIST, &cont->child, 0,
+ LY_STMT_MUST, &cont->musts, 0,
+ LY_STMT_NOTIFICATION, &cont->notifs, YIN_SUBELEM_VER2,
+ LY_STMT_PRESENCE, &cont->presence, YIN_SUBELEM_UNIQUE,
+ LY_STMT_REFERENCE, &cont->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_STATUS, &cont->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_TYPEDEF, &cont->typedefs, 0,
+ LY_STMT_USES, &cont->child, 0,
+ LY_STMT_WHEN, &cont->when, YIN_SUBELEM_UNIQUE,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 21, data, YANG_CONTAINER, NULL, &cont->exts);
+ ret = yin_parse_content(ctx, subelems, 21, data, LY_STMT_CONTAINER, NULL, &cont->exts);
subelems_deallocator(21, subelems);
LY_CHECK_RET(ret);
@@ -2333,26 +2333,26 @@
cas->parent = node_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &cas->name, Y_IDENTIF_ARG, YANG_CASE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &cas->name, Y_IDENTIF_ARG, LY_STMT_CASE));
/* parse case content */
LY_CHECK_RET(subelems_allocator(ctx, 14, (struct lysp_node *)cas, &subelems,
- YANG_ANYDATA, &cas->child, YIN_SUBELEM_VER2,
- YANG_ANYXML, &cas->child, 0,
- YANG_CHOICE, &cas->child, 0,
- YANG_CONTAINER, &cas->child, 0,
- YANG_DESCRIPTION, &cas->dsc, YIN_SUBELEM_UNIQUE,
- YANG_IF_FEATURE, &cas->iffeatures, 0,
- YANG_LEAF, &cas->child, 0,
- YANG_LEAF_LIST, &cas->child, 0,
- YANG_LIST, &cas->child, 0,
- YANG_REFERENCE, &cas->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, &cas->flags, YIN_SUBELEM_UNIQUE,
- YANG_USES, &cas->child, 0,
- YANG_WHEN, &cas->when, YIN_SUBELEM_UNIQUE,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ANYDATA, &cas->child, YIN_SUBELEM_VER2,
+ LY_STMT_ANYXML, &cas->child, 0,
+ LY_STMT_CHOICE, &cas->child, 0,
+ LY_STMT_CONTAINER, &cas->child, 0,
+ LY_STMT_DESCRIPTION, &cas->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_IF_FEATURE, &cas->iffeatures, 0,
+ LY_STMT_LEAF, &cas->child, 0,
+ LY_STMT_LEAF_LIST, &cas->child, 0,
+ LY_STMT_LIST, &cas->child, 0,
+ LY_STMT_REFERENCE, &cas->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_STATUS, &cas->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_USES, &cas->child, 0,
+ LY_STMT_WHEN, &cas->when, YIN_SUBELEM_UNIQUE,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 14, data, YANG_CASE, NULL, &cas->exts);
+ ret = yin_parse_content(ctx, subelems, 14, data, LY_STMT_CASE, NULL, &cas->exts);
subelems_deallocator(14, subelems);
return ret;
@@ -2383,29 +2383,29 @@
choice->parent = node_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &choice->name, Y_IDENTIF_ARG, YANG_CHOICE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &choice->name, Y_IDENTIF_ARG, LY_STMT_CHOICE));
/* parse choice content */
LY_CHECK_RET(subelems_allocator(ctx, 17, (struct lysp_node *)choice, &subelems,
- YANG_ANYDATA, &choice->child, YIN_SUBELEM_VER2,
- YANG_ANYXML, &choice->child, 0,
- YANG_CASE, &choice->child, 0,
- YANG_CHOICE, &choice->child, YIN_SUBELEM_VER2,
- YANG_CONFIG, &choice->flags, YIN_SUBELEM_UNIQUE,
- YANG_CONTAINER, &choice->child, 0,
- YANG_DEFAULT, &choice->dflt, YIN_SUBELEM_UNIQUE,
- YANG_DESCRIPTION, &choice->dsc, YIN_SUBELEM_UNIQUE,
- YANG_IF_FEATURE, &choice->iffeatures, 0,
- YANG_LEAF, &choice->child, 0,
- YANG_LEAF_LIST, &choice->child, 0,
- YANG_LIST, &choice->child, 0,
- YANG_MANDATORY, &choice->flags, YIN_SUBELEM_UNIQUE,
- YANG_REFERENCE, &choice->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, &choice->flags, YIN_SUBELEM_UNIQUE,
- YANG_WHEN, &choice->when, YIN_SUBELEM_UNIQUE,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ANYDATA, &choice->child, YIN_SUBELEM_VER2,
+ LY_STMT_ANYXML, &choice->child, 0,
+ LY_STMT_CASE, &choice->child, 0,
+ LY_STMT_CHOICE, &choice->child, YIN_SUBELEM_VER2,
+ LY_STMT_CONFIG, &choice->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_CONTAINER, &choice->child, 0,
+ LY_STMT_DEFAULT, &choice->dflt, YIN_SUBELEM_UNIQUE,
+ LY_STMT_DESCRIPTION, &choice->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_IF_FEATURE, &choice->iffeatures, 0,
+ LY_STMT_LEAF, &choice->child, 0,
+ LY_STMT_LEAF_LIST, &choice->child, 0,
+ LY_STMT_LIST, &choice->child, 0,
+ LY_STMT_MANDATORY, &choice->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_REFERENCE, &choice->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_STATUS, &choice->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_WHEN, &choice->when, YIN_SUBELEM_UNIQUE,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 17, data, YANG_CHOICE, NULL, &choice->exts);
+ ret = yin_parse_content(ctx, subelems, 17, data, LY_STMT_CHOICE, NULL, &choice->exts);
subelems_deallocator(17, subelems);
return ret;
}
@@ -2422,14 +2422,14 @@
* @return LY_ERR values.
*/
static LY_ERR
-yin_parse_inout(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum yang_keyword inout_kw,
+yin_parse_inout(struct yin_parser_ctx *ctx, struct yin_arg_record *attrs, const char **data, enum ly_stmt inout_kw,
struct inout_meta *inout_meta)
{
LY_ERR ret = LY_SUCCESS;
struct yin_subelement *subelems = NULL;
/* initiate structure */
- inout_meta->inout_p->nodetype = (inout_kw == YANG_INPUT) ? LYS_INPUT : LYS_OUTPUT;
+ inout_meta->inout_p->nodetype = (inout_kw == LY_STMT_INPUT) ? LYS_INPUT : LYS_OUTPUT;
inout_meta->inout_p->parent = inout_meta->parent;
/* check attributes */
@@ -2437,18 +2437,18 @@
/* parser input/output content */
LY_CHECK_RET(subelems_allocator(ctx, 12, (struct lysp_node *)inout_meta->inout_p, &subelems,
- YANG_ANYDATA, &inout_meta->inout_p->data, YIN_SUBELEM_VER2,
- YANG_ANYXML, &inout_meta->inout_p->data, 0,
- YANG_CHOICE, &inout_meta->inout_p->data, 0,
- YANG_CONTAINER, &inout_meta->inout_p->data, 0,
- YANG_GROUPING, &inout_meta->inout_p->groupings, 0,
- YANG_LEAF, &inout_meta->inout_p->data, 0,
- YANG_LEAF_LIST, &inout_meta->inout_p->data, 0,
- YANG_LIST, &inout_meta->inout_p->data, 0,
- YANG_MUST, &inout_meta->inout_p->musts, YIN_SUBELEM_VER2,
- YANG_TYPEDEF, &inout_meta->inout_p->typedefs, 0,
- YANG_USES, &inout_meta->inout_p->data, 0,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ANYDATA, &inout_meta->inout_p->data, YIN_SUBELEM_VER2,
+ LY_STMT_ANYXML, &inout_meta->inout_p->data, 0,
+ LY_STMT_CHOICE, &inout_meta->inout_p->data, 0,
+ LY_STMT_CONTAINER, &inout_meta->inout_p->data, 0,
+ LY_STMT_GROUPING, &inout_meta->inout_p->groupings, 0,
+ LY_STMT_LEAF, &inout_meta->inout_p->data, 0,
+ LY_STMT_LEAF_LIST, &inout_meta->inout_p->data, 0,
+ LY_STMT_LIST, &inout_meta->inout_p->data, 0,
+ LY_STMT_MUST, &inout_meta->inout_p->musts, YIN_SUBELEM_VER2,
+ LY_STMT_TYPEDEF, &inout_meta->inout_p->typedefs, 0,
+ LY_STMT_USES, &inout_meta->inout_p->data, 0,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
ret = yin_parse_content(ctx, subelems, 12, data, inout_kw, NULL, &inout_meta->inout_p->exts);
subelems_deallocator(12, subelems);
@@ -2484,21 +2484,21 @@
act->parent = act_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &act->name, Y_IDENTIF_ARG, YANG_ACTION));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_NAME, &act->name, Y_IDENTIF_ARG, LY_STMT_ACTION));
/* parse content */
LY_CHECK_RET(subelems_allocator(ctx, 9, (struct lysp_node *)act, &subelems,
- YANG_DESCRIPTION, &act->dsc, YIN_SUBELEM_UNIQUE,
- YANG_GROUPING, &act->groupings, 0,
- YANG_IF_FEATURE, &act->iffeatures, 0,
- YANG_INPUT, &act->input, YIN_SUBELEM_UNIQUE,
- YANG_OUTPUT, &act->output, YIN_SUBELEM_UNIQUE,
- YANG_REFERENCE, &act->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, &act->flags, YIN_SUBELEM_UNIQUE,
- YANG_TYPEDEF, &act->typedefs, 0,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_DESCRIPTION, &act->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_GROUPING, &act->groupings, 0,
+ LY_STMT_IF_FEATURE, &act->iffeatures, 0,
+ LY_STMT_INPUT, &act->input, YIN_SUBELEM_UNIQUE,
+ LY_STMT_OUTPUT, &act->output, YIN_SUBELEM_UNIQUE,
+ LY_STMT_REFERENCE, &act->ref, YIN_SUBELEM_UNIQUE,
+ 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, 9, data, YANG_ACTION, NULL, &act->exts));
+ ret = (yin_parse_content(ctx, subelems, 9, data, LY_STMT_ACTION, NULL, &act->exts));
subelems_deallocator(9, subelems);
LY_CHECK_RET(ret);
@@ -2532,30 +2532,30 @@
aug->parent = aug_meta->parent;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_TARGET_NODE, &aug->nodeid, Y_STR_ARG, YANG_AUGMENT));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_TARGET_NODE, &aug->nodeid, Y_STR_ARG, LY_STMT_AUGMENT));
YANG_CHECK_NONEMPTY((struct lys_parser_ctx *)ctx, strlen(aug->nodeid), "augment");
/* parser augment content */
LY_CHECK_RET(subelems_allocator(ctx, 17, (struct lysp_node *)aug, &subelems,
- YANG_ACTION, &aug->actions, YIN_SUBELEM_VER2,
- YANG_ANYDATA, &aug->child, YIN_SUBELEM_VER2,
- YANG_ANYXML, &aug->child, 0,
- YANG_CASE, &aug->child, 0,
- YANG_CHOICE, &aug->child, 0,
- YANG_CONTAINER, &aug->child, 0,
- YANG_DESCRIPTION, &aug->dsc, YIN_SUBELEM_UNIQUE,
- YANG_IF_FEATURE, &aug->iffeatures, 0,
- YANG_LEAF, &aug->child, 0,
- YANG_LEAF_LIST, &aug->child, 0,
- YANG_LIST, &aug->child, 0,
- YANG_NOTIFICATION, &aug->notifs, YIN_SUBELEM_VER2,
- YANG_REFERENCE, &aug->ref, YIN_SUBELEM_UNIQUE,
- YANG_STATUS, &aug->flags, YIN_SUBELEM_UNIQUE,
- YANG_USES, &aug->child, 0,
- YANG_WHEN, &aug->when, YIN_SUBELEM_UNIQUE,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ACTION, &aug->actions, YIN_SUBELEM_VER2,
+ LY_STMT_ANYDATA, &aug->child, YIN_SUBELEM_VER2,
+ LY_STMT_ANYXML, &aug->child, 0,
+ LY_STMT_CASE, &aug->child, 0,
+ LY_STMT_CHOICE, &aug->child, 0,
+ LY_STMT_CONTAINER, &aug->child, 0,
+ LY_STMT_DESCRIPTION, &aug->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_IF_FEATURE, &aug->iffeatures, 0,
+ LY_STMT_LEAF, &aug->child, 0,
+ LY_STMT_LEAF_LIST, &aug->child, 0,
+ LY_STMT_LIST, &aug->child, 0,
+ LY_STMT_NOTIFICATION, &aug->notifs, YIN_SUBELEM_VER2,
+ LY_STMT_REFERENCE, &aug->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_STATUS, &aug->flags, YIN_SUBELEM_UNIQUE,
+ LY_STMT_USES, &aug->child, 0,
+ LY_STMT_WHEN, &aug->when, YIN_SUBELEM_UNIQUE,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 17, data, YANG_AUGMENT, NULL, &aug->exts);
+ ret = yin_parse_content(ctx, subelems, 17, data, LY_STMT_AUGMENT, NULL, &aug->exts);
subelems_deallocator(17, subelems);
LY_CHECK_RET(ret);
@@ -2587,7 +2587,7 @@
struct lysp_deviate_del *d_del = NULL;
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, YANG_DEVIATE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_DEVIATE));
if (strcmp(temp_val, "not-supported") == 0) {
dev_mod = LYS_DEV_NOT_SUPPORTED;
@@ -2609,9 +2609,9 @@
d = calloc(1, sizeof *d);
LY_CHECK_ERR_RET(!d, LOGMEM(ctx->xml_ctx.ctx), LY_EMEM);
struct yin_subelement subelems[1] = {
- {YANG_CUSTOM, NULL, 0}
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
};
- ret = yin_parse_content(ctx, subelems, 1, data, YANG_DEVIATE, NULL, &d->exts);
+ ret = yin_parse_content(ctx, subelems, 1, data, LY_STMT_DEVIATE, NULL, &d->exts);
} else if (dev_mod == LYS_DEV_ADD) {
d_add = calloc(1, sizeof *d_add);
@@ -2620,17 +2620,17 @@
struct minmax_dev_meta min = {&d_add->min, &d_add->flags, &d_add->exts};
struct minmax_dev_meta max = {&d_add->max, &d_add->flags, &d_add->exts};
struct yin_subelement subelems[9] = {
- {YANG_CONFIG, &d_add->flags, YIN_SUBELEM_UNIQUE},
- {YANG_DEFAULT, &d_add->dflts, 0},
- {YANG_MANDATORY, &d_add->flags, YIN_SUBELEM_UNIQUE},
- {YANG_MAX_ELEMENTS, &max, YIN_SUBELEM_UNIQUE},
- {YANG_MIN_ELEMENTS, &min, YIN_SUBELEM_UNIQUE},
- {YANG_MUST, &d_add->musts, 0},
- {YANG_UNIQUE, &d_add->uniques, 0},
- {YANG_UNITS, &d_add->units, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_CONFIG, &d_add->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DEFAULT, &d_add->dflts, 0},
+ {LY_STMT_MANDATORY, &d_add->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MAX_ELEMENTS, &max, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MIN_ELEMENTS, &min, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MUST, &d_add->musts, 0},
+ {LY_STMT_UNIQUE, &d_add->uniques, 0},
+ {LY_STMT_UNITS, &d_add->units, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- ret = yin_parse_content(ctx, subelems, 9, data, YANG_DEVIATE, NULL, &d_add->exts);
+ ret = yin_parse_content(ctx, subelems, 9, data, LY_STMT_DEVIATE, NULL, &d_add->exts);
} else if (dev_mod == LYS_DEV_REPLACE) {
d_rpl = calloc(1, sizeof *d_rpl);
@@ -2639,29 +2639,29 @@
struct minmax_dev_meta min = {&d_rpl->min, &d_rpl->flags, &d_rpl->exts};
struct minmax_dev_meta max = {&d_rpl->max, &d_rpl->flags, &d_rpl->exts};
struct yin_subelement subelems[8] = {
- {YANG_CONFIG, &d_rpl->flags, YIN_SUBELEM_UNIQUE},
- {YANG_DEFAULT, &d_rpl->dflt, YIN_SUBELEM_UNIQUE},
- {YANG_MANDATORY, &d_rpl->flags, YIN_SUBELEM_UNIQUE},
- {YANG_MAX_ELEMENTS, &max, YIN_SUBELEM_UNIQUE},
- {YANG_MIN_ELEMENTS, &min, YIN_SUBELEM_UNIQUE},
- {YANG_TYPE, &d_rpl->type, YIN_SUBELEM_UNIQUE},
- {YANG_UNITS, &d_rpl->units, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_CONFIG, &d_rpl->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DEFAULT, &d_rpl->dflt, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MANDATORY, &d_rpl->flags, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MAX_ELEMENTS, &max, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_MIN_ELEMENTS, &min, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_TYPE, &d_rpl->type, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_UNITS, &d_rpl->units, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- ret = yin_parse_content(ctx, subelems, 8, data, YANG_DEVIATE, NULL, &d_rpl->exts);
+ ret = yin_parse_content(ctx, subelems, 8, data, LY_STMT_DEVIATE, NULL, &d_rpl->exts);
} else {
d_del = calloc(1, sizeof *d_del);
LY_CHECK_ERR_RET(!d_del, LOGMEM(ctx->xml_ctx.ctx), LY_EMEM);
d = (struct lysp_deviate *)d_del;
struct yin_subelement subelems[5] = {
- {YANG_DEFAULT, &d_del->dflts, 0},
- {YANG_MUST, &d_del->musts, 0},
- {YANG_UNIQUE, &d_del->uniques, 0},
- {YANG_UNITS, &d_del->units, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_DEFAULT, &d_del->dflts, 0},
+ {LY_STMT_MUST, &d_del->musts, 0},
+ {LY_STMT_UNIQUE, &d_del->uniques, 0},
+ {LY_STMT_UNITS, &d_del->units, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- ret = yin_parse_content(ctx, subelems, 5, data, YANG_DEVIATE, NULL, &d_del->exts);
+ ret = yin_parse_content(ctx, subelems, 5, data, LY_STMT_DEVIATE, NULL, &d_del->exts);
}
LY_CHECK_GOTO(ret, cleanup);
@@ -2696,15 +2696,15 @@
LY_ARRAY_NEW_RET(ctx->xml_ctx.ctx, *deviations, dev, LY_EMEM);
/* parse argument */
- LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_TARGET_NODE, &dev->nodeid, Y_STR_ARG, YANG_DEVIATION));
+ LY_CHECK_RET(yin_parse_attribute(ctx, attrs, YIN_ARG_TARGET_NODE, &dev->nodeid, Y_STR_ARG, LY_STMT_DEVIATION));
YANG_CHECK_NONEMPTY((struct lys_parser_ctx *)ctx, strlen(dev->nodeid), "deviation");
struct yin_subelement subelems[4] = {
- {YANG_DESCRIPTION, &dev->dsc, YIN_SUBELEM_UNIQUE},
- {YANG_DEVIATE, &dev->deviates, YIN_SUBELEM_MANDATORY},
- {YANG_REFERENCE, &dev->ref, YIN_SUBELEM_UNIQUE},
- {YANG_CUSTOM, NULL, 0},
+ {LY_STMT_DESCRIPTION, &dev->dsc, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DEVIATE, &dev->deviates, YIN_SUBELEM_MANDATORY},
+ {LY_STMT_REFERENCE, &dev->ref, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
};
- return yin_parse_content(ctx, subelems, 4, data, YANG_DEVIATION, NULL, &dev->exts);
+ return yin_parse_content(ctx, subelems, 4, data, LY_STMT_DEVIATION, NULL, &dev->exts);
}
/**
@@ -2715,72 +2715,72 @@
* @return correct LYEXT_SUBSTMT information.
*/
static LYEXT_SUBSTMT
-kw2lyext_substmt(enum yang_keyword kw)
+kw2lyext_substmt(enum ly_stmt kw)
{
switch (kw) {
- case YANG_ARGUMENT:
+ case LY_STMT_ARGUMENT:
return LYEXT_SUBSTMT_ARGUMENT;
- case YANG_BASE:
+ case LY_STMT_BASE:
return LYEXT_SUBSTMT_BASE;
- case YANG_BELONGS_TO:
+ case LY_STMT_BELONGS_TO:
return LYEXT_SUBSTMT_BELONGSTO;
- case YANG_CONTACT:
+ case LY_STMT_CONTACT:
return LYEXT_SUBSTMT_CONTACT;
- case YANG_DEFAULT:
+ case LY_STMT_DEFAULT:
return LYEXT_SUBSTMT_DEFAULT;
- case YANG_DESCRIPTION:
+ case LY_STMT_DESCRIPTION:
return LYEXT_SUBSTMT_DESCRIPTION;
- case YANG_ERROR_APP_TAG:
+ case LY_STMT_ERROR_APP_TAG:
return LYEXT_SUBSTMT_ERRTAG;
- case YANG_ERROR_MESSAGE:
+ case LY_STMT_ERROR_MESSAGE:
return LYEXT_SUBSTMT_ERRMSG;
- case YANG_KEY:
+ case LY_STMT_KEY:
return LYEXT_SUBSTMT_KEY;
- case YANG_NAMESPACE:
+ case LY_STMT_NAMESPACE:
return LYEXT_SUBSTMT_NAMESPACE;
- case YANG_ORGANIZATION:
+ case LY_STMT_ORGANIZATION:
return LYEXT_SUBSTMT_ORGANIZATION;
- case YANG_PATH:
+ case LY_STMT_PATH:
return LYEXT_SUBSTMT_PATH;
- case YANG_PREFIX:
+ case LY_STMT_PREFIX:
return LYEXT_SUBSTMT_PREFIX;
- case YANG_PRESENCE:
+ case LY_STMT_PRESENCE:
return LYEXT_SUBSTMT_PRESENCE;
- case YANG_REFERENCE:
+ case LY_STMT_REFERENCE:
return LYEXT_SUBSTMT_REFERENCE;
- case YANG_REVISION_DATE:
+ case LY_STMT_REVISION_DATE:
return LYEXT_SUBSTMT_REVISIONDATE;
- case YANG_UNITS:
+ case LY_STMT_UNITS:
return LYEXT_SUBSTMT_UNITS;
- case YANG_VALUE:
+ case LY_STMT_VALUE:
return LYEXT_SUBSTMT_VALUE;
- case YANG_YANG_VERSION:
+ case LY_STMT_YANG_VERSION:
return LYEXT_SUBSTMT_VERSION;
- case YANG_MODIFIER:
+ case LY_STMT_MODIFIER:
return LYEXT_SUBSTMT_MODIFIER;
- case YANG_REQUIRE_INSTANCE:
+ case LY_STMT_REQUIRE_INSTANCE:
return LYEXT_SUBSTMT_REQINSTANCE;
- case YANG_YIN_ELEMENT:
+ case LY_STMT_YIN_ELEMENT:
return LYEXT_SUBSTMT_YINELEM;
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
return LYEXT_SUBSTMT_CONFIG;
- case YANG_MANDATORY:
+ case LY_STMT_MANDATORY:
return LYEXT_SUBSTMT_MANDATORY;
- case YANG_ORDERED_BY:
+ case LY_STMT_ORDERED_BY:
return LYEXT_SUBSTMT_ORDEREDBY;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
return LYEXT_SUBSTMT_STATUS;
- case YANG_FRACTION_DIGITS:
+ case LY_STMT_FRACTION_DIGITS:
return LYEXT_SUBSTMT_FRACDIGITS;
- case YANG_MAX_ELEMENTS:
+ case LY_STMT_MAX_ELEMENTS:
return LYEXT_SUBSTMT_MAX;
- case YANG_MIN_ELEMENTS:
+ case LY_STMT_MIN_ELEMENTS:
return LYEXT_SUBSTMT_MIN;
- case YANG_POSITION:
+ case LY_STMT_POSITION:
return LYEXT_SUBSTMT_POSITION;
- case YANG_UNIQUE:
+ case LY_STMT_UNIQUE:
return LYEXT_SUBSTMT_UNIQUE;
- case YANG_IF_FEATURE:
+ case LY_STMT_IF_FEATURE:
return LYEXT_SUBSTMT_IFFEATURE;
default:
return LYEXT_SUBSTMT_SELF;
@@ -2797,52 +2797,52 @@
* @return LY_SUCCESS on success LY_EINT if kw can't be mapped to kw_group, should not happen if called correctly.
*/
static LY_ERR
-kw2kw_group(struct yin_parser_ctx *ctx, enum yang_keyword kw, enum yang_module_stmt *group)
+kw2kw_group(struct yin_parser_ctx *ctx, enum ly_stmt kw, enum yang_module_stmt *group)
{
switch (kw) {
/* module header */
- case YANG_NONE:
- case YANG_NAMESPACE:
- case YANG_PREFIX:
- case YANG_BELONGS_TO:
- case YANG_YANG_VERSION:
+ case LY_STMT_NONE:
+ case LY_STMT_NAMESPACE:
+ case LY_STMT_PREFIX:
+ case LY_STMT_BELONGS_TO:
+ case LY_STMT_YANG_VERSION:
*group = Y_MOD_MODULE_HEADER;
break;
/* linkage */
- case YANG_INCLUDE:
- case YANG_IMPORT:
+ case LY_STMT_INCLUDE:
+ case LY_STMT_IMPORT:
*group = Y_MOD_LINKAGE;
break;
/* meta */
- case YANG_ORGANIZATION:
- case YANG_CONTACT:
- case YANG_DESCRIPTION:
- case YANG_REFERENCE:
+ case LY_STMT_ORGANIZATION:
+ case LY_STMT_CONTACT:
+ case LY_STMT_DESCRIPTION:
+ case LY_STMT_REFERENCE:
*group = Y_MOD_META;
break;
/* revision */
- case YANG_REVISION:
+ case LY_STMT_REVISION:
*group = Y_MOD_REVISION;
break;
/* body */
- case YANG_ANYDATA:
- case YANG_ANYXML:
- case YANG_AUGMENT:
- case YANG_CHOICE:
- case YANG_CONTAINER:
- case YANG_DEVIATION:
- case YANG_EXTENSION:
- case YANG_FEATURE:
- case YANG_GROUPING:
- case YANG_IDENTITY:
- case YANG_LEAF:
- case YANG_LEAF_LIST:
- case YANG_LIST:
- case YANG_NOTIFICATION:
- case YANG_RPC:
- case YANG_TYPEDEF:
- case YANG_USES:
- case YANG_CUSTOM:
+ case LY_STMT_ANYDATA:
+ case LY_STMT_ANYXML:
+ case LY_STMT_AUGMENT:
+ case LY_STMT_CHOICE:
+ case LY_STMT_CONTAINER:
+ case LY_STMT_DEVIATION:
+ case LY_STMT_EXTENSION:
+ case LY_STMT_FEATURE:
+ case LY_STMT_GROUPING:
+ case LY_STMT_IDENTITY:
+ case LY_STMT_LEAF:
+ case LY_STMT_LEAF_LIST:
+ case LY_STMT_LIST:
+ case LY_STMT_NOTIFICATION:
+ case LY_STMT_RPC:
+ case LY_STMT_TYPEDEF:
+ case LY_STMT_USES:
+ case LY_STMT_EXTENSION_INSTANCE:
*group = Y_MOD_BODY;
break;
default:
@@ -2859,15 +2859,15 @@
* @param[in] ctx YIN parser context used for logging.
* @param[in] kw Current keyword.
* @param[in] next_kw Next keyword.
- * @param[in] parrent Identification of parrent element, can be se to to YANG_MODULE of YANG_SUBMODULE,
+ * @param[in] parrent Identification of parrent element, can be se to to LY_STMT_MODULE of LY_STMT_SUBMODULE,
* because relative order is required only in module and submodule sub-elements, used for logging.
*
* @return LY_SUCCESS on success and LY_EVALID if relative order is invalid.
*/
static LY_ERR
-yin_check_relative_order(struct yin_parser_ctx *ctx, enum yang_keyword kw, enum yang_keyword next_kw, enum yang_keyword parrent)
+yin_check_relative_order(struct yin_parser_ctx *ctx, enum ly_stmt kw, enum ly_stmt next_kw, enum ly_stmt parrent)
{
- assert(parrent == YANG_MODULE || parrent == YANG_SUBMODULE);
+ assert(parrent == LY_STMT_MODULE || parrent == LY_STMT_SUBMODULE);
enum yang_module_stmt gr, next_gr;
LY_CHECK_RET(kw2kw_group(ctx, kw, &gr));
@@ -2883,7 +2883,7 @@
LY_ERR
yin_parse_content(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info, signed char subelem_info_size,
- const char **data, enum yang_keyword current_element, const char **text_content, struct lysp_ext_instance **exts)
+ const char **data, enum ly_stmt current_element, const char **text_content, struct lysp_ext_instance **exts)
{
LY_ERR ret = LY_SUCCESS;
char *out = NULL;
@@ -2891,7 +2891,7 @@
size_t out_len = 0, prefix_len, name_len;
int dynamic = 0;
struct yin_arg_record *attrs = NULL;
- enum yang_keyword kw = YANG_NONE, last_kw = YANG_NONE;
+ enum ly_stmt kw = LY_STMT_NONE, last_kw = LY_STMT_NONE;
struct yin_subelement *subelem = NULL;
assert(is_ordered(subelem_info, subelem_info_size));
@@ -2915,7 +2915,7 @@
/* check if this element can be child of current element */
subelem = get_record(kw, subelem_info_size, subelem_info);
if (!subelem) {
- if (current_element == YANG_DEVIATE && isdevsub(kw)) {
+ if (current_element == LY_STMT_DEVIATE && isdevsub(kw)) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INDEV_YIN, ly_stmt2str(kw));
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, name_len, name, ly_stmt2str(current_element));
@@ -2925,7 +2925,7 @@
}
/* relative order is required only in module and submodule sub-elements */
- if (current_element == YANG_MODULE || current_element == YANG_SUBMODULE) {
+ if (current_element == LY_STMT_MODULE || current_element == LY_STMT_SUBMODULE) {
ret = yin_check_relative_order(ctx, last_kw, kw, current_element);
LY_CHECK_GOTO(ret, cleanup);
}
@@ -2954,188 +2954,188 @@
switch (kw) {
/* call responsible function */
- case YANG_CUSTOM:
+ case LY_STMT_EXTENSION_INSTANCE:
ret = yin_parse_extension_instance(ctx, attrs, data, name2fname(name, prefix_len),
len2flen(name_len, prefix_len),
kw2lyext_substmt(current_element),
(subelem->dest) ? *((uint32_t*)subelem->dest) : 0, exts);
break;
- case YANG_ACTION:
- case YANG_RPC:
+ case LY_STMT_ACTION:
+ case LY_STMT_RPC:
ret = yin_parse_action(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_ANYDATA:
- case YANG_ANYXML:
+ case LY_STMT_ANYDATA:
+ case LY_STMT_ANYXML:
ret = yin_parse_any(ctx, attrs, data, kw, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_ARGUMENT:
+ case LY_STMT_ARGUMENT:
ret = yin_parse_argument(ctx, attrs, data, (struct yin_argument_meta *)subelem->dest, exts);
break;
- case YANG_AUGMENT:
+ case LY_STMT_AUGMENT:
ret = yin_parse_augment(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_BASE:
+ case LY_STMT_BASE:
ret = yin_parse_base(ctx, attrs, data, current_element, subelem->dest, exts);
break;
- case YANG_BELONGS_TO:
+ case LY_STMT_BELONGS_TO:
ret = yin_parse_belongs_to(ctx, attrs, data, (struct lysp_submodule *)subelem->dest, exts);
break;
- case YANG_BIT:
+ case LY_STMT_BIT:
ret = yin_parse_bit(ctx, attrs, data, (struct lysp_type *)subelem->dest);
break;
- case YANG_CASE:
+ case LY_STMT_CASE:
ret = yin_parse_case(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_CHOICE:
+ case LY_STMT_CHOICE:
ret = yin_parse_choice(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_CONFIG:
+ case LY_STMT_CONFIG:
ret = yin_parse_config(ctx, attrs, data, (uint16_t *)subelem->dest, exts);
break;
- case YANG_CONTACT:
- case YANG_DESCRIPTION:
- case YANG_ORGANIZATION:
- case YANG_REFERENCE:
+ case LY_STMT_CONTACT:
+ case LY_STMT_DESCRIPTION:
+ case LY_STMT_ORGANIZATION:
+ case LY_STMT_REFERENCE:
ret = yin_parse_meta(ctx, attrs, data, kw, (const char **)subelem->dest, exts);
break;
- case YANG_CONTAINER:
+ case LY_STMT_CONTAINER:
ret = yin_parse_container(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_DEFAULT:
- case YANG_ERROR_APP_TAG:
- case YANG_KEY:
- case YANG_PRESENCE:
+ case LY_STMT_DEFAULT:
+ case LY_STMT_ERROR_APP_TAG:
+ case LY_STMT_KEY:
+ case LY_STMT_PRESENCE:
ret = yin_parse_simple_elem(ctx, attrs, data, kw, subelem, YIN_ARG_VALUE, Y_STR_ARG, exts);
break;
- case YANG_DEVIATE:
+ case LY_STMT_DEVIATE:
ret = yin_parse_deviate(ctx, attrs, data, (struct lysp_deviate **)subelem->dest);
break;
- case YANG_DEVIATION:
+ case LY_STMT_DEVIATION:
ret = yin_parse_deviation(ctx, attrs, data, (struct lysp_deviation **)subelem->dest);
break;
- case YANG_ENUM:
+ case LY_STMT_ENUM:
ret = yin_parse_enum(ctx, attrs, data, (struct lysp_type *)subelem->dest);
break;
- case YANG_ERROR_MESSAGE:
+ case LY_STMT_ERROR_MESSAGE:
ret = yin_parse_err_msg(ctx, attrs, data, (const char **)subelem->dest, exts);
break;
- case YANG_EXTENSION:
+ case LY_STMT_EXTENSION:
ret = yin_parse_extension(ctx, attrs, data, (struct lysp_ext **)subelem->dest);
break;
- case YANG_FEATURE:
+ case LY_STMT_FEATURE:
ret = yin_parse_feature(ctx, attrs, data, (struct lysp_feature **)subelem->dest);
break;
- case YANG_FRACTION_DIGITS:
+ case LY_STMT_FRACTION_DIGITS:
ret = yin_parse_fracdigits(ctx, attrs, data, (struct lysp_type *)subelem->dest);
break;
- case YANG_GROUPING:
+ case LY_STMT_GROUPING:
ret = yin_parse_grouping(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_IDENTITY:
+ case LY_STMT_IDENTITY:
ret = yin_parse_identity(ctx, attrs, data, (struct lysp_ident **)subelem->dest);
break;
- case YANG_IF_FEATURE:
- case YANG_UNITS:
+ case LY_STMT_IF_FEATURE:
+ case LY_STMT_UNITS:
ret = yin_parse_simple_elem(ctx, attrs, data, kw, subelem, YIN_ARG_NAME, Y_STR_ARG, exts);
break;
- case YANG_IMPORT:
+ case LY_STMT_IMPORT:
ret = yin_parse_import(ctx, attrs, data, (struct import_meta *)subelem->dest);
break;
- case YANG_INCLUDE:
+ case LY_STMT_INCLUDE:
ret = yin_parse_include(ctx, attrs, data, (struct include_meta *)subelem->dest);
break;
- case YANG_INPUT:
- case YANG_OUTPUT:
+ case LY_STMT_INPUT:
+ case LY_STMT_OUTPUT:
ret = yin_parse_inout(ctx, attrs, data, kw, (struct inout_meta *)subelem->dest);
break;
- case YANG_LEAF:
+ case LY_STMT_LEAF:
ret = yin_parse_leaf(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_LEAF_LIST:
+ case LY_STMT_LEAF_LIST:
ret = yin_parse_leaflist(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_LENGTH:
+ case LY_STMT_LENGTH:
ret = yin_parse_length(ctx, attrs, data, (struct lysp_type *)subelem->dest);
break;
- case YANG_LIST:
+ case LY_STMT_LIST:
ret = yin_parse_list(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_MANDATORY:
+ case LY_STMT_MANDATORY:
ret = yin_parse_mandatory(ctx, attrs, data, (uint16_t *)subelem->dest, exts);
break;
- case YANG_MAX_ELEMENTS:
- case YANG_MIN_ELEMENTS:
+ case LY_STMT_MAX_ELEMENTS:
+ case LY_STMT_MIN_ELEMENTS:
ret = yin_parse_minmax(ctx, attrs, data, current_element, kw, subelem->dest);
break;
- case YANG_MODIFIER:
+ case LY_STMT_MODIFIER:
ret = yin_parse_modifier(ctx, attrs, data, (const char **)subelem->dest, exts);
break;
- case YANG_MUST:
+ case LY_STMT_MUST:
ret = yin_parse_must(ctx, attrs, data, (struct lysp_restr **)subelem->dest);
break;
- case YANG_NAMESPACE:
+ case LY_STMT_NAMESPACE:
ret = yin_parse_simple_elem(ctx, attrs, data, kw, subelem, YIN_ARG_URI, Y_STR_ARG, exts);
break;
- case YANG_NOTIFICATION:
+ case LY_STMT_NOTIFICATION:
ret = yin_parse_notification(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_ORDERED_BY:
+ case LY_STMT_ORDERED_BY:
ret = yin_parse_orderedby(ctx, attrs, data, (uint16_t *)subelem->dest, exts);
break;
- case YANG_PATH:
+ case LY_STMT_PATH:
ret = yin_parse_path(ctx, attrs, data, kw, (struct lysp_type *)subelem->dest);
break;
- case YANG_PATTERN:
+ case LY_STMT_PATTERN:
ret = yin_parse_pattern(ctx, attrs, data, (struct lysp_type *)subelem->dest);
break;
- case YANG_VALUE:
- case YANG_POSITION:
+ case LY_STMT_VALUE:
+ case LY_STMT_POSITION:
ret = yin_parse_value_pos(ctx, attrs, data, kw, (struct lysp_type_enum *)subelem->dest);
break;
- case YANG_PREFIX:
+ case LY_STMT_PREFIX:
ret = yin_parse_simple_elem(ctx, attrs, data, kw, subelem, YIN_ARG_VALUE, Y_IDENTIF_ARG, exts);
break;
- case YANG_RANGE:
+ case LY_STMT_RANGE:
ret = yin_parse_range(ctx, attrs, data, (struct lysp_type *)subelem->dest);
break;
- case YANG_REFINE:
+ case LY_STMT_REFINE:
ret = yin_parse_refine(ctx, attrs, data, (struct lysp_refine **)subelem->dest);
break;
- case YANG_REQUIRE_INSTANCE:
+ case LY_STMT_REQUIRE_INSTANCE:
ret = yin_pasrse_reqinstance(ctx, attrs, data, (struct lysp_type *)subelem->dest);
break;
- case YANG_REVISION:
+ case LY_STMT_REVISION:
ret = yin_parse_revision(ctx, attrs, data, (struct lysp_revision **)subelem->dest);
break;
- case YANG_REVISION_DATE:
+ case LY_STMT_REVISION_DATE:
ret = yin_parse_revision_date(ctx, attrs, data, (char *)subelem->dest, exts);
break;
- case YANG_STATUS:
+ case LY_STMT_STATUS:
ret = yin_parse_status(ctx, attrs, data, (uint16_t *)subelem->dest, exts);
break;
- case YANG_TYPE:
+ case LY_STMT_TYPE:
ret = yin_parse_type(ctx, attrs, data, current_element, subelem);
break;
- case YANG_TYPEDEF:
+ case LY_STMT_TYPEDEF:
ret = yin_parse_typedef(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_UNIQUE:
+ case LY_STMT_UNIQUE:
ret = yin_parse_simple_elem(ctx, attrs, data, kw, subelem, YIN_ARG_TAG, Y_STR_ARG, exts);
break;
- case YANG_USES:
+ case LY_STMT_USES:
ret = yin_parse_uses(ctx, attrs, data, (struct tree_node_meta *)subelem->dest);
break;
- case YANG_WHEN:
+ case LY_STMT_WHEN:
ret = yin_parse_when(ctx, attrs, data, (struct lysp_when **)subelem->dest);
break;
- case YANG_YANG_VERSION:
+ case LY_STMT_YANG_VERSION:
ret = yin_parse_yangversion(ctx, attrs, data, (uint8_t *)subelem->dest, exts);
break;
- case YANG_YIN_ELEMENT:
+ case LY_STMT_YIN_ELEMENT:
ret = yin_parse_yin_element(ctx, attrs, data, (uint16_t *)subelem->dest, exts);
break;
- case YIN_TEXT:
- case YIN_VALUE:
+ case LY_STMT_ARG_TEXT:
+ case LY_STMT_ARG_VALUE:
ret = yin_parse_content(ctx, NULL, 0, data, kw, (const char **)subelem->dest, NULL);
break;
default:
@@ -3339,39 +3339,39 @@
LY_ERR ret = LY_SUCCESS;
struct yin_subelement *subelems = NULL;
- LY_CHECK_RET(yin_parse_attribute(ctx, mod_attrs, YIN_ARG_NAME, &mod->mod->name, Y_IDENTIF_ARG, YANG_MODULE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, mod_attrs, YIN_ARG_NAME, &mod->mod->name, Y_IDENTIF_ARG, LY_STMT_MODULE));
LY_CHECK_RET(subelems_allocator(ctx, 28, NULL, &subelems,
- YANG_ANYDATA, &mod->data, YIN_SUBELEM_VER2,
- YANG_ANYXML, &mod->data, 0,
- YANG_AUGMENT, &mod->augments, 0,
- YANG_CHOICE, &mod->data, 0,
- YANG_CONTACT, &mod->mod->contact, YIN_SUBELEM_UNIQUE,
- YANG_CONTAINER, &mod->data, 0,
- YANG_DESCRIPTION, &mod->mod->dsc, YIN_SUBELEM_UNIQUE,
- YANG_DEVIATION, &mod->deviations, 0,
- YANG_EXTENSION, &mod->extensions, 0,
- YANG_FEATURE, &mod->features, 0,
- YANG_GROUPING, &mod->groupings, 0,
- YANG_IDENTITY, &mod->identities, 0,
- YANG_IMPORT, mod->mod->prefix, &mod->imports, 0,
- YANG_INCLUDE, mod->mod->name, &mod->includes, 0,
- YANG_LEAF, &mod->data, 0,
- YANG_LEAF_LIST, &mod->data, 0,
- YANG_LIST, &mod->data, 0,
- YANG_NAMESPACE, &mod->mod->ns, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
- YANG_NOTIFICATION, &mod->notifs, 0,
- YANG_ORGANIZATION, &mod->mod->org, YIN_SUBELEM_UNIQUE,
- YANG_PREFIX, &mod->mod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
- YANG_REFERENCE, &mod->mod->ref, YIN_SUBELEM_UNIQUE,
- YANG_REVISION, &mod->revs, 0,
- YANG_RPC, &mod->rpcs, 0,
- YANG_TYPEDEF, &mod->typedefs, 0,
- YANG_USES, &mod->data, 0,
- YANG_YANG_VERSION, &mod->mod->version, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ANYDATA, &mod->data, YIN_SUBELEM_VER2,
+ LY_STMT_ANYXML, &mod->data, 0,
+ LY_STMT_AUGMENT, &mod->augments, 0,
+ LY_STMT_CHOICE, &mod->data, 0,
+ LY_STMT_CONTACT, &mod->mod->contact, YIN_SUBELEM_UNIQUE,
+ LY_STMT_CONTAINER, &mod->data, 0,
+ LY_STMT_DESCRIPTION, &mod->mod->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_DEVIATION, &mod->deviations, 0,
+ LY_STMT_EXTENSION, &mod->extensions, 0,
+ LY_STMT_FEATURE, &mod->features, 0,
+ LY_STMT_GROUPING, &mod->groupings, 0,
+ LY_STMT_IDENTITY, &mod->identities, 0,
+ LY_STMT_IMPORT, mod->mod->prefix, &mod->imports, 0,
+ LY_STMT_INCLUDE, mod->mod->name, &mod->includes, 0,
+ LY_STMT_LEAF, &mod->data, 0,
+ LY_STMT_LEAF_LIST, &mod->data, 0,
+ LY_STMT_LIST, &mod->data, 0,
+ LY_STMT_NAMESPACE, &mod->mod->ns, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+ LY_STMT_NOTIFICATION, &mod->notifs, 0,
+ LY_STMT_ORGANIZATION, &mod->mod->org, YIN_SUBELEM_UNIQUE,
+ LY_STMT_PREFIX, &mod->mod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+ LY_STMT_REFERENCE, &mod->mod->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_REVISION, &mod->revs, 0,
+ LY_STMT_RPC, &mod->rpcs, 0,
+ LY_STMT_TYPEDEF, &mod->typedefs, 0,
+ LY_STMT_USES, &mod->data, 0,
+ LY_STMT_YANG_VERSION, &mod->mod->version, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 28, data, YANG_MODULE, NULL, &mod->exts);
+ ret = yin_parse_content(ctx, subelems, 28, data, LY_STMT_MODULE, NULL, &mod->exts);
subelems_deallocator(28, subelems);
return ret;
@@ -3383,38 +3383,38 @@
LY_ERR ret = LY_SUCCESS;
struct yin_subelement *subelems = NULL;
- LY_CHECK_RET(yin_parse_attribute(ctx, mod_attrs, YIN_ARG_NAME, &submod->name, Y_IDENTIF_ARG, YANG_SUBMODULE));
+ LY_CHECK_RET(yin_parse_attribute(ctx, mod_attrs, YIN_ARG_NAME, &submod->name, Y_IDENTIF_ARG, LY_STMT_SUBMODULE));
LY_CHECK_RET(subelems_allocator(ctx, 27, NULL, &subelems,
- YANG_ANYDATA, &submod->data, YIN_SUBELEM_VER2,
- YANG_ANYXML, &submod->data, 0,
- YANG_AUGMENT, &submod->augments, 0,
- YANG_BELONGS_TO, submod, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
- YANG_CHOICE, &submod->data, 0,
- YANG_CONTACT, &submod->contact, YIN_SUBELEM_UNIQUE,
- YANG_CONTAINER, &submod->data, 0,
- YANG_DESCRIPTION, &submod->dsc, YIN_SUBELEM_UNIQUE,
- YANG_DEVIATION, &submod->deviations, 0,
- YANG_EXTENSION, &submod->extensions, 0,
- YANG_FEATURE, &submod->features, 0,
- YANG_GROUPING, &submod->groupings, 0,
- YANG_IDENTITY, &submod->identities, 0,
- YANG_IMPORT, submod->prefix, &submod->imports, 0,
- YANG_INCLUDE, submod->name, &submod->includes, 0,
- YANG_LEAF, &submod->data, 0,
- YANG_LEAF_LIST, &submod->data, 0,
- YANG_LIST, &submod->data, 0,
- YANG_NOTIFICATION, &submod->notifs, 0,
- YANG_ORGANIZATION, &submod->org, YIN_SUBELEM_UNIQUE,
- YANG_REFERENCE, &submod->ref, YIN_SUBELEM_UNIQUE,
- YANG_REVISION, &submod->revs, 0,
- YANG_RPC, &submod->rpcs, 0,
- YANG_TYPEDEF, &submod->typedefs, 0,
- YANG_USES, &submod->data, 0,
- YANG_YANG_VERSION, &submod->version, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
- YANG_CUSTOM, NULL, 0
+ LY_STMT_ANYDATA, &submod->data, YIN_SUBELEM_VER2,
+ LY_STMT_ANYXML, &submod->data, 0,
+ LY_STMT_AUGMENT, &submod->augments, 0,
+ LY_STMT_BELONGS_TO, submod, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+ LY_STMT_CHOICE, &submod->data, 0,
+ LY_STMT_CONTACT, &submod->contact, YIN_SUBELEM_UNIQUE,
+ LY_STMT_CONTAINER, &submod->data, 0,
+ LY_STMT_DESCRIPTION, &submod->dsc, YIN_SUBELEM_UNIQUE,
+ LY_STMT_DEVIATION, &submod->deviations, 0,
+ LY_STMT_EXTENSION, &submod->extensions, 0,
+ LY_STMT_FEATURE, &submod->features, 0,
+ LY_STMT_GROUPING, &submod->groupings, 0,
+ LY_STMT_IDENTITY, &submod->identities, 0,
+ LY_STMT_IMPORT, submod->prefix, &submod->imports, 0,
+ LY_STMT_INCLUDE, submod->name, &submod->includes, 0,
+ LY_STMT_LEAF, &submod->data, 0,
+ LY_STMT_LEAF_LIST, &submod->data, 0,
+ LY_STMT_LIST, &submod->data, 0,
+ LY_STMT_NOTIFICATION, &submod->notifs, 0,
+ LY_STMT_ORGANIZATION, &submod->org, YIN_SUBELEM_UNIQUE,
+ LY_STMT_REFERENCE, &submod->ref, YIN_SUBELEM_UNIQUE,
+ LY_STMT_REVISION, &submod->revs, 0,
+ LY_STMT_RPC, &submod->rpcs, 0,
+ LY_STMT_TYPEDEF, &submod->typedefs, 0,
+ LY_STMT_USES, &submod->data, 0,
+ LY_STMT_YANG_VERSION, &submod->version, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+ LY_STMT_EXTENSION_INSTANCE, NULL, 0
));
- ret = yin_parse_content(ctx, subelems, 27, data, YANG_SUBMODULE, NULL, &submod->exts);
+ ret = yin_parse_content(ctx, subelems, 27, data, LY_STMT_SUBMODULE, NULL, &submod->exts);
subelems_deallocator(27, subelems);
return ret;
@@ -3423,7 +3423,7 @@
LY_ERR
yin_parse_submodule(struct yin_parser_ctx **yin_ctx, struct ly_ctx *ctx, struct lys_parser_ctx *main_ctx, const char *data, struct lysp_submodule **submod)
{
- enum yang_keyword kw = YANG_NONE;
+ enum ly_stmt kw = LY_STMT_NONE;
LY_ERR ret = LY_SUCCESS;
const char *prefix, *name;
size_t prefix_len, name_len;
@@ -3445,13 +3445,13 @@
LY_CHECK_GOTO(ret, cleanup);
ret = yin_load_attributes(*yin_ctx, &data, &attrs);
LY_CHECK_GOTO(ret, cleanup);
- kw = yin_match_keyword(*yin_ctx, name, name_len, prefix, prefix_len, YANG_NONE);
+ kw = yin_match_keyword(*yin_ctx, name, name_len, prefix, prefix_len, LY_STMT_NONE);
- if (kw == YANG_MODULE) {
+ if (kw == LY_STMT_MODULE) {
LOGERR(ctx, LY_EDENIED, "Input data contains module in situation when a submodule is expected.");
ret = LY_EINVAL;
goto cleanup;
- } else if (kw != YANG_SUBMODULE) {
+ } else if (kw != LY_STMT_SUBMODULE) {
LOGVAL_PARSER((struct lys_parser_ctx *)*yin_ctx, LY_VCODE_MOD_SUBOMD, ly_stmt2str(kw));
ret = LY_EVALID;
goto cleanup;
@@ -3493,7 +3493,7 @@
yin_parse_module(struct yin_parser_ctx **yin_ctx, const char *data, struct lys_module *mod)
{
LY_ERR ret = LY_SUCCESS;
- enum yang_keyword kw = YANG_NONE;
+ enum ly_stmt kw = LY_STMT_NONE;
struct lysp_module *mod_p = NULL;
const char *prefix, *name;
size_t prefix_len, name_len;
@@ -3510,12 +3510,12 @@
LY_CHECK_GOTO(ret, cleanup);
ret = yin_load_attributes(*yin_ctx, &data, &attrs);
LY_CHECK_GOTO(ret, cleanup);
- kw = yin_match_keyword(*yin_ctx, name, name_len, prefix, prefix_len, YANG_NONE);
- if (kw == YANG_SUBMODULE) {
+ kw = yin_match_keyword(*yin_ctx, name, name_len, prefix, prefix_len, LY_STMT_NONE);
+ if (kw == LY_STMT_SUBMODULE) {
LOGERR(mod->ctx, LY_EDENIED, "Input data contains submodule which cannot be parsed directly without its main module.");
ret = LY_EINVAL;
goto cleanup;
- } else if (kw != YANG_MODULE) {
+ } else if (kw != LY_STMT_MODULE) {
LOGVAL_PARSER((struct lys_parser_ctx *)*yin_ctx, LY_VCODE_MOD_SUBOMD, ly_stmt2str(kw));
ret = LY_EVALID;
goto cleanup;
diff --git a/src/parser_yin.h b/src/parser_yin.h
index 7bf278a..1f26eb5 100644
--- a/src/parser_yin.h
+++ b/src/parser_yin.h
@@ -53,10 +53,10 @@
#define VALID_VALS4 " Valid values are \"%s\", \"%s\", \"%s\" and \"%s\"."
/* shortcut to determin if keyword can in general be subelement of deviation regardles of it's type */
-#define isdevsub(kw) (kw == YANG_CONFIG || kw == YANG_DEFAULT || kw == YANG_MANDATORY || \
- kw == YANG_MAX_ELEMENTS || kw == YANG_MIN_ELEMENTS || \
- kw == YANG_MUST || kw == YANG_TYPE || kw == YANG_UNIQUE || \
- kw == YANG_UNITS || kw == YANG_CUSTOM)
+#define isdevsub(kw) (kw == LY_STMT_CONFIG || kw == LY_STMT_DEFAULT || kw == LY_STMT_MANDATORY || \
+ kw == LY_STMT_MAX_ELEMENTS || kw == LY_STMT_MIN_ELEMENTS || \
+ kw == LY_STMT_MUST || kw == LY_STMT_TYPE || kw == LY_STMT_UNIQUE || \
+ kw == LY_STMT_UNITS || kw == LY_STMT_EXTENSION_INSTANCE)
/**
* @brief insert string into dictionary and store as target.
@@ -108,7 +108,7 @@
time to simply check validity of given constraints */
struct yin_subelement {
- enum yang_keyword type; /**< type of keyword */
+ enum ly_stmt type; /**< type of keyword */
void *dest; /**< meta infromation passed to responsible function (mostly information about where parsed subelement should be stored) */
uint8_t flags; /**< describes constraints of subelement can be set to YIN_SUBELEM_MANDATORY, YIN_SUBELEM_UNIQUE, YIN_SUBELEM_FIRST and YIN_SUBELEM_VER2 */
};
@@ -187,7 +187,7 @@
* @return LY_ERR values.
*/
LY_ERR yin_parse_content(struct yin_parser_ctx *ctx, struct yin_subelement *subelem_info, signed char subelem_info_size,
- const char **data, enum yang_keyword current_element, const char **text_content,
+ const char **data, enum ly_stmt current_element, const char **text_content,
struct lysp_ext_instance **exts);
/**
@@ -211,12 +211,12 @@
* @param[in] name_len Lenght of keyword name.
* @param[in] prefix Start of keyword prefix.
* @param[in] prefix_len Lenght of prefix.
- * @param[in] parrent Identification of parrent element, use YANG_NONE for elements without parrent.
+ * @param[in] parrent Identification of parrent element, use LY_STMT_NONE for elements without parrent.
*
* @return yang_keyword values.
*/
-enum yang_keyword yin_match_keyword(struct yin_parser_ctx *ctx, const char *name, size_t name_len,
- const char *prefix, size_t prefix_len, enum yang_keyword parrent);
+enum ly_stmt yin_match_keyword(struct yin_parser_ctx *ctx, const char *name, size_t name_len,
+ const char *prefix, size_t prefix_len, enum ly_stmt parrent);
/**
* @brief Load all attributes of element into ([sized array](@ref sizedarrays)). Caller is suposed to free the array.
diff --git a/src/plugins_exts.c b/src/plugins_exts.c
index 720f828..6fbe719 100644
--- a/src/plugins_exts.c
+++ b/src/plugins_exts.c
@@ -16,15 +16,17 @@
#include "plugins_exts.h"
#include "plugins_exts_nacm.c"
+#include "plugins_exts_metadata.c"
/**
* @brief list of all extension plugins implemented internally
*/
-struct lyext_plugins_list lyext_plugins_internal[5] = {
+struct lyext_plugins_list lyext_plugins_internal[6] = {
{"ietf-netconf-acm", "2012-02-22", "default-deny-write", &nacm_plugin},
{"ietf-netconf-acm", "2018-02-14", "default-deny-write", &nacm_plugin},
{"ietf-netconf-acm", "2012-02-22", "default-deny-all", &nacm_plugin},
{"ietf-netconf-acm", "2018-02-14", "default-deny-all", &nacm_plugin},
+ {"ietf-yang-metadata", "2016-08-05", "annotation", &metadata_plugin},
{NULL, NULL, NULL, NULL} /* terminating item */
};
diff --git a/src/plugins_exts.h b/src/plugins_exts.h
index 6684d6a..6e81c94 100644
--- a/src/plugins_exts.h
+++ b/src/plugins_exts.h
@@ -74,6 +74,35 @@
};
/**
+ * @brief Possible cardinalities of the YANG statements.
+ *
+ * Used in extensions plugins to define cardinalities of the extension instance substatements.
+ */
+enum ly_stmt_cardinality {
+ LY_STMT_CARD_OPT, /* 0..1 */
+ LY_STMT_CARD_MAND, /* 1 */
+ LY_STMT_CARD_SOME, /* 1..n */
+ LY_STMT_CARD_ANY /* 0..n */
+};
+
+/**
+ * @brief Description of the extension instance substatements.
+ *
+ * Provided by extensions plugins to libyang's lyext_compile_stmts() to be able to correctly compile the content of extension instances.
+ */
+struct lysc_ext_substmt {
+ enum ly_stmt stmt; /**< allowed substatement */
+ enum ly_stmt_cardinality cardinality; /**< cardinality of the substatement */
+ void *storage; /**< pointer to the storage of the compiled statement according to the specific
+ lysc_ext_substmt::stmt and lysc_ext_substmt::cardinality */
+};
+
+/**
+ * @brief Compile substatements of an extension instance.
+ */
+LY_ERR lys_compile_extension_instance(struct lysc_ctx *ctx, const struct lysp_ext_instance *ext, struct lysc_ext_substmt *substmts);
+
+/**
* @brief Update path in the compile context, which is used for logging where the compilation failed.
*
* @param[in] ctx Compile context with the path.
diff --git a/src/plugins_exts_metadata.c b/src/plugins_exts_metadata.c
new file mode 100644
index 0000000..d2e9dca
--- /dev/null
+++ b/src/plugins_exts_metadata.c
@@ -0,0 +1,91 @@
+/**
+ * @file plugins_exts_nacm.c
+ * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @brief libyang extension plugin - Metadata (RFC 7952)
+ *
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * https://opensource.org/licenses/BSD-3-Clause
+ */
+#include "common.h"
+
+#include <stdlib.h>
+
+#include "plugins_exts.h"
+#include "tree_schema.h"
+#include "plugins_exts_metadata.h"
+
+/**
+ * @brief Storage for ID used to check plugin API version compatibility.
+ * Ignored here in the internal plugin.
+LYEXT_VERSION_CHECK
+ */
+
+/**
+ * @brief Compile annotation extension instances.
+ *
+ * Implementation of lyext_clb_compile callback set as lyext_plugin::compile.
+ */
+LY_ERR
+annotation_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *p_ext, struct lysc_ext_instance *c_ext)
+{
+ struct lyext_metadata *annotation;
+ struct lysc_module *mod_c;
+ struct lysp_stmt *stmt;
+ unsigned int u;
+ struct lysc_ext_substmt annotation_substmt[7] = {
+ {LY_STMT_IF_FEATURE, LY_STMT_CARD_ANY, NULL},
+ {LY_STMT_TYPE, LY_STMT_CARD_MAND, NULL},
+ {LY_STMT_UNITS, LY_STMT_CARD_OPT, NULL},
+ {LY_STMT_STATUS, LY_STMT_CARD_OPT, NULL},
+ {LY_STMT_DESCRIPTION, LY_STMT_CARD_OPT, NULL},
+ {LY_STMT_REFERENCE, LY_STMT_CARD_OPT, NULL},
+ {0, 0, 0} /* terminating item */
+ };
+
+ /* annotations can appear only at the top level of a YANG module or submodule */
+ if (c_ext->parent_type != LYEXT_PAR_MODULE) {
+ lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path, "Extension %s is allowed only at the top level of a YANG module or submodule, but it is placed in \"%s\" statement.",
+ p_ext->name, lyext_parent2str(c_ext->parent_type));
+ return LY_EVALID;
+ }
+
+ mod_c = (struct lysc_module *)c_ext->parent;
+
+ /* check for duplication */
+ LY_ARRAY_FOR(mod_c->exts, u) {
+ if (&mod_c->exts[u] != c_ext && mod_c->exts[u].def == c_ext->def) {
+ /* duplication of a annotation extension in a single module */
+ lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path, "Extension %s is instantiated multiple times.", p_ext->name);
+ return LY_EVALID;
+ }
+ }
+
+ /* compile annotation substatements */
+ c_ext->data = annotation = calloc(1, sizeof *annotation);
+ LY_CHECK_RET(annotation, LY_EMEM);
+ annotation_substmt[0].storage = &annotation->iffeatures;
+ annotation_substmt[1].storage = &annotation->type;
+ annotation_substmt[2].storage = &annotation->units;
+ annotation_substmt[3].storage = &annotation->flags;
+ /* description and reference are allowed, but not compiled */
+
+ LY_CHECK_RET(lys_compile_extension_instance(cctx, p_ext, annotation_substmt));
+
+ return LY_SUCCESS;
+}
+
+
+/**
+ * @brief Plugin for the Metadata's annotation extension
+ */
+struct lyext_plugin metadata_plugin = {
+ .id = "libyang 2 - metadata, version 1",
+ .compile = &annotation_compile,
+ .validate = NULL,
+ .free = NULL
+};
diff --git a/src/plugins_exts_metadata.h b/src/plugins_exts_metadata.h
new file mode 100644
index 0000000..653a5f1
--- /dev/null
+++ b/src/plugins_exts_metadata.h
@@ -0,0 +1,39 @@
+/**
+ * @file plugins_exts_metadata.h
+ * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @brief ietf-yang-metadata API
+ *
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * https://opensource.org/licenses/BSD-3-Clause
+ */
+
+#ifndef LY_PLUGINS_EXTS_METADATA_H_
+#define LY_PLUGINS_EXTS_METADATA_H_
+
+#include "tree_schema.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Representation of the compiled metadata substatements as provided by libyang 2 metadata extension plugin.
+ */
+struct lyext_metadata {
+ struct lysc_type *type; /**< type of the metadata (mandatory) */
+ const char *units; /**< units of the leaf's type */
+ struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
+ uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
+};
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LY_PLUGINS_EXTS_METADATA_H_ */
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 4a3dbec..eeb0fd7 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -162,6 +162,89 @@
#define LYS_AUGMENT 0x2000
/**
+ * @brief List of YANG statements
+ */
+enum ly_stmt {
+ LY_STMT_NONE = 0,
+ LY_STMT_ACTION,
+ LY_STMT_ANYDATA,
+ LY_STMT_ANYXML,
+ LY_STMT_ARGUMENT,
+ LY_STMT_AUGMENT,
+ LY_STMT_BASE,
+ LY_STMT_BELONGS_TO,
+ LY_STMT_BIT,
+ LY_STMT_CASE,
+ LY_STMT_CHOICE,
+ LY_STMT_CONFIG,
+ LY_STMT_CONTACT,
+ LY_STMT_CONTAINER,
+ LY_STMT_DEFAULT,
+ LY_STMT_DESCRIPTION,
+ LY_STMT_DEVIATE,
+ LY_STMT_DEVIATION,
+ LY_STMT_ENUM,
+ LY_STMT_ERROR_APP_TAG,
+ LY_STMT_ERROR_MESSAGE,
+ LY_STMT_EXTENSION,
+ LY_STMT_FEATURE,
+ LY_STMT_FRACTION_DIGITS,
+ LY_STMT_GROUPING,
+ LY_STMT_IDENTITY,
+ LY_STMT_IF_FEATURE,
+ LY_STMT_IMPORT,
+ LY_STMT_INCLUDE,
+ LY_STMT_INPUT,
+ LY_STMT_KEY,
+ LY_STMT_LEAF,
+ LY_STMT_LEAF_LIST,
+ LY_STMT_LENGTH,
+ LY_STMT_LIST,
+ LY_STMT_MANDATORY,
+ LY_STMT_MAX_ELEMENTS,
+ LY_STMT_MIN_ELEMENTS,
+ LY_STMT_MODIFIER,
+ LY_STMT_MODULE,
+ LY_STMT_MUST,
+ LY_STMT_NAMESPACE,
+ LY_STMT_NOTIFICATION,
+ LY_STMT_ORDERED_BY,
+ LY_STMT_ORGANIZATION,
+ LY_STMT_OUTPUT,
+ LY_STMT_PATH,
+ LY_STMT_PATTERN,
+ LY_STMT_POSITION,
+ LY_STMT_PREFIX,
+ LY_STMT_PRESENCE,
+ LY_STMT_RANGE,
+ LY_STMT_REFERENCE,
+ LY_STMT_REFINE,
+ LY_STMT_REQUIRE_INSTANCE,
+ LY_STMT_REVISION,
+ LY_STMT_REVISION_DATE,
+ LY_STMT_RPC,
+ LY_STMT_STATUS,
+ LY_STMT_SUBMODULE,
+ LY_STMT_TYPE,
+ LY_STMT_TYPEDEF,
+ LY_STMT_UNIQUE,
+ LY_STMT_UNITS,
+ LY_STMT_USES,
+ LY_STMT_VALUE,
+ LY_STMT_WHEN,
+ LY_STMT_YANG_VERSION,
+ LY_STMT_YIN_ELEMENT,
+ LY_STMT_EXTENSION_INSTANCE,
+
+ LY_STMT_SYNTAX_SEMICOLON,
+ LY_STMT_SYNTAX_LEFT_BRACE,
+ LY_STMT_SYNTAX_RIGHT_BRACE,
+
+ LY_STMT_ARG_TEXT,
+ LY_STMT_ARG_VALUE
+};
+
+/**
* @brief Extension instance structure parent enumeration
*/
typedef enum {
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 61019e2..bc6c805 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -475,6 +475,37 @@
return LY_SUCCESS;
}
+LY_ERR
+lys_compile_extension_instance(struct lysc_ctx *ctx, const struct lysp_ext_instance *ext, struct lysc_ext_substmt *substmts)
+{
+ unsigned int u;
+ struct lysp_stmt *stmt;
+
+ for (stmt = ext->child; stmt; stmt = stmt->next) {
+ const char *s = stmt->stmt;
+ enum ly_stmt kw = lysp_match_kw(NULL, &s);
+ if (!kw || *s != '\0') {
+ /* TODO handle other extension instances */
+ goto invalid_stmt;
+ }
+ for (u = 0; substmts[u].stmt; ++u) {
+ if (substmts[u].stmt == kw) {
+ break;
+ }
+ }
+ if (!substmts[u].stmt) {
+invalid_stmt:
+ LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid keyword \"%s\" as a child of \"%s\" extension instance.",
+ ly_stmt2str(kw), ext->name);
+ return LY_EVALID;
+ }
+
+ /* TODO parse stmt to lysp */
+ /* TODO compile lysp to lysc */
+ }
+ return LY_SUCCESS;
+}
+
/**
* @brief Fill in the prepared compiled extensions definition structure according to the parsed extension definition.
*/
@@ -4191,7 +4222,7 @@
if (any->flags & LYS_CONFIG_W) {
LOGWRN(ctx->ctx, "Use of %s to define configuration data is not recommended.",
- ly_stmt2str(any->nodetype == LYS_ANYDATA ? YANG_ANYDATA : YANG_ANYXML));
+ ly_stmt2str(any->nodetype == LYS_ANYDATA ? LY_STMT_ANYDATA : LY_STMT_ANYXML));
}
done:
return ret;
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 46d7801..1cc11c2 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1410,7 +1410,7 @@
return NULL;
}
-enum yang_keyword
+enum ly_stmt
lysp_match_kw(struct lys_parser_ctx *ctx, const char **data)
{
/**
@@ -1424,183 +1424,183 @@
#define IF_KW_PREFIX(STR, LEN) if (!strncmp(*(data), STR, LEN)) {MOVE_IN(ctx, data, LEN);
#define IF_KW_PREFIX_END }
- enum yang_keyword result = YANG_NONE;
- enum yang_keyword *kw = &result;
+ enum ly_stmt result = LY_STMT_NONE;
+ enum ly_stmt *kw = &result;
/* read the keyword itself */
switch (**data) {
case 'a':
MOVE_IN(ctx, data, 1);
- IF_KW("rgument", 7, YANG_ARGUMENT)
- else IF_KW("ugment", 6, YANG_AUGMENT)
- else IF_KW("ction", 5, YANG_ACTION)
+ IF_KW("rgument", 7, LY_STMT_ARGUMENT)
+ else IF_KW("ugment", 6, LY_STMT_AUGMENT)
+ else IF_KW("ction", 5, LY_STMT_ACTION)
else IF_KW_PREFIX("ny", 2)
- IF_KW("data", 4, YANG_ANYDATA)
- else IF_KW("xml", 3, YANG_ANYXML)
+ IF_KW("data", 4, LY_STMT_ANYDATA)
+ else IF_KW("xml", 3, LY_STMT_ANYXML)
IF_KW_PREFIX_END
break;
case 'b':
MOVE_IN(ctx, data, 1);
- IF_KW("ase", 3, YANG_BASE)
- else IF_KW("elongs-to", 9, YANG_BELONGS_TO)
- else IF_KW("it", 2, YANG_BIT)
+ IF_KW("ase", 3, LY_STMT_BASE)
+ else IF_KW("elongs-to", 9, LY_STMT_BELONGS_TO)
+ else IF_KW("it", 2, LY_STMT_BIT)
break;
case 'c':
MOVE_IN(ctx, data, 1);
- IF_KW("ase", 3, YANG_CASE)
- else IF_KW("hoice", 5, YANG_CHOICE)
+ IF_KW("ase", 3, LY_STMT_CASE)
+ else IF_KW("hoice", 5, LY_STMT_CHOICE)
else IF_KW_PREFIX("on", 2)
- IF_KW("fig", 3, YANG_CONFIG)
+ IF_KW("fig", 3, LY_STMT_CONFIG)
else IF_KW_PREFIX("ta", 2)
- IF_KW("ct", 2, YANG_CONTACT)
- else IF_KW("iner", 4, YANG_CONTAINER)
+ IF_KW("ct", 2, LY_STMT_CONTACT)
+ else IF_KW("iner", 4, LY_STMT_CONTAINER)
IF_KW_PREFIX_END
IF_KW_PREFIX_END
break;
case 'd':
MOVE_IN(ctx, data, 1);
IF_KW_PREFIX("e", 1)
- IF_KW("fault", 5, YANG_DEFAULT)
- else IF_KW("scription", 9, YANG_DESCRIPTION)
+ IF_KW("fault", 5, LY_STMT_DEFAULT)
+ else IF_KW("scription", 9, LY_STMT_DESCRIPTION)
else IF_KW_PREFIX("viat", 4)
- IF_KW("e", 1, YANG_DEVIATE)
- else IF_KW("ion", 3, YANG_DEVIATION)
+ IF_KW("e", 1, LY_STMT_DEVIATE)
+ else IF_KW("ion", 3, LY_STMT_DEVIATION)
IF_KW_PREFIX_END
IF_KW_PREFIX_END
break;
case 'e':
MOVE_IN(ctx, data, 1);
- IF_KW("num", 3, YANG_ENUM)
+ IF_KW("num", 3, LY_STMT_ENUM)
else IF_KW_PREFIX("rror-", 5)
- IF_KW("app-tag", 7, YANG_ERROR_APP_TAG)
- else IF_KW("message", 7, YANG_ERROR_MESSAGE)
+ IF_KW("app-tag", 7, LY_STMT_ERROR_APP_TAG)
+ else IF_KW("message", 7, LY_STMT_ERROR_MESSAGE)
IF_KW_PREFIX_END
- else IF_KW("xtension", 8, YANG_EXTENSION)
+ else IF_KW("xtension", 8, LY_STMT_EXTENSION)
break;
case 'f':
MOVE_IN(ctx, data, 1);
- IF_KW("eature", 6, YANG_FEATURE)
- else IF_KW("raction-digits", 14, YANG_FRACTION_DIGITS)
+ IF_KW("eature", 6, LY_STMT_FEATURE)
+ else IF_KW("raction-digits", 14, LY_STMT_FRACTION_DIGITS)
break;
case 'g':
MOVE_IN(ctx, data, 1);
- IF_KW("rouping", 7, YANG_GROUPING)
+ IF_KW("rouping", 7, LY_STMT_GROUPING)
break;
case 'i':
MOVE_IN(ctx, data, 1);
- IF_KW("dentity", 7, YANG_IDENTITY)
- else IF_KW("f-feature", 9, YANG_IF_FEATURE)
- else IF_KW("mport", 5, YANG_IMPORT)
+ IF_KW("dentity", 7, LY_STMT_IDENTITY)
+ else IF_KW("f-feature", 9, LY_STMT_IF_FEATURE)
+ else IF_KW("mport", 5, LY_STMT_IMPORT)
else IF_KW_PREFIX("n", 1)
- IF_KW("clude", 5, YANG_INCLUDE)
- else IF_KW("put", 3, YANG_INPUT)
+ IF_KW("clude", 5, LY_STMT_INCLUDE)
+ else IF_KW("put", 3, LY_STMT_INPUT)
IF_KW_PREFIX_END
break;
case 'k':
MOVE_IN(ctx, data, 1);
- IF_KW("ey", 2, YANG_KEY)
+ IF_KW("ey", 2, LY_STMT_KEY)
break;
case 'l':
MOVE_IN(ctx, data, 1);
IF_KW_PREFIX("e", 1)
- IF_KW("af-list", 7, YANG_LEAF_LIST)
- else IF_KW("af", 2, YANG_LEAF)
- else IF_KW("ngth", 4, YANG_LENGTH)
+ IF_KW("af-list", 7, LY_STMT_LEAF_LIST)
+ else IF_KW("af", 2, LY_STMT_LEAF)
+ else IF_KW("ngth", 4, LY_STMT_LENGTH)
IF_KW_PREFIX_END
- else IF_KW("ist", 3, YANG_LIST)
+ else IF_KW("ist", 3, LY_STMT_LIST)
break;
case 'm':
MOVE_IN(ctx, data, 1);
IF_KW_PREFIX("a", 1)
- IF_KW("ndatory", 7, YANG_MANDATORY)
- else IF_KW("x-elements", 10, YANG_MAX_ELEMENTS)
+ IF_KW("ndatory", 7, LY_STMT_MANDATORY)
+ else IF_KW("x-elements", 10, LY_STMT_MAX_ELEMENTS)
IF_KW_PREFIX_END
- else IF_KW("in-elements", 11, YANG_MIN_ELEMENTS)
- else IF_KW("ust", 3, YANG_MUST)
+ else IF_KW("in-elements", 11, LY_STMT_MIN_ELEMENTS)
+ else IF_KW("ust", 3, LY_STMT_MUST)
else IF_KW_PREFIX("od", 2)
- IF_KW("ule", 3, YANG_MODULE)
- else IF_KW("ifier", 5, YANG_MODIFIER)
+ IF_KW("ule", 3, LY_STMT_MODULE)
+ else IF_KW("ifier", 5, LY_STMT_MODIFIER)
IF_KW_PREFIX_END
break;
case 'n':
MOVE_IN(ctx, data, 1);
- IF_KW("amespace", 8, YANG_NAMESPACE)
- else IF_KW("otification", 11, YANG_NOTIFICATION)
+ IF_KW("amespace", 8, LY_STMT_NAMESPACE)
+ else IF_KW("otification", 11, LY_STMT_NOTIFICATION)
break;
case 'o':
MOVE_IN(ctx, data, 1);
IF_KW_PREFIX("r", 1)
- IF_KW("dered-by", 8, YANG_ORDERED_BY)
- else IF_KW("ganization", 10, YANG_ORGANIZATION)
+ IF_KW("dered-by", 8, LY_STMT_ORDERED_BY)
+ else IF_KW("ganization", 10, LY_STMT_ORGANIZATION)
IF_KW_PREFIX_END
- else IF_KW("utput", 5, YANG_OUTPUT)
+ else IF_KW("utput", 5, LY_STMT_OUTPUT)
break;
case 'p':
MOVE_IN(ctx, data, 1);
- IF_KW("ath", 3, YANG_PATH)
- else IF_KW("attern", 6, YANG_PATTERN)
- else IF_KW("osition", 7, YANG_POSITION)
+ IF_KW("ath", 3, LY_STMT_PATH)
+ else IF_KW("attern", 6, LY_STMT_PATTERN)
+ else IF_KW("osition", 7, LY_STMT_POSITION)
else IF_KW_PREFIX("re", 2)
- IF_KW("fix", 3, YANG_PREFIX)
- else IF_KW("sence", 5, YANG_PRESENCE)
+ IF_KW("fix", 3, LY_STMT_PREFIX)
+ else IF_KW("sence", 5, LY_STMT_PRESENCE)
IF_KW_PREFIX_END
break;
case 'r':
MOVE_IN(ctx, data, 1);
- IF_KW("ange", 4, YANG_RANGE)
+ IF_KW("ange", 4, LY_STMT_RANGE)
else IF_KW_PREFIX("e", 1)
IF_KW_PREFIX("f", 1)
- IF_KW("erence", 6, YANG_REFERENCE)
- else IF_KW("ine", 3, YANG_REFINE)
+ IF_KW("erence", 6, LY_STMT_REFERENCE)
+ else IF_KW("ine", 3, LY_STMT_REFINE)
IF_KW_PREFIX_END
- else IF_KW("quire-instance", 14, YANG_REQUIRE_INSTANCE)
- else IF_KW("vision-date", 11, YANG_REVISION_DATE)
- else IF_KW("vision", 6, YANG_REVISION)
+ else IF_KW("quire-instance", 14, LY_STMT_REQUIRE_INSTANCE)
+ else IF_KW("vision-date", 11, LY_STMT_REVISION_DATE)
+ else IF_KW("vision", 6, LY_STMT_REVISION)
IF_KW_PREFIX_END
- else IF_KW("pc", 2, YANG_RPC)
+ else IF_KW("pc", 2, LY_STMT_RPC)
break;
case 's':
MOVE_IN(ctx, data, 1);
- IF_KW("tatus", 5, YANG_STATUS)
- else IF_KW("ubmodule", 8, YANG_SUBMODULE)
+ IF_KW("tatus", 5, LY_STMT_STATUS)
+ else IF_KW("ubmodule", 8, LY_STMT_SUBMODULE)
break;
case 't':
MOVE_IN(ctx, data, 1);
- IF_KW("ypedef", 6, YANG_TYPEDEF)
- else IF_KW("ype", 3, YANG_TYPE)
+ IF_KW("ypedef", 6, LY_STMT_TYPEDEF)
+ else IF_KW("ype", 3, LY_STMT_TYPE)
break;
case 'u':
MOVE_IN(ctx, data, 1);
IF_KW_PREFIX("ni", 2)
- IF_KW("que", 3, YANG_UNIQUE)
- else IF_KW("ts", 2, YANG_UNITS)
+ IF_KW("que", 3, LY_STMT_UNIQUE)
+ else IF_KW("ts", 2, LY_STMT_UNITS)
IF_KW_PREFIX_END
- else IF_KW("ses", 3, YANG_USES)
+ else IF_KW("ses", 3, LY_STMT_USES)
break;
case 'v':
MOVE_IN(ctx, data, 1);
- IF_KW("alue", 4, YANG_VALUE)
+ IF_KW("alue", 4, LY_STMT_VALUE)
break;
case 'w':
MOVE_IN(ctx, data, 1);
- IF_KW("hen", 3, YANG_WHEN)
+ IF_KW("hen", 3, LY_STMT_WHEN)
break;
case 'y':
MOVE_IN(ctx, data, 1);
- IF_KW("ang-version", 11, YANG_YANG_VERSION)
- else IF_KW("in-element", 10, YANG_YIN_ELEMENT)
+ IF_KW("ang-version", 11, LY_STMT_YANG_VERSION)
+ else IF_KW("in-element", 10, LY_STMT_YIN_ELEMENT)
break;
default:
/* if context is not NULL we are matching keyword from YANG data*/
if (ctx) {
if (**data == ';') {
MOVE_IN(ctx, data, 1);
- *kw = YANG_SEMICOLON;
+ *kw = LY_STMT_SYNTAX_SEMICOLON;
} else if (**data == '{') {
MOVE_IN(ctx, data, 1);
- *kw = YANG_LEFT_BRACE;
+ *kw = LY_STMT_SYNTAX_LEFT_BRACE;
} else if (**data == '}') {
MOVE_IN(ctx, data, 1);
- *kw = YANG_RIGHT_BRACE;
+ *kw = LY_STMT_SYNTAX_RIGHT_BRACE;
}
}
break;
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 1ff883d..209b8b2 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -650,7 +650,7 @@
uint8_t lysc_iff_getop(uint8_t *list, int pos);
/**
- * @brief Internal wrapper around lys_compile_extension() to be able to prepare list of compiled extension definition
+ * @brief Internal wrapper around lys_compile_extension() to be able to prepare list of compiled extension definitions
* even for the parsed (not-implemented) module - see lys_module::off_extensions.
*
* @param[in] ctx_sc Compile context - alternative to the combination of @p ctx and @p module.
@@ -844,6 +844,6 @@
*
* return yang_keyword values.
*/
-enum yang_keyword lysp_match_kw(struct lys_parser_ctx *ctx, const char **data);
+enum ly_stmt lysp_match_kw(struct lys_parser_ctx *ctx, const char **data);
#endif /* LY_TREE_SCHEMA_INTERNAL_H_ */