diff --git a/tools/widl/header.c b/tools/widl/header.c index 2f275c7ac24..bd9f21c8299 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1342,6 +1342,7 @@ static void write_imports(FILE *header, const statement_list_t *stmts) case STMT_TYPEDEF: case STMT_MODULE: case STMT_CPPQUOTE: + case STMT_PRAGMA: case STMT_DECLARATION: /* not processed here */ break; @@ -1376,6 +1377,7 @@ static void write_forward_decls(FILE *header, const statement_list_t *stmts) case STMT_TYPEDEF: case STMT_MODULE: case STMT_CPPQUOTE: + case STMT_PRAGMA: case STMT_DECLARATION: /* not processed here */ break; @@ -1428,6 +1430,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons break; case STMT_IMPORTLIB: case STMT_MODULE: + case STMT_PRAGMA: /* not included in header */ break; case STMT_IMPORT: diff --git a/tools/widl/parser.l b/tools/widl/parser.l index fb61e219685..b911186fc51 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -37,6 +37,7 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)* %x WSTRQUOTE %x ATTR %x PP_LINE +%x PP_PRAGMA %x SQUOTE %{ @@ -125,6 +126,7 @@ UUID *parse_uuid(const char *u) ************************************************************************** */ %% +^{ws}*\#{ws}*pragma{ws}+ yy_push_state(PP_PRAGMA); ^{ws}*\#{ws}* yy_push_state(PP_LINE); [^\n]* { int lineno; @@ -144,6 +146,8 @@ UUID *parse_uuid(const char *u) line_number = lineno - 1; /* We didn't read the newline */ input_name = xstrdup(fname); } +midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE; +[^\n]* parser_lval.str = xstrdup(yytext); yy_pop_state(); return aPRAGMA; \" yy_push_state(QUOTE); cbufidx = 0; \" { yy_pop_state(); diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 97c3896567b..946d165a3f0 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -114,6 +114,7 @@ static statement_t *make_statement_type_decl(type_t *type); static statement_t *make_statement_reference(type_t *type); static statement_t *make_statement_declaration(var_t *var); static statement_t *make_statement_library(typelib_t *typelib); +static statement_t *make_statement_pragma(const char *str); static statement_t *make_statement_cppquote(const char *str); static statement_t *make_statement_importlib(const char *str); static statement_t *make_statement_module(type_t *type); @@ -152,7 +153,7 @@ static attr_list_t *append_attribs(attr_list_t *, attr_list_t *); enum storage_class stgclass; } -%token aIDENTIFIER +%token aIDENTIFIER aPRAGMA %token aKNOWNTYPE %token aNUM aHEXNUM %token aDOUBLE @@ -363,6 +364,7 @@ statement: | declaration ';' { $$ = make_statement_declaration($1); } | import { $$ = make_statement_import($1); } | typedef ';' { $$ = $1; } + | aPRAGMA { $$ = make_statement_pragma($1); } ; typedecl: @@ -2744,6 +2746,13 @@ static statement_t *make_statement_library(typelib_t *typelib) return stmt; } +static statement_t *make_statement_pragma(const char *str) +{ + statement_t *stmt = make_statement(STMT_PRAGMA); + stmt->u.str = str; + return stmt; +} + static statement_t *make_statement_cppquote(const char *str) { statement_t *stmt = make_statement(STMT_CPPQUOTE); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index efde0b0f074..30b6560f3d5 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -243,6 +243,7 @@ enum statement_type STMT_TYPEDEF, STMT_IMPORT, STMT_IMPORTLIB, + STMT_PRAGMA, STMT_CPPQUOTE }; diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index dd984863f16..6eb229af119 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2266,6 +2266,7 @@ static void add_entry(msft_typelib_t *typelib, const statement_t *stmt) switch(stmt->type) { case STMT_LIBRARY: case STMT_IMPORT: + case STMT_PRAGMA: case STMT_CPPQUOTE: case STMT_DECLARATION: /* not included in typelib */