diff --git a/CHANGELOG.md b/CHANGELOG.md index d6fa4508..b49318fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,8 @@ Users may have to change how they access the system ### Corrected Bugs +* Partly Fixed: [String concatenation in YANG model leads to syntax error](https://github.com/clicon/clixon/issues/265) + * In this case, eg "uses", single quotes can now be used, but not `qstring + qstring` in this case * Fixed: [Performance issue when parsing large JSON param](https://github.com/clicon/clixon/issues/266) * Fixed: [Duplicate lines emitted by cli_show_config (cli output style) when yang list element has composite key](https://github.com/clicon/clixon/issues/258) * Fixed: [JSON leaf-list output single element leaf-list does not use array](https://github.com/clicon/clixon/issues/261) diff --git a/lib/src/clixon_yang_parse.l b/lib/src/clixon_yang_parse.l index f0a769fe..c71cd1ce 100644 --- a/lib/src/clixon_yang_parse.l +++ b/lib/src/clixon_yang_parse.l @@ -220,7 +220,7 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]* ; { BEGIN(KEYWORD); return *yytext; } \" { _YY->yy_lex_string_state =STRING; BEGIN(STRINGDQ); return *yytext; } -\' { _YY->yy_lex_string_state =STRING; BEGIN(STRINGSQ); return SQ; } +\' { _YY->yy_lex_string_state =STRING; BEGIN(STRINGSQ); return *yytext; } \{ { BEGIN(KEYWORD); return *yytext; } [ \t\n]+ { return WS; } [^{"'; \t\n]+ { clixon_yang_parselval.string = strdup(yytext); @@ -244,12 +244,13 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]* ; { BEGIN(KEYWORD); return *yytext; } {identifier} { clixon_yang_parselval.string = strdup(yytext); return IDENTIFIER;} + . { return *yytext; } \{ { BEGIN(KEYWORD); return *yytext; } ; { BEGIN(KEYWORD); return *yytext; } \" { _YY->yy_lex_string_state =STRING; BEGIN(STRINGDQ); return *yytext; } -\' { _YY->yy_lex_string_state =STRING; BEGIN(STRINGSQ); return SQ; } +\' { _YY->yy_lex_string_state =STRING; BEGIN(STRINGSQ); return *yytext; } \+ { return *yytext; } [^\"\'\+\{\;\n \t]+ { clixon_yang_parselval.string = strdup(yytext); /* XXX [.]+ */ return CHARS;} @@ -262,11 +263,11 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]* [^\\"\n]+ { clixon_yang_parselval.string = strdup(yytext); return CHARS;} -\' { BEGIN(_YY->yy_lex_string_state); return SQ; } +\' { BEGIN(_YY->yy_lex_string_state); return *yytext; } \n { _YY->yy_linenum++; clixon_yang_parselval.string = strdup(yytext); return CHARS;} -[^'\n]+ { clixon_yang_parselval.string = strdup(yytext); +[^'\n]+ { clixon_yang_parselval.string = strdup(yytext); return CHARS;} [nt"\\] { BEGIN(_YY->yy_lex_state); diff --git a/lib/src/clixon_yang_parse.y b/lib/src/clixon_yang_parse.y index 3c144dcf..454f868f 100644 --- a/lib/src/clixon_yang_parse.y +++ b/lib/src/clixon_yang_parse.y @@ -56,7 +56,6 @@ } %token MY_EOF -%token SQ /* Single quote: ' */ %token WS /* white space (at least one) */ %token CHARS %token ERRCHARS /* Error chars */ @@ -1532,7 +1531,7 @@ deviation_substmt : description_stmt { _PARSE_DEBUG("deviation-substmt -> descr not_supported_keyword_str : D_NOT_SUPPORTED | '"' D_NOT_SUPPORTED '"' - | SQ D_NOT_SUPPORTED SQ + | '\'' D_NOT_SUPPORTED '\'' ; deviate_not_supported_stmt @@ -1543,7 +1542,7 @@ deviate_not_supported_stmt add_keyword_str : D_ADD | '"' D_ADD '"' - | SQ D_ADD SQ + | '\'' D_ADD '\'' ; deviate_add_stmt : K_DEVIATE add_keyword_str ';' @@ -1575,7 +1574,7 @@ deviate_add_substmt : units_stmt { _PARSE_DEBUG("deviate-add-substmt -> units delete_keyword_str : D_DELETE | '"' D_DELETE '"' - | SQ D_DELETE SQ + | '\'' D_DELETE '\'' ; deviate_delete_stmt : K_DEVIATE delete_keyword_str ';' @@ -1602,7 +1601,7 @@ deviate_delete_substmt : units_stmt { _PARSE_DEBUG("deviate-delete-substmt -> un replace_keyword_str : D_REPLACE | '"' D_REPLACE '"' - | SQ D_REPLACE SQ + | '\'' D_REPLACE '\'' ; deviate_replace_stmt : K_DEVIATE replace_keyword_str ';' @@ -1827,9 +1826,9 @@ qstring : '"' ustring '"' { $$=$2; _PARSE_DEBUG("qstring-> \" ustring \"");} | '"' '"' { $$=strdup(""); _PARSE_DEBUG("qstring-> \" \"");} - | SQ ustring SQ { $$=$2; + | '\'' ustring '\'' { $$=$2; _PARSE_DEBUG("qstring-> ' ustring '"); } - | SQ SQ { $$=strdup(""); + | '\'' '\'' { $$=strdup(""); _PARSE_DEBUG("qstring-> ' '");} ; @@ -1874,8 +1873,12 @@ desc_schema_nodeid_str : desc_schema_nodeid _PARSE_DEBUG("descendant-schema-nodeid-str -> descendant-schema-nodeid"); } | '"' desc_schema_nodeid '"' { $$=$2; - _PARSE_DEBUG("descendant-schema-nodeid-str -> descendant-schema-nodeid"); } - ; + _PARSE_DEBUG("descendant-schema-nodeid-str -> \" descendant-schema-nodeid \" "); } + | '\'' desc_schema_nodeid '\'' + { $$=$2; + _PARSE_DEBUG("descendant-schema-nodeid-str -> ' descendant-schema-nodeid '"); } + +; /* descendant-schema-nodeid */ desc_schema_nodeid : node_identifier @@ -1888,22 +1891,29 @@ desc_schema_nodeid : node_identifier identifier_str : '"' IDENTIFIER '"' { $$ = $2; _PARSE_DEBUG("identifier_str -> \" IDENTIFIER \" ");} + | '\'' IDENTIFIER '\'' { $$ = $2; + _PARSE_DEBUG("identifier_str -> ' IDENTIFIER ' ");} | IDENTIFIER { $$ = $1; _PARSE_DEBUG("identifier_str -> IDENTIFIER ");} ; identifier_ref_str : '"' identifier_ref '"' { $$ = $2; _PARSE_DEBUG("identifier_ref_str -> \" identifier_ref \" ");} + | '\'' identifier_ref '\'' { $$ = $2; + _PARSE_DEBUG("identifier_ref_str -> ' identifier_ref ' ");} | identifier_ref { $$ = $1; _PARSE_DEBUG("identifier_ref_str -> identifier_ref ");} ; integer_value_str : '"' INT '"' { $$=$2; } + | '\'' INT '\'' { $$=$2; } | INT { $$=$1; } ; bool_str : '"' BOOL '"' { $$ = $2; _PARSE_DEBUG("bool_str -> \" BOOL \" ");} + | '\'' BOOL '\'' { $$ = $2; + _PARSE_DEBUG("bool_str -> ' BOOL ' ");} | BOOL { $$ = $1; _PARSE_DEBUG("bool_str -> BOOL ");} ; diff --git a/test/test_perf_json.sh b/test/test_perf_json.sh index 3dfab307..f65a7528 100755 --- a/test/test_perf_json.sh +++ b/test/test_perf_json.sh @@ -8,7 +8,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi : ${clixon_util_json:="clixon_util_json"} # Number of list/leaf-list entries in file -: ${perfnr:=20000} +: ${perfnr:=100000} fjson=$dir/long.json diff --git a/test/test_type.sh b/test/test_type.sh index f6bb5082..e45a34e0 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -174,7 +174,7 @@ module example{ } container c{ description "transitive type- exists in ex3"; - uses ex2:gr2; + uses 'ex2:gr2'; } leaf digit4{ type string {