parsers CHANGE move statements lists from YANG parser
Make the statements list available for other (YIN) parser and convert
stringify functions from the switch function to a faster macro providing
data from a constant string arrays.
diff --git a/src/common.c b/src/common.c
index 5cd0a90..03d2ff2 100644
--- a/src/common.c
+++ b/src/common.c
@@ -22,6 +22,123 @@
#include "common.h"
#include "tree_schema.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] = "identitiy",
+ [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] = "}",
+};
+
+const char *const lyext_substmt_list[] = {
+ [LYEXT_SUBSTMT_ARGUMENT] = "argument",
+ [LYEXT_SUBSTMT_BASE] = "base",
+ [LYEXT_SUBSTMT_BELONGSTO] = "belongs-to",
+ [LYEXT_SUBSTMT_CONTACT] = "contact",
+ [LYEXT_SUBSTMT_DEFAULT] = "default",
+ [LYEXT_SUBSTMT_DESCRIPTION] = "description",
+ [LYEXT_SUBSTMT_ERRTAG] = "error-app-tag",
+ [LYEXT_SUBSTMT_ERRMSG] = "error-message",
+ [LYEXT_SUBSTMT_KEY] = "key",
+ [LYEXT_SUBSTMT_NAMESPACE] = "namespace",
+ [LYEXT_SUBSTMT_ORGANIZATION] = "organization",
+ [LYEXT_SUBSTMT_PATH] = "path",
+ [LYEXT_SUBSTMT_PREFIX] = "prefix",
+ [LYEXT_SUBSTMT_PRESENCE] = "presence",
+ [LYEXT_SUBSTMT_REFERENCE] = "reference",
+ [LYEXT_SUBSTMT_REVISIONDATE] = "revision-date",
+ [LYEXT_SUBSTMT_UNITS] = "units",
+ [LYEXT_SUBSTMT_VALUE] = "value",
+ [LYEXT_SUBSTMT_VERSION] = "yang-version",
+ [LYEXT_SUBSTMT_MODIFIER] = "modifier",
+ [LYEXT_SUBSTMT_REQINSTANCE] = "require-instance",
+ [LYEXT_SUBSTMT_YINELEM] = "yin-element",
+ [LYEXT_SUBSTMT_CONFIG] = "config",
+ [LYEXT_SUBSTMT_MANDATORY] = "mandatory",
+ [LYEXT_SUBSTMT_ORDEREDBY] = "ordered-by",
+ [LYEXT_SUBSTMT_STATUS] = "status",
+ [LYEXT_SUBSTMT_FRACDIGITS] = "fraction-digits",
+ [LYEXT_SUBSTMT_MAX] = "max-elements",
+ [LYEXT_SUBSTMT_MIN] = "min-elements",
+ [LYEXT_SUBSTMT_POSITION] = "position",
+ [LYEXT_SUBSTMT_UNIQUE] = "unique",
+ [LYEXT_SUBSTMT_IFFEATURE] = "if-feature",
+};
+
+const char *const ly_devmod_list[] = {
+ [LYS_DEV_NOT_SUPPORTED] = "not-supported",
+ [LYS_DEV_ADD] = "add",
+ [LYS_DEV_DELETE] = "delete",
+ [LYS_DEV_REPLACE] = "replace",
+};
+
void *
ly_realloc(void *ptr, size_t size)
{