Fixed some OOM conditions in GlobalAlloc.
[wine/multimedia.git] / tools / wrc / parser.y
blob4215982fdaee81c61e872bd660f793158653dc05
1 %{
2 /*
3 * Copyright 1994 Martin von Loewis
4 * Copyright 1998-2000 Bertho A. Stultiens (BS)
5 * 1999 Juergen Schmied (JS)
7 * 21-May-2000 BS - Partial implementation of font resources.
8 * - Corrected language propagation for binary
9 * resources such as bitmaps, isons, cursors,
10 * userres and rcdata. The language is now
11 * correct in .res files.
12 * - Fixed reading the resource name as ident,
13 * so that it may overlap keywords.
14 * 20-May-2000 BS - Implemented animated cursors and icons
15 * resource types.
16 * 30-Apr-2000 BS - Reintegration into the wine-tree
17 * 14-Jan-2000 BS - Redid the usertype resources so that they
18 * are compatible.
19 * 02-Jan-2000 BS - Removed the preprocessor from the grammar
20 * expect for the # command (line numbers).
22 * 06-Nov-1999 JS - see CHANGES
24 * 29-Dec-1998 AdH - Grammar and function extensions.
25 * grammar: TOOLBAR resources, Named ICONs in
26 * DIALOGS
27 * functions: semantic actions for the grammar
28 * changes, resource files can now be anywhere
29 * on the include path instead of just in the
30 * current directory
32 * 20-Jun-1998 BS - Fixed a bug in load_file() where the name was not
33 * printed out correctly.
35 * 17-Jun-1998 BS - Fixed a bug in CLASS statement parsing which should
36 * also accept a tSTRING as argument.
38 * 25-May-1998 BS - Found out that I need to support language, version
39 * and characteristics in inline resources (bitmap,
40 * cursor, etc) but they can also be specified with
41 * a filename. This renders my filename-scanning scheme
42 * worthless. Need to build newline parsing to solve
43 * this one.
44 * It will come with version 1.1.0 (sigh).
46 * 19-May-1998 BS - Started to build a builtin preprocessor
48 * 30-Apr-1998 BS - Redid the stringtable parsing/handling. My previous
49 * ideas had some serious flaws.
51 * 27-Apr-1998 BS - Removed a lot of dead comments and put it in a doc
52 * file.
54 * 21-Apr-1998 BS - Added correct behavior for cursors and icons.
55 * - This file is growing too big. It is time to strip
56 * things and put it in a support file.
58 * 19-Apr-1998 BS - Tagged the stringtable resource so that only one
59 * resource will be created. This because the table
60 * has a different layout than other resources. The
61 * table has to be sorted, and divided into smaller
62 * resource entries (see comment in source).
64 * 17-Apr-1998 BS - Almost all strings, including identifiers, are parsed
65 * as string_t which include unicode strings upon
66 * input.
67 * - Parser now emits a warning when compiling win32
68 * extensions in win16 mode.
70 * 16-Apr-1998 BS - Raw data elements are now *optionally* seperated
71 * by commas. Read the comments in file sq2dq.l.
72 * - FIXME: there are instances in the source that rely
73 * on the fact that int==32bit and pointers are int size.
74 * - Fixed the conflict in menuex by changing a rule
75 * back into right recursion. See note in source.
76 * - UserType resources cannot have an expression as its
77 * typeclass. See note in source.
79 * 15-Apr-1998 BS - Changed all right recursion into left recursion to
80 * get reduction of the parsestack.
81 * This also helps communication between bison and flex.
82 * Main advantage is that the Empty rule gets reduced
83 * first, which is used to allocate/link things.
84 * It also added a shift/reduce conflict in the menuex
85 * handling, due to expression/option possibility,
86 * although not serious.
88 * 14-Apr-1998 BS - Redone almost the entire parser. We're not talking
89 * about making it more efficient, but readable (for me)
90 * and slightly easier to expand/change.
91 * This is done primarily by using more reduce states
92 * with many (intuitive) types for the various resource
93 * statements.
94 * - Added expression handling for all resources where a
95 * number is accepted (not only for win32). Also added
96 * multiply and division (not MS compatible, but handy).
97 * Unary minus introduced a shift/reduce conflict, but
98 * it is not serious.
100 * 13-Apr-1998 BS - Reordered a lot of things
101 * - Made the source more readable
102 * - Added Win32 resource definitions
103 * - Corrected syntax problems with an old yacc (;)
104 * - Added extra comment about grammar
106 #include "config.h"
108 #include <stdio.h>
109 #include <stdlib.h>
110 #include <stdarg.h>
111 #include <assert.h>
112 #include <ctype.h>
113 #include <string.h>
114 #ifdef HAVE_ALLOCA_H
115 #include <alloca.h>
116 #endif
118 #include "wrc.h"
119 #include "utils.h"
120 #include "newstruc.h"
121 #include "dumpres.h"
122 #include "preproc.h"
123 #include "parser.h"
124 #include "windef.h"
125 #include "wingdi.h"
126 #include "winuser.h"
128 int want_nl = 0; /* Signal flex that we need the next newline */
129 int want_id = 0; /* Signal flex that we need the next identifier */
130 stringtable_t *tagstt; /* Stringtable tag.
131 * It is set while parsing a stringtable to one of
132 * the stringtables in the sttres list or a new one
133 * if the language was not parsed before.
135 stringtable_t *sttres; /* Stringtable resources. This holds the list of
136 * stringtables with different lanuages
138 /* Set to the current options of the currently scanning stringtable */
139 static int *tagstt_memopt;
140 static characts_t *tagstt_characts;
141 static version_t *tagstt_version;
143 static const char riff[4] = "RIFF"; /* RIFF file magic for animated cursor/icon */
145 /* Prototypes of here defined functions */
146 static event_t *get_event_head(event_t *p);
147 static control_t *get_control_head(control_t *p);
148 static ver_value_t *get_ver_value_head(ver_value_t *p);
149 static ver_block_t *get_ver_block_head(ver_block_t *p);
150 static resource_t *get_resource_head(resource_t *p);
151 static menuex_item_t *get_itemex_head(menuex_item_t *p);
152 static menu_item_t *get_item_head(menu_item_t *p);
153 static raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str);
154 static raw_data_t *merge_raw_data_int(raw_data_t *r1, int i);
155 static raw_data_t *merge_raw_data_long(raw_data_t *r1, int i);
156 static raw_data_t *merge_raw_data(raw_data_t *r1, raw_data_t *r2);
157 static raw_data_t *str2raw_data(string_t *str);
158 static raw_data_t *int2raw_data(int i);
159 static raw_data_t *long2raw_data(int i);
160 static raw_data_t *load_file(string_t *name);
161 static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid);
162 static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev);
163 static event_t *add_event(int key, int id, int flags, event_t *prev);
164 static dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg);
165 static dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg);
166 static dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg);
167 static dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg);
168 static dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg);
169 static dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg);
170 static dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg);
171 static dialogex_t *dialogex_exstyle(style_t *st, dialogex_t *dlg);
172 static dialogex_t *dialogex_style(style_t *st, dialogex_t *dlg);
173 static name_id_t *convert_ctlclass(name_id_t *cls);
174 static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev);
175 static dialog_t *dialog_version(version_t *v, dialog_t *dlg);
176 static dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg);
177 static dialog_t *dialog_language(language_t *l, dialog_t *dlg);
178 static dialog_t *dialog_menu(name_id_t *m, dialog_t *dlg);
179 static dialog_t *dialog_class(name_id_t *n, dialog_t *dlg);
180 static dialog_t *dialog_font(font_id_t *f, dialog_t *dlg);
181 static dialog_t *dialog_caption(string_t *s, dialog_t *dlg);
182 static dialog_t *dialog_exstyle(style_t * st, dialog_t *dlg);
183 static dialog_t *dialog_style(style_t * st, dialog_t *dlg);
184 static resource_t *build_stt_resources(stringtable_t *stthead);
185 static stringtable_t *find_stringtable(lvc_t *lvc);
186 static toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec);
187 static toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems);
188 static string_t *make_filename(string_t *s);
189 static resource_t *build_fontdirs(resource_t *tail);
190 static resource_t *build_fontdir(resource_t **fnt, int nfnt);
191 static int rsrcid_to_token(int lookahead);
194 %union{
195 string_t *str;
196 int num;
197 int *iptr;
198 char *cptr;
199 resource_t *res;
200 accelerator_t *acc;
201 bitmap_t *bmp;
202 dialog_t *dlg;
203 dialogex_t *dlgex;
204 font_t *fnt;
205 fontdir_t *fnd;
206 menu_t *men;
207 menuex_t *menex;
208 rcdata_t *rdt;
209 stringtable_t *stt;
210 stt_entry_t *stte;
211 user_t *usr;
212 messagetable_t *msg;
213 versioninfo_t *veri;
214 control_t *ctl;
215 name_id_t *nid;
216 font_id_t *fntid;
217 language_t *lan;
218 version_t *ver;
219 characts_t *chars;
220 event_t *event;
221 menu_item_t *menitm;
222 menuex_item_t *menexitm;
223 itemex_opt_t *exopt;
224 raw_data_t *raw;
225 lvc_t *lvc;
226 ver_value_t *val;
227 ver_block_t *blk;
228 ver_words_t *verw;
229 toolbar_t *tlbar;
230 toolbar_item_t *tlbarItems;
231 dlginit_t *dginit;
232 style_pair_t *styles;
233 style_t *style;
234 ani_any_t *ani;
237 %token tTYPEDEF tEXTERN tSTRUCT tENUM tCPPCLASS tINLINE tSTATIC tNL
238 %token <num> tNUMBER tLNUMBER
239 %token <str> tSTRING tIDENT tFILENAME
240 %token <raw> tRAWDATA
241 %token tACCELERATORS tBITMAP tCURSOR tDIALOG tDIALOGEX tMENU tMENUEX tMESSAGETABLE
242 %token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON
243 %token tAUTO3STATE tAUTOCHECKBOX tAUTORADIOBUTTON tCHECKBOX tDEFPUSHBUTTON
244 %token tPUSHBUTTON tRADIOBUTTON tSTATE3 /* PUSHBOX */
245 %token tGROUPBOX tCOMBOBOX tLISTBOX tSCROLLBAR
246 %token tCONTROL tEDITTEXT
247 %token tRTEXT tCTEXT tLTEXT
248 %token tBLOCK tVALUE
249 %token tSHIFT tALT tASCII tVIRTKEY tGRAYED tCHECKED tINACTIVE tNOINVERT
250 %token tPURE tIMPURE tDISCARDABLE tLOADONCALL tPRELOAD tFIXED tMOVEABLE
251 %token tCLASS tCAPTION tCHARACTERISTICS tEXSTYLE tSTYLE tVERSION tLANGUAGE
252 %token tFILEVERSION tPRODUCTVERSION tFILEFLAGSMASK tFILEOS tFILETYPE tFILEFLAGS tFILESUBTYPE
253 %token tMENUBARBREAK tMENUBREAK tMENUITEM tPOPUP tSEPARATOR
254 %token tHELP
255 %token tSTRING tIDENT tRAWDATA
256 %token tTOOLBAR tBUTTON
257 %token tBEGIN tEND
258 %token tDLGINIT
259 %left '|'
260 %left '^'
261 %left '&'
262 %left '+' '-'
263 %left '*' '/'
264 %right '~' tNOT
265 %left pUPM
267 %type <res> resource_file resource resources resource_definition
268 %type <stt> stringtable strings
269 %type <fnt> font
270 %type <fnd> fontdir
271 %type <acc> accelerators
272 %type <event> events
273 %type <bmp> bitmap
274 %type <ani> cursor icon
275 %type <dlg> dialog dlg_attributes
276 %type <ctl> ctrls gen_ctrl lab_ctrl ctrl_desc iconinfo
277 %type <iptr> helpid
278 %type <dlgex> dialogex dlgex_attribs
279 %type <ctl> exctrls gen_exctrl lab_exctrl exctrl_desc
280 %type <rdt> rcdata
281 %type <raw> raw_data raw_elements opt_data file_raw
282 %type <veri> versioninfo fix_version
283 %type <verw> ver_words
284 %type <blk> ver_blocks ver_block
285 %type <val> ver_values ver_value
286 %type <men> menu
287 %type <menitm> item_definitions menu_body
288 %type <menex> menuex
289 %type <menexitm> itemex_definitions menuex_body
290 %type <exopt> itemex_p_options itemex_options
291 %type <msg> messagetable
292 %type <usr> userres
293 %type <num> item_options
294 %type <nid> nameid nameid_s ctlclass usertype
295 %type <num> acc_opt acc accs
296 %type <iptr> loadmemopts lamo lama
297 %type <fntid> opt_font opt_exfont opt_expr
298 %type <lvc> opt_lvc
299 %type <lan> opt_language
300 %type <chars> opt_characts
301 %type <ver> opt_version
302 %type <num> expr xpr
303 %type <iptr> e_expr
304 %type <tlbar> toolbar
305 %type <tlbarItems> toolbar_items
306 %type <dginit> dlginit
307 %type <styles> optional_style_pair
308 %type <num> any_num any_nums
309 %type <style> optional_style
310 %type <style> style
311 %type <str> filename
315 resource_file
316 : resources {
317 resource_t *rsc;
318 /* First add stringtables to the resource-list */
319 rsc = build_stt_resources(sttres);
320 /* 'build_stt_resources' returns a head and $1 is a tail */
321 if($1)
323 $1->next = rsc;
324 if(rsc)
325 rsc->prev = $1;
327 else
328 $1 = rsc;
329 /* Find the tail again */
330 while($1 && $1->next)
331 $1 = $1->next;
332 /* Now add any fontdirecory */
333 rsc = build_fontdirs($1);
334 /* 'build_fontdir' returns a head and $1 is a tail */
335 if($1)
337 $1->next = rsc;
338 if(rsc)
339 rsc->prev = $1;
341 else
342 $1 = rsc;
343 /* Final statement before were done */
344 resource_top = get_resource_head($1);
348 /* Resources are put into a linked list */
349 resources
350 : /* Empty */ { $$ = NULL; want_id = 1; }
351 | resources resource {
352 if($2)
354 resource_t *tail = $2;
355 resource_t *head = $2;
356 while(tail->next)
357 tail = tail->next;
358 while(head->prev)
359 head = head->prev;
360 head->prev = $1;
361 if($1)
362 $1->next = head;
363 $$ = tail;
364 /* Check for duplicate identifiers */
365 while($1 && head)
367 resource_t *rsc = $1;
368 while(rsc)
370 if(rsc->type == head->type
371 && rsc->lan->id == head->lan->id
372 && rsc->lan->sub == head->lan->sub
373 && !compare_name_id(rsc->name, head->name))
375 yyerror("Duplicate resource name '%s'", get_nameid_str(rsc->name));
377 rsc = rsc->prev;
379 head = head->next;
382 else if($1)
384 resource_t *tail = $1;
385 while(tail->next)
386 tail = tail->next;
387 $$ = tail;
389 else
390 $$ = NULL;
391 want_id = 1;
393 | resources preprocessor { $$ = $1; want_id = 1; }
394 | resources cjunk { $$ = $1; want_id = 1; }
398 * The preprocessor generates line directives a la gcc
399 * in the format:
400 * # <linenum> "filename" <codes>
402 * Codes can be a sequence of:
403 * - 1 start of new file
404 * - 2 returning to previous
405 * - 3 system header
406 * - 4 interpret as C-code
408 * 4 is not used and 1 mutually excludes 2
409 * Anyhow, we are not really interested in these at all
410 * because we only want to know the linenumber and
411 * filename.
413 preprocessor
414 : '#' { want_nl = 1; } tNUMBER tSTRING any_nums tNL {
415 line_number = $3;
416 input_name = $4->str.cstr;
417 /* fprintf(stderr, "Now at %s:%d\n", input_name, line_number); */
421 any_nums: any_num
422 | any_nums any_num
425 /* C ignore stuff */
426 cjunk : tTYPEDEF { strip_til_semicolon(); }
427 | tSTRUCT { strip_til_semicolon(); }
428 | tEXTERN { strip_til_semicolon(); }
429 | tENUM { strip_til_semicolon(); }
430 | tCPPCLASS { strip_til_semicolon(); }
431 | tSTATIC { strip_til_semicolon(); }
432 | tINLINE { internal_error(__FILE__, __LINE__, "Don't yet know how to strip inline functions\n"); }
433 /* | tIDENT tIDENT { strip_til_semicolon(); } */
434 | tIDENT tIDENT '(' { strip_til_parenthesis(); }
435 /* | tIDENT '(' { strip_til_parenthesis(); } */
436 | tIDENT '*' { strip_til_semicolon(); }
439 /* Parse top level resource definitions etc. */
440 resource
441 : nameid usrcvt resource_definition {
442 $$ = $3;
443 if($$)
445 $$->name = $1;
446 if($1->type == name_ord)
448 chat("Got %s (%d)",get_typename($3),$1->name.i_name);
450 else if($1->type == name_str)
452 chat("Got %s (%s)",get_typename($3),$1->name.s_name->str.cstr);
456 | stringtable {
457 /* Don't do anything, stringtables are converted to
458 * resource_t structures when we are finished parsing and
459 * the final rule of the parser is reduced (see above)
461 $$ = NULL;
462 chat("Got STRINGTABLE");
464 | tLANGUAGE {want_nl = 1; } expr ',' expr tNL {
465 /* We *NEED* the newline to delimit the expression.
466 * Otherwise, we would not be able to set the next
467 * want_id anymore because of the token-lookahead.
469 if(!win32)
470 yywarning("LANGUAGE not supported in 16-bit mode");
471 if(currentlanguage)
472 free(currentlanguage);
473 currentlanguage = new_language($3, $5);
474 $$ = NULL;
479 * Remapping of numerical resource types
480 * (see also comment of called function below)
482 usrcvt : /* Empty */ { yychar = rsrcid_to_token(yychar); }
486 * Get a valid name/id
488 nameid : expr {
489 if($1 > 65535 || $1 < -32768)
490 yyerror("Resource's ID out of range (%d)", $1);
491 $$ = new_name_id();
492 $$->type = name_ord;
493 $$->name.i_name = $1;
495 | tIDENT {
496 $$ = new_name_id();
497 $$->type = name_str;
498 $$->name.s_name = $1;
503 * Extra string recognition for CLASS statement in dialogs
505 nameid_s: nameid { $$ = $1; }
506 | tSTRING {
507 $$ = new_name_id();
508 $$->type = name_str;
509 $$->name.s_name = $1;
513 /* get the value for a single resource*/
514 resource_definition
515 : accelerators { $$ = new_resource(res_acc, $1, $1->memopt, $1->lvc.language); }
516 | bitmap { $$ = new_resource(res_bmp, $1, $1->memopt, $1->data->lvc.language); }
517 | cursor {
518 resource_t *rsc;
519 if($1->type == res_anicur)
521 $$ = rsc = new_resource(res_anicur, $1->u.ani, $1->u.ani->memopt, $1->u.ani->data->lvc.language);
523 else if($1->type == res_curg)
525 cursor_t *cur;
526 $$ = rsc = new_resource(res_curg, $1->u.curg, $1->u.curg->memopt, $1->u.curg->lvc.language);
527 for(cur = $1->u.curg->cursorlist; cur; cur = cur->next)
529 rsc->prev = new_resource(res_cur, cur, $1->u.curg->memopt, $1->u.curg->lvc.language);
530 rsc->prev->next = rsc;
531 rsc = rsc->prev;
532 rsc->name = new_name_id();
533 rsc->name->type = name_ord;
534 rsc->name->name.i_name = cur->id;
537 else
538 internal_error(__FILE__, __LINE__, "Invalid top-level type %d in cursor resource", $1->type);
539 free($1);
541 | dialog { $$ = new_resource(res_dlg, $1, $1->memopt, $1->lvc.language); }
542 | dialogex {
543 if(win32)
544 $$ = new_resource(res_dlgex, $1, $1->memopt, $1->lvc.language);
545 else
546 $$ = NULL;
548 | dlginit { $$ = new_resource(res_dlginit, $1, $1->memopt, $1->data->lvc.language); }
549 | font { $$ = new_resource(res_fnt, $1, $1->memopt, $1->data->lvc.language); }
550 | fontdir { $$ = new_resource(res_fntdir, $1, $1->memopt, $1->data->lvc.language); }
551 | icon {
552 resource_t *rsc;
553 if($1->type == res_aniico)
555 $$ = rsc = new_resource(res_aniico, $1->u.ani, $1->u.ani->memopt, $1->u.ani->data->lvc.language);
557 else if($1->type == res_icog)
559 icon_t *ico;
560 $$ = rsc = new_resource(res_icog, $1->u.icog, $1->u.icog->memopt, $1->u.icog->lvc.language);
561 for(ico = $1->u.icog->iconlist; ico; ico = ico->next)
563 rsc->prev = new_resource(res_ico, ico, $1->u.icog->memopt, $1->u.icog->lvc.language);
564 rsc->prev->next = rsc;
565 rsc = rsc->prev;
566 rsc->name = new_name_id();
567 rsc->name->type = name_ord;
568 rsc->name->name.i_name = ico->id;
571 else
572 internal_error(__FILE__, __LINE__, "Invalid top-level type %d in icon resource", $1->type);
573 free($1);
575 | menu { $$ = new_resource(res_men, $1, $1->memopt, $1->lvc.language); }
576 | menuex {
577 if(win32)
578 $$ = new_resource(res_menex, $1, $1->memopt, $1->lvc.language);
579 else
580 $$ = NULL;
582 | messagetable { $$ = new_resource(res_msg, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, dup_language(currentlanguage)); }
583 | rcdata { $$ = new_resource(res_rdt, $1, $1->memopt, $1->data->lvc.language); }
584 | toolbar { $$ = new_resource(res_toolbar, $1, $1->memopt, $1->lvc.language); }
585 | userres { $$ = new_resource(res_usr, $1, $1->memopt, $1->data->lvc.language); }
586 | versioninfo { $$ = new_resource(res_ver, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, $1->lvc.language); }
590 filename: tFILENAME { $$ = make_filename($1); }
591 | tIDENT { $$ = make_filename($1); }
592 | tSTRING { $$ = make_filename($1); }
595 /* ------------------------------ Bitmap ------------------------------ */
596 bitmap : tBITMAP loadmemopts file_raw { $$ = new_bitmap($3, $2); }
599 /* ------------------------------ Cursor ------------------------------ */
600 cursor : tCURSOR loadmemopts file_raw {
601 $$ = new_ani_any();
602 if($3->size > 4 && !memcmp($3->data, riff, sizeof(riff)))
604 $$->type = res_anicur;
605 $$->u.ani = new_ani_curico(res_anicur, $3, $2);
607 else
609 $$->type = res_curg;
610 $$->u.curg = new_cursor_group($3, $2);
615 /* ------------------------------ Icon ------------------------------ */
616 icon : tICON loadmemopts file_raw {
617 $$ = new_ani_any();
618 if($3->size > 4 && !memcmp($3->data, riff, sizeof(riff)))
620 $$->type = res_aniico;
621 $$->u.ani = new_ani_curico(res_aniico, $3, $2);
623 else
625 $$->type = res_icog;
626 $$->u.icog = new_icon_group($3, $2);
631 /* ------------------------------ Font ------------------------------ */
633 * The reading of raw_data for fonts is a Borland BRC
634 * extension. MS generates an error. However, it is
635 * most logical to support this, considering how wine
636 * enters things in CVS (ascii).
638 font : tFONT loadmemopts file_raw { $$ = new_font($3, $2); }
642 * The fontdir is a Borland BRC extension which only
643 * reads the data as 'raw_data' from the file.
644 * I don't know whether it is interpreted.
645 * The fontdir is generated if it was not present and
646 * fonts are defined in the source.
648 fontdir : tFONTDIR loadmemopts file_raw { $$ = new_fontdir($3, $2); }
651 /* ------------------------------ MessageTable ------------------------------ */
652 /* It might be interesting to implement the MS Message compiler here as well
653 * to get everything in one source. Might be a future project.
655 messagetable
656 : tMESSAGETABLE loadmemopts file_raw {
657 if(!win32)
658 yywarning("MESSAGETABLE not supported in 16-bit mode");
659 $$ = new_messagetable($3, $2);
663 /* ------------------------------ RCData ------------------------------ */
664 rcdata : tRCDATA loadmemopts file_raw { $$ = new_rcdata($3, $2); }
667 /* ------------------------------ DLGINIT ------------------------------ */
668 dlginit : tDLGINIT loadmemopts file_raw { $$ = new_dlginit($3, $2); }
671 /* ------------------------------ UserType ------------------------------ */
672 userres : usertype loadmemopts file_raw {
673 #ifdef WORDS_BIGENDIAN
674 if(pedantic && byteorder != WRC_BO_LITTLE)
675 #else
676 if(pedantic && byteorder == WRC_BO_BIG)
677 #endif
678 yywarning("Byteordering is not little-endian and type cannot be interpreted");
679 $$ = new_user($1, $3, $2);
683 usertype: tNUMBER {
684 $$ = new_name_id();
685 $$->type = name_ord;
686 $$->name.i_name = $1;
688 | tIDENT {
689 $$ = new_name_id();
690 $$->type = name_str;
691 $$->name.s_name = $1;
695 /* ------------------------------ Accelerator ------------------------------ */
696 accelerators
697 : tACCELERATORS loadmemopts opt_lvc tBEGIN events tEND {
698 $$ = new_accelerator();
699 if($2)
701 $$->memopt = *($2);
702 free($2);
704 else
706 $$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE;
708 if(!$5)
709 yyerror("Accelerator table must have at least one entry");
710 $$->events = get_event_head($5);
711 if($3)
713 $$->lvc = *($3);
714 free($3);
716 if(!$$->lvc.language)
717 $$->lvc.language = dup_language(currentlanguage);
721 events : /* Empty */ { $$=NULL; }
722 | events tSTRING ',' expr acc_opt { $$=add_string_event($2, $4, $5, $1); }
723 | events expr ',' expr acc_opt { $$=add_event($2, $4, $5, $1); }
727 * The empty rule generates a s/r conflict because of {bi,u}nary expr
728 * on - and +. It cannot be solved in any way because it is the same as
729 * the if/then/else problem (LALR(1) problem). The conflict is moved
730 * away by forcing it to be in the expression handling below.
732 acc_opt : /* Empty */ { $$ = 0; }
733 | ',' accs { $$ = $2; }
736 accs : acc { $$ = $1; }
737 | accs ',' acc { $$ = $1 | $3; }
740 acc : tNOINVERT { $$ = WRC_AF_NOINVERT; }
741 | tSHIFT { $$ = WRC_AF_SHIFT; }
742 | tCONTROL { $$ = WRC_AF_CONTROL; }
743 | tALT { $$ = WRC_AF_ALT; }
744 | tASCII { $$ = WRC_AF_ASCII; }
745 | tVIRTKEY { $$ = WRC_AF_VIRTKEY; }
748 /* ------------------------------ Dialog ------------------------------ */
749 /* FIXME: Support EXSTYLE in the dialog line itself */
750 dialog : tDIALOG loadmemopts expr ',' expr ',' expr ',' expr dlg_attributes
751 tBEGIN ctrls tEND {
752 if($2)
754 $10->memopt = *($2);
755 free($2);
757 else
758 $10->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE;
759 $10->x = $3;
760 $10->y = $5;
761 $10->width = $7;
762 $10->height = $9;
763 $10->controls = get_control_head($12);
764 $$ = $10;
765 if(!$$->gotstyle)
767 $$->style->or_mask = WS_POPUP;
768 $$->gotstyle = TRUE;
770 if($$->title)
771 $$->style->or_mask |= WS_CAPTION;
772 if($$->font)
773 $$->style->or_mask |= DS_SETFONT;
775 $$->style->or_mask &= ~($$->style->and_mask);
776 $$->style->and_mask = 0;
778 if(!$$->lvc.language)
779 $$->lvc.language = dup_language(currentlanguage);
783 dlg_attributes
784 : /* Empty */ { $$=new_dialog(); }
785 | dlg_attributes tSTYLE style { $$=dialog_style($3,$1); }
786 | dlg_attributes tEXSTYLE style { $$=dialog_exstyle($3,$1); }
787 | dlg_attributes tCAPTION tSTRING { $$=dialog_caption($3,$1); }
788 | dlg_attributes opt_font { $$=dialog_font($2,$1); }
789 | dlg_attributes tCLASS nameid_s { $$=dialog_class($3,$1); }
790 | dlg_attributes tCPPCLASS nameid_s { $$=dialog_class($3,$1); }
791 | dlg_attributes tMENU nameid { $$=dialog_menu($3,$1); }
792 | dlg_attributes opt_language { $$=dialog_language($2,$1); }
793 | dlg_attributes opt_characts { $$=dialog_characteristics($2,$1); }
794 | dlg_attributes opt_version { $$=dialog_version($2,$1); }
797 ctrls : /* Empty */ { $$ = NULL; }
798 | ctrls tCONTROL gen_ctrl { $$=ins_ctrl(-1, 0, $3, $1); }
799 | ctrls tEDITTEXT ctrl_desc { $$=ins_ctrl(CT_EDIT, 0, $3, $1); }
800 | ctrls tLISTBOX ctrl_desc { $$=ins_ctrl(CT_LISTBOX, 0, $3, $1); }
801 | ctrls tCOMBOBOX ctrl_desc { $$=ins_ctrl(CT_COMBOBOX, 0, $3, $1); }
802 | ctrls tSCROLLBAR ctrl_desc { $$=ins_ctrl(CT_SCROLLBAR, 0, $3, $1); }
803 | ctrls tCHECKBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_CHECKBOX, $3, $1); }
804 | ctrls tDEFPUSHBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_DEFPUSHBUTTON, $3, $1); }
805 | ctrls tGROUPBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_GROUPBOX, $3, $1);}
806 | ctrls tPUSHBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBUTTON, $3, $1); }
807 /* | ctrls tPUSHBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
808 | ctrls tRADIOBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_RADIOBUTTON, $3, $1); }
809 | ctrls tAUTO3STATE lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTO3STATE, $3, $1); }
810 | ctrls tSTATE3 lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_3STATE, $3, $1); }
811 | ctrls tAUTOCHECKBOX lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTOCHECKBOX, $3, $1); }
812 | ctrls tAUTORADIOBUTTON lab_ctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTORADIOBUTTON, $3, $1); }
813 | ctrls tLTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_LEFT, $3, $1); }
814 | ctrls tCTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_CENTER, $3, $1); }
815 | ctrls tRTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); }
816 /* special treatment for icons, as the extent is optional */
817 | ctrls tICON nameid_s opt_comma expr ',' expr ',' expr iconinfo {
818 $10->title = $3;
819 $10->id = $5;
820 $10->x = $7;
821 $10->y = $9;
822 $$ = ins_ctrl(CT_STATIC, SS_ICON, $10, $1);
826 lab_ctrl
827 : tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style {
828 $$=new_control();
829 $$->title = new_name_id();
830 $$->title->type = name_str;
831 $$->title->name.s_name = $1;
832 $$->id = $3;
833 $$->x = $5;
834 $$->y = $7;
835 $$->width = $9;
836 $$->height = $11;
837 if($12)
839 $$->style = $12;
840 $$->gotstyle = TRUE;
845 ctrl_desc
846 : expr ',' expr ',' expr ',' expr ',' expr optional_style {
847 $$ = new_control();
848 $$->id = $1;
849 $$->x = $3;
850 $$->y = $5;
851 $$->width = $7;
852 $$->height = $9;
853 if($10)
855 $$->style = $10;
856 $$->gotstyle = TRUE;
861 iconinfo: /* Empty */
862 { $$ = new_control(); }
864 | ',' expr ',' expr {
865 $$ = new_control();
866 $$->width = $2;
867 $$->height = $4;
869 | ',' expr ',' expr ',' style {
870 $$ = new_control();
871 $$->width = $2;
872 $$->height = $4;
873 $$->style = $6;
874 $$->gotstyle = TRUE;
876 | ',' expr ',' expr ',' style ',' style {
877 $$ = new_control();
878 $$->width = $2;
879 $$->height = $4;
880 $$->style = $6;
881 $$->gotstyle = TRUE;
882 $$->exstyle = $8;
883 $$->gotexstyle = TRUE;
887 gen_ctrl: nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ',' expr ',' style {
888 $$=new_control();
889 $$->title = $1;
890 $$->id = $3;
891 $$->ctlclass = convert_ctlclass($5);
892 $$->style = $7;
893 $$->gotstyle = TRUE;
894 $$->x = $9;
895 $$->y = $11;
896 $$->width = $13;
897 $$->height = $15;
898 $$->exstyle = $17;
899 $$->gotexstyle = TRUE;
901 | nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ',' expr {
902 $$=new_control();
903 $$->title = $1;
904 $$->id = $3;
905 $$->ctlclass = convert_ctlclass($5);
906 $$->style = $7;
907 $$->gotstyle = TRUE;
908 $$->x = $9;
909 $$->y = $11;
910 $$->width = $13;
911 $$->height = $15;
915 opt_font
916 : tFONT expr ',' tSTRING { $$ = new_font_id($2, $4, 0, 0); }
919 /* ------------------------------ style flags ------------------------------ */
920 optional_style /* Abbused once to get optional ExStyle */
921 : /* Empty */ { $$ = NULL; }
922 | ',' style { $$ = $2; }
925 optional_style_pair
926 : /* Empty */ { $$ = NULL; }
927 | ',' style { $$ = new_style_pair($2, 0); }
928 | ',' style ',' style { $$ = new_style_pair($2, $4); }
931 style
932 : style '|' style { $$ = new_style($1->or_mask | $3->or_mask, $1->and_mask | $3->and_mask); free($1); free($3);}
933 | '(' style ')' { $$ = $2; }
934 | any_num { $$ = new_style($1, 0); }
935 | tNOT any_num { $$ = new_style(0, $2); }
938 ctlclass
939 : expr {
940 $$ = new_name_id();
941 $$->type = name_ord;
942 $$->name.i_name = $1;
944 | tSTRING {
945 $$ = new_name_id();
946 $$->type = name_str;
947 $$->name.s_name = $1;
951 /* ------------------------------ DialogEx ------------------------------ */
952 dialogex: tDIALOGEX loadmemopts expr ',' expr ',' expr ',' expr helpid dlgex_attribs
953 tBEGIN exctrls tEND {
954 if(!win32)
955 yywarning("DIALOGEX not supported in 16-bit mode");
956 if($2)
958 $11->memopt = *($2);
959 free($2);
961 else
962 $11->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE;
963 $11->x = $3;
964 $11->y = $5;
965 $11->width = $7;
966 $11->height = $9;
967 if($10)
969 $11->helpid = *($10);
970 $11->gothelpid = TRUE;
971 free($10);
973 $11->controls = get_control_head($13);
974 $$ = $11;
976 assert($$->style != NULL);
977 if(!$$->gotstyle)
979 $$->style->or_mask = WS_POPUP;
980 $$->gotstyle = TRUE;
982 if($$->title)
983 $$->style->or_mask |= WS_CAPTION;
984 if($$->font)
985 $$->style->or_mask |= DS_SETFONT;
987 $$->style->or_mask &= ~($$->style->and_mask);
988 $$->style->and_mask = 0;
990 if(!$$->lvc.language)
991 $$->lvc.language = dup_language(currentlanguage);
995 dlgex_attribs
996 : /* Empty */ { $$=new_dialogex(); }
997 | dlgex_attribs tSTYLE style { $$=dialogex_style($3,$1); }
998 | dlgex_attribs tEXSTYLE style { $$=dialogex_exstyle($3,$1); }
999 | dlgex_attribs tCAPTION tSTRING { $$=dialogex_caption($3,$1); }
1000 | dlgex_attribs opt_font { $$=dialogex_font($2,$1); }
1001 | dlgex_attribs opt_exfont { $$=dialogex_font($2,$1); }
1002 | dlgex_attribs tCLASS nameid_s { $$=dialogex_class($3,$1); }
1003 | dlgex_attribs tCPPCLASS nameid_s { $$=dialogex_class($3,$1); }
1004 | dlgex_attribs tMENU nameid { $$=dialogex_menu($3,$1); }
1005 | dlgex_attribs opt_language { $$=dialogex_language($2,$1); }
1006 | dlgex_attribs opt_characts { $$=dialogex_characteristics($2,$1); }
1007 | dlgex_attribs opt_version { $$=dialogex_version($2,$1); }
1010 exctrls : /* Empty */ { $$ = NULL; }
1011 | exctrls tCONTROL gen_exctrl { $$=ins_ctrl(-1, 0, $3, $1); }
1012 | exctrls tEDITTEXT exctrl_desc { $$=ins_ctrl(CT_EDIT, 0, $3, $1); }
1013 | exctrls tLISTBOX exctrl_desc { $$=ins_ctrl(CT_LISTBOX, 0, $3, $1); }
1014 | exctrls tCOMBOBOX exctrl_desc { $$=ins_ctrl(CT_COMBOBOX, 0, $3, $1); }
1015 | exctrls tSCROLLBAR exctrl_desc { $$=ins_ctrl(CT_SCROLLBAR, 0, $3, $1); }
1016 | exctrls tCHECKBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_CHECKBOX, $3, $1); }
1017 | exctrls tDEFPUSHBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_DEFPUSHBUTTON, $3, $1); }
1018 | exctrls tGROUPBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_GROUPBOX, $3, $1);}
1019 | exctrls tPUSHBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBUTTON, $3, $1); }
1020 /* | exctrls tPUSHBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_PUSHBOX, $3, $1); } */
1021 | exctrls tRADIOBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_RADIOBUTTON, $3, $1); }
1022 | exctrls tAUTO3STATE lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTO3STATE, $3, $1); }
1023 | exctrls tSTATE3 lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_3STATE, $3, $1); }
1024 | exctrls tAUTOCHECKBOX lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTOCHECKBOX, $3, $1); }
1025 | exctrls tAUTORADIOBUTTON lab_exctrl { $$=ins_ctrl(CT_BUTTON, BS_AUTORADIOBUTTON, $3, $1); }
1026 | exctrls tLTEXT lab_exctrl { $$=ins_ctrl(CT_STATIC, SS_LEFT, $3, $1); }
1027 | exctrls tCTEXT lab_exctrl { $$=ins_ctrl(CT_STATIC, SS_CENTER, $3, $1); }
1028 | exctrls tRTEXT lab_exctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); }
1029 /* special treatment for icons, as the extent is optional */
1030 | exctrls tICON nameid_s opt_comma expr ',' expr ',' expr iconinfo {
1031 $10->title = $3;
1032 $10->id = $5;
1033 $10->x = $7;
1034 $10->y = $9;
1035 $$ = ins_ctrl(CT_STATIC, SS_ICON, $10, $1);
1039 gen_exctrl
1040 : nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ','
1041 expr ',' style helpid opt_data {
1042 $$=new_control();
1043 $$->title = $1;
1044 $$->id = $3;
1045 $$->ctlclass = convert_ctlclass($5);
1046 $$->style = $7;
1047 $$->gotstyle = TRUE;
1048 $$->x = $9;
1049 $$->y = $11;
1050 $$->width = $13;
1051 $$->height = $15;
1052 if($17)
1054 $$->exstyle = $17;
1055 $$->gotexstyle = TRUE;
1057 if($18)
1059 $$->helpid = *($18);
1060 $$->gothelpid = TRUE;
1061 free($18);
1063 $$->extra = $19;
1065 | nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ',' expr opt_data {
1066 $$=new_control();
1067 $$->title = $1;
1068 $$->id = $3;
1069 $$->style = $7;
1070 $$->gotstyle = TRUE;
1071 $$->ctlclass = convert_ctlclass($5);
1072 $$->x = $9;
1073 $$->y = $11;
1074 $$->width = $13;
1075 $$->height = $15;
1076 $$->extra = $16;
1080 lab_exctrl
1081 : tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style_pair opt_data {
1082 $$=new_control();
1083 $$->title = new_name_id();
1084 $$->title->type = name_str;
1085 $$->title->name.s_name = $1;
1086 $$->id = $3;
1087 $$->x = $5;
1088 $$->y = $7;
1089 $$->width = $9;
1090 $$->height = $11;
1091 if($12)
1093 $$->style = $12->style;
1094 $$->gotstyle = TRUE;
1096 if ($12->exstyle)
1098 $$->exstyle = $12->exstyle;
1099 $$->gotexstyle = TRUE;
1101 free($12);
1104 $$->extra = $13;
1108 exctrl_desc
1109 : expr ',' expr ',' expr ',' expr ',' expr optional_style_pair opt_data {
1110 $$ = new_control();
1111 $$->id = $1;
1112 $$->x = $3;
1113 $$->y = $5;
1114 $$->width = $7;
1115 $$->height = $9;
1116 if($10)
1118 $$->style = $10->style;
1119 $$->gotstyle = TRUE;
1121 if ($10->exstyle)
1123 $$->exstyle = $10->exstyle;
1124 $$->gotexstyle = TRUE;
1126 free($10);
1128 $$->extra = $11;
1132 opt_data: /* Empty */ { $$ = NULL; }
1133 | raw_data { $$ = $1; }
1136 helpid : /* Empty */ { $$ = NULL; }
1137 | ',' expr { $$ = new_int($2); }
1140 opt_exfont
1141 : tFONT expr ',' tSTRING ',' expr ',' expr opt_expr { $$ = new_font_id($2, $4, $6, $8); }
1145 * FIXME: This odd expression is here to nullify an extra token found
1146 * in some appstudio produced resources which appear to do nothing.
1148 opt_expr: /* Empty */ { $$ = NULL; }
1149 | ',' expr { $$ = NULL; }
1152 /* ------------------------------ Menu ------------------------------ */
1153 menu : tMENU loadmemopts opt_lvc menu_body {
1154 if(!$4)
1155 yyerror("Menu must contain items");
1156 $$ = new_menu();
1157 if($2)
1159 $$->memopt = *($2);
1160 free($2);
1162 else
1163 $$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE;
1164 $$->items = get_item_head($4);
1165 if($3)
1167 $$->lvc = *($3);
1168 free($3);
1170 if(!$$->lvc.language)
1171 $$->lvc.language = dup_language(currentlanguage);
1175 menu_body
1176 : tBEGIN item_definitions tEND { $$ = $2; }
1179 item_definitions
1180 : /* Empty */ {$$ = NULL;}
1181 | item_definitions tMENUITEM tSTRING opt_comma expr item_options {
1182 $$=new_menu_item();
1183 $$->prev = $1;
1184 if($1)
1185 $1->next = $$;
1186 $$->id = $5;
1187 $$->state = $6;
1188 $$->name = $3;
1190 | item_definitions tMENUITEM tSEPARATOR {
1191 $$=new_menu_item();
1192 $$->prev = $1;
1193 if($1)
1194 $1->next = $$;
1196 | item_definitions tPOPUP tSTRING item_options menu_body {
1197 $$ = new_menu_item();
1198 $$->prev = $1;
1199 if($1)
1200 $1->next = $$;
1201 $$->popup = get_item_head($5);
1202 $$->name = $3;
1206 /* NOTE: item_options is right recursive because it would introduce
1207 * a shift/reduce conflict on ',' in itemex_options due to the
1208 * empty rule here. The parser is now forced to look beyond the ','
1209 * before reducing (force shift).
1210 * Right recursion here is not a problem because we cannot expect
1211 * more than 7 parserstack places to be occupied while parsing this
1212 * (who would want to specify a MF_x flag twice?).
1214 item_options
1215 : /* Empty */ { $$ = 0; }
1216 | ',' tCHECKED item_options { $$ = $3 | MF_CHECKED; }
1217 | ',' tGRAYED item_options { $$ = $3 | MF_GRAYED; }
1218 | ',' tHELP item_options { $$ = $3 | MF_HELP; }
1219 | ',' tINACTIVE item_options { $$ = $3 | MF_DISABLED; }
1220 | ',' tMENUBARBREAK item_options { $$ = $3 | MF_MENUBARBREAK; }
1221 | ',' tMENUBREAK item_options { $$ = $3 | MF_MENUBREAK; }
1224 /* ------------------------------ MenuEx ------------------------------ */
1225 menuex : tMENUEX loadmemopts opt_lvc menuex_body {
1226 if(!win32)
1227 yywarning("MENUEX not supported in 16-bit mode");
1228 if(!$4)
1229 yyerror("MenuEx must contain items");
1230 $$ = new_menuex();
1231 if($2)
1233 $$->memopt = *($2);
1234 free($2);
1236 else
1237 $$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE;
1238 $$->items = get_itemex_head($4);
1239 if($3)
1241 $$->lvc = *($3);
1242 free($3);
1244 if(!$$->lvc.language)
1245 $$->lvc.language = dup_language(currentlanguage);
1249 menuex_body
1250 : tBEGIN itemex_definitions tEND { $$ = $2; }
1253 itemex_definitions
1254 : /* Empty */ {$$ = NULL; }
1255 | itemex_definitions tMENUITEM tSTRING itemex_options {
1256 $$ = new_menuex_item();
1257 $$->prev = $1;
1258 if($1)
1259 $1->next = $$;
1260 $$->name = $3;
1261 $$->id = $4->id;
1262 $$->type = $4->type;
1263 $$->state = $4->state;
1264 $$->helpid = $4->helpid;
1265 $$->gotid = $4->gotid;
1266 $$->gottype = $4->gottype;
1267 $$->gotstate = $4->gotstate;
1268 $$->gothelpid = $4->gothelpid;
1269 free($4);
1271 | itemex_definitions tMENUITEM tSEPARATOR {
1272 $$ = new_menuex_item();
1273 $$->prev = $1;
1274 if($1)
1275 $1->next = $$;
1277 | itemex_definitions tPOPUP tSTRING itemex_p_options menuex_body {
1278 $$ = new_menuex_item();
1279 $$->prev = $1;
1280 if($1)
1281 $1->next = $$;
1282 $$->popup = get_itemex_head($5);
1283 $$->name = $3;
1284 $$->id = $4->id;
1285 $$->type = $4->type;
1286 $$->state = $4->state;
1287 $$->helpid = $4->helpid;
1288 $$->gotid = $4->gotid;
1289 $$->gottype = $4->gottype;
1290 $$->gotstate = $4->gotstate;
1291 $$->gothelpid = $4->gothelpid;
1292 free($4);
1296 itemex_options
1297 : /* Empty */ { $$ = new_itemex_opt(0, 0, 0, 0); }
1298 | ',' expr {
1299 $$ = new_itemex_opt($2, 0, 0, 0);
1300 $$->gotid = TRUE;
1302 | ',' e_expr ',' e_expr item_options {
1303 $$ = new_itemex_opt($2 ? *($2) : 0, $4 ? *($4) : 0, $5, 0);
1304 $$->gotid = TRUE;
1305 $$->gottype = TRUE;
1306 $$->gotstate = TRUE;
1307 if($2) free($2);
1308 if($4) free($4);
1310 | ',' e_expr ',' e_expr ',' expr {
1311 $$ = new_itemex_opt($2 ? *($2) : 0, $4 ? *($4) : 0, $6, 0);
1312 $$->gotid = TRUE;
1313 $$->gottype = TRUE;
1314 $$->gotstate = TRUE;
1315 if($2) free($2);
1316 if($4) free($4);
1320 itemex_p_options
1321 : /* Empty */ { $$ = new_itemex_opt(0, 0, 0, 0); }
1322 | ',' expr {
1323 $$ = new_itemex_opt($2, 0, 0, 0);
1324 $$->gotid = TRUE;
1326 | ',' e_expr ',' expr {
1327 $$ = new_itemex_opt($2 ? *($2) : 0, $4, 0, 0);
1328 if($2) free($2);
1329 $$->gotid = TRUE;
1330 $$->gottype = TRUE;
1332 | ',' e_expr ',' e_expr ',' expr {
1333 $$ = new_itemex_opt($2 ? *($2) : 0, $4 ? *($4) : 0, $6, 0);
1334 if($2) free($2);
1335 if($4) free($4);
1336 $$->gotid = TRUE;
1337 $$->gottype = TRUE;
1338 $$->gotstate = TRUE;
1340 | ',' e_expr ',' e_expr ',' e_expr ',' expr {
1341 $$ = new_itemex_opt($2 ? *($2) : 0, $4 ? *($4) : 0, $6 ? *($6) : 0, $8);
1342 if($2) free($2);
1343 if($4) free($4);
1344 if($6) free($6);
1345 $$->gotid = TRUE;
1346 $$->gottype = TRUE;
1347 $$->gotstate = TRUE;
1348 $$->gothelpid = TRUE;
1352 /* ------------------------------ StringTable ------------------------------ */
1353 /* Stringtables are parsed differently than other resources because their
1354 * layout is substantially different from other resources.
1355 * The table is parsed through a _global_ variable 'tagstt' which holds the
1356 * current stringtable descriptor (stringtable_t *) and 'sttres' that holds a
1357 * list of stringtables of different languages.
1359 stringtable
1360 : stt_head tBEGIN strings tEND {
1361 if(!$3)
1363 yyerror("Stringtable must have at least one entry");
1365 else
1367 stringtable_t *stt;
1368 /* Check if we added to a language table or created
1369 * a new one.
1371 for(stt = sttres; stt; stt = stt->next)
1373 if(stt == tagstt)
1374 break;
1376 if(!stt)
1378 /* It is a new one */
1379 if(sttres)
1381 sttres->prev = tagstt;
1382 tagstt->next = sttres;
1383 sttres = tagstt;
1385 else
1386 sttres = tagstt;
1388 /* Else were done */
1390 if(tagstt_memopt)
1392 free(tagstt_memopt);
1393 tagstt_memopt = NULL;
1396 $$ = tagstt;
1400 /* This is to get the language of the currently parsed stringtable */
1401 stt_head: tSTRINGTABLE loadmemopts opt_lvc {
1402 if((tagstt = find_stringtable($3)) == NULL)
1403 tagstt = new_stringtable($3);
1404 tagstt_memopt = $2;
1405 tagstt_version = $3->version;
1406 tagstt_characts = $3->characts;
1407 if($3)
1408 free($3);
1412 strings : /* Empty */ { $$ = NULL; }
1413 | strings expr opt_comma tSTRING {
1414 int i;
1415 assert(tagstt != NULL);
1416 if($2 > 65535 || $2 < -32768)
1417 yyerror("Stringtable entry's ID out of range (%d)", $2);
1418 /* Search for the ID */
1419 for(i = 0; i < tagstt->nentries; i++)
1421 if(tagstt->entries[i].id == $2)
1422 yyerror("Stringtable ID %d already in use", $2);
1424 /* If we get here, then we have a new unique entry */
1425 tagstt->nentries++;
1426 tagstt->entries = xrealloc(tagstt->entries, sizeof(tagstt->entries[0]) * tagstt->nentries);
1427 tagstt->entries[tagstt->nentries-1].id = $2;
1428 tagstt->entries[tagstt->nentries-1].str = $4;
1429 if(tagstt_memopt)
1430 tagstt->entries[tagstt->nentries-1].memopt = *tagstt_memopt;
1431 else
1432 tagstt->entries[tagstt->nentries-1].memopt = WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE;
1433 tagstt->entries[tagstt->nentries-1].version = tagstt_version;
1434 tagstt->entries[tagstt->nentries-1].characts = tagstt_characts;
1436 if(!win32 && $4->size > 254)
1437 yyerror("Stringtable entry more than 254 characters");
1438 if(win32 && $4->size > 65534) /* Hmm..., does this happen? */
1439 yyerror("Stringtable entry more than 65534 characters (probably something else that went wrong)");
1440 $$ = tagstt;
1444 opt_comma /* There seem to be two ways to specify a stringtable... */
1445 : /* Empty */
1446 | ','
1449 /* ------------------------------ VersionInfo ------------------------------ */
1450 versioninfo
1451 : tVERSIONINFO loadmemopts fix_version tBEGIN ver_blocks tEND {
1452 $$ = $3;
1453 if($2)
1455 $$->memopt = *($2);
1456 free($2);
1458 else
1459 $$->memopt = WRC_MO_MOVEABLE | (win32 ? WRC_MO_PURE : 0);
1460 $$->blocks = get_ver_block_head($5);
1461 /* Set language; there is no version or characteristics */
1462 $$->lvc.language = dup_language(currentlanguage);
1466 fix_version
1467 : /* Empty */ { $$ = new_versioninfo(); }
1468 | fix_version tFILEVERSION expr ',' expr ',' expr ',' expr {
1469 if($1->gotit.fv)
1470 yyerror("FILEVERSION already defined");
1471 $$ = $1;
1472 $$->filever_maj1 = $3;
1473 $$->filever_maj2 = $5;
1474 $$->filever_min1 = $7;
1475 $$->filever_min2 = $9;
1476 $$->gotit.fv = 1;
1478 | fix_version tPRODUCTVERSION expr ',' expr ',' expr ',' expr {
1479 if($1->gotit.pv)
1480 yyerror("PRODUCTVERSION already defined");
1481 $$ = $1;
1482 $$->prodver_maj1 = $3;
1483 $$->prodver_maj2 = $5;
1484 $$->prodver_min1 = $7;
1485 $$->prodver_min2 = $9;
1486 $$->gotit.pv = 1;
1488 | fix_version tFILEFLAGS expr {
1489 if($1->gotit.ff)
1490 yyerror("FILEFLAGS already defined");
1491 $$ = $1;
1492 $$->fileflags = $3;
1493 $$->gotit.ff = 1;
1495 | fix_version tFILEFLAGSMASK expr {
1496 if($1->gotit.ffm)
1497 yyerror("FILEFLAGSMASK already defined");
1498 $$ = $1;
1499 $$->fileflagsmask = $3;
1500 $$->gotit.ffm = 1;
1502 | fix_version tFILEOS expr {
1503 if($1->gotit.fo)
1504 yyerror("FILEOS already defined");
1505 $$ = $1;
1506 $$->fileos = $3;
1507 $$->gotit.fo = 1;
1509 | fix_version tFILETYPE expr {
1510 if($1->gotit.ft)
1511 yyerror("FILETYPE already defined");
1512 $$ = $1;
1513 $$->filetype = $3;
1514 $$->gotit.ft = 1;
1516 | fix_version tFILESUBTYPE expr {
1517 if($1->gotit.fst)
1518 yyerror("FILESUBTYPE already defined");
1519 $$ = $1;
1520 $$->filesubtype = $3;
1521 $$->gotit.fst = 1;
1525 ver_blocks
1526 : /* Empty */ { $$ = NULL; }
1527 | ver_blocks ver_block {
1528 $$ = $2;
1529 $$->prev = $1;
1530 if($1)
1531 $1->next = $$;
1535 ver_block
1536 : tBLOCK tSTRING tBEGIN ver_values tEND {
1537 $$ = new_ver_block();
1538 $$->name = $2;
1539 $$->values = get_ver_value_head($4);
1543 ver_values
1544 : /* Empty */ { $$ = NULL; }
1545 | ver_values ver_value {
1546 $$ = $2;
1547 $$->prev = $1;
1548 if($1)
1549 $1->next = $$;
1553 ver_value
1554 : ver_block {
1555 $$ = new_ver_value();
1556 $$->type = val_block;
1557 $$->value.block = $1;
1559 | tVALUE tSTRING ',' tSTRING {
1560 $$ = new_ver_value();
1561 $$->type = val_str;
1562 $$->key = $2;
1563 $$->value.str = $4;
1565 | tVALUE tSTRING ',' ver_words {
1566 $$ = new_ver_value();
1567 $$->type = val_words;
1568 $$->key = $2;
1569 $$->value.words = $4;
1573 ver_words
1574 : expr { $$ = new_ver_words($1); }
1575 | ver_words ',' expr { $$ = add_ver_words($1, $3); }
1578 /* ------------------------------ Toolbar ------------------------------ */
1579 toolbar: tTOOLBAR loadmemopts expr ',' expr opt_lvc tBEGIN toolbar_items tEND {
1580 int nitems;
1581 toolbar_item_t *items = get_tlbr_buttons_head($8, &nitems);
1582 $$ = new_toolbar($3, $5, items, nitems);
1583 if($2)
1585 $$->memopt = *($2);
1586 free($2);
1588 else
1590 $$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE;
1592 if($6)
1594 $$->lvc = *($6);
1595 free($6);
1597 if(!$$->lvc.language)
1599 $$->lvc.language = dup_language(currentlanguage);
1604 toolbar_items
1605 : /* Empty */ { $$ = NULL; }
1606 | toolbar_items tBUTTON expr {
1607 toolbar_item_t *idrec = new_toolbar_item();
1608 idrec->id = $3;
1609 $$ = ins_tlbr_button($1, idrec);
1611 | toolbar_items tSEPARATOR {
1612 toolbar_item_t *idrec = new_toolbar_item();
1613 idrec->id = 0;
1614 $$ = ins_tlbr_button($1, idrec);
1618 /* ------------------------------ Memory options ------------------------------ */
1619 loadmemopts
1620 : /* Empty */ { $$ = NULL; }
1621 | loadmemopts lamo {
1622 if($1)
1624 *($1) |= *($2);
1625 $$ = $1;
1626 free($2);
1628 else
1629 $$ = $2;
1631 | loadmemopts lama {
1632 if($1)
1634 *($1) &= *($2);
1635 $$ = $1;
1636 free($2);
1638 else
1640 *$2 &= WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE | WRC_MO_PURE;
1641 $$ = $2;
1646 lamo : tPRELOAD { $$ = new_int(WRC_MO_PRELOAD); }
1647 | tMOVEABLE { $$ = new_int(WRC_MO_MOVEABLE); }
1648 | tDISCARDABLE { $$ = new_int(WRC_MO_DISCARDABLE); }
1649 | tPURE { $$ = new_int(WRC_MO_PURE); }
1652 lama : tLOADONCALL { $$ = new_int(~WRC_MO_PRELOAD); }
1653 | tFIXED { $$ = new_int(~WRC_MO_MOVEABLE); }
1654 | tIMPURE { $$ = new_int(~WRC_MO_PURE); }
1657 /* ------------------------------ Win32 options ------------------------------ */
1658 opt_lvc : /* Empty */ { $$ = new_lvc(); }
1659 | opt_lvc opt_language {
1660 if(!win32)
1661 yywarning("LANGUAGE not supported in 16-bit mode");
1662 if($1->language)
1663 yyerror("Language already defined");
1664 $$ = $1;
1665 $1->language = $2;
1667 | opt_lvc opt_characts {
1668 if(!win32)
1669 yywarning("CHARACTERISTICS not supported in 16-bit mode");
1670 if($1->characts)
1671 yyerror("Characteristics already defined");
1672 $$ = $1;
1673 $1->characts = $2;
1675 | opt_lvc opt_version {
1676 if(!win32)
1677 yywarning("VERSION not supported in 16-bit mode");
1678 if($1->version)
1679 yyerror("Version already defined");
1680 $$ = $1;
1681 $1->version = $2;
1686 * This here is another s/r conflict on {bi,u}nary + and -.
1687 * It is due to the look-ahead which must determine when the
1688 * rule opt_language ends. It could be solved with adding a
1689 * tNL at the end, but that seems unreasonable to do.
1690 * The conflict is now moved to the expression handling below.
1692 opt_language
1693 : tLANGUAGE expr ',' expr { $$ = new_language($2, $4); }
1696 opt_characts
1697 : tCHARACTERISTICS expr { $$ = new_characts($2); }
1700 opt_version
1701 : tVERSION expr { $$ = new_version($2); }
1704 /* ------------------------------ Raw data handling ------------------------------ */
1705 raw_data: opt_lvc tBEGIN raw_elements tEND {
1706 if($1)
1708 $3->lvc = *($1);
1709 free($1);
1712 if(!$3->lvc.language)
1713 $3->lvc.language = dup_language(currentlanguage);
1715 $$ = $3;
1719 raw_elements
1720 : tRAWDATA { $$ = $1; }
1721 | tNUMBER { $$ = int2raw_data($1); }
1722 | tLNUMBER { $$ = long2raw_data($1); }
1723 | tSTRING { $$ = str2raw_data($1); }
1724 | raw_elements opt_comma tRAWDATA { $$ = merge_raw_data($1, $3); free($3->data); free($3); }
1725 | raw_elements opt_comma tNUMBER { $$ = merge_raw_data_int($1, $3); }
1726 | raw_elements opt_comma tLNUMBER { $$ = merge_raw_data_long($1, $3); }
1727 | raw_elements opt_comma tSTRING { $$ = merge_raw_data_str($1, $3); }
1730 /* File data or raw data */
1731 file_raw: filename {
1732 $$ = load_file($1);
1733 $$->lvc.language = dup_language(currentlanguage);
1735 | raw_data { $$ = $1; }
1738 /* ------------------------------ Win32 expressions ------------------------------ */
1739 /* All win16 numbers are also handled here. This is inconsistent with MS'
1740 * resource compiler, but what the heck, its just handy to have.
1742 e_expr : /* Empty */ { $$ = 0; }
1743 | expr { $$ = new_int($1); }
1746 /* This rule moves ALL s/r conflicts on {bi,u}nary - and + to here */
1747 expr : xpr { $$ = ($1); }
1750 xpr : xpr '+' xpr { $$ = ($1) + ($3); }
1751 | xpr '-' xpr { $$ = ($1) - ($3); }
1752 | xpr '|' xpr { $$ = ($1) | ($3); }
1753 | xpr '&' xpr { $$ = ($1) & ($3); }
1754 | xpr '*' xpr { $$ = ($1) * ($3); }
1755 | xpr '/' xpr { $$ = ($1) / ($3); }
1756 | xpr '^' xpr { $$ = ($1) ^ ($3); }
1757 | '~' xpr { $$ = ~($2); }
1758 | '-' xpr %prec pUPM { $$ = -($2); }
1759 | '+' xpr %prec pUPM { $$ = $2; }
1760 | '(' xpr ')' { $$ = $2; }
1761 | any_num { $$ = $1; }
1762 | tNOT any_num { $$ = ~($2); }
1765 any_num : tNUMBER { $$ = $1; }
1766 | tLNUMBER { $$ = $1; }
1770 /* Dialog specific functions */
1771 static dialog_t *dialog_style(style_t * st, dialog_t *dlg)
1773 assert(dlg != NULL);
1774 if(dlg->style == NULL)
1776 dlg->style = new_style(0,0);
1779 if(dlg->gotstyle)
1781 yywarning("Style already defined, or-ing together");
1783 else
1785 dlg->style->or_mask = 0;
1786 dlg->style->and_mask = 0;
1788 dlg->style->or_mask |= st->or_mask;
1789 dlg->style->and_mask |= st->and_mask;
1790 dlg->gotstyle = TRUE;
1791 free(st);
1792 return dlg;
1795 static dialog_t *dialog_exstyle(style_t *st, dialog_t *dlg)
1797 assert(dlg != NULL);
1798 if(dlg->exstyle == NULL)
1800 dlg->exstyle = new_style(0,0);
1803 if(dlg->gotexstyle)
1805 yywarning("ExStyle already defined, or-ing together");
1807 else
1809 dlg->exstyle->or_mask = 0;
1810 dlg->exstyle->and_mask = 0;
1812 dlg->exstyle->or_mask |= st->or_mask;
1813 dlg->exstyle->and_mask |= st->and_mask;
1814 dlg->gotexstyle = TRUE;
1815 free(st);
1816 return dlg;
1819 static dialog_t *dialog_caption(string_t *s, dialog_t *dlg)
1821 assert(dlg != NULL);
1822 if(dlg->title)
1823 yyerror("Caption already defined");
1824 dlg->title = s;
1825 return dlg;
1828 static dialog_t *dialog_font(font_id_t *f, dialog_t *dlg)
1830 assert(dlg != NULL);
1831 if(dlg->font)
1832 yyerror("Font already defined");
1833 dlg->font = f;
1834 return dlg;
1837 static dialog_t *dialog_class(name_id_t *n, dialog_t *dlg)
1839 assert(dlg != NULL);
1840 if(dlg->dlgclass)
1841 yyerror("Class already defined");
1842 dlg->dlgclass = n;
1843 return dlg;
1846 static dialog_t *dialog_menu(name_id_t *m, dialog_t *dlg)
1848 assert(dlg != NULL);
1849 if(dlg->menu)
1850 yyerror("Menu already defined");
1851 dlg->menu = m;
1852 return dlg;
1855 static dialog_t *dialog_language(language_t *l, dialog_t *dlg)
1857 assert(dlg != NULL);
1858 if(dlg->lvc.language)
1859 yyerror("Language already defined");
1860 dlg->lvc.language = l;
1861 return dlg;
1864 static dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg)
1866 assert(dlg != NULL);
1867 if(dlg->lvc.characts)
1868 yyerror("Characteristics already defined");
1869 dlg->lvc.characts = c;
1870 return dlg;
1873 static dialog_t *dialog_version(version_t *v, dialog_t *dlg)
1875 assert(dlg != NULL);
1876 if(dlg->lvc.version)
1877 yyerror("Version already defined");
1878 dlg->lvc.version = v;
1879 return dlg;
1882 /* Controls specific functions */
1883 static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev)
1885 /* Hm... this seems to be jammed in at all time... */
1886 int defaultstyle = WS_CHILD | WS_VISIBLE;
1888 assert(ctrl != NULL);
1889 ctrl->prev = prev;
1891 if(prev)
1892 prev->next = ctrl;
1894 if(type != -1)
1896 ctrl->ctlclass = new_name_id();
1897 ctrl->ctlclass->type = name_ord;
1898 ctrl->ctlclass->name.i_name = type;
1901 switch(type)
1903 case CT_BUTTON:
1904 if(special_style != BS_GROUPBOX && special_style != BS_RADIOBUTTON)
1905 defaultstyle |= WS_TABSTOP;
1906 break;
1907 case CT_EDIT:
1908 defaultstyle |= WS_TABSTOP | WS_BORDER;
1909 break;
1910 case CT_LISTBOX:
1911 defaultstyle |= LBS_NOTIFY | WS_BORDER;
1912 break;
1913 case CT_COMBOBOX:
1914 defaultstyle |= CBS_SIMPLE;
1915 break;
1916 case CT_STATIC:
1917 if(special_style == SS_CENTER || special_style == SS_LEFT || special_style == SS_RIGHT)
1918 defaultstyle |= WS_GROUP;
1919 break;
1922 if(!ctrl->gotstyle) /* Handle default style setting */
1924 switch(type)
1926 case CT_EDIT:
1927 defaultstyle |= ES_LEFT;
1928 break;
1929 case CT_LISTBOX:
1930 defaultstyle |= LBS_NOTIFY;
1931 break;
1932 case CT_COMBOBOX:
1933 defaultstyle |= CBS_SIMPLE | WS_TABSTOP;
1934 break;
1935 case CT_SCROLLBAR:
1936 defaultstyle |= SBS_HORZ;
1937 break;
1938 case CT_BUTTON:
1939 switch(special_style)
1941 case BS_CHECKBOX:
1942 case BS_DEFPUSHBUTTON:
1943 case BS_PUSHBUTTON:
1944 case BS_GROUPBOX:
1945 /* case BS_PUSHBOX: */
1946 case BS_AUTORADIOBUTTON:
1947 case BS_AUTO3STATE:
1948 case BS_3STATE:
1949 case BS_AUTOCHECKBOX:
1950 defaultstyle |= WS_TABSTOP;
1951 break;
1952 default:
1953 yywarning("Unknown default button control-style 0x%08x", special_style);
1954 case BS_RADIOBUTTON:
1955 break;
1957 break;
1959 case CT_STATIC:
1960 switch(special_style)
1962 case SS_LEFT:
1963 case SS_RIGHT:
1964 case SS_CENTER:
1965 defaultstyle |= WS_GROUP;
1966 break;
1967 case SS_ICON: /* Special case */
1968 break;
1969 default:
1970 yywarning("Unknown default static control-style 0x%08x", special_style);
1971 break;
1973 break;
1974 case -1: /* Generic control */
1975 goto byebye;
1977 default:
1978 yyerror("Internal error (report this): Got weird control type 0x%08x", type);
1982 /* The SS_ICON flag is always forced in for icon controls */
1983 if(type == CT_STATIC && special_style == SS_ICON)
1984 defaultstyle |= SS_ICON;
1986 if (!ctrl->gotstyle)
1987 ctrl->style = new_style(0,0);
1989 /* combine all styles */
1990 ctrl->style->or_mask = ctrl->style->or_mask | defaultstyle | special_style;
1991 ctrl->gotstyle = TRUE;
1992 byebye:
1993 /* combine with NOT mask */
1994 if (ctrl->gotstyle)
1996 ctrl->style->or_mask &= ~(ctrl->style->and_mask);
1997 ctrl->style->and_mask = 0;
1999 if (ctrl->gotexstyle)
2001 ctrl->exstyle->or_mask &= ~(ctrl->exstyle->and_mask);
2002 ctrl->exstyle->and_mask = 0;
2004 return ctrl;
2007 static name_id_t *convert_ctlclass(name_id_t *cls)
2009 char *cc = NULL;
2010 int iclass;
2012 if(cls->type == name_ord)
2013 return cls;
2014 assert(cls->type == name_str);
2015 if(cls->type == str_unicode)
2017 yyerror("Don't yet support unicode class comparison");
2019 else
2020 cc = cls->name.s_name->str.cstr;
2022 if(!strcasecmp("BUTTON", cc))
2023 iclass = CT_BUTTON;
2024 else if(!strcasecmp("COMBOBOX", cc))
2025 iclass = CT_COMBOBOX;
2026 else if(!strcasecmp("LISTBOX", cc))
2027 iclass = CT_LISTBOX;
2028 else if(!strcasecmp("EDIT", cc))
2029 iclass = CT_EDIT;
2030 else if(!strcasecmp("STATIC", cc))
2031 iclass = CT_STATIC;
2032 else if(!strcasecmp("SCROLLBAR", cc))
2033 iclass = CT_SCROLLBAR;
2034 else
2035 return cls; /* No default, return user controlclass */
2037 free(cls->name.s_name->str.cstr);
2038 free(cls->name.s_name);
2039 cls->type = name_ord;
2040 cls->name.i_name = iclass;
2041 return cls;
2044 /* DialogEx specific functions */
2045 static dialogex_t *dialogex_style(style_t * st, dialogex_t *dlg)
2047 assert(dlg != NULL);
2048 if(dlg->style == NULL)
2050 dlg->style = new_style(0,0);
2053 if(dlg->gotstyle)
2055 yywarning("Style already defined, or-ing together");
2057 else
2059 dlg->style->or_mask = 0;
2060 dlg->style->and_mask = 0;
2062 dlg->style->or_mask |= st->or_mask;
2063 dlg->style->and_mask |= st->and_mask;
2064 dlg->gotstyle = TRUE;
2065 free(st);
2066 return dlg;
2069 static dialogex_t *dialogex_exstyle(style_t * st, dialogex_t *dlg)
2071 assert(dlg != NULL);
2072 if(dlg->exstyle == NULL)
2074 dlg->exstyle = new_style(0,0);
2077 if(dlg->gotexstyle)
2079 yywarning("ExStyle already defined, or-ing together");
2081 else
2083 dlg->exstyle->or_mask = 0;
2084 dlg->exstyle->and_mask = 0;
2086 dlg->exstyle->or_mask |= st->or_mask;
2087 dlg->exstyle->and_mask |= st->and_mask;
2088 dlg->gotexstyle = TRUE;
2089 free(st);
2090 return dlg;
2093 static dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg)
2095 assert(dlg != NULL);
2096 if(dlg->title)
2097 yyerror("Caption already defined");
2098 dlg->title = s;
2099 return dlg;
2102 static dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg)
2104 assert(dlg != NULL);
2105 if(dlg->font)
2106 yyerror("Font already defined");
2107 dlg->font = f;
2108 return dlg;
2111 static dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg)
2113 assert(dlg != NULL);
2114 if(dlg->dlgclass)
2115 yyerror("Class already defined");
2116 dlg->dlgclass = n;
2117 return dlg;
2120 static dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg)
2122 assert(dlg != NULL);
2123 if(dlg->menu)
2124 yyerror("Menu already defined");
2125 dlg->menu = m;
2126 return dlg;
2129 static dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg)
2131 assert(dlg != NULL);
2132 if(dlg->lvc.language)
2133 yyerror("Language already defined");
2134 dlg->lvc.language = l;
2135 return dlg;
2138 static dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg)
2140 assert(dlg != NULL);
2141 if(dlg->lvc.characts)
2142 yyerror("Characteristics already defined");
2143 dlg->lvc.characts = c;
2144 return dlg;
2147 static dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg)
2149 assert(dlg != NULL);
2150 if(dlg->lvc.version)
2151 yyerror("Version already defined");
2152 dlg->lvc.version = v;
2153 return dlg;
2156 /* Accelerator specific functions */
2157 static event_t *add_event(int key, int id, int flags, event_t *prev)
2159 event_t *ev = new_event();
2161 if((flags & (WRC_AF_VIRTKEY | WRC_AF_ASCII)) == (WRC_AF_VIRTKEY | WRC_AF_ASCII))
2162 yyerror("Cannot use both ASCII and VIRTKEY");
2164 ev->key = key;
2165 ev->id = id;
2166 ev->flags = flags & ~WRC_AF_ASCII;
2167 ev->prev = prev;
2168 if(prev)
2169 prev->next = ev;
2170 return ev;
2173 static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev)
2175 int keycode = 0;
2176 event_t *ev = new_event();
2178 if(key->type != str_char)
2179 yyerror("Key code must be an ascii string");
2181 if((flags & WRC_AF_VIRTKEY) && (!isupper(key->str.cstr[0] & 0xff) && !isdigit(key->str.cstr[0] & 0xff)))
2182 yyerror("VIRTKEY code is not equal to ascii value");
2184 if(key->str.cstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0)
2186 yyerror("Cannot use both '^' and CONTROL modifier");
2188 else if(key->str.cstr[0] == '^')
2190 keycode = toupper(key->str.cstr[1]) - '@';
2191 if(keycode >= ' ')
2192 yyerror("Control-code out of range");
2194 else
2195 keycode = key->str.cstr[0];
2196 ev->key = keycode;
2197 ev->id = id;
2198 ev->flags = flags & ~WRC_AF_ASCII;
2199 ev->prev = prev;
2200 if(prev)
2201 prev->next = ev;
2202 return ev;
2205 /* MenuEx specific functions */
2206 static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid)
2208 itemex_opt_t *opt = (itemex_opt_t *)xmalloc(sizeof(itemex_opt_t));
2209 opt->id = id;
2210 opt->type = type;
2211 opt->state = state;
2212 opt->helpid = helpid;
2213 return opt;
2216 /* Raw data functions */
2217 static raw_data_t *load_file(string_t *name)
2219 FILE *fp;
2220 raw_data_t *rd;
2221 if(name->type != str_char)
2222 yyerror("Filename must be ASCII string");
2224 fp = open_include(name->str.cstr, 1, NULL);
2225 if(!fp)
2226 yyerror("Cannot open file %s", name->str.cstr);
2227 rd = new_raw_data();
2228 fseek(fp, 0, SEEK_END);
2229 rd->size = ftell(fp);
2230 fseek(fp, 0, SEEK_SET);
2231 rd->data = (char *)xmalloc(rd->size);
2232 fread(rd->data, rd->size, 1, fp);
2233 fclose(fp);
2234 return rd;
2237 static raw_data_t *int2raw_data(int i)
2239 raw_data_t *rd;
2241 if((int)((short)i) != i)
2242 yywarning("Integer constant out of 16bit range (%d), truncated to %d\n", i, (short)i);
2244 rd = new_raw_data();
2245 rd->size = sizeof(short);
2246 rd->data = (char *)xmalloc(rd->size);
2247 switch(byteorder)
2249 #ifndef WORDS_BIGENDIAN
2250 case WRC_BO_BIG:
2251 #else
2252 case WRC_BO_LITTLE:
2253 #endif
2254 *(WORD *)(rd->data) = BYTESWAP_WORD((WORD)i);
2255 break;
2256 default:
2257 *(WORD *)(rd->data) = (WORD)i;
2258 break;
2260 return rd;
2263 static raw_data_t *long2raw_data(int i)
2265 raw_data_t *rd;
2266 rd = new_raw_data();
2267 rd->size = sizeof(int);
2268 rd->data = (char *)xmalloc(rd->size);
2269 switch(byteorder)
2271 #ifndef WORDS_BIGENDIAN
2272 case WRC_BO_BIG:
2273 #else
2274 case WRC_BO_LITTLE:
2275 #endif
2276 *(DWORD *)(rd->data) = BYTESWAP_DWORD((DWORD)i);
2277 break;
2278 default:
2279 *(DWORD *)(rd->data) = (DWORD)i;
2280 break;
2282 return rd;
2285 static raw_data_t *str2raw_data(string_t *str)
2287 raw_data_t *rd;
2288 rd = new_raw_data();
2289 rd->size = str->size * (str->type == str_char ? 1 : 2);
2290 rd->data = (char *)xmalloc(rd->size);
2291 if(str->type == str_char)
2292 memcpy(rd->data, str->str.cstr, rd->size);
2293 else if(str->type == str_unicode)
2295 int i;
2296 switch(byteorder)
2298 #ifndef WORDS_BIGENDIAN
2299 case WRC_BO_BIG:
2300 #else
2301 case WRC_BO_LITTLE:
2302 #endif
2303 for(i = 0; i < str->size; i++)
2304 *(WORD *)&(rd->data[2*i]) = BYTESWAP_WORD((WORD)str->str.wstr[i]);
2305 break;
2306 default:
2307 for(i = 0; i < str->size; i++)
2308 *(WORD *)&(rd->data[2*i]) = (WORD)str->str.wstr[i];
2309 break;
2312 else
2313 internal_error(__FILE__, __LINE__, "Invalid stringtype");
2314 return rd;
2317 static raw_data_t *merge_raw_data(raw_data_t *r1, raw_data_t *r2)
2319 r1->data = xrealloc(r1->data, r1->size + r2->size);
2320 memcpy(r1->data + r1->size, r2->data, r2->size);
2321 r1->size += r2->size;
2322 return r1;
2325 static raw_data_t *merge_raw_data_int(raw_data_t *r1, int i)
2327 raw_data_t *t = int2raw_data(i);
2328 merge_raw_data(r1, t);
2329 free(t->data);
2330 free(t);
2331 return r1;
2334 static raw_data_t *merge_raw_data_long(raw_data_t *r1, int i)
2336 raw_data_t *t = long2raw_data(i);
2337 merge_raw_data(r1, t);
2338 free(t->data);
2339 free(t);
2340 return r1;
2343 static raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str)
2345 raw_data_t *t = str2raw_data(str);
2346 merge_raw_data(r1, t);
2347 free(t->data);
2348 free(t);
2349 return r1;
2352 /* Function the go back in a list to get the head */
2353 static menu_item_t *get_item_head(menu_item_t *p)
2355 if(!p)
2356 return NULL;
2357 while(p->prev)
2358 p = p->prev;
2359 return p;
2362 static menuex_item_t *get_itemex_head(menuex_item_t *p)
2364 if(!p)
2365 return NULL;
2366 while(p->prev)
2367 p = p->prev;
2368 return p;
2371 static resource_t *get_resource_head(resource_t *p)
2373 if(!p)
2374 return NULL;
2375 while(p->prev)
2376 p = p->prev;
2377 return p;
2380 static ver_block_t *get_ver_block_head(ver_block_t *p)
2382 if(!p)
2383 return NULL;
2384 while(p->prev)
2385 p = p->prev;
2386 return p;
2389 static ver_value_t *get_ver_value_head(ver_value_t *p)
2391 if(!p)
2392 return NULL;
2393 while(p->prev)
2394 p = p->prev;
2395 return p;
2398 static control_t *get_control_head(control_t *p)
2400 if(!p)
2401 return NULL;
2402 while(p->prev)
2403 p = p->prev;
2404 return p;
2407 static event_t *get_event_head(event_t *p)
2409 if(!p)
2410 return NULL;
2411 while(p->prev)
2412 p = p->prev;
2413 return p;
2416 /* Find a stringtable with given language */
2417 static stringtable_t *find_stringtable(lvc_t *lvc)
2419 stringtable_t *stt;
2421 assert(lvc != NULL);
2423 if(!lvc->language)
2424 lvc->language = dup_language(currentlanguage);
2426 for(stt = sttres; stt; stt = stt->next)
2428 if(stt->lvc.language->id == lvc->language->id
2429 && stt->lvc.language->id == lvc->language->id)
2431 /* Found a table with the same language */
2432 /* The version and characteristics are now handled
2433 * in the generation of the individual stringtables.
2434 * This enables localized analysis.
2435 if((stt->lvc.version && lvc->version && *(stt->lvc.version) != *(lvc->version))
2436 || (!stt->lvc.version && lvc->version)
2437 || (stt->lvc.version && !lvc->version))
2438 yywarning("Stringtable's versions are not the same, using first definition");
2440 if((stt->lvc.characts && lvc->characts && *(stt->lvc.characts) != *(lvc->characts))
2441 || (!stt->lvc.characts && lvc->characts)
2442 || (stt->lvc.characts && !lvc->characts))
2443 yywarning("Stringtable's characteristics are not the same, using first definition");
2445 return stt;
2448 return NULL;
2451 /* qsort sorting function for string table entries */
2452 #define STE(p) ((stt_entry_t *)(p))
2453 static int sort_stt_entry(const void *e1, const void *e2)
2455 return STE(e1)->id - STE(e2)->id;
2457 #undef STE
2459 static resource_t *build_stt_resources(stringtable_t *stthead)
2461 stringtable_t *stt;
2462 stringtable_t *newstt;
2463 resource_t *rsc;
2464 resource_t *rsclist = NULL;
2465 resource_t *rsctail = NULL;
2466 int i;
2467 int j;
2468 DWORD andsum;
2469 DWORD orsum;
2470 characts_t *characts;
2471 version_t *version;
2473 if(!stthead)
2474 return NULL;
2476 /* For all languages defined */
2477 for(stt = stthead; stt; stt = stt->next)
2479 assert(stt->nentries > 0);
2481 /* Sort the entries */
2482 if(stt->nentries > 1)
2483 qsort(stt->entries, stt->nentries, sizeof(stt->entries[0]), sort_stt_entry);
2485 for(i = 0; i < stt->nentries; )
2487 newstt = new_stringtable(&stt->lvc);
2488 newstt->entries = (stt_entry_t *)xmalloc(16 * sizeof(stt_entry_t));
2489 newstt->nentries = 16;
2490 newstt->idbase = stt->entries[i].id & ~0xf;
2491 for(j = 0; j < 16 && i < stt->nentries; j++)
2493 if(stt->entries[i].id - newstt->idbase == j)
2495 newstt->entries[j] = stt->entries[i];
2496 i++;
2499 andsum = ~0;
2500 orsum = 0;
2501 characts = NULL;
2502 version = NULL;
2503 /* Check individual memory options and get
2504 * the first characteristics/version
2506 for(j = 0; j < 16; j++)
2508 if(!newstt->entries[j].str)
2509 continue;
2510 andsum &= newstt->entries[j].memopt;
2511 orsum |= newstt->entries[j].memopt;
2512 if(!characts)
2513 characts = newstt->entries[j].characts;
2514 if(!version)
2515 version = newstt->entries[j].version;
2517 if(andsum != orsum)
2519 warning("Stringtable's memory options are not equal (idbase: %d)", newstt->idbase);
2521 /* Check version and characteristics */
2522 for(j = 0; j < 16; j++)
2524 if(characts
2525 && newstt->entries[j].characts
2526 && *newstt->entries[j].characts != *characts)
2527 warning("Stringtable's characteristics are not the same (idbase: %d)", newstt->idbase);
2528 if(version
2529 && newstt->entries[j].version
2530 && *newstt->entries[j].version != *version)
2531 warning("Stringtable's versions are not the same (idbase: %d)", newstt->idbase);
2533 rsc = new_resource(res_stt, newstt, newstt->memopt, newstt->lvc.language);
2534 rsc->name = new_name_id();
2535 rsc->name->type = name_ord;
2536 rsc->name->name.i_name = (newstt->idbase >> 4) + 1;
2537 rsc->memopt = andsum; /* Set to least common denominator */
2538 newstt->memopt = andsum;
2539 newstt->lvc.characts = characts;
2540 newstt->lvc.version = version;
2541 if(!rsclist)
2543 rsclist = rsc;
2544 rsctail = rsc;
2546 else
2548 rsctail->next = rsc;
2549 rsc->prev = rsctail;
2550 rsctail = rsc;
2554 return rsclist;
2558 static toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec)
2560 idrec->prev = prev;
2561 if(prev)
2562 prev->next = idrec;
2564 return idrec;
2567 static toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems)
2569 if(!p)
2571 *nitems = 0;
2572 return NULL;
2575 *nitems = 1;
2577 while(p->prev)
2579 (*nitems)++;
2580 p = p->prev;
2583 return p;
2586 static string_t *make_filename(string_t *str)
2588 char *cptr;
2590 if(str->type != str_char)
2591 yyerror("Cannot handle UNICODE filenames");
2593 /* Remove escaped backslash and convert to forward */
2594 cptr = str->str.cstr;
2595 for(cptr = str->str.cstr; (cptr = strchr(cptr, '\\')) != NULL; cptr++)
2597 if(cptr[1] == '\\')
2599 memmove(cptr, cptr+1, strlen(cptr));
2600 str->size--;
2602 *cptr = '/';
2605 /* Convert to lower case. Seems to be reasonable to do */
2606 for(cptr = str->str.cstr; !leave_case && *cptr; cptr++)
2608 *cptr = tolower(*cptr);
2610 return str;
2614 * Process all resources to extract fonts and build
2615 * a fontdir resource.
2617 * Note: MS' resource compiler (build 1472) does not
2618 * handle font resources with different languages.
2619 * The fontdir is generated in the last active language
2620 * and font identifiers must be unique across the entire
2621 * source.
2622 * This is not logical considering the localization
2623 * constraints of all other resource types. MS has,
2624 * most probably, never testet localized fonts. However,
2625 * using fontresources is rare, so it might not occur
2626 * in normal applications.
2627 * Wine does require better localization because a lot
2628 * of languages are coded into the same executable.
2629 * Therefore, I will generate fontdirs for *each*
2630 * localized set of fonts.
2632 static resource_t *build_fontdir(resource_t **fnt, int nfnt)
2634 static int once = 0;
2635 if(!once)
2637 warning("Need to parse fonts, not yet implemented");
2638 once++;
2640 return NULL;
2643 static resource_t *build_fontdirs(resource_t *tail)
2645 resource_t *rsc;
2646 resource_t *lst = NULL;
2647 resource_t **fnt = NULL; /* List of all fonts */
2648 int nfnt = 0;
2649 resource_t **fnd = NULL; /* List of all fontdirs */
2650 int nfnd = 0;
2651 resource_t **lanfnt = NULL;
2652 int nlanfnt = 0;
2653 int i;
2654 name_id_t nid;
2655 string_t str;
2656 int fntleft;
2658 nid.type = name_str;
2659 nid.name.s_name = &str;
2660 str.type = str_char;
2661 str.str.cstr = "FONTDIR";
2662 str.size = 7;
2664 /* Extract all fonts and fontdirs */
2665 for(rsc = tail; rsc; rsc = rsc->prev)
2667 if(rsc->type == res_fnt)
2669 nfnt++;
2670 fnt = xrealloc(fnt, nfnt * sizeof(*fnt));
2671 fnt[nfnt-1] = rsc;
2673 else if(rsc->type == res_fntdir)
2675 nfnd++;
2676 fnd = xrealloc(fnd, nfnd * sizeof(*fnd));
2677 fnd[nfnd-1] = rsc;
2681 /* Verify the name of the present fontdirs */
2682 for(i = 0; i < nfnd; i++)
2684 if(compare_name_id(&nid, fnd[i]->name))
2686 warning("User supplied FONTDIR entry has an invalid name '%s', ignored",
2687 get_nameid_str(fnd[i]->name));
2688 fnd[i] = NULL;
2692 /* Sanity check */
2693 if(nfnt == 0)
2695 if(nfnd != 0)
2696 warning("Found %d FONTDIR entries without any fonts present", nfnd);
2697 goto clean;
2700 /* Copy space */
2701 lanfnt = xmalloc(nfnt * sizeof(*lanfnt));
2703 /* Get all fonts covered by fontdirs */
2704 for(i = 0; i < nfnd; i++)
2706 int j;
2707 WORD cnt;
2708 int isswapped = 0;
2710 if(!fnd[i])
2711 continue;
2712 for(j = 0; j < nfnt; j++)
2714 if(!fnt[j])
2715 continue;
2716 if(fnt[j]->lan->id == fnd[i]->lan->id && fnt[j]->lan->sub == fnd[i]->lan->sub)
2718 lanfnt[nlanfnt] = fnt[j];
2719 nlanfnt++;
2720 fnt[j] = NULL;
2724 cnt = *(WORD *)fnd[i]->res.fnd->data->data;
2725 if(nlanfnt == cnt)
2726 isswapped = 0;
2727 else if(nlanfnt == BYTESWAP_WORD(cnt))
2728 isswapped = 1;
2729 else
2730 error("FONTDIR for language %d,%d has wrong count (%d, expected %d)",
2731 fnd[i]->lan->id, fnd[i]->lan->sub, cnt, nlanfnt);
2732 #ifdef WORDS_BIGENDIAN
2733 if((byteorder == WRC_BO_LITTLE && !isswapped) || (byteorder != WRC_BO_LITTLE && isswapped))
2734 #else
2735 if((byteorder == WRC_BO_BIG && !isswapped) || (byteorder != WRC_BO_BIG && isswapped))
2736 #endif
2738 internal_error(__FILE__, __LINE__, "User supplied FONTDIR needs byteswapping");
2742 /* We now have fonts left where we need to make a fontdir resource */
2743 for(i = fntleft = 0; i < nfnt; i++)
2745 if(fnt[i])
2746 fntleft++;
2748 while(fntleft)
2750 /* Get fonts of same language in lanfnt[] */
2751 for(i = nlanfnt = 0; i < nfnt; i++)
2753 if(fnt[i])
2755 if(!nlanfnt)
2757 addlanfnt:
2758 lanfnt[nlanfnt] = fnt[i];
2759 nlanfnt++;
2760 fnt[i] = NULL;
2761 fntleft--;
2763 else if(fnt[i]->lan->id == lanfnt[0]->lan->id && fnt[i]->lan->sub == lanfnt[0]->lan->sub)
2764 goto addlanfnt;
2767 /* and build a fontdir */
2768 rsc = build_fontdir(lanfnt, nlanfnt);
2769 if(rsc)
2771 if(lst)
2773 lst->next = rsc;
2774 rsc->prev = lst;
2776 lst = rsc;
2780 free(lanfnt);
2781 clean:
2782 if(fnt)
2783 free(fnt);
2784 if(fnd)
2785 free(fnd);
2786 return lst;
2790 * This gets invoked to determine whether the next resource
2791 * is to be of a standard-type (e.g. bitmaps etc.), or should
2792 * be a user-type resource. This function is required because
2793 * there is the _possibility_ of a lookahead token in the
2794 * parser, which is generated from the "expr" state in the
2795 * "nameid" parsing.
2797 * The general resource format is:
2798 * <identifier> <type> <flags> <resourcebody>
2800 * The <identifier> can either be tIDENT or "expr". The latter
2801 * will always generate a lookahead, which is the <type> of the
2802 * resource to parse. Otherwise, we need to get a new token from
2803 * the scanner to determine the next step.
2805 * The problem arrises when <type> is numerical. This case should
2806 * map onto default resource-types and be parsed as such instead
2807 * of being mapped onto user-type resources.
2809 * The trick lies in the fact that yacc (bison) doesn't care about
2810 * intermediate changes of the lookahead while reducing a rule. We
2811 * simply replace the lookahead with a token that will result in
2812 * a shift to the appropriate rule for the specific resource-type.
2814 static int rsrcid_to_token(int lookahead)
2816 int token;
2817 char *type = "?";
2819 /* Get a token if we don't have one yet */
2820 if(lookahead == YYEMPTY)
2821 lookahead = YYLEX;
2823 /* Only numbers are possibly interesting */
2824 switch(lookahead)
2826 case tNUMBER:
2827 case tLNUMBER:
2828 break;
2829 default:
2830 return lookahead;
2833 token = lookahead;
2835 switch(yylval.num)
2837 case WRC_RT_CURSOR:
2838 type = "CURSOR";
2839 token = tCURSOR;
2840 break;
2841 case WRC_RT_ICON:
2842 type = "ICON";
2843 token = tICON;
2844 break;
2845 case WRC_RT_BITMAP:
2846 type = "BITMAP";
2847 token = tBITMAP;
2848 break;
2849 case WRC_RT_FONT:
2850 type = "FONT";
2851 token = tFONT;
2852 break;
2853 case WRC_RT_FONTDIR:
2854 type = "FONTDIR";
2855 token = tFONTDIR;
2856 break;
2857 case WRC_RT_RCDATA:
2858 type = "RCDATA";
2859 token = tRCDATA;
2860 break;
2861 case WRC_RT_MESSAGETABLE:
2862 type = "MESSAGETABLE";
2863 token = tMESSAGETABLE;
2864 break;
2865 case WRC_RT_DLGINIT:
2866 type = "DLGINIT";
2867 token = tDLGINIT;
2868 break;
2869 case WRC_RT_ACCELERATOR:
2870 type = "ACCELERATOR";
2871 token = tACCELERATORS;
2872 break;
2873 case WRC_RT_MENU:
2874 type = "MENU";
2875 token = tMENU;
2876 break;
2877 case WRC_RT_DIALOG:
2878 type = "DIALOG";
2879 token = tDIALOG;
2880 break;
2881 case WRC_RT_VERSION:
2882 type = "VERSION";
2883 token = tVERSIONINFO;
2884 break;
2885 case WRC_RT_TOOLBAR:
2886 type = "TOOLBAR";
2887 token = tTOOLBAR;
2888 break;
2890 case WRC_RT_STRING:
2891 type = "STRINGTABLE";
2892 break;
2894 case WRC_RT_ANICURSOR:
2895 case WRC_RT_ANIICON:
2896 case WRC_RT_GROUP_CURSOR:
2897 case WRC_RT_GROUP_ICON:
2898 yywarning("Usertype uses reserved type-ID %d, which is auto-generated", yylval.num);
2899 return lookahead;
2901 case WRC_RT_DLGINCLUDE:
2902 case WRC_RT_PLUGPLAY:
2903 case WRC_RT_VXD:
2904 case WRC_RT_HTML:
2905 yywarning("Usertype uses reserved type-ID %d, which is not supported by wrc", yylval.num);
2906 default:
2907 return lookahead;
2910 if(remap)
2911 return token;
2912 else
2913 yywarning("Usertype uses reserved type-ID %d, which is used by %s", yylval.num, type);
2914 return lookahead;