From 0ef704563b22c2cc6671cbb058f48c3ec2802609 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 29 May 2019 19:36:23 +0200 Subject: [PATCH] empty unquoted string; unknown in anydata/xml --- lib/src/clixon_regex.c | 1 - lib/src/clixon_yang_parse.l | 15 ++++++++++++++- lib/src/clixon_yang_parse.y | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/src/clixon_regex.c b/lib/src/clixon_regex.c index 663c6f03..c0d7b0a0 100644 --- a/lib/src/clixon_regex.c +++ b/lib/src/clixon_regex.c @@ -79,7 +79,6 @@ * \i letters + underscore and colon * \c XML Namechar, see: https://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameChar * - * Not implemented: * \p{X} category escape. the ones identified in openconfig and yang-models are: * \p{L} Letters [ultmo]? * \p{M} Marks [nce]? diff --git a/lib/src/clixon_yang_parse.l b/lib/src/clixon_yang_parse.l index 5afcbeda..c852b4d7 100644 --- a/lib/src/clixon_yang_parse.l +++ b/lib/src/clixon_yang_parse.l @@ -33,7 +33,8 @@ * Yang parser. Hopefully useful but not complete * @see https://tools.ietf.org/html/rfc6020 YANG 1.0 * @see https://tools.ietf.org/html/rfc7950 YANG 1.1 -* + * @note differences in double quoted strings: 1.1 does not allow \x, but 1.0 + * does (where x is not n|t|"|\). See mode DQESC */ %{ @@ -247,6 +248,18 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]* [nt"\\] { BEGIN(_YY->yy_lex_state); clixon_yang_parselval.string = strdup(yytext); return CHARS; } +[nt"\\] { BEGIN(_YY->yy_lex_state); + clixon_yang_parselval.string = strdup(yytext); + return CHARS; } +[^nt"\\] { char *str = malloc(3); + /* This is for Yang 1.0 double-quoted strings */ + BEGIN(_YY->yy_lex_state); + str[0] = '\\'; + str[1] = yytext[0]; + str[2] = '\0'; + clixon_yang_parselval.string = str; + return CHARS; } + [^*\n]* /* eat anything that's not a '*' */ "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ "*"+"/" BEGIN(_YY->yy_lex_state); diff --git a/lib/src/clixon_yang_parse.y b/lib/src/clixon_yang_parse.y index 050a2d5e..74acccf2 100644 --- a/lib/src/clixon_yang_parse.y +++ b/lib/src/clixon_yang_parse.y @@ -1288,6 +1288,7 @@ anyxml_substmt : when_stmt { clicon_debug(2,"anyxml-substmt -> when-st | description_stmt { clicon_debug(2,"anyxml-substmt -> description-stmt"); } | reference_stmt { clicon_debug(2,"anyxml-substmt -> reference-stmt"); } | ustring ':' ustring ';' { free($1); free($3); clicon_debug(2,"anyxml-substmt -> anyxml extension"); } + | unknown_stmt { clicon_debug(2,"anyxml-substmt -> unknown-stmt");} ; /* uses-stmt = uses-keyword identifier-ref-arg-str */ @@ -1728,7 +1729,8 @@ qstrings : qstrings '+' qstring qstring : '"' ustring '"' { $$=$2; clicon_debug(2,"string-> \" ustring \"");} | '"' '"' { $$=strdup(""); clicon_debug(2,"string-> \" \"");} | SQ ustring SQ { $$=$2; clicon_debug(2,"string-> ' ustring '"); } - ; + | SQ SQ { $$=strdup(""); clicon_debug(2,"string-> ' '");} + ; /* unquoted string */ ustring : ustring CHARS