Commit cc02e152 authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Add support for #pragma directives.

parent 1f3e3fa4
...@@ -1342,6 +1342,7 @@ static void write_imports(FILE *header, const statement_list_t *stmts) ...@@ -1342,6 +1342,7 @@ static void write_imports(FILE *header, const statement_list_t *stmts)
case STMT_TYPEDEF: case STMT_TYPEDEF:
case STMT_MODULE: case STMT_MODULE:
case STMT_CPPQUOTE: case STMT_CPPQUOTE:
case STMT_PRAGMA:
case STMT_DECLARATION: case STMT_DECLARATION:
/* not processed here */ /* not processed here */
break; break;
...@@ -1376,6 +1377,7 @@ static void write_forward_decls(FILE *header, const statement_list_t *stmts) ...@@ -1376,6 +1377,7 @@ static void write_forward_decls(FILE *header, const statement_list_t *stmts)
case STMT_TYPEDEF: case STMT_TYPEDEF:
case STMT_MODULE: case STMT_MODULE:
case STMT_CPPQUOTE: case STMT_CPPQUOTE:
case STMT_PRAGMA:
case STMT_DECLARATION: case STMT_DECLARATION:
/* not processed here */ /* not processed here */
break; break;
...@@ -1428,6 +1430,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons ...@@ -1428,6 +1430,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
break; break;
case STMT_IMPORTLIB: case STMT_IMPORTLIB:
case STMT_MODULE: case STMT_MODULE:
case STMT_PRAGMA:
/* not included in header */ /* not included in header */
break; break;
case STMT_IMPORT: case STMT_IMPORT:
......
...@@ -37,6 +37,7 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)* ...@@ -37,6 +37,7 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
%x WSTRQUOTE %x WSTRQUOTE
%x ATTR %x ATTR
%x PP_LINE %x PP_LINE
%x PP_PRAGMA
%x SQUOTE %x SQUOTE
%{ %{
...@@ -125,6 +126,7 @@ UUID *parse_uuid(const char *u) ...@@ -125,6 +126,7 @@ UUID *parse_uuid(const char *u)
************************************************************************** **************************************************************************
*/ */
%% %%
<INITIAL>^{ws}*\#{ws}*pragma{ws}+ yy_push_state(PP_PRAGMA);
<INITIAL,ATTR>^{ws}*\#{ws}* yy_push_state(PP_LINE); <INITIAL,ATTR>^{ws}*\#{ws}* yy_push_state(PP_LINE);
<PP_LINE>[^\n]* { <PP_LINE>[^\n]* {
int lineno; int lineno;
...@@ -144,6 +146,8 @@ UUID *parse_uuid(const char *u) ...@@ -144,6 +146,8 @@ UUID *parse_uuid(const char *u)
line_number = lineno - 1; /* We didn't read the newline */ line_number = lineno - 1; /* We didn't read the newline */
input_name = xstrdup(fname); input_name = xstrdup(fname);
} }
<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE;
<PP_PRAGMA>[^\n]* parser_lval.str = xstrdup(yytext); yy_pop_state(); return aPRAGMA;
<INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0; <INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0;
<QUOTE>\" { <QUOTE>\" {
yy_pop_state(); yy_pop_state();
......
...@@ -114,6 +114,7 @@ static statement_t *make_statement_type_decl(type_t *type); ...@@ -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_reference(type_t *type);
static statement_t *make_statement_declaration(var_t *var); static statement_t *make_statement_declaration(var_t *var);
static statement_t *make_statement_library(typelib_t *typelib); 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_cppquote(const char *str);
static statement_t *make_statement_importlib(const char *str); static statement_t *make_statement_importlib(const char *str);
static statement_t *make_statement_module(type_t *type); 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 *); ...@@ -152,7 +153,7 @@ static attr_list_t *append_attribs(attr_list_t *, attr_list_t *);
enum storage_class stgclass; enum storage_class stgclass;
} }
%token <str> aIDENTIFIER %token <str> aIDENTIFIER aPRAGMA
%token <str> aKNOWNTYPE %token <str> aKNOWNTYPE
%token <num> aNUM aHEXNUM %token <num> aNUM aHEXNUM
%token <dbl> aDOUBLE %token <dbl> aDOUBLE
...@@ -363,6 +364,7 @@ statement: ...@@ -363,6 +364,7 @@ statement:
| declaration ';' { $$ = make_statement_declaration($1); } | declaration ';' { $$ = make_statement_declaration($1); }
| import { $$ = make_statement_import($1); } | import { $$ = make_statement_import($1); }
| typedef ';' { $$ = $1; } | typedef ';' { $$ = $1; }
| aPRAGMA { $$ = make_statement_pragma($1); }
; ;
typedecl: typedecl:
...@@ -2744,6 +2746,13 @@ static statement_t *make_statement_library(typelib_t *typelib) ...@@ -2744,6 +2746,13 @@ static statement_t *make_statement_library(typelib_t *typelib)
return stmt; 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) static statement_t *make_statement_cppquote(const char *str)
{ {
statement_t *stmt = make_statement(STMT_CPPQUOTE); statement_t *stmt = make_statement(STMT_CPPQUOTE);
......
...@@ -243,6 +243,7 @@ enum statement_type ...@@ -243,6 +243,7 @@ enum statement_type
STMT_TYPEDEF, STMT_TYPEDEF,
STMT_IMPORT, STMT_IMPORT,
STMT_IMPORTLIB, STMT_IMPORTLIB,
STMT_PRAGMA,
STMT_CPPQUOTE STMT_CPPQUOTE
}; };
......
...@@ -2266,6 +2266,7 @@ static void add_entry(msft_typelib_t *typelib, const statement_t *stmt) ...@@ -2266,6 +2266,7 @@ static void add_entry(msft_typelib_t *typelib, const statement_t *stmt)
switch(stmt->type) { switch(stmt->type) {
case STMT_LIBRARY: case STMT_LIBRARY:
case STMT_IMPORT: case STMT_IMPORT:
case STMT_PRAGMA:
case STMT_CPPQUOTE: case STMT_CPPQUOTE:
case STMT_DECLARATION: case STMT_DECLARATION:
/* not included in typelib */ /* not included in typelib */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment