Re: [tools 1/2] Handle "midl_pragma warning" statement in parser
On 20.03.2016 13:11, Bolotov Sergey wrote:
Signed-off-by: Bolotov Sergey <bolotov.s.s(a)yandex.ru> --- tools/widl/parser.h | 2 ++ tools/widl/parser.l | 25 +++++++++++++++++++++++++ tools/widl/parser.y | 38 +++++++++++++++++++++++++++++++++++++- tools/widl/widltypes.h | 7 +++++++ 4 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/tools/widl/parser.h b/tools/widl/parser.h index 1bcc3c1..c15d874 100644 --- a/tools/widl/parser.h +++ b/tools/widl/parser.h @@ -45,6 +45,8 @@ void pop_import(void);
int is_type(const char *name);
+int do_warning(char *toggle, warning_list_t *wnum); + extern char *temp_name;
#endif diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 5c2dcab..65e0f45 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -164,6 +164,7 @@ UUID *parse_uuid(const char *u) yy_pop_state(); } <PP_PRAGMA>[^\n]* parser_lval.str = xstrdup(yytext); yy_pop_state(); return aPRAGMA; +<INITIAL>^{ws}*"midl_pragma warning" return tPRAGMA_WARNING; <INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0; <QUOTE>\" {
This is wrong, any number of spaces is allowed before 'warning'.
yy_pop_state(); @@ -555,3 +556,27 @@ void abort_import(void) for (ptr=0; ptr<import_stack_ptr; ptr++) unlink(import_stack[ptr].temp_name); } + +static void warning_disable(int warning) +{ + printf("disable %d\n", warning); +} + +static void warning_enable(int warning) +{ + printf("enable %d\n", warning); +} + +int do_warning(char *toggle, warning_list_t *wnum) +{ + warning_t *warning; + if(!strcmp(toggle, "disable")) + LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry) + warning_disable(warning->num); + else if(!strcmp(toggle, "enable")) + LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry) + warning_enable(warning->num); + else + return 0; + return 1; +}
You remove this in next patch, I think it'd be enough to add parser support first, so widl does not fail on such construct, and add handling as 2/2. Why do you need this in a first place? Is it to process some third party idls?
participants (1)
-
Nikolay Sivov