Support for empty yang string added, eg default "";

if-feature added in yang parser at several places.
This commit is contained in:
Olof hagsand 2019-01-06 16:31:36 +01:00
parent 0502ca4218
commit bd67a2a5f2
5 changed files with 36 additions and 21 deletions

View file

@ -112,6 +112,7 @@
* <!DOCTYPE (ie DTD) is not supported. * <!DOCTYPE (ie DTD) is not supported.
### Corrected Bugs ### Corrected Bugs
* Support for empty yang string added, eg `default "";`
* Removed CLI generation for yang notifications (and other non-data yang nodes) * Removed CLI generation for yang notifications (and other non-data yang nodes)
* Some restconf error messages contained "rpc-reply" or "rpc-error" which have now been removed. * Some restconf error messages contained "rpc-reply" or "rpc-error" which have now been removed.
* getopt return value changed from char to int (https://github.com/clicon/clixon/issues/58) * getopt return value changed from char to int (https://github.com/clicon/clixon/issues/58)

View file

@ -206,7 +206,7 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
<BOOLEAN>\{ { BEGIN(KEYWORD); return *yytext; } <BOOLEAN>\{ { BEGIN(KEYWORD); return *yytext; }
<BOOLEAN>. { return *yytext; } <BOOLEAN>. { return *yytext; }
<INTEGER>[0-9][0-9]* { clixon_yang_parselval.string = strdup(yytext); <INTEGER>\-?[0-9][0-9]* { clixon_yang_parselval.string = strdup(yytext);
return INT; } return INT; }
<INTEGER>; { BEGIN(KEYWORD); return *yytext; } <INTEGER>; { BEGIN(KEYWORD); return *yytext; }
<INTEGER>\{ { BEGIN(KEYWORD); return *yytext; } <INTEGER>\{ { BEGIN(KEYWORD); return *yytext; }

View file

@ -641,7 +641,8 @@ identity_substmts : identity_substmts identity_substmt
{ clicon_debug(2,"identity-substmts -> identity-substmt"); } { clicon_debug(2,"identity-substmts -> identity-substmt"); }
; ;
identity_substmt : base_stmt { clicon_debug(2,"identity-substmt -> base-stmt"); } identity_substmt : if_feature_stmt { clicon_debug(2,"identity-substmt -> if-feature-stmt"); }
| base_stmt { clicon_debug(2,"identity-substmt -> base-stmt"); }
| status_stmt { clicon_debug(2,"identity-substmt -> status-stmt"); } | status_stmt { clicon_debug(2,"identity-substmt -> status-stmt"); }
| description_stmt { clicon_debug(2,"identity-substmt -> description-stmt"); } | description_stmt { clicon_debug(2,"identity-substmt -> description-stmt"); }
| reference_stmt { clicon_debug(2,"identity-substmt -> reference-stmt"); } | reference_stmt { clicon_debug(2,"identity-substmt -> reference-stmt"); }
@ -876,7 +877,8 @@ enum_substmts : enum_substmts enum_substmt
{ clicon_debug(2,"enum-substmts -> enum-substmt"); } { clicon_debug(2,"enum-substmts -> enum-substmt"); }
; ;
enum_substmt : value_stmt { clicon_debug(2,"enum-substmt -> value-stmt"); } enum_substmt : if_feature_stmt { clicon_debug(2,"enum-substmt -> if-feature-stmt"); }
| value_stmt { clicon_debug(2,"enum-substmt -> value-stmt"); }
| status_stmt { clicon_debug(2,"enum-substmt -> status-stmt"); } | status_stmt { clicon_debug(2,"enum-substmt -> status-stmt"); }
| description_stmt { clicon_debug(2,"enum-substmt -> description-stmt"); } | description_stmt { clicon_debug(2,"enum-substmt -> description-stmt"); }
| reference_stmt { clicon_debug(2,"enum-substmt -> reference-stmt"); } | reference_stmt { clicon_debug(2,"enum-substmt -> reference-stmt"); }
@ -911,7 +913,8 @@ bit_substmts : bit_substmts bit_substmt
{ clicon_debug(2,"bit-substmts -> bit-substmt"); } { clicon_debug(2,"bit-substmts -> bit-substmt"); }
; ;
bit_substmt : position_stmt { clicon_debug(2,"bit-substmt -> positition-stmt"); } bit_substmt : if_feature_stmt { clicon_debug(2,"bit-substmt -> if-feature-stmt"); }
| position_stmt { clicon_debug(2,"bit-substmt -> positition-stmt"); }
| status_stmt { clicon_debug(2,"bit-substmt -> status-stmt"); } | status_stmt { clicon_debug(2,"bit-substmt -> status-stmt"); }
| description_stmt { clicon_debug(2,"bit-substmt -> description-stmt"); } | description_stmt { clicon_debug(2,"bit-substmt -> description-stmt"); }
| reference_stmt { clicon_debug(2,"bit-substmt -> reference-stmt"); } | reference_stmt { clicon_debug(2,"bit-substmt -> reference-stmt"); }
@ -1318,9 +1321,16 @@ refine_substmts : refine_substmts refine_substmt
{ clicon_debug(2,"refine-substmts -> refine-substmt"); } { clicon_debug(2,"refine-substmts -> refine-substmt"); }
; ;
refine_substmt : must_stmt { clicon_debug(2,"refine-substmt -> must-stmt"); } refine_substmt : if_feature_stmt { clicon_debug(2,"refine-substmt -> if-feature-stmt"); }
| mandatory_stmt { clicon_debug(2,"refine-substmt -> mandatory-stmt"); } | must_stmt { clicon_debug(2,"refine-substmt -> must-stmt"); }
| presence_stmt { clicon_debug(2,"refine-substmt -> presence-stmt"); }
| default_stmt { clicon_debug(2,"refine-substmt -> default-stmt"); } | default_stmt { clicon_debug(2,"refine-substmt -> default-stmt"); }
| config_stmt { clicon_debug(2,"refine-substmt -> config-stmt"); }
| mandatory_stmt { clicon_debug(2,"refine-substmt -> mandatory-stmt"); }
| min_elements_stmt { clicon_debug(2,"refine-substmt -> min-elements-stmt"); }
| max_elements_stmt { clicon_debug(2,"refine-substmt -> max-elements-stmt"); }
| description_stmt { clicon_debug(2,"refine-substmt -> description-stmt"); }
| reference_stmt { clicon_debug(2,"refine-substmt -> reference-stmt"); }
| unknown_stmt { clicon_debug(2,"refine-substmt -> unknown-stmt");} | unknown_stmt { clicon_debug(2,"refine-substmt -> unknown-stmt");}
| { clicon_debug(2,"refine-substmt -> "); } | { clicon_debug(2,"refine-substmt -> "); }
; ;
@ -1561,7 +1571,8 @@ qstrings : qstrings '+' qstring
{ $$=$1; clicon_debug(2,"qstrings-> qstring"); } { $$=$1; clicon_debug(2,"qstrings-> qstring"); }
; ;
qstring : DQ ustring DQ { $$=$2; clicon_debug(2,"string-> \" ustring \"");} qstring : DQ ustring DQ { $$=$2; clicon_debug(2,"string-> \" ustring \"");}
| DQ DQ { $$=strdup(""); clicon_debug(2,"string-> \" \"");}
| SQ ustring SQ { $$=$2; clicon_debug(2,"string-> ' ustring '"); } | SQ ustring SQ { $$=$2; clicon_debug(2,"string-> ' ustring '"); }
; ;

View file

@ -13,6 +13,14 @@ testname=
# If set, enable debugging (of backend) # If set, enable debugging (of backend)
: ${DBG:=0} : ${DBG:=0}
# Parse yangmodels from https://github.com/YangModels/yang
# Recommended: checkout yangmodels elsewhere in the tree and set the env
# to that
: ${YANGMODELS=$(pwd)/yang}
# Parse yang openconfig models from https://github.com/openconfig/public
: ${OPENCONFIG=$(pwd)/public}
# For memcheck # For memcheck
#clixon_cli="valgrind --leak-check=full --show-leak-kinds=all clixon_cli" #clixon_cli="valgrind --leak-check=full --show-leak-kinds=all clixon_cli"
clixon_cli=clixon_cli clixon_cli=clixon_cli

View file

@ -6,29 +6,24 @@
# - release/models/wifi/types/openconfig-wifi-types.yang # - release/models/wifi/types/openconfig-wifi-types.yang
# issue: https://github.com/clicon/clixon/issues/59 # issue: https://github.com/clicon/clixon/issues/59
# #
OPENCONFIG=public
OCDIR=$OPENCONFIG/release/models
# Clone openconfig dir if not there
if [ ! -d public ]; then
git clone https://github.com/openconfig/public
#else
# (cd public;
# #git pull
# )
fi
# include err() and new() functions and creates $dir
. ./lib.sh
# Yang specifics: multi-keys and empty type # Yang specifics: multi-keys and empty type
APPNAME=example APPNAME=example
# include err() and new() functions and creates $dir # include err() and new() functions and creates $dir
. ./lib.sh . ./lib.sh
cfg=$dir/conf_yang.xml cfg=$dir/conf_yang.xml
fyang=$dir/test.yang fyang=$dir/test.yang
new "openconfig"
if [ ! -d "$OPENCONFIG" ]; then
err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?"
fi
OCDIR=$OPENCONFIG/release/models
cat <<EOF > $cfg cat <<EOF > $cfg
<config> <config>
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE> <CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>