parser yin ADD function to match yin argument name
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 29fa079..866d145 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -14,201 +14,85 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 
 #include "common.h"
 #include "context.h"
 #include "libyang.h"
 #include "xml.h"
 #include "tree_schema_internal.h"
-#include "string.h"
 
-LY_ERR
-match_argument_name()
-{
+enum YIN_ARGUMENT {
+    YIN_ARG_NONE = 0,
+    YIN_ARG_NAME,
+    YIN_ARG_TARGET_NODE,
+    YIN_ARG_MODULE,
+    YIN_ARG_VALUE,
+    YIN_ARG_TEXT,
+    YIN_ARG_CONDITION,
+    YIN_ARG_URI,
+    YIN_ARG_DATE,
+    YIN_ARG_TAG,
+};
 
-}
-
-#define MOVE_START(array, offset) array = &array[offset];
-#define IF_KW(STR, LEN, SHIFT, STMT) if (!strncmp((word), STR, LEN)) {MOVE_START(word, SHIFT);kw=STMT;}
-#define IF_KW_PREFIX(STR, LEN, SHIFT) if (!strncmp((word), STR, LEN)) {MOVE_START(word, SHIFT);
+#define MOVE_INPUT(DATA, COUNT) already_read+=COUNT;
+#define IF_KW(STR, LEN, STMT) if (!strncmp((name) + already_read, STR, LEN)) {MOVE_INPUT(name, LEN);arg=STMT;}
+#define IF_KW_PREFIX(STR, LEN) if (!strncmp((name) + already_read, STR, LEN)) {MOVE_INPUT(name, LEN);
 #define IF_KW_PREFIX_END }
 
