-Yang Deviation/deviate : added yacc/lex syntax
This commit is contained in:
parent
ad0af26649
commit
d48b8a8fad
5 changed files with 111 additions and 45 deletions
|
|
@ -32,6 +32,12 @@
|
||||||
## 5.2.0
|
## 5.2.0
|
||||||
Expected: June 2021
|
Expected: June 2021
|
||||||
|
|
||||||
|
### New features
|
||||||
|
|
||||||
|
* Yang Deviation/deviate [deviation statement not yet support #211](https://github.com/clicon/clixon/issues/211)
|
||||||
|
* See RFC7950 Sec 5.6.3
|
||||||
|
* Work-in-progress
|
||||||
|
|
||||||
### Minor features
|
### Minor features
|
||||||
|
|
||||||
* Add default network namespace constant: `RESTCONF_NETNS_DEFAULT` with default value "default".
|
* Add default network namespace constant: `RESTCONF_NETNS_DEFAULT` with default value "default".
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ restconf_reply_send(void *req0,
|
||||||
evhtp_connection_t *conn;
|
evhtp_connection_t *conn;
|
||||||
struct evbuffer *eb = NULL;
|
struct evbuffer *eb = NULL;
|
||||||
|
|
||||||
|
clicon_debug(1, "%s code:%d", __FUNCTION__, code);
|
||||||
req->status = code;
|
req->status = code;
|
||||||
if ((reason_phrase = restconf_code2reason(code)) == NULL)
|
if ((reason_phrase = restconf_code2reason(code)) == NULL)
|
||||||
reason_phrase="";
|
reason_phrase="";
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,5 @@ comment:
|
||||||
require_changes: no
|
require_changes: no
|
||||||
|
|
||||||
ignore:
|
ignore:
|
||||||
- "util" # ignore folders and all its contents
|
- "util/" # ignore folders and all its contents
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ clixon_yang_parsewrap(void)
|
||||||
identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
||||||
|
|
||||||
%x KEYWORD
|
%x KEYWORD
|
||||||
|
%x DEVIATE
|
||||||
%s BOOLEAN
|
%s BOOLEAN
|
||||||
%s INTEGER
|
%s INTEGER
|
||||||
%s STRARG
|
%s STRARG
|
||||||
|
|
@ -106,12 +107,12 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
||||||
|
|
||||||
%%
|
%%
|
||||||
/* Common tokens */
|
/* Common tokens */
|
||||||
<KEYWORD,BOOLEAN,INTEGER,STRARG,STRING>[ \t]
|
<KEYWORD,DEVIATE,BOOLEAN,INTEGER,STRARG,STRING>[ \t]
|
||||||
<KEYWORD,STRING,UNKNOWN,UNKNOWN2,COMMENT2><<EOF>> { return MY_EOF; }
|
<KEYWORD,DEVIATE,STRING,UNKNOWN,UNKNOWN2,COMMENT2><<EOF>> { return MY_EOF; }
|
||||||
<KEYWORD,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\n { _YY->yy_linenum++; }
|
<KEYWORD,DEVIATE,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\n { _YY->yy_linenum++; }
|
||||||
<KEYWORD,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\r
|
<KEYWORD,DEVIATE,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\r
|
||||||
<KEYWORD,STRING,UNKNOWN,UNKNOWN2>"/*" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT1); }
|
<KEYWORD,DEVIATE,STRING,UNKNOWN,UNKNOWN2>"/*" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT1); }
|
||||||
<KEYWORD,STRING,UNKNOWN,UNKNOWN2>"//" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT2); }
|
<KEYWORD,DEVIATE,STRING,UNKNOWN,UNKNOWN2>"//" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT2); }
|
||||||
|
|
||||||
|
|
||||||
<KEYWORD>input { return K_INPUT; } /* No argument */
|
<KEYWORD>input { return K_INPUT; } /* No argument */
|
||||||
|
|
@ -163,7 +164,7 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
||||||
<KEYWORD>contact { BEGIN(STRING); return K_CONTACT; }
|
<KEYWORD>contact { BEGIN(STRING); return K_CONTACT; }
|
||||||
<KEYWORD>default { BEGIN(STRING); return K_DEFAULT; }
|
<KEYWORD>default { BEGIN(STRING); return K_DEFAULT; }
|
||||||
<KEYWORD>description { BEGIN(STRING); return K_DESCRIPTION; }
|
<KEYWORD>description { BEGIN(STRING); return K_DESCRIPTION; }
|
||||||
<KEYWORD>deviate { BEGIN(STRING); return K_DEVIATE; }
|
<KEYWORD>deviate { BEGIN(DEVIATE); return K_DEVIATE; }
|
||||||
<KEYWORD>deviation { BEGIN(STRING); return K_DEVIATION; }
|
<KEYWORD>deviation { BEGIN(STRING); return K_DEVIATION; }
|
||||||
<KEYWORD>enum { BEGIN(STRING); return K_ENUM; }
|
<KEYWORD>enum { BEGIN(STRING); return K_ENUM; }
|
||||||
<KEYWORD>error-app-tag { BEGIN(STRING); return K_ERROR_APP_TAG; }
|
<KEYWORD>error-app-tag { BEGIN(STRING); return K_ERROR_APP_TAG; }
|
||||||
|
|
@ -197,6 +198,11 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
||||||
<KEYWORD>. { clixon_yang_parselval.string = strdup(yytext);
|
<KEYWORD>. { clixon_yang_parselval.string = strdup(yytext);
|
||||||
BEGIN(UNKNOWN); return CHARS; }
|
BEGIN(UNKNOWN); return CHARS; }
|
||||||
|
|
||||||
|
<DEVIATE>not-supported { BEGIN(KEYWORD); return D_NOT_SUPPORTED; }
|
||||||
|
<DEVIATE>add { BEGIN(KEYWORD); return D_ADD; }
|
||||||
|
<DEVIATE>delete { BEGIN(KEYWORD); return D_DELETE; }
|
||||||
|
<DEVIATE>replace { BEGIN(KEYWORD); return D_REPLACE; }
|
||||||
|
<DEVIATE>. { BEGIN(KEYWORD); return *yytext; }
|
||||||
<UNKNOWN>: { return *yytext; }
|
<UNKNOWN>: { return *yytext; }
|
||||||
<UNKNOWN>; { BEGIN(KEYWORD); return *yytext; }
|
<UNKNOWN>; { BEGIN(KEYWORD); return *yytext; }
|
||||||
<UNKNOWN>\{ { BEGIN(KEYWORD); return *yytext; }
|
<UNKNOWN>\{ { BEGIN(KEYWORD); return *yytext; }
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,13 @@
|
||||||
%token K_YIN_ELEMENT
|
%token K_YIN_ELEMENT
|
||||||
|
|
||||||
|
|
||||||
|
/* Deviate keywords
|
||||||
|
*/
|
||||||
|
%token D_NOT_SUPPORTED
|
||||||
|
%token D_ADD
|
||||||
|
%token D_DELETE
|
||||||
|
%token D_REPLACE
|
||||||
|
|
||||||
%lex-param {void *_yy} /* Add this argument to parse() and lex() function */
|
%lex-param {void *_yy} /* Add this argument to parse() and lex() function */
|
||||||
%parse-param {void *_yy}
|
%parse-param {void *_yy}
|
||||||
|
|
||||||
|
|
@ -1522,46 +1529,93 @@ deviation_substmts : deviation_substmts deviation_substmt
|
||||||
|
|
||||||
deviation_substmt : description_stmt { _PARSE_DEBUG("deviation-substmt -> description-stmt"); }
|
deviation_substmt : description_stmt { _PARSE_DEBUG("deviation-substmt -> description-stmt"); }
|
||||||
| reference_stmt { _PARSE_DEBUG("deviation-substmt -> reference-stmt"); }
|
| reference_stmt { _PARSE_DEBUG("deviation-substmt -> reference-stmt"); }
|
||||||
| deviate_stmt { _PARSE_DEBUG("deviation-substmt -> deviate-stmt"); }
|
| deviate_not_supported_stmt { _PARSE_DEBUG("yang-stmt -> deviate-not-supported-stmt");}
|
||||||
|
| deviate_add_stmt { _PARSE_DEBUG("deviation-stmt -> deviate-add-stmt");}
|
||||||
|
| deviate_delete_stmt { _PARSE_DEBUG("deviation-stmt -> deviate-delete-stmt");}
|
||||||
|
| deviate_replace_stmt { _PARSE_DEBUG("deviation-stmt -> deviate-replace-stmt");}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* RFC7950 differentiates between deviate-not-supported, deviate-add,
|
deviate_not_supported_stmt
|
||||||
* deviate-replave, and deviate-delete. Here all are bundled into a single
|
: K_DEVIATE D_NOT_SUPPORTED ';'
|
||||||
* deviate rule. For now, until "deviate" gets supported.
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("not-supported") /* D_NOT_SUPPORTED*/, NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
*/
|
_PARSE_DEBUG("deviate-not-supported-stmt -> DEVIATE not-supported ;"); }
|
||||||
deviate_stmt : K_DEVIATE string ';'
|
;
|
||||||
{ if (ysp_add(_yy, Y_DEVIATE, $2, NULL) == NULL) _YYERROR("notification_stmt");
|
|
||||||
_PARSE_DEBUG("deviate-not-supported-stmt -> DEVIATE string ;"); }
|
deviate_add_stmt : K_DEVIATE D_ADD ';'
|
||||||
| K_DEVIATE string
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("add") /* D_NOT_SUPPORTED*/, NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
{ if (ysp_add_push(_yy, Y_DEVIATE, $2, NULL) == NULL) _YYERROR("deviate_stmt"); }
|
_PARSE_DEBUG("deviate-add-stmt -> DEVIATE add ;"); }
|
||||||
'{' deviate_substmts '}'
|
| K_DEVIATE D_ADD
|
||||||
|
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("add"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
||||||
|
'{' deviate_add_substmts '}'
|
||||||
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
||||||
_PARSE_DEBUG("deviate-stmt -> DEVIATE string { deviate-substmts }"); }
|
_PARSE_DEBUG("deviate-add-stmt -> DEVIATE add { deviate-substmts }"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* RFC7950 differentiates between deviate-not-supported, deviate-add,
|
deviate_add_substmts : deviate_add_substmts deviate_add_substmt
|
||||||
* deviate-replave, and deviate-delete. Here all are bundled into a single
|
{ _PARSE_DEBUG("deviate-add-substmts -> deviate-add-substmts deviate-add-substmt"); }
|
||||||
* deviate-substmt rule. For now, until "deviate" gets supported.
|
| deviate_add_substmt
|
||||||
*/
|
{ _PARSE_DEBUG("deviate-add-substmts -> deviate-add-substmt"); }
|
||||||
deviate_substmts : deviate_substmts deviate_substmt
|
|
||||||
{ _PARSE_DEBUG("deviate-substmts -> deviate-substmts deviate-substmt"); }
|
|
||||||
| deviate_substmt
|
|
||||||
{ _PARSE_DEBUG("deviate-substmts -> deviate-substmt"); }
|
|
||||||
;
|
;
|
||||||
/* Bundled */
|
deviate_add_substmt : units_stmt { _PARSE_DEBUG("deviate-add-substmt -> units-stmt"); }
|
||||||
deviate_substmt : type_stmt { _PARSE_DEBUG("deviate-substmt -> type-stmt"); }
|
| must_stmt { _PARSE_DEBUG("deviate-add-substmt -> must-stmt"); }
|
||||||
| units_stmt { _PARSE_DEBUG("deviate-substmt -> units-stmt"); }
|
| unique_stmt { _PARSE_DEBUG("deviate-add-substmt -> unique-stmt"); }
|
||||||
| must_stmt { _PARSE_DEBUG("deviate-substmt -> must-stmt"); }
|
| default_stmt { _PARSE_DEBUG("deviate-add-substmt -> default-stmt"); }
|
||||||
| unique_stmt { _PARSE_DEBUG("deviate-substmt -> unique-stmt"); }
|
| config_stmt { _PARSE_DEBUG("deviate-add-substmt -> config-stmt"); }
|
||||||
| default_stmt { _PARSE_DEBUG("deviate-substmt -> default-stmt"); }
|
| mandatory_stmt { _PARSE_DEBUG("deviate-add-substmt -> mandatory-stmt"); }
|
||||||
| config_stmt { _PARSE_DEBUG("deviate-substmt -> config-stmt"); }
|
| min_elements_stmt { _PARSE_DEBUG("deviate-add-substmt -> min-elements-stmt"); }
|
||||||
| mandatory_stmt { _PARSE_DEBUG("deviate-substmt -> mandatory-stmt"); }
|
| max_elements_stmt { _PARSE_DEBUG("deviate-add-substmt -> max-elements-stmt"); }
|
||||||
| min_elements_stmt { _PARSE_DEBUG("deviate-substmt -> min-elements-stmt"); }
|
| { _PARSE_DEBUG("deviate-add-substmt -> "); }
|
||||||
| max_elements_stmt { _PARSE_DEBUG("deviate-substmt -> max-elements-stmt"); }
|
|
||||||
| { _PARSE_DEBUG("deviate-substmt -> "); }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
deviate_delete_stmt : K_DEVIATE D_DELETE ';'
|
||||||
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("add") /* D_NOT_SUPPORTED*/, NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
|
_PARSE_DEBUG("deviate-delete-stmt -> DEVIATE add ;"); }
|
||||||
|
| K_DEVIATE D_DELETE
|
||||||
|
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("add"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
||||||
|
'{' deviate_delete_substmts '}'
|
||||||
|
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
||||||
|
_PARSE_DEBUG("deviate-delete-stmt -> DEVIATE add { deviate-substmts }"); }
|
||||||
|
;
|
||||||
|
|
||||||
|
deviate_delete_substmts : deviate_delete_substmts deviate_delete_substmt
|
||||||
|
{ _PARSE_DEBUG("deviate-delete-substmts -> deviate-delete-substmts deviate-delete-substmt"); }
|
||||||
|
| deviate_delete_substmt
|
||||||
|
{ _PARSE_DEBUG("deviate-delete-substmts -> deviate-delete-substmt"); }
|
||||||
|
;
|
||||||
|
deviate_delete_substmt : units_stmt { _PARSE_DEBUG("deviate-delete-substmt -> units-stmt"); }
|
||||||
|
| must_stmt { _PARSE_DEBUG("deviate-delete-substmt -> must-stmt"); }
|
||||||
|
| unique_stmt { _PARSE_DEBUG("deviate-delete-substmt -> unique-stmt"); }
|
||||||
|
| default_stmt { _PARSE_DEBUG("deviate-delete-substmt -> default-stmt"); }
|
||||||
|
| { _PARSE_DEBUG("deviate-delete-substmt -> "); }
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
deviate_replace_stmt : K_DEVIATE D_REPLACE ';'
|
||||||
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("add") /* D_NOT_SUPPORTED*/, NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
|
_PARSE_DEBUG("deviate-replace-stmt -> DEVIATE add ;"); }
|
||||||
|
| K_DEVIATE D_REPLACE
|
||||||
|
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("add"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
||||||
|
'{' deviate_replace_substmts '}'
|
||||||
|
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
||||||
|
_PARSE_DEBUG("deviate-replace-stmt -> DEVIATE add { deviate-substmts }"); }
|
||||||
|
;
|
||||||
|
|
||||||
|
deviate_replace_substmts : deviate_replace_substmts deviate_replace_substmt
|
||||||
|
{ _PARSE_DEBUG("deviate-replace-substmts -> deviate-replace-substmts deviate-replace-substmt"); }
|
||||||
|
| deviate_replace_substmt
|
||||||
|
{ _PARSE_DEBUG("deviate-replace-substmts -> deviate-replace-substmt"); }
|
||||||
|
;
|
||||||
|
deviate_replace_substmt : type_stmt { _PARSE_DEBUG("deviate-replace-substmt -> type-stmt"); }
|
||||||
|
| units_stmt { _PARSE_DEBUG("deviate-replace-substmt -> units-stmt"); }
|
||||||
|
| default_stmt { _PARSE_DEBUG("deviate-replace-substmt -> default-stmt"); }
|
||||||
|
| config_stmt { _PARSE_DEBUG("deviate-replace-substmt -> config-stmt"); }
|
||||||
|
| mandatory_stmt { _PARSE_DEBUG("deviate-replace-substmt -> mandatory-stmt"); }
|
||||||
|
| min_elements_stmt { _PARSE_DEBUG("deviate-replace-substmt -> min-elements-stmt"); }
|
||||||
|
| max_elements_stmt { _PARSE_DEBUG("deviate-replace-substmt -> max-elements-stmt"); }
|
||||||
|
| { _PARSE_DEBUG("deviate-replace-substmt -> "); }
|
||||||
|
;
|
||||||
|
|
||||||
/* Represents the usage of an extension
|
/* Represents the usage of an extension
|
||||||
unknown-statement = prefix ":" identifier [sep string] optsep
|
unknown-statement = prefix ":" identifier [sep string] optsep
|
||||||
(";" /
|
(";" /
|
||||||
|
|
@ -1612,12 +1666,10 @@ yang_stmt : action_stmt { _PARSE_DEBUG("yang-stmt -> action-stmt");
|
||||||
| container_stmt { _PARSE_DEBUG("yang-stmt -> container-stmt");}
|
| container_stmt { _PARSE_DEBUG("yang-stmt -> container-stmt");}
|
||||||
| default_stmt { _PARSE_DEBUG("yang-stmt -> default-stmt");}
|
| default_stmt { _PARSE_DEBUG("yang-stmt -> default-stmt");}
|
||||||
| description_stmt { _PARSE_DEBUG("yang-stmt -> description-stmt");}
|
| description_stmt { _PARSE_DEBUG("yang-stmt -> description-stmt");}
|
||||||
| deviate_stmt { _PARSE_DEBUG("yang-stmt -> deviate-stmt");}
|
| deviate_not_supported_stmt { _PARSE_DEBUG("yang-stmt -> deviate-not-supported-stmt");}
|
||||||
/* deviate is not yet implemented, the above may be replaced by the following lines
|
|
||||||
| deviate_add_stmt { _PARSE_DEBUG("yang-stmt -> deviate-add-stmt");}
|
| deviate_add_stmt { _PARSE_DEBUG("yang-stmt -> deviate-add-stmt");}
|
||||||
| deviate_delete_stmt { _PARSE_DEBUG("yang-stmt -> deviate-add-stmt");}
|
| deviate_delete_stmt { _PARSE_DEBUG("yang-stmt -> deviate-delete-stmt");}
|
||||||
| deviate_replace_stmt { _PARSE_DEBUG("yang-stmt -> deviate-add-stmt");}
|
| deviate_replace_stmt { _PARSE_DEBUG("yang-stmt -> deviate-replace-stmt");}
|
||||||
*/
|
|
||||||
| deviation_stmt { _PARSE_DEBUG("yang-stmt -> deviation-stmt");}
|
| deviation_stmt { _PARSE_DEBUG("yang-stmt -> deviation-stmt");}
|
||||||
| enum_stmt { _PARSE_DEBUG("yang-stmt -> enum-stmt");}
|
| enum_stmt { _PARSE_DEBUG("yang-stmt -> enum-stmt");}
|
||||||
| error_app_tag_stmt { _PARSE_DEBUG("yang-stmt -> error-app-tag-stmt");}
|
| error_app_tag_stmt { _PARSE_DEBUG("yang-stmt -> error-app-tag-stmt");}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue