YANG parser BUGFIX processing ';', '{' and '}' as keywords
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 77c7084..9a04440 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -884,15 +884,15 @@
case ';':
MOVE_INPUT(ctx, data, 1);
*kw = YANG_SEMICOLON;
- break;
+ goto success;
case '{':
MOVE_INPUT(ctx, data, 1);
*kw = YANG_LEFT_BRACE;
- break;
+ goto success;
case '}':
MOVE_INPUT(ctx, data, 1);
*kw = YANG_RIGHT_BRACE;
- break;
+ goto success;
default:
break;
}
@@ -942,7 +942,7 @@
*kw = YANG_CUSTOM;
}
-
+success:
if (word_p) {
*word_p = (char *)word_start;
*word_len = *data - word_start;
diff --git a/tests/src/test_parser_yang.c b/tests/src/test_parser_yang.c
index 60ba4ad..9033a84 100644
--- a/tests/src/test_parser_yang.c
+++ b/tests/src/test_parser_yang.c
@@ -612,6 +612,21 @@
assert_int_equal(LY_SUCCESS, get_keyword(&ctx, &str, &kw, &word, &len));
assert_int_equal(YANG_YIN_ELEMENT, kw);
assert_int_equal(11, len);
+ str = ";config false;";
+ assert_int_equal(LY_SUCCESS, get_keyword(&ctx, &str, &kw, &word, &len));
+ assert_int_equal(YANG_SEMICOLON, kw);
+ assert_int_equal(1, len);
+ assert_string_equal("config false;", str);
+ str = "{ config false;";
+ assert_int_equal(LY_SUCCESS, get_keyword(&ctx, &str, &kw, &word, &len));
+ assert_int_equal(YANG_LEFT_BRACE, kw);
+ assert_int_equal(1, len);
+ assert_string_equal(" config false;", str);
+ str = "}";
+ assert_int_equal(LY_SUCCESS, get_keyword(&ctx, &str, &kw, &word, &len));
+ assert_int_equal(YANG_RIGHT_BRACE, kw);
+ assert_int_equal(1, len);
+ assert_string_equal("", str);
/* geenric extension */
str = p = "nacm:default-deny-write;";