- Fixed deviate keywords as strings: https://github.com/clicon/clixon/issues/211
This commit is contained in:
parent
866d8d1d0a
commit
1c5c5a71f2
3 changed files with 44 additions and 16 deletions
|
|
@ -93,6 +93,7 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
||||||
|
|
||||||
%x KEYWORD
|
%x KEYWORD
|
||||||
%x DEVIATE
|
%x DEVIATE
|
||||||
|
%x DEVIATESTR
|
||||||
%s BOOLEAN
|
%s BOOLEAN
|
||||||
%s INTEGER
|
%s INTEGER
|
||||||
%s STRARG
|
%s STRARG
|
||||||
|
|
@ -107,12 +108,12 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
||||||
|
|
||||||
%%
|
%%
|
||||||
/* Common tokens */
|
/* Common tokens */
|
||||||
<KEYWORD,DEVIATE,BOOLEAN,INTEGER,STRARG,STRING>[ \t]
|
<KEYWORD,DEVIATE,DEVIATESTR,BOOLEAN,INTEGER,STRARG,STRING>[ \t]
|
||||||
<KEYWORD,DEVIATE,STRING,UNKNOWN,UNKNOWN2,COMMENT2><<EOF>> { return MY_EOF; }
|
<KEYWORD,DEVIATE,DEVIATESTR,STRING,UNKNOWN,UNKNOWN2,COMMENT2><<EOF>> { return MY_EOF; }
|
||||||
<KEYWORD,DEVIATE,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\n { _YY->yy_linenum++; }
|
<KEYWORD,DEVIATE,DEVIATESTR,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\n { _YY->yy_linenum++; }
|
||||||
<KEYWORD,DEVIATE,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\r
|
<KEYWORD,DEVIATE,DEVIATESTR,BOOLEAN,INTEGER,STRARG,STRING,COMMENT1,UNKNOWN,UNKNOWN2>\r
|
||||||
<KEYWORD,DEVIATE,STRING,UNKNOWN,UNKNOWN2>"/*" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT1); }
|
<KEYWORD,DEVIATE,DEVIATESTR,STRING,UNKNOWN,UNKNOWN2>"/*" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT1); }
|
||||||
<KEYWORD,DEVIATE,STRING,UNKNOWN,UNKNOWN2>"//" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT2); }
|
<KEYWORD,DEVIATE,DEVIATESTR,STRING,UNKNOWN,UNKNOWN2>"//" { _YY->yy_lex_state = YYSTATE; BEGIN(COMMENT2); }
|
||||||
|
|
||||||
|
|
||||||
<KEYWORD>input { return K_INPUT; } /* No argument */
|
<KEYWORD>input { return K_INPUT; } /* No argument */
|
||||||
|
|
@ -202,7 +203,14 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
||||||
<DEVIATE>add { BEGIN(KEYWORD); return D_ADD; }
|
<DEVIATE>add { BEGIN(KEYWORD); return D_ADD; }
|
||||||
<DEVIATE>delete { BEGIN(KEYWORD); return D_DELETE; }
|
<DEVIATE>delete { BEGIN(KEYWORD); return D_DELETE; }
|
||||||
<DEVIATE>replace { BEGIN(KEYWORD); return D_REPLACE; }
|
<DEVIATE>replace { BEGIN(KEYWORD); return D_REPLACE; }
|
||||||
|
<DEVIATE>\" { BEGIN(DEVIATESTR); return *yytext; }
|
||||||
|
<DEVIATE>\' { BEGIN(DEVIATESTR); return *yytext; }
|
||||||
<DEVIATE>. { BEGIN(KEYWORD); return *yytext; }
|
<DEVIATE>. { BEGIN(KEYWORD); return *yytext; }
|
||||||
|
<DEVIATESTR>not-supported { return D_NOT_SUPPORTED; }
|
||||||
|
<DEVIATESTR>add { return D_ADD; }
|
||||||
|
<DEVIATESTR>delete { return D_DELETE; }
|
||||||
|
<DEVIATESTR>replace { return D_REPLACE; }
|
||||||
|
<DEVIATESTR>. { 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; }
|
||||||
|
|
|
||||||
|
|
@ -1529,16 +1529,26 @@ deviation_substmt : description_stmt { _PARSE_DEBUG("deviation-substmt -> descr
|
||||||
| deviate_replace_stmt { _PARSE_DEBUG("deviation-stmt -> deviate-replace-stmt");}
|
| deviate_replace_stmt { _PARSE_DEBUG("deviation-stmt -> deviate-replace-stmt");}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
not_supported_keyword_str : D_NOT_SUPPORTED
|
||||||
|
| '"' D_NOT_SUPPORTED '"'
|
||||||
|
| SQ D_NOT_SUPPORTED SQ
|
||||||
|
;
|
||||||
|
|
||||||
deviate_not_supported_stmt
|
deviate_not_supported_stmt
|
||||||
: K_DEVIATE D_NOT_SUPPORTED ';'
|
: K_DEVIATE not_supported_keyword_str ';'
|
||||||
{ if (ysp_add(_yy, Y_DEVIATE, strdup("not-supported") /* D_NOT_SUPPORTED*/, NULL) == NULL) _YYERROR("notification_stmt");
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("not-supported"), NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
_PARSE_DEBUG("deviate-not-supported-stmt -> DEVIATE not-supported ;"); }
|
_PARSE_DEBUG("deviate-not-supported-stmt -> DEVIATE not-supported ;"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
deviate_add_stmt : K_DEVIATE D_ADD ';'
|
add_keyword_str : D_ADD
|
||||||
{ if (ysp_add(_yy, Y_DEVIATE, strdup("add") /* D_NOT_SUPPORTED*/, NULL) == NULL) _YYERROR("notification_stmt");
|
| '"' D_ADD '"'
|
||||||
|
| SQ D_ADD SQ
|
||||||
|
;
|
||||||
|
|
||||||
|
deviate_add_stmt : K_DEVIATE add_keyword_str ';'
|
||||||
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("add"), NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
_PARSE_DEBUG("deviate-add-stmt -> DEVIATE add ;"); }
|
_PARSE_DEBUG("deviate-add-stmt -> DEVIATE add ;"); }
|
||||||
| K_DEVIATE D_ADD
|
| K_DEVIATE add_keyword_str
|
||||||
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("add"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("add"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
||||||
'{' deviate_add_substmts '}'
|
'{' deviate_add_substmts '}'
|
||||||
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
||||||
|
|
@ -1562,10 +1572,15 @@ deviate_add_substmt : units_stmt { _PARSE_DEBUG("deviate-add-substmt -> units
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
deviate_delete_stmt : K_DEVIATE D_DELETE ';'
|
delete_keyword_str : D_DELETE
|
||||||
|
| '"' D_DELETE '"'
|
||||||
|
| SQ D_DELETE SQ
|
||||||
|
;
|
||||||
|
|
||||||
|
deviate_delete_stmt : K_DEVIATE delete_keyword_str ';'
|
||||||
{ if (ysp_add(_yy, Y_DEVIATE, strdup("delete"), NULL) == NULL) _YYERROR("notification_stmt");
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("delete"), NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
_PARSE_DEBUG("deviate-delete-stmt -> DEVIATE delete ;"); }
|
_PARSE_DEBUG("deviate-delete-stmt -> DEVIATE delete ;"); }
|
||||||
| K_DEVIATE D_DELETE
|
| K_DEVIATE delete_keyword_str
|
||||||
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("delete"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("delete"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
||||||
'{' deviate_delete_substmts '}'
|
'{' deviate_delete_substmts '}'
|
||||||
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
||||||
|
|
@ -1584,10 +1599,15 @@ deviate_delete_substmt : units_stmt { _PARSE_DEBUG("deviate-delete-substmt -> un
|
||||||
| { _PARSE_DEBUG("deviate-delete-substmt -> "); }
|
| { _PARSE_DEBUG("deviate-delete-substmt -> "); }
|
||||||
;
|
;
|
||||||
|
|
||||||
deviate_replace_stmt : K_DEVIATE D_REPLACE ';'
|
replace_keyword_str : D_REPLACE
|
||||||
|
| '"' D_REPLACE '"'
|
||||||
|
| SQ D_REPLACE SQ
|
||||||
|
;
|
||||||
|
|
||||||
|
deviate_replace_stmt : K_DEVIATE replace_keyword_str ';'
|
||||||
{ if (ysp_add(_yy, Y_DEVIATE, strdup("replace"), NULL) == NULL) _YYERROR("notification_stmt");
|
{ if (ysp_add(_yy, Y_DEVIATE, strdup("replace"), NULL) == NULL) _YYERROR("notification_stmt");
|
||||||
_PARSE_DEBUG("deviate-replace-stmt -> DEVIATE replace ;"); }
|
_PARSE_DEBUG("deviate-replace-stmt -> DEVIATE replace ;"); }
|
||||||
| K_DEVIATE D_REPLACE
|
| K_DEVIATE replace_keyword_str
|
||||||
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("replace"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
{ if (ysp_add_push(_yy, Y_DEVIATE, strdup("replace"), NULL) == NULL) _YYERROR("deviate_stmt"); }
|
||||||
'{' deviate_replace_substmts '}'
|
'{' deviate_replace_substmts '}'
|
||||||
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
{ if (ystack_pop(_yy) < 0) _YYERROR("deviate_stmt");
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ module example-deviations{
|
||||||
prefix base;
|
prefix base;
|
||||||
}
|
}
|
||||||
deviation /base:system/base:daytime {
|
deviation /base:system/base:daytime {
|
||||||
deviate not-supported;
|
deviate "not-supported"; // Note a string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue