diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 342109e8bd1..3cbf4ff2d2b 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -76,6 +76,8 @@ static int cbufalloc = 0; static int kw_token(const char *kw); static int attr_token(const char *kw); +static void switch_to_acf(void); + static warning_list_t *disabled_warnings = NULL; #define MAX_IMPORT_DEPTH 20 @@ -225,9 +227,14 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY; \.\.\. return ELLIPSIS; . return yytext[0]; <> { - if (import_stack_ptr) - return aEOF; - else yyterminate(); + if (import_stack_ptr) + return aEOF; + if (acf_name) + { + switch_to_acf(); + return aACF; + } + yyterminate(); } %% @@ -563,6 +570,38 @@ void abort_import(void) unlink(import_stack[ptr].temp_name); } +static void switch_to_acf(void) +{ + int ptr = import_stack_ptr; + int ret, fd; + char *name; + FILE *f; + + assert(import_stack_ptr == 0); + + input_name = acf_name; + acf_name = NULL; + line_number = 1; + + name = xstrdup( "widl.XXXXXX" ); + if((fd = mkstemps( name, 0 )) == -1) + error("Could not generate a temp name from %s\n", name); + + temp_name = name; + if (!(f = fdopen(fd, "wt"))) + error("Could not open fd %s for writing\n", name); + + ret = wpp_parse(input_name, f); + fclose(f); + if (ret) exit(1); + + if((f = fopen(temp_name, "r")) == NULL) + error_loc("Unable to open %s\n", temp_name); + + import_stack[ptr].state = YY_CURRENT_BUFFER; + yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE)); +} + static void warning_disable(int warning) { warning_t *warning_entry; diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 757d7968477..542ee43e9ff 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -173,7 +173,7 @@ static typelib_t *current_typelib; %token aDOUBLE %token aSTRING aWSTRING aSQSTRING %token aUUID -%token aEOF +%token aEOF aACF %token SHL SHR %token MEMBERPTR %token EQUALITY INEQUALITY @@ -321,7 +321,7 @@ static typelib_t *current_typelib; %% -input: gbl_statements { fix_incomplete(); +input: gbl_statements m_acf { fix_incomplete(); check_statements($1, FALSE); check_all_user_types($1); write_header($1); @@ -336,6 +336,8 @@ input: gbl_statements { fix_incomplete(); } ; +m_acf: /* empty */ | aACF acf_statements + gbl_statements: { $$ = NULL; } | gbl_statements namespacedef '{' { push_namespace($2); } gbl_statements '}' { pop_namespace($2); $$ = append_statements($1, $5); } @@ -1150,6 +1152,9 @@ version: | aHEXNUM { $$ = $1; } ; +acf_statements + : /* empty */ + %% static void decl_builtin_basic(const char *name, enum type_basic_type type)