-enum yang_keyword
-match_keyword(const char *word, size_t len)
+enum YIN_ARGUMENT
+match_argument_name(char *name, size_t len)
 {
-    if (!word) {
-        return YANG_NONE;
-    }
-    enum yang_keyword kw = YANG_NONE;
+    enum YIN_ARGUMENT arg = YIN_ARG_NONE;
+    size_t already_read = 0;
 
-    /* try to match the keyword */
-    switch (*word) {
-    case 'a':
-        MOVE_START(word, 1);
-        IF_KW("rgument", len, 7, YANG_ARGUMENT)
-        else IF_KW("ugment", len, 6, YANG_AUGMENT)
-        else IF_KW("ction", len, 5, YANG_ACTION)
-        else IF_KW_PREFIX("ny", len, 2)
-            IF_KW("data", len, 4, YANG_ANYDATA)
-            else IF_KW("xml", len, 3, YANG_ANYXML)
-        IF_KW_PREFIX_END
+    switch(*name) {
+        case 'c':
+            MOVE_INPUT(name, 1);
+            IF_KW("ondition", 8, YIN_ARG_CONDITION);
         break;
-    case 'b':
-        MOVE_START(word, 1);
-        IF_KW("ase", len, 3, YANG_BASE)
-        else IF_KW("elongs-to", len, 9, YANG_BELONGS_TO)
-        else IF_KW("it", len, 2, YANG_BIT)
+
+        case 'd':
+            MOVE_INPUT(name, 1);
+            IF_KW("ate", 3, YIN_ARG_DATE);
         break;
-    case 'c':
-        MOVE_START(word, 1);
-        IF_KW("ase", len, 3, YANG_CASE)
-        else IF_KW("hoice", len, 5, YANG_CHOICE)
-        else IF_KW_PREFIX("on", len, 2)
-            IF_KW("fig", len, 3, YANG_CONFIG)
-            else IF_KW_PREFIX("ta", len, 2)
-                IF_KW("ct", len, 2, YANG_CONTACT)
-                else IF_KW("iner", len, 4, YANG_CONTAINER)
+
+        case 'm':
+            MOVE_INPUT(name, 1);
+            IF_KW("odule", 5, YIN_ARG_MODULE);
+        break;
+
+        case 'n':
+            MOVE_INPUT(name, 1);
+            IF_KW("ame", 3, YIN_ARG_NAME);
+        break;
+
+        case 't':
+            MOVE_INPUT(name, 1);
+            IF_KW_PREFIX("a", 1)
+                IF_KW("g", 1, YIN_ARG_TAG)
+                else IF_KW("rget-node", 9, YIN_ARG_TARGET_NODE)
             IF_KW_PREFIX_END
-        IF_KW_PREFIX_END
+            else IF_KW("ext", 3, YIN_ARG_TEXT)
         break;
-    case 'd':
-        MOVE_START(word, 1);
-        IF_KW_PREFIX("e", len, 1)
-            IF_KW("fault", len, 5, YANG_DEFAULT)
-            else IF_KW("scription", len, 9, YANG_DESCRIPTION)
-            else IF_KW_PREFIX("viat", len, 4)
-                IF_KW("e", len, 1, YANG_DEVIATE)
-                else IF_KW("ion", len, 3, YANG_DEVIATION)
-            IF_KW_PREFIX_END
-        IF_KW_PREFIX_END
+
+        case 'u':
+            MOVE_INPUT(name, 1);
+            IF_KW("ri", 2, YIN_ARG_URI)
         break;
-    case 'e':
-        MOVE_START(word, 1);
-        IF_KW("num", len, 3, YANG_ENUM)
-        else IF_KW_PREFIX("rror-", len, 5)
-            IF_KW("app-tag", len, 7, YANG_ERROR_APP_TAG)
-            else IF_KW("message", len, 7, YANG_ERROR_MESSAGE)
-        IF_KW_PREFIX_END
-        else IF_KW("xtension", len, 8, YANG_EXTENSION)
-        break;
-    case 'f':
-        MOVE_START(word, 1);
-        IF_KW("eature", len, 6, YANG_FEATURE)
-        else IF_KW("raction-digits", len, 14, YANG_FRACTION_DIGITS)
-        break;
-    case 'g':
-        MOVE_START(word, 1);
-        IF_KW("rouping", len, 7, YANG_GROUPING)
-        break;
-    case 'i':
-        MOVE_START(word, 1);
-        IF_KW("dentity", len, 7, YANG_IDENTITY)
-        else IF_KW("f-feature", len, 9, YANG_IF_FEATURE)
-        else IF_KW("mport", len, 5, YANG_IMPORT)
-        else IF_KW_PREFIX("n", len, 1)
-            IF_KW("clude", len, 5, YANG_INCLUDE)
-            else IF_KW("put", len, 3, YANG_INPUT)
-        IF_KW_PREFIX_END
-        break;
-    case 'k':
-        MOVE_START(word, 1);
-        IF_KW("ey", len, 2, YANG_KEY)
-        break;
-    case 'l':
-        MOVE_START(word, 1);
-        IF_KW_PREFIX("e", len, 1)
-            IF_KW("af-list", len, 7, YANG_LEAF_LIST)
-            else IF_KW("af", len, 2, YANG_LEAF)
-            else IF_KW("ngth", len, 4, YANG_LENGTH)
-        IF_KW_PREFIX_END
-        else IF_KW("ist", len, 3, YANG_LIST)
-        break;
-    case 'm':
-        MOVE_START(word, 1);
-        IF_KW_PREFIX("a", len, 1)
-            IF_KW("ndatory", len, 7, YANG_MANDATORY)
-            else IF_KW("x-elements", len, 10, YANG_MAX_ELEMENTS)
-        IF_KW_PREFIX_END
-        else IF_KW("in-elements", len, 11, YANG_MIN_ELEMENTS)
-        else IF_KW("ust", len, 3, YANG_MUST)
-        else IF_KW_PREFIX("od", len, 2)
-            IF_KW("ule", len, 3, YANG_MODULE)
-            else IF_KW("ifier", len, 5, YANG_MODIFIER)
-        IF_KW_PREFIX_END
-        break;
-    case 'n':
-        MOVE_START(word, 1);
-        IF_KW("amespace", len, 8, YANG_NAMESPACE)
-        else IF_KW("otification", len, 11, YANG_NOTIFICATION)
-        break;
-    case 'o':
-        MOVE_START(word, 1);
-        IF_KW_PREFIX("r", len, 1)
-            IF_KW("dered-by", len, 8, YANG_ORDERED_BY)
-            else IF_KW("ganization", len, 10, YANG_ORGANIZATION)
-        IF_KW_PREFIX_END
-        else IF_KW("utput", len, 5, YANG_OUTPUT)
-        break;
-    case 'p':
-        MOVE_START(word, 1);
-        IF_KW("ath", len, 3, YANG_PATH)
-        else IF_KW("attern", len, 6, YANG_PATTERN)
-        else IF_KW("osition", len, 7, YANG_POSITION)
-        else IF_KW_PREFIX("re", len, 2)
-            IF_KW("fix", len, 3, YANG_PREFIX)
-            else IF_KW("sence", len, 5, YANG_PRESENCE)
-        IF_KW_PREFIX_END
-        break;
-    case 'r':
-        MOVE_START(word, 1);
-        IF_KW("ange", len, 4, YANG_RANGE)
-        else IF_KW_PREFIX("e", len, 1)
-            IF_KW_PREFIX("f", len, 1)
-                IF_KW("erence", len, 6, YANG_REFERENCE)
-                else IF_KW("ine", len, 3, YANG_REFINE)
-            IF_KW_PREFIX_END
-            else IF_KW("quire-instance", len, 14, YANG_REQUIRE_INSTANCE)
-            else IF_KW("vision-date", len, 11, YANG_REVISION_DATE)
-            else IF_KW("vision", len, 6, YANG_REVISION)
-        IF_KW_PREFIX_END
-        else IF_KW("pc", len, 2, YANG_RPC)
-        break;
-    case 's':
-        MOVE_START(word, 1);
-        IF_KW("tatus", len, 5, YANG_STATUS)
-        else IF_KW("ubmodule", len, 8, YANG_SUBMODULE)
-        break;
-    case 't':
-        MOVE_START(word, 1);
-        IF_KW("ypedef", len, 6, YANG_TYPEDEF)
-        else IF_KW("ype", len, 3, YANG_TYPE)
-        break;
-    case 'u':
-        MOVE_START(word, 1);
-        IF_KW_PREFIX("ni", len, 2)
-            IF_KW("que", len, 3, YANG_UNIQUE)
-            else IF_KW("ts", len, 2, YANG_UNITS)
-        IF_KW_PREFIX_END
-        else IF_KW("ses", len, 3, YANG_USES)
-        break;
-    case 'v':
-        MOVE_START(word, 1);
-        IF_KW("alue", len, 4, YANG_VALUE)
-        break;
-    case 'w':
-        MOVE_START(word, 1);
-        IF_KW("hen", len, 3, YANG_WHEN)
-        break;
-    case 'y':
-        MOVE_START(word, 1);
-        IF_KW("ang-version", len, 11, YANG_YANG_VERSION)
-        else IF_KW("in-element", len, 10, YANG_YIN_ELEMENT)
-        break;
-    default:
+
+        case 'v':
+            MOVE_INPUT(name, 1);
+            IF_KW("alue", 4, YIN_ARG_VALUE);
         break;
     }
 
-    return kw;
+    /* whole keyword must be matched */
+    if (already_read != len) {
+        arg = YIN_ARG_NONE;
+    }
+
+    return arg;
 }
 
 LY_ERR
@@ -219,17 +103,17 @@
     const char *prefix, *name, *elem;
     size_t prefix_len, name_len;
 
-    /* inefficient keyword check - just temporary */
+    /* check if root keyword is module or submodule */
     ret = lyxml_get_element(xml_ctx, data, &prefix, &prefix_len, &name, &name_len);
     LY_CHECK_ERR_RET(ret != LY_SUCCESS, LOGMEM(xml_ctx->ctx), LY_EMEM);
-    if ((strncmp("module", name, name_len) != 0) && (strncmp("submodule", name, name_len) != 0)) {
+    if (match_keyword(name) != YANG_MODULE && match_keyword(name) != YANG_SUBMODULE) {
         LOGVAL(xml_ctx->ctx, xml_ctx->line, &xml_ctx->line, LYVE_SYNTAX, "Invalid keyword \"%s\", expected \"module\" or \"submodule\".", name);
     }
 
-    /* inefficient argument name check - just temporary */
+    /* check if module/submodule has argument "name" */
     ret = lyxml_get_attribute(xml_ctx, data, &prefix, &prefix_len, &name, &name_len);
     LY_CHECK_ERR_RET(ret != LY_SUCCESS, LOGMEM(xml_ctx->ctx), LY_EMEM);
-    if (strncmp("name", name, name_len)) {
+    if (match_argument_name(name, name_len) != YIN_ARG_NAME) {
         LOGVAL(xml_ctx->ctx, xml_ctx->line, &xml_ctx->line, LYVE_SYNTAX, "Invalid argument name \"%s\", expected \"name\".", name);
     }