* dwarf2dbg.c (get_filenum): Skip as-yet unassigned file numbers.
[binutils.git] / binutils / rcparse.y
blobf287eb44f2833aa4b9fbcd2a70315b0eb9f5c073
1 %{ /* rcparse.y -- parser for Windows rc files
2 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
22 /* This is a parser for Windows rc files. It is based on the parser
23 by Gunther Ebert <gunther.ebert@ixos-leipzig.de>. */
25 #include "bfd.h"
26 #include "bucomm.h"
27 #include "libiberty.h"
28 #include "windres.h"
29 #include "safe-ctype.h"
31 /* The current language. */
33 static unsigned short language;
35 /* The resource information during a sub statement. */
37 static struct res_res_info sub_res_info;
39 /* Dialog information. This is built by the nonterminals styles and
40 controls. */
42 static struct dialog dialog;
44 /* This is used when building a style. It is modified by the
45 nonterminal styleexpr. */
47 static unsigned long style;
49 /* These are used when building a control. They are set before using
50 control_params. */
52 static unsigned long base_style;
53 static unsigned long default_style;
54 static unsigned long class;
58 %union
60 struct accelerator acc;
61 struct accelerator *pacc;
62 struct dialog_control *dialog_control;
63 struct menuitem *menuitem;
64 struct
66 struct rcdata_item *first;
67 struct rcdata_item *last;
68 } rcdata;
69 struct rcdata_item *rcdata_item;
70 struct stringtable_data *stringtable;
71 struct fixed_versioninfo *fixver;
72 struct ver_info *verinfo;
73 struct ver_stringinfo *verstring;
74 struct ver_varinfo *vervar;
75 struct res_id id;
76 struct res_res_info res_info;
77 struct
79 unsigned short on;
80 unsigned short off;
81 } memflags;
82 struct
84 unsigned long val;
85 /* Nonzero if this number was explicitly specified as long. */
86 int dword;
87 } i;
88 unsigned long il;
89 unsigned short is;
90 const char *s;
91 struct
93 unsigned long length;
94 const char *s;
95 } ss;
98 %token BEG END
99 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
100 %token BITMAP
101 %token CURSOR
102 %token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
103 %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
104 %token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
105 %token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
106 %token BEDIT HEDIT IEDIT
107 %token FONT
108 %token ICON
109 %token LANGUAGE CHARACTERISTICS VERSIONK
110 %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
111 %token MENUBARBREAK MENUBREAK
112 %token MESSAGETABLE
113 %token RCDATA
114 %token STRINGTABLE
115 %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
116 %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
117 %token VALUE
118 %token <s> BLOCK
119 %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
120 %token NOT
121 %token <s> QUOTEDSTRING STRING
122 %token <i> NUMBER
123 %token <ss> SIZEDSTRING
124 %token IGNORED_TOKEN
126 %type <pacc> acc_entries
127 %type <acc> acc_entry acc_event
128 %type <dialog_control> control control_params
129 %type <menuitem> menuitems menuitem menuexitems menuexitem
130 %type <rcdata> optrcdata_data optrcdata_data_int rcdata_data
131 %type <rcdata_item> opt_control_data
132 %type <fixver> fixedverinfo
133 %type <verinfo> verblocks
134 %type <verstring> vervals
135 %type <vervar> vertrans
136 %type <res_info> suboptions memflags_move_discard memflags_move
137 %type <memflags> memflag
138 %type <id> id optresidc resref
139 %type <il> exstyle parennumber
140 %type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
141 %type <is> acc_options acc_option menuitem_flags menuitem_flag
142 %type <s> file_name resname
143 %type <i> sizednumexpr sizedposnumexpr
145 %left '|'
146 %left '^'
147 %left '&'
148 %left '+' '-'
149 %left '*' '/' '%'
150 %right '~' NEG
154 input:
155 /* empty */
156 | input accelerator
157 | input bitmap
158 | input cursor
159 | input dialog
160 | input font
161 | input icon
162 | input language
163 | input menu
164 | input menuex
165 | input messagetable
166 | input rcdata
167 | input stringtable
168 | input user
169 | input versioninfo
170 | input IGNORED_TOKEN
173 /* Accelerator resources. */
175 accelerator:
176 id ACCELERATORS suboptions BEG acc_entries END
178 define_accelerator ($1, &$3, $5);
179 if (yychar != YYEMPTY)
180 YYERROR;
181 rcparse_discard_strings ();
185 acc_entries:
186 /* empty */
188 $$ = NULL;
190 | acc_entries acc_entry
192 struct accelerator *a;
194 a = (struct accelerator *) res_alloc (sizeof *a);
195 *a = $2;
196 if ($1 == NULL)
197 $$ = a;
198 else
200 struct accelerator **pp;
202 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
204 *pp = a;
205 $$ = $1;
210 acc_entry:
211 acc_event cposnumexpr
213 $$ = $1;
214 $$.id = $2;
216 | acc_event cposnumexpr ',' acc_options
218 $$ = $1;
219 $$.id = $2;
220 $$.flags |= $4;
221 if (($$.flags & ACC_VIRTKEY) == 0
222 && ($$.flags & (ACC_SHIFT | ACC_CONTROL)) != 0)
223 rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
227 acc_event:
228 QUOTEDSTRING
230 const char *s = $1;
231 char ch;
233 $$.next = NULL;
234 $$.id = 0;
235 ch = *s;
236 if (ch != '^')
237 $$.flags = 0;
238 else
240 $$.flags = ACC_CONTROL | ACC_VIRTKEY;
241 ++s;
242 ch = *s;
243 ch = TOUPPER (ch);
245 $$.key = ch;
246 if (s[1] != '\0')
247 rcparse_warning (_("accelerator should only be one character"));
249 | posnumexpr
251 $$.next = NULL;
252 $$.flags = 0;
253 $$.id = 0;
254 $$.key = $1;
258 acc_options:
259 acc_option
261 $$ = $1;
263 | acc_options ',' acc_option
265 $$ = $1 | $3;
267 /* I've had one report that the comma is optional. */
268 | acc_options acc_option
270 $$ = $1 | $2;
274 acc_option:
275 VIRTKEY
277 $$ = ACC_VIRTKEY;
279 | ASCII
281 /* This is just the absence of VIRTKEY. */
282 $$ = 0;
284 | NOINVERT
286 $$ = ACC_NOINVERT;
288 | SHIFT
290 $$ = ACC_SHIFT;
292 | CONTROL
294 $$ = ACC_CONTROL;
296 | ALT
298 $$ = ACC_ALT;
302 /* Bitmap resources. */
304 bitmap:
305 id BITMAP memflags_move file_name
307 define_bitmap ($1, &$3, $4);
308 if (yychar != YYEMPTY)
309 YYERROR;
310 rcparse_discard_strings ();
314 /* Cursor resources. */
316 cursor:
317 id CURSOR memflags_move_discard file_name
319 define_cursor ($1, &$3, $4);
320 if (yychar != YYEMPTY)
321 YYERROR;
322 rcparse_discard_strings ();
326 /* Dialog resources. */
328 dialog:
329 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
330 cnumexpr
332 memset (&dialog, 0, sizeof dialog);
333 dialog.x = $5;
334 dialog.y = $6;
335 dialog.width = $7;
336 dialog.height = $8;
337 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
338 dialog.exstyle = $4;
339 dialog.menu.named = 1;
340 dialog.class.named = 1;
341 dialog.font = NULL;
342 dialog.ex = NULL;
343 dialog.controls = NULL;
344 sub_res_info = $3;
345 style = 0;
347 styles BEG controls END
349 define_dialog ($1, &sub_res_info, &dialog);
350 if (yychar != YYEMPTY)
351 YYERROR;
352 rcparse_discard_strings ();
354 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
355 cnumexpr
357 memset (&dialog, 0, sizeof dialog);
358 dialog.x = $5;
359 dialog.y = $6;
360 dialog.width = $7;
361 dialog.height = $8;
362 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
363 dialog.exstyle = $4;
364 dialog.menu.named = 1;
365 dialog.class.named = 1;
366 dialog.font = NULL;
367 dialog.ex = ((struct dialog_ex *)
368 res_alloc (sizeof (struct dialog_ex)));
369 memset (dialog.ex, 0, sizeof (struct dialog_ex));
370 dialog.controls = NULL;
371 sub_res_info = $3;
372 style = 0;
374 styles BEG controls END
376 define_dialog ($1, &sub_res_info, &dialog);
377 if (yychar != YYEMPTY)
378 YYERROR;
379 rcparse_discard_strings ();
381 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
382 cnumexpr cnumexpr
384 memset (&dialog, 0, sizeof dialog);
385 dialog.x = $5;
386 dialog.y = $6;
387 dialog.width = $7;
388 dialog.height = $8;
389 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
390 dialog.exstyle = $4;
391 dialog.menu.named = 1;
392 dialog.class.named = 1;
393 dialog.font = NULL;
394 dialog.ex = ((struct dialog_ex *)
395 res_alloc (sizeof (struct dialog_ex)));
396 memset (dialog.ex, 0, sizeof (struct dialog_ex));
397 dialog.ex->help = $9;
398 dialog.controls = NULL;
399 sub_res_info = $3;
400 style = 0;
402 styles BEG controls END
404 define_dialog ($1, &sub_res_info, &dialog);
405 if (yychar != YYEMPTY)
406 YYERROR;
407 rcparse_discard_strings ();
411 exstyle:
412 /* empty */
414 $$ = 0;
416 | EXSTYLE '=' numexpr
418 $$ = $3;
422 styles:
423 /* empty */
424 | styles CAPTION QUOTEDSTRING
426 dialog.style |= WS_CAPTION;
427 style |= WS_CAPTION;
428 unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
430 | styles CLASS id
432 dialog.class = $3;
434 | styles STYLE
435 styleexpr
437 dialog.style = style;
439 | styles EXSTYLE numexpr
441 dialog.exstyle = $3;
443 | styles CLASS QUOTEDSTRING
445 res_string_to_id (& dialog.class, $3);
447 | styles FONT numexpr ',' QUOTEDSTRING
449 dialog.style |= DS_SETFONT;
450 style |= DS_SETFONT;
451 dialog.pointsize = $3;
452 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
453 if (dialog.ex != NULL)
455 dialog.ex->weight = 0;
456 dialog.ex->italic = 0;
457 dialog.ex->charset = 1;
460 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr
462 dialog.style |= DS_SETFONT;
463 style |= DS_SETFONT;
464 dialog.pointsize = $3;
465 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
466 if (dialog.ex == NULL)
467 rcparse_warning (_("extended FONT requires DIALOGEX"));
468 else
470 dialog.ex->weight = $6;
471 dialog.ex->italic = 0;
472 dialog.ex->charset = 1;
475 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
477 dialog.style |= DS_SETFONT;
478 style |= DS_SETFONT;
479 dialog.pointsize = $3;
480 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
481 if (dialog.ex == NULL)
482 rcparse_warning (_("extended FONT requires DIALOGEX"));
483 else
485 dialog.ex->weight = $6;
486 dialog.ex->italic = $7;
487 dialog.ex->charset = 1;
490 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr
492 dialog.style |= DS_SETFONT;
493 style |= DS_SETFONT;
494 dialog.pointsize = $3;
495 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
496 if (dialog.ex == NULL)
497 rcparse_warning (_("extended FONT requires DIALOGEX"));
498 else
500 dialog.ex->weight = $6;
501 dialog.ex->italic = $7;
502 dialog.ex->charset = $8;
505 | styles MENU id
507 dialog.menu = $3;
509 | styles CHARACTERISTICS numexpr
511 sub_res_info.characteristics = $3;
513 | styles LANGUAGE numexpr cnumexpr
515 sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT);
517 | styles VERSIONK numexpr
519 sub_res_info.version = $3;
523 controls:
524 /* empty */
525 | controls control
527 struct dialog_control **pp;
529 for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
531 *pp = $2;
535 control:
536 AUTO3STATE
538 default_style = BS_AUTO3STATE | WS_TABSTOP;
539 base_style = BS_AUTO3STATE;
540 class = CTL_BUTTON;
542 control_params
544 $$ = $3;
546 | AUTOCHECKBOX
548 default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
549 base_style = BS_AUTOCHECKBOX;
550 class = CTL_BUTTON;
552 control_params
554 $$ = $3;
556 | AUTORADIOBUTTON
558 default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
559 base_style = BS_AUTORADIOBUTTON;
560 class = CTL_BUTTON;
562 control_params
564 $$ = $3;
566 | BEDIT
568 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
569 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
570 class = CTL_EDIT;
572 control_params
574 $$ = $3;
575 if (dialog.ex == NULL)
576 rcparse_warning (_("BEDIT requires DIALOGEX"));
577 res_string_to_id (&$$->class, "BEDIT");
579 | CHECKBOX
581 default_style = BS_CHECKBOX | WS_TABSTOP;
582 base_style = BS_CHECKBOX | WS_TABSTOP;
583 class = CTL_BUTTON;
585 control_params
587 $$ = $3;
589 | COMBOBOX
591 default_style = CBS_SIMPLE | WS_TABSTOP;
592 base_style = 0;
593 class = CTL_COMBOBOX;
595 control_params
597 $$ = $3;
599 | CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
600 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
602 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
603 if ($11 != NULL)
605 if (dialog.ex == NULL)
606 rcparse_warning (_("control data requires DIALOGEX"));
607 $$->data = $11;
610 | CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
611 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
613 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
614 if (dialog.ex == NULL)
615 rcparse_warning (_("help ID requires DIALOGEX"));
616 $$->help = $11;
617 $$->data = $12;
619 | CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
620 cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
622 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
623 if ($12 != NULL)
625 if (dialog.ex == NULL)
626 rcparse_warning ("control data requires DIALOGEX");
627 $$->data = $12;
629 $$->class.named = 1;
630 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
632 | CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
633 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
635 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
636 if (dialog.ex == NULL)
637 rcparse_warning ("help ID requires DIALOGEX");
638 $$->help = $12;
639 $$->data = $13;
640 $$->class.named = 1;
641 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
643 | CTEXT
645 default_style = SS_CENTER | WS_GROUP;
646 base_style = SS_CENTER;
647 class = CTL_STATIC;
649 control_params
651 $$ = $3;
653 | DEFPUSHBUTTON
655 default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
656 base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
657 class = CTL_BUTTON;
659 control_params
661 $$ = $3;
663 | EDITTEXT
665 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
666 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
667 class = CTL_EDIT;
669 control_params
671 $$ = $3;
673 | GROUPBOX
675 default_style = BS_GROUPBOX;
676 base_style = BS_GROUPBOX;
677 class = CTL_BUTTON;
679 control_params
681 $$ = $3;
683 | HEDIT
685 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
686 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
687 class = CTL_EDIT;
689 control_params
691 $$ = $3;
692 if (dialog.ex == NULL)
693 rcparse_warning (_("IEDIT requires DIALOGEX"));
694 res_string_to_id (&$$->class, "HEDIT");
696 | ICON resref numexpr cnumexpr cnumexpr opt_control_data
698 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
699 dialog.ex);
701 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
702 opt_control_data
704 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
705 dialog.ex);
707 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
708 icon_styleexpr optcnumexpr opt_control_data
710 $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
711 dialog.ex);
713 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
714 icon_styleexpr cnumexpr cnumexpr opt_control_data
716 $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
717 dialog.ex);
719 | IEDIT
721 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
722 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
723 class = CTL_EDIT;
725 control_params
727 $$ = $3;
728 if (dialog.ex == NULL)
729 rcparse_warning (_("IEDIT requires DIALOGEX"));
730 res_string_to_id (&$$->class, "IEDIT");
732 | LISTBOX
734 default_style = LBS_NOTIFY | WS_BORDER;
735 base_style = LBS_NOTIFY | WS_BORDER;
736 class = CTL_LISTBOX;
738 control_params
740 $$ = $3;
742 | LTEXT
744 default_style = SS_LEFT | WS_GROUP;
745 base_style = SS_LEFT;
746 class = CTL_STATIC;
748 control_params
750 $$ = $3;
752 | PUSHBOX
754 default_style = BS_PUSHBOX | WS_TABSTOP;
755 base_style = BS_PUSHBOX;
756 class = CTL_BUTTON;
758 control_params
760 $$ = $3;
762 | PUSHBUTTON
764 default_style = BS_PUSHBUTTON | WS_TABSTOP;
765 base_style = BS_PUSHBUTTON | WS_TABSTOP;
766 class = CTL_BUTTON;
768 control_params
770 $$ = $3;
772 | RADIOBUTTON
774 default_style = BS_RADIOBUTTON | WS_TABSTOP;
775 base_style = BS_RADIOBUTTON;
776 class = CTL_BUTTON;
778 control_params
780 $$ = $3;
782 | RTEXT
784 default_style = SS_RIGHT | WS_GROUP;
785 base_style = SS_RIGHT;
786 class = CTL_STATIC;
788 control_params
790 $$ = $3;
792 | SCROLLBAR
794 default_style = SBS_HORZ;
795 base_style = 0;
796 class = CTL_SCROLLBAR;
798 control_params
800 $$ = $3;
802 | STATE3
804 default_style = BS_3STATE | WS_TABSTOP;
805 base_style = BS_3STATE;
806 class = CTL_BUTTON;
808 control_params
810 $$ = $3;
812 | USERBUTTON resref numexpr ',' numexpr ',' numexpr ','
813 numexpr ',' numexpr ','
814 { style = WS_CHILD | WS_VISIBLE; }
815 styleexpr optcnumexpr
817 $$ = define_control ($2, $3, $5, $7, $9, $11, CTL_BUTTON,
818 style, $15);
822 /* Parameters for a control. The static variables DEFAULT_STYLE,
823 BASE_STYLE, and CLASS must be initialized before this nonterminal
824 is used. DEFAULT_STYLE is the style to use if no style expression
825 is specified. BASE_STYLE is the base style to use if a style
826 expression is specified; the style expression modifies the base
827 style. CLASS is the class of the control. */
829 control_params:
830 optresidc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
831 opt_control_data
833 $$ = define_control ($1, $2, $3, $4, $5, $6, class,
834 default_style | WS_CHILD | WS_VISIBLE, 0);
835 if ($7 != NULL)
837 if (dialog.ex == NULL)
838 rcparse_warning (_("control data requires DIALOGEX"));
839 $$->data = $7;
842 | optresidc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
843 control_params_styleexpr optcnumexpr opt_control_data
845 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
846 if ($9 != NULL)
848 if (dialog.ex == NULL)
849 rcparse_warning (_("control data requires DIALOGEX"));
850 $$->data = $9;
853 | optresidc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
854 control_params_styleexpr cnumexpr cnumexpr opt_control_data
856 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
857 if (dialog.ex == NULL)
858 rcparse_warning (_("help ID requires DIALOGEX"));
859 $$->help = $9;
860 $$->data = $10;
864 optresidc:
865 /* empty */
867 res_string_to_id (&$$, "");
869 | posnumexpr ','
871 $$.named = 0;
872 $$.u.id = $1;
874 | QUOTEDSTRING
876 res_string_to_id (&$$, $1);
878 | QUOTEDSTRING ','
880 res_string_to_id (&$$, $1);
884 opt_control_data:
885 /* empty */
887 $$ = NULL;
889 | BEG optrcdata_data END
891 $$ = $2.first;
895 /* These only exist to parse a reduction out of a common case. */
897 control_styleexpr:
899 { style = WS_CHILD | WS_VISIBLE; }
900 styleexpr
903 icon_styleexpr:
905 { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
906 styleexpr
909 control_params_styleexpr:
911 { style = base_style | WS_CHILD | WS_VISIBLE; }
912 styleexpr
915 /* Font resources. */
917 font:
918 id FONT memflags_move_discard file_name
920 define_font ($1, &$3, $4);
921 if (yychar != YYEMPTY)
922 YYERROR;
923 rcparse_discard_strings ();
927 /* Icon resources. */
929 icon:
930 id ICON memflags_move_discard file_name
932 define_icon ($1, &$3, $4);
933 if (yychar != YYEMPTY)
934 YYERROR;
935 rcparse_discard_strings ();
939 /* Language command. This changes the static variable language, which
940 affects all subsequent resources. */
942 language:
943 LANGUAGE numexpr cnumexpr
945 language = $2 | ($3 << SUBLANG_SHIFT);
949 /* Menu resources. */
951 menu:
952 id MENU suboptions BEG menuitems END
954 define_menu ($1, &$3, $5);
955 if (yychar != YYEMPTY)
956 YYERROR;
957 rcparse_discard_strings ();
961 menuitems:
962 /* empty */
964 $$ = NULL;
966 | menuitems menuitem
968 if ($1 == NULL)
969 $$ = $2;
970 else
972 struct menuitem **pp;
974 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
976 *pp = $2;
977 $$ = $1;
982 menuitem:
983 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
985 $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
987 | MENUITEM SEPARATOR
989 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
991 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
993 $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
997 menuitem_flags:
998 /* empty */
1000 $$ = 0;
1002 | menuitem_flags ',' menuitem_flag
1004 $$ = $1 | $3;
1006 | menuitem_flags menuitem_flag
1008 $$ = $1 | $2;
1012 menuitem_flag:
1013 CHECKED
1015 $$ = MENUITEM_CHECKED;
1017 | GRAYED
1019 $$ = MENUITEM_GRAYED;
1021 | HELP
1023 $$ = MENUITEM_HELP;
1025 | INACTIVE
1027 $$ = MENUITEM_INACTIVE;
1029 | MENUBARBREAK
1031 $$ = MENUITEM_MENUBARBREAK;
1033 | MENUBREAK
1035 $$ = MENUITEM_MENUBREAK;
1039 /* Menuex resources. */
1041 menuex:
1042 id MENUEX suboptions BEG menuexitems END
1044 define_menu ($1, &$3, $5);
1045 if (yychar != YYEMPTY)
1046 YYERROR;
1047 rcparse_discard_strings ();
1051 menuexitems:
1052 /* empty */
1054 $$ = NULL;
1056 | menuexitems menuexitem
1058 if ($1 == NULL)
1059 $$ = $2;
1060 else
1062 struct menuitem **pp;
1064 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
1066 *pp = $2;
1067 $$ = $1;
1072 menuexitem:
1073 MENUITEM QUOTEDSTRING
1075 $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
1077 | MENUITEM QUOTEDSTRING cnumexpr
1079 $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
1081 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
1083 $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
1085 | MENUITEM SEPARATOR
1087 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
1089 | POPUP QUOTEDSTRING BEG menuexitems END
1091 $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
1093 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
1095 $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
1097 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
1099 $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
1101 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
1102 BEG menuexitems END
1104 $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
1108 /* Messagetable resources. */
1110 messagetable:
1111 id MESSAGETABLE memflags_move file_name
1113 define_messagetable ($1, &$3, $4);
1114 if (yychar != YYEMPTY)
1115 YYERROR;
1116 rcparse_discard_strings ();
1120 /* Rcdata resources. */
1122 rcdata:
1123 id RCDATA suboptions BEG optrcdata_data END
1125 define_rcdata ($1, &$3, $5.first);
1126 if (yychar != YYEMPTY)
1127 YYERROR;
1128 rcparse_discard_strings ();
1132 /* We use a different lexing algorithm, because rcdata strings may
1133 contain embedded null bytes, and we need to know the length to use. */
1135 optrcdata_data:
1137 rcparse_rcdata ();
1139 optrcdata_data_int
1141 rcparse_normal ();
1142 $$ = $2;
1146 optrcdata_data_int:
1147 /* empty */
1149 $$.first = NULL;
1150 $$.last = NULL;
1152 | rcdata_data
1154 $$ = $1;
1158 rcdata_data:
1159 SIZEDSTRING
1161 struct rcdata_item *ri;
1163 ri = define_rcdata_string ($1.s, $1.length);
1164 $$.first = ri;
1165 $$.last = ri;
1167 | sizednumexpr
1169 struct rcdata_item *ri;
1171 ri = define_rcdata_number ($1.val, $1.dword);
1172 $$.first = ri;
1173 $$.last = ri;
1175 | rcdata_data ',' SIZEDSTRING
1177 struct rcdata_item *ri;
1179 ri = define_rcdata_string ($3.s, $3.length);
1180 $$.first = $1.first;
1181 $1.last->next = ri;
1182 $$.last = ri;
1184 | rcdata_data ',' sizednumexpr
1186 struct rcdata_item *ri;
1188 ri = define_rcdata_number ($3.val, $3.dword);
1189 $$.first = $1.first;
1190 $1.last->next = ri;
1191 $$.last = ri;
1195 /* Stringtable resources. */
1197 stringtable:
1198 STRINGTABLE suboptions BEG
1199 { sub_res_info = $2; }
1200 string_data END
1203 string_data:
1204 /* empty */
1205 | string_data numexpr QUOTEDSTRING
1207 define_stringtable (&sub_res_info, $2, $3);
1208 if (yychar != YYEMPTY)
1209 YYERROR;
1210 rcparse_discard_strings ();
1212 | string_data numexpr ',' QUOTEDSTRING
1214 define_stringtable (&sub_res_info, $2, $4);
1215 if (yychar != YYEMPTY)
1216 YYERROR;
1217 rcparse_discard_strings ();
1221 /* User defined resources. We accept general suboptions in the
1222 file_name case to keep the parser happy. */
1224 user:
1225 id id suboptions BEG optrcdata_data END
1227 define_user_data ($1, $2, &$3, $5.first);
1228 if (yychar != YYEMPTY)
1229 YYERROR;
1230 rcparse_discard_strings ();
1232 | id id suboptions file_name
1234 define_user_file ($1, $2, &$3, $4);
1235 if (yychar != YYEMPTY)
1236 YYERROR;
1237 rcparse_discard_strings ();
1241 /* Versioninfo resources. */
1243 versioninfo:
1244 id VERSIONINFO fixedverinfo BEG verblocks END
1246 define_versioninfo ($1, language, $3, $5);
1247 if (yychar != YYEMPTY)
1248 YYERROR;
1249 rcparse_discard_strings ();
1253 fixedverinfo:
1254 /* empty */
1256 $$ = ((struct fixed_versioninfo *)
1257 res_alloc (sizeof (struct fixed_versioninfo)));
1258 memset ($$, 0, sizeof (struct fixed_versioninfo));
1260 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1262 $1->file_version_ms = ($3 << 16) | $4;
1263 $1->file_version_ls = ($5 << 16) | $6;
1264 $$ = $1;
1266 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1268 $1->product_version_ms = ($3 << 16) | $4;
1269 $1->product_version_ls = ($5 << 16) | $6;
1270 $$ = $1;
1272 | fixedverinfo FILEFLAGSMASK numexpr
1274 $1->file_flags_mask = $3;
1275 $$ = $1;
1277 | fixedverinfo FILEFLAGS numexpr
1279 $1->file_flags = $3;
1280 $$ = $1;
1282 | fixedverinfo FILEOS numexpr
1284 $1->file_os = $3;
1285 $$ = $1;
1287 | fixedverinfo FILETYPE numexpr
1289 $1->file_type = $3;
1290 $$ = $1;
1292 | fixedverinfo FILESUBTYPE numexpr
1294 $1->file_subtype = $3;
1295 $$ = $1;
1299 /* To handle verblocks successfully, the lexer handles BLOCK
1300 specially. A BLOCK "StringFileInfo" is returned as
1301 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1302 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1303 with the string as the value. */
1305 verblocks:
1306 /* empty */
1308 $$ = NULL;
1310 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1312 $$ = append_ver_stringfileinfo ($1, $4, $6);
1314 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1316 $$ = append_ver_varfileinfo ($1, $5, $6);
1320 vervals:
1321 /* empty */
1323 $$ = NULL;
1325 | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
1327 $$ = append_verval ($1, $3, $5);
1331 vertrans:
1332 /* empty */
1334 $$ = NULL;
1336 | vertrans cnumexpr cnumexpr
1338 $$ = append_vertrans ($1, $2, $3);
1342 /* A resource ID. */
1345 posnumexpr
1347 $$.named = 0;
1348 $$.u.id = $1;
1350 | STRING
1352 char *copy, *s;
1354 /* It seems that resource ID's are forced to upper case. */
1355 copy = xstrdup ($1);
1356 for (s = copy; *s != '\0'; s++)
1357 *s = TOUPPER (*s);
1358 res_string_to_id (&$$, copy);
1359 free (copy);
1363 /* A resource reference. */
1365 resname:
1366 QUOTEDSTRING
1368 $$ = $1;
1370 | QUOTEDSTRING ','
1372 $$ = $1;
1374 | STRING ','
1376 $$ = $1;
1381 resref:
1382 posnumexpr ','
1384 $$.named = 0;
1385 $$.u.id = $1;
1387 | resname
1389 char *copy, *s;
1391 /* It seems that resource ID's are forced to upper case. */
1392 copy = xstrdup ($1);
1393 for (s = copy; *s != '\0'; s++)
1394 *s = TOUPPER (*s);
1395 res_string_to_id (&$$, copy);
1396 free (copy);
1400 /* Generic suboptions. These may appear before the BEGIN in any
1401 multiline statement. */
1403 suboptions:
1404 /* empty */
1406 memset (&$$, 0, sizeof (struct res_res_info));
1407 $$.language = language;
1408 /* FIXME: Is this the right default? */
1409 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
1411 | suboptions memflag
1413 $$ = $1;
1414 $$.memflags |= $2.on;
1415 $$.memflags &=~ $2.off;
1417 | suboptions CHARACTERISTICS numexpr
1419 $$ = $1;
1420 $$.characteristics = $3;
1422 | suboptions LANGUAGE numexpr cnumexpr
1424 $$ = $1;
1425 $$.language = $3 | ($4 << SUBLANG_SHIFT);
1427 | suboptions VERSIONK numexpr
1429 $$ = $1;
1430 $$.version = $3;
1434 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1436 memflags_move_discard:
1437 /* empty */
1439 memset (&$$, 0, sizeof (struct res_res_info));
1440 $$.language = language;
1441 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
1443 | memflags_move_discard memflag
1445 $$ = $1;
1446 $$.memflags |= $2.on;
1447 $$.memflags &=~ $2.off;
1451 /* Memory flags which default to MOVEABLE. */
1453 memflags_move:
1454 /* empty */
1456 memset (&$$, 0, sizeof (struct res_res_info));
1457 $$.language = language;
1458 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
1460 | memflags_move memflag
1462 $$ = $1;
1463 $$.memflags |= $2.on;
1464 $$.memflags &=~ $2.off;
1468 /* Memory flags. This returns a struct with two integers, because we
1469 sometimes want to set bits and we sometimes want to clear them. */
1471 memflag:
1472 MOVEABLE
1474 $$.on = MEMFLAG_MOVEABLE;
1475 $$.off = 0;
1477 | FIXED
1479 $$.on = 0;
1480 $$.off = MEMFLAG_MOVEABLE;
1482 | PURE
1484 $$.on = MEMFLAG_PURE;
1485 $$.off = 0;
1487 | IMPURE
1489 $$.on = 0;
1490 $$.off = MEMFLAG_PURE;
1492 | PRELOAD
1494 $$.on = MEMFLAG_PRELOAD;
1495 $$.off = 0;
1497 | LOADONCALL
1499 $$.on = 0;
1500 $$.off = MEMFLAG_PRELOAD;
1502 | DISCARDABLE
1504 $$.on = MEMFLAG_DISCARDABLE;
1505 $$.off = 0;
1509 /* A file name. */
1511 file_name:
1512 QUOTEDSTRING
1514 $$ = $1;
1516 | STRING
1518 $$ = $1;
1522 /* A style expression. This changes the static variable STYLE. We do
1523 it this way because rc appears to permit a style to be set to
1524 something like
1525 WS_GROUP | NOT WS_TABSTOP
1526 to mean that a default of WS_TABSTOP should be removed. Anything
1527 which wants to accept a style must first set STYLE to the default
1528 value. The styleexpr nonterminal will change STYLE as specified by
1529 the user. Note that we do not accept arbitrary expressions here,
1530 just numbers separated by '|'. */
1532 styleexpr:
1533 parennumber
1535 style |= $1;
1537 | NOT parennumber
1539 style &=~ $2;
1541 | styleexpr '|' parennumber
1543 style |= $3;
1545 | styleexpr '|' NOT parennumber
1547 style &=~ $4;
1551 parennumber:
1552 NUMBER
1554 $$ = $1.val;
1556 | '(' numexpr ')'
1558 $$ = $2;
1562 /* An optional expression with a leading comma. */
1564 optcnumexpr:
1565 /* empty */
1567 $$ = 0;
1569 | cnumexpr
1571 $$ = $1;
1575 /* An expression with a leading comma. */
1577 cnumexpr:
1578 ',' numexpr
1580 $$ = $2;
1584 /* A possibly negated numeric expression. */
1586 numexpr:
1587 sizednumexpr
1589 $$ = $1.val;
1593 /* A possibly negated expression with a size. */
1595 sizednumexpr:
1596 NUMBER
1598 $$ = $1;
1600 | '(' sizednumexpr ')'
1602 $$ = $2;
1604 | '~' sizednumexpr %prec '~'
1606 $$.val = ~ $2.val;
1607 $$.dword = $2.dword;
1609 | '-' sizednumexpr %prec NEG
1611 $$.val = - $2.val;
1612 $$.dword = $2.dword;
1614 | sizednumexpr '*' sizednumexpr
1616 $$.val = $1.val * $3.val;
1617 $$.dword = $1.dword || $3.dword;
1619 | sizednumexpr '/' sizednumexpr
1621 $$.val = $1.val / $3.val;
1622 $$.dword = $1.dword || $3.dword;
1624 | sizednumexpr '%' sizednumexpr
1626 $$.val = $1.val % $3.val;
1627 $$.dword = $1.dword || $3.dword;
1629 | sizednumexpr '+' sizednumexpr
1631 $$.val = $1.val + $3.val;
1632 $$.dword = $1.dword || $3.dword;
1634 | sizednumexpr '-' sizednumexpr
1636 $$.val = $1.val - $3.val;
1637 $$.dword = $1.dword || $3.dword;
1639 | sizednumexpr '&' sizednumexpr
1641 $$.val = $1.val & $3.val;
1642 $$.dword = $1.dword || $3.dword;
1644 | sizednumexpr '^' sizednumexpr
1646 $$.val = $1.val ^ $3.val;
1647 $$.dword = $1.dword || $3.dword;
1649 | sizednumexpr '|' sizednumexpr
1651 $$.val = $1.val | $3.val;
1652 $$.dword = $1.dword || $3.dword;
1656 /* An expression with a leading comma which does not use unary
1657 negation. */
1659 cposnumexpr:
1660 ',' posnumexpr
1662 $$ = $2;
1666 /* An expression which does not use unary negation. */
1668 posnumexpr:
1669 sizedposnumexpr
1671 $$ = $1.val;
1675 /* An expression which does not use unary negation. We separate unary
1676 negation to avoid parsing conflicts when two numeric expressions
1677 appear consecutively. */
1679 sizedposnumexpr:
1680 NUMBER
1682 $$ = $1;
1684 | '(' sizednumexpr ')'
1686 $$ = $2;
1688 | '~' sizednumexpr %prec '~'
1690 $$.val = ~ $2.val;
1691 $$.dword = $2.dword;
1693 | sizedposnumexpr '*' sizednumexpr
1695 $$.val = $1.val * $3.val;
1696 $$.dword = $1.dword || $3.dword;
1698 | sizedposnumexpr '/' sizednumexpr
1700 $$.val = $1.val / $3.val;
1701 $$.dword = $1.dword || $3.dword;
1703 | sizedposnumexpr '%' sizednumexpr
1705 $$.val = $1.val % $3.val;
1706 $$.dword = $1.dword || $3.dword;
1708 | sizedposnumexpr '+' sizednumexpr
1710 $$.val = $1.val + $3.val;
1711 $$.dword = $1.dword || $3.dword;
1713 | sizedposnumexpr '-' sizednumexpr
1715 $$.val = $1.val - $3.val;
1716 $$.dword = $1.dword || $3.dword;
1718 | sizedposnumexpr '&' sizednumexpr
1720 $$.val = $1.val & $3.val;
1721 $$.dword = $1.dword || $3.dword;
1723 | sizedposnumexpr '^' sizednumexpr
1725 $$.val = $1.val ^ $3.val;
1726 $$.dword = $1.dword || $3.dword;
1728 | sizedposnumexpr '|' sizednumexpr
1730 $$.val = $1.val | $3.val;
1731 $$.dword = $1.dword || $3.dword;
1737 /* Set the language from the command line. */
1739 void
1740 rcparse_set_language (lang)
1741 int lang;
1743 language = lang;