* COP2 testing changes.
[binutils-gdb.git] / binutils / rcparse.y
blob0ab87d2cf80103000836753aa70856833522c14a
1 %{ /* rcparse.y -- parser for Windows rc files
2 Copyright 1997 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"
30 #include <ctype.h>
32 /* The current language. */
34 static unsigned short language;
36 /* The resource information during a sub statement. */
38 static struct res_res_info sub_res_info;
40 /* Dialog information. This is built by the nonterminals styles and
41 controls. */
43 static struct dialog dialog;
45 /* This is used when building a style. It is modified by the
46 nonterminal styleexpr. */
48 static unsigned long style;
50 /* These are used when building a control. They are set before using
51 control_params. */
53 static unsigned long base_style;
54 static unsigned long default_style;
55 static unsigned long class;
59 %union
61 struct accelerator acc;
62 struct accelerator *pacc;
63 struct dialog_control *dialog_control;
64 struct menuitem *menuitem;
65 struct
67 struct rcdata_item *first;
68 struct rcdata_item *last;
69 } rcdata;
70 struct rcdata_item *rcdata_item;
71 struct stringtable_data *stringtable;
72 struct fixed_versioninfo *fixver;
73 struct ver_info *verinfo;
74 struct ver_stringinfo *verstring;
75 struct ver_varinfo *vervar;
76 struct res_id id;
77 struct res_res_info res_info;
78 struct
80 unsigned short on;
81 unsigned short off;
82 } memflags;
83 struct
85 unsigned long val;
86 /* Nonzero if this number was explicitly specified as long. */
87 int dword;
88 } i;
89 unsigned long il;
90 unsigned short is;
91 const char *s;
92 struct
94 unsigned long length;
95 const char *s;
96 } ss;
99 %token BEG END
100 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
101 %token BITMAP
102 %token CURSOR
103 %token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
104 %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
105 %token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
106 %token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
107 %token BEDIT HEDIT IEDIT
108 %token FONT
109 %token ICON
110 %token LANGUAGE CHARACTERISTICS VERSION
111 %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
112 %token MENUBARBREAK MENUBREAK
113 %token MESSAGETABLE
114 %token RCDATA
115 %token STRINGTABLE
116 %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
117 %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
118 %token VALUE
119 %token <s> BLOCK
120 %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
121 %token NOT
122 %token <s> QUOTEDSTRING STRING
123 %token <i> NUMBER
124 %token <ss> SIZEDSTRING
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
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> optstringc file_name
143 %type <i> sizednumexpr sizedposnumexpr
145 %left '|'
146 %left '^'
147 %left '&'
148 %left '+' '-'
149 %left '*' '/' '%'
150 %right '~' NEG
154 input:
155 /* empty */
156 | input newcmd accelerator
157 | input newcmd bitmap
158 | input newcmd cursor
159 | input newcmd dialog
160 | input newcmd font
161 | input newcmd icon
162 | input newcmd language
163 | input newcmd menu
164 | input newcmd menuex
165 | input newcmd messagetable
166 | input newcmd rcdata
167 | input newcmd stringtable
168 | input newcmd user
169 | input newcmd versioninfo
172 newcmd:
173 /* empty */
175 rcparse_discard_strings ();
179 /* Accelerator resources. */
181 accelerator:
182 id ACCELERATORS suboptions BEG acc_entries END
184 define_accelerator ($1, &$3, $5);
188 acc_entries:
189 /* empty */
191 $$ = NULL;
193 | acc_entries acc_entry
195 struct accelerator *a;
197 a = (struct accelerator *) res_alloc (sizeof *a);
198 *a = $2;
199 if ($1 == NULL)
200 $$ = a;
201 else
203 struct accelerator **pp;
205 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
207 *pp = a;
208 $$ = $1;
213 acc_entry:
214 acc_event cposnumexpr
216 $$ = $1;
217 $$.id = $2;
219 | acc_event cposnumexpr ',' acc_options
221 $$ = $1;
222 $$.id = $2;
223 $$.flags |= $4;
227 acc_event:
228 QUOTEDSTRING
230 const char *s = $1;
232 $$.id = 0;
233 if (*s != '^')
234 $$.flags = 0;
235 else
237 $$.flags = ACC_CONTROL;
238 ++s;
240 $$.key = *s;
241 if (s[1] != '\0')
242 rcparse_warning ("accelerator should only be one character");
244 | posnumexpr
246 $$.flags = 0;
247 $$.id = 0;
248 $$.key = $1;
252 acc_options:
253 acc_option
255 $$ = $1;
257 | acc_options ',' acc_option
259 $$ = $1 | $3;
263 acc_option:
264 VIRTKEY
266 $$ = ACC_VIRTKEY;
268 | ASCII
270 /* This is just the absence of VIRTKEY. */
271 $$ = 0;
273 | NOINVERT
275 $$ = ACC_NOINVERT;
277 | SHIFT
279 $$ = ACC_SHIFT;
281 | CONTROL
283 $$ = ACC_CONTROL;
285 | ALT
287 $$ = ACC_ALT;
291 /* Bitmap resources. */
293 bitmap:
294 id BITMAP memflags_move file_name
296 define_bitmap ($1, &$3, $4);
300 /* Cursor resources. */
302 cursor:
303 id CURSOR memflags_move_discard file_name
305 define_cursor ($1, &$3, $4);
309 /* Dialog resources. */
311 dialog:
312 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
313 cnumexpr
315 memset (&dialog, 0, sizeof dialog);
316 dialog.x = $5;
317 dialog.y = $6;
318 dialog.width = $7;
319 dialog.height = $8;
320 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
321 dialog.exstyle = $4;
322 dialog.menu.named = 1;
323 dialog.class.named = 1;
324 dialog.font = NULL;
325 dialog.ex = NULL;
326 dialog.controls = NULL;
327 sub_res_info = $3;
329 styles BEG controls END
331 define_dialog ($1, &sub_res_info, &dialog);
333 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
334 cnumexpr
336 memset (&dialog, 0, sizeof dialog);
337 dialog.x = $5;
338 dialog.y = $6;
339 dialog.width = $7;
340 dialog.height = $8;
341 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
342 dialog.exstyle = $4;
343 dialog.menu.named = 1;
344 dialog.class.named = 1;
345 dialog.font = NULL;
346 dialog.ex = ((struct dialog_ex *)
347 res_alloc (sizeof (struct dialog_ex)));
348 memset (dialog.ex, 0, sizeof (struct dialog_ex));
349 dialog.controls = NULL;
350 sub_res_info = $3;
352 styles BEG controls END
354 define_dialog ($1, &sub_res_info, &dialog);
356 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
357 cnumexpr cnumexpr
359 memset (&dialog, 0, sizeof dialog);
360 dialog.x = $5;
361 dialog.y = $6;
362 dialog.width = $7;
363 dialog.height = $8;
364 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
365 dialog.exstyle = $4;
366 dialog.menu.named = 1;
367 dialog.class.named = 1;
368 dialog.font = NULL;
369 dialog.ex = ((struct dialog_ex *)
370 res_alloc (sizeof (struct dialog_ex)));
371 memset (dialog.ex, 0, sizeof (struct dialog_ex));
372 dialog.ex->help = $9;
373 dialog.controls = NULL;
374 sub_res_info = $3;
376 styles BEG controls END
378 define_dialog ($1, &sub_res_info, &dialog);
382 exstyle:
383 /* empty */
385 $$ = 0;
387 | EXSTYLE '=' numexpr
389 $$ = $3;
393 styles:
394 /* empty */
395 | styles CAPTION QUOTEDSTRING
397 unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
399 | styles CLASS id
401 dialog.class = $3;
403 | styles STYLE
404 { style = dialog.style; }
405 styleexpr
407 dialog.style = style;
409 | styles EXSTYLE numexpr
411 dialog.exstyle = $3;
413 | styles FONT numexpr ',' QUOTEDSTRING
415 dialog.style |= DS_SETFONT;
416 dialog.pointsize = $3;
417 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
419 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
421 dialog.style |= DS_SETFONT;
422 dialog.pointsize = $3;
423 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
424 if (dialog.ex == NULL)
425 rcparse_warning ("extended FONT requires DIALOGEX");
426 else
428 dialog.ex->weight = $6;
429 dialog.ex->italic = $7;
432 | styles MENU id
434 dialog.menu = $3;
436 | styles CHARACTERISTICS numexpr
438 sub_res_info.characteristics = $3;
440 | styles LANGUAGE numexpr cnumexpr
442 sub_res_info.language = $3 | ($4 << 8);
444 | styles VERSION numexpr
446 sub_res_info.version = $3;
450 controls:
451 /* empty */
452 | controls control
454 struct dialog_control **pp;
456 for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
458 *pp = $2;
462 control:
463 AUTO3STATE
465 default_style = BS_AUTO3STATE | WS_TABSTOP;
466 base_style = BS_AUTO3STATE;
467 class = CTL_BUTTON;
469 control_params
471 $$ = $3;
473 | AUTOCHECKBOX
475 default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
476 base_style = BS_AUTOCHECKBOX;
477 class = CTL_BUTTON;
479 control_params
481 $$ = $3;
483 | AUTORADIOBUTTON
485 default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
486 base_style = BS_AUTORADIOBUTTON;
487 class = CTL_BUTTON;
489 control_params
491 $$ = $3;
493 | BEDIT
495 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
496 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
497 class = CTL_EDIT;
499 control_params
501 $$ = $3;
502 if (dialog.ex == NULL)
503 rcparse_warning ("IEDIT requires DIALOGEX");
504 res_string_to_id (&$$->class, "BEDIT");
506 | CHECKBOX
508 default_style = BS_CHECKBOX | WS_TABSTOP;
509 base_style = BS_CHECKBOX | WS_TABSTOP;
510 class = CTL_BUTTON;
512 control_params
514 $$ = $3;
516 | COMBOBOX
518 default_style = CBS_SIMPLE | WS_TABSTOP;
519 base_style = 0;
520 class = CTL_COMBOBOX;
522 control_params
524 $$ = $3;
526 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
527 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
529 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
530 if ($11 != NULL)
532 if (dialog.ex == NULL)
533 rcparse_warning ("control data requires DIALOGEX");
534 $$->data = $11;
537 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
538 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
540 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
541 if (dialog.ex == NULL)
542 rcparse_warning ("help ID requires DIALOGEX");
543 $$->help = $11;
544 $$->data = $12;
546 | CTEXT
548 default_style = SS_CENTER | WS_GROUP;
549 base_style = SS_CENTER;
550 class = CTL_STATIC;
552 control_params
554 $$ = $3;
556 | DEFPUSHBUTTON
558 default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
559 base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
560 class = CTL_BUTTON;
562 control_params
564 $$ = $3;
566 | EDITTEXT
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;
576 | GROUPBOX
578 default_style = BS_GROUPBOX;
579 base_style = BS_GROUPBOX;
580 class = CTL_BUTTON;
582 control_params
584 $$ = $3;
586 | HEDIT
588 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
589 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
590 class = CTL_EDIT;
592 control_params
594 $$ = $3;
595 if (dialog.ex == NULL)
596 rcparse_warning ("IEDIT requires DIALOGEX");
597 res_string_to_id (&$$->class, "HEDIT");
599 | ICON optstringc numexpr cnumexpr cnumexpr opt_control_data
601 $$ = define_control ($2, $3, $4, $5, 0, 0, CTL_STATIC,
602 SS_ICON | WS_CHILD | WS_VISIBLE, 0);
603 if ($6 != NULL)
605 if (dialog.ex == NULL)
606 rcparse_warning ("control data requires DIALOGEX");
607 $$->data = $6;
610 | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
611 icon_styleexpr optcnumexpr opt_control_data
613 $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
614 style, $9);
615 if ($10 != NULL)
617 if (dialog.ex == NULL)
618 rcparse_warning ("control data requires DIALOGEX");
619 $$->data = $10;
622 | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
623 icon_styleexpr cnumexpr cnumexpr opt_control_data
625 $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
626 style, $9);
627 if (dialog.ex == NULL)
628 rcparse_warning ("help ID requires DIALOGEX");
629 $$->help = $10;
630 $$->data = $11;
632 | IEDIT
634 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
635 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
636 class = CTL_EDIT;
638 control_params
640 $$ = $3;
641 if (dialog.ex == NULL)
642 rcparse_warning ("IEDIT requires DIALOGEX");
643 res_string_to_id (&$$->class, "IEDIT");
645 | LISTBOX
647 default_style = LBS_NOTIFY | WS_BORDER;
648 base_style = LBS_NOTIFY | WS_BORDER;
649 class = CTL_LISTBOX;
651 control_params
653 $$ = $3;
655 | LTEXT
657 default_style = SS_LEFT | WS_GROUP;
658 base_style = SS_LEFT;
659 class = CTL_STATIC;
661 control_params
663 $$ = $3;
665 | PUSHBOX
667 default_style = BS_PUSHBOX | WS_TABSTOP;
668 base_style = BS_PUSHBOX;
669 class = CTL_BUTTON;
671 control_params
673 $$ = $3;
675 | PUSHBUTTON
677 default_style = BS_PUSHBUTTON | WS_TABSTOP;
678 base_style = BS_PUSHBUTTON | WS_TABSTOP;
679 class = CTL_BUTTON;
681 control_params
683 $$ = $3;
685 | RADIOBUTTON
687 default_style = BS_RADIOBUTTON | WS_TABSTOP;
688 base_style = BS_RADIOBUTTON;
689 class = CTL_BUTTON;
691 control_params
693 $$ = $3;
695 | RTEXT
697 default_style = SS_RIGHT | WS_GROUP;
698 base_style = SS_RIGHT;
699 class = CTL_STATIC;
701 control_params
703 $$ = $3;
705 | SCROLLBAR
707 default_style = SBS_HORZ;
708 base_style = 0;
709 class = CTL_SCROLLBAR;
711 control_params
713 $$ = $3;
715 | STATE3
717 default_style = BS_3STATE | WS_TABSTOP;
718 base_style = BS_3STATE;
719 class = CTL_BUTTON;
721 control_params
723 $$ = $3;
725 | USERBUTTON QUOTEDSTRING ',' numexpr ',' numexpr ',' numexpr ','
726 numexpr ',' numexpr ','
727 { style = WS_CHILD | WS_VISIBLE; }
728 styleexpr optcnumexpr
730 $$ = define_control ($2, $4, $6, $8, $10, $12, CTL_BUTTON,
731 style, $16);
735 /* Parameters for a control. The static variables DEFAULT_STYLE,
736 BASE_STYLE, and CLASS must be initialized before this nonterminal
737 is used. DEFAULT_STYLE is the style to use if no style expression
738 is specified. BASE_STYLE is the base style to use if a style
739 expression is specified; the style expression modifies the base
740 style. CLASS is the class of the control. */
742 control_params:
743 optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
744 opt_control_data
746 $$ = define_control ($1, $2, $3, $4, $5, $6, class,
747 default_style | WS_CHILD | WS_VISIBLE, 0);
748 if ($7 != NULL)
750 if (dialog.ex == NULL)
751 rcparse_warning ("control data requires DIALOGEX");
752 $$->data = $7;
755 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
756 control_params_styleexpr optcnumexpr opt_control_data
758 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
759 if ($9 != NULL)
761 if (dialog.ex == NULL)
762 rcparse_warning ("control data requires DIALOGEX");
763 $$->data = $9;
766 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
767 control_params_styleexpr cnumexpr cnumexpr opt_control_data
769 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
770 if (dialog.ex == NULL)
771 rcparse_warning ("help ID requires DIALOGEX");
772 $$->help = $9;
773 $$->data = $10;
777 optstringc:
778 /* empty */
780 $$ = NULL;
782 | QUOTEDSTRING ','
784 $$ = $1;
788 opt_control_data:
789 /* empty */
791 $$ = NULL;
793 | BEG optrcdata_data END
795 $$ = $2.first;
799 /* These only exist to parse a reduction out of a common case. */
801 control_styleexpr:
803 { style = WS_CHILD | WS_VISIBLE; }
804 styleexpr
807 icon_styleexpr:
809 { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
810 styleexpr
813 control_params_styleexpr:
815 { style = base_style | WS_CHILD | WS_VISIBLE; }
816 styleexpr
819 /* Font resources. */
821 font:
822 id FONT memflags_move_discard file_name
824 define_font ($1, &$3, $4);
828 /* Icon resources. */
830 icon:
831 id ICON memflags_move_discard file_name
833 define_icon ($1, &$3, $4);
837 /* Language command. This changes the static variable language, which
838 affects all subsequent resources. */
840 language:
841 LANGUAGE numexpr cnumexpr
843 language = $2 | ($3 << 8);
847 /* Menu resources. */
849 menu:
850 id MENU suboptions BEG menuitems END
852 define_menu ($1, &$3, $5);
856 menuitems:
857 /* empty */
859 $$ = NULL;
861 | menuitems menuitem
863 if ($1 == NULL)
864 $$ = $2;
865 else
867 struct menuitem **pp;
869 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
871 *pp = $2;
872 $$ = $1;
877 menuitem:
878 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
880 $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
882 | MENUITEM SEPARATOR
884 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
886 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
888 $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
892 menuitem_flags:
893 /* empty */
895 $$ = 0;
897 | menuitem_flags ',' menuitem_flag
899 $$ = $1 | $3;
901 | menuitem_flags menuitem_flag
903 $$ = $1 | $2;
907 menuitem_flag:
908 CHECKED
910 $$ = MENUITEM_CHECKED;
912 | GRAYED
914 $$ = MENUITEM_GRAYED;
916 | HELP
918 $$ = MENUITEM_HELP;
920 | INACTIVE
922 $$ = MENUITEM_INACTIVE;
924 | MENUBARBREAK
926 $$ = MENUITEM_MENUBARBREAK;
928 | MENUBREAK
930 $$ = MENUITEM_MENUBREAK;
934 /* Menuex resources. */
936 menuex:
937 id MENUEX suboptions BEG menuexitems END
939 define_menu ($1, &$3, $5);
943 menuexitems:
944 /* empty */
946 $$ = NULL;
948 | menuexitems menuexitem
950 if ($1 == NULL)
951 $$ = $2;
952 else
954 struct menuitem **pp;
956 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
958 *pp = $2;
959 $$ = $1;
964 menuexitem:
965 MENUITEM QUOTEDSTRING
967 $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
969 | MENUITEM QUOTEDSTRING cnumexpr
971 $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
973 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
975 $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
977 | POPUP QUOTEDSTRING BEG menuexitems END
979 $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
981 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
983 $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
985 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
987 $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
989 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
990 BEG menuexitems END
992 $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
996 /* Messagetable resources. */
998 messagetable:
999 id MESSAGETABLE memflags_move file_name
1001 define_messagetable ($1, &$3, $4);
1005 /* Rcdata resources. */
1007 rcdata:
1008 id RCDATA suboptions BEG optrcdata_data END
1010 define_rcdata ($1, &$3, $5.first);
1014 /* We use a different lexing algorithm, because rcdata strings may
1015 contain embedded null bytes, and we need to know the length to use. */
1017 optrcdata_data:
1019 rcparse_rcdata ();
1021 optrcdata_data_int
1023 rcparse_normal ();
1024 $$ = $2;
1028 optrcdata_data_int:
1029 /* empty */
1031 $$.first = NULL;
1032 $$.last = NULL;
1034 | rcdata_data
1036 $$ = $1;
1040 rcdata_data:
1041 SIZEDSTRING
1043 struct rcdata_item *ri;
1045 ri = define_rcdata_string ($1.s, $1.length);
1046 $$.first = ri;
1047 $$.last = ri;
1049 | sizednumexpr
1051 struct rcdata_item *ri;
1053 ri = define_rcdata_number ($1.val, $1.dword);
1054 $$.first = ri;
1055 $$.last = ri;
1057 | rcdata_data ',' SIZEDSTRING
1059 struct rcdata_item *ri;
1061 ri = define_rcdata_string ($3.s, $3.length);
1062 $$.first = $1.first;
1063 $1.last->next = ri;
1064 $$.last = ri;
1066 | rcdata_data ',' sizednumexpr
1068 struct rcdata_item *ri;
1070 ri = define_rcdata_number ($3.val, $3.dword);
1071 $$.first = $1.first;
1072 $1.last->next = ri;
1073 $$.last = ri;
1077 /* Stringtable resources. */
1079 stringtable:
1080 STRINGTABLE suboptions BEG
1081 { sub_res_info = $2; }
1082 string_data END
1085 string_data:
1086 /* empty */
1087 | string_data numexpr QUOTEDSTRING
1089 define_stringtable (&sub_res_info, $2, $3);
1091 | string_data numexpr ',' QUOTEDSTRING
1093 define_stringtable (&sub_res_info, $2, $4);
1097 /* User defined resources. We accept general suboptions in the
1098 file_name case to keep the parser happy. */
1100 user:
1101 id id suboptions BEG optrcdata_data END
1103 define_user_data ($1, $2, &$3, $5.first);
1105 | id id suboptions file_name
1107 define_user_file ($1, $2, &$3, $4);
1111 /* Versioninfo resources. */
1113 versioninfo:
1114 id VERSIONINFO fixedverinfo BEG verblocks END
1116 define_versioninfo ($1, language, $3, $5);
1120 fixedverinfo:
1121 /* empty */
1123 $$ = ((struct fixed_versioninfo *)
1124 res_alloc (sizeof (struct fixed_versioninfo)));
1125 memset ($$, 0, sizeof (struct fixed_versioninfo));
1127 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1129 $1->file_version_ms = ($3 << 16) | $4;
1130 $1->file_version_ls = ($5 << 16) | $6;
1131 $$ = $1;
1133 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1135 $1->product_version_ms = ($3 << 16) | $4;
1136 $1->product_version_ls = ($5 << 16) | $6;
1137 $$ = $1;
1139 | fixedverinfo FILEFLAGSMASK numexpr
1141 $1->file_flags_mask = $3;
1142 $$ = $1;
1144 | fixedverinfo FILEFLAGS numexpr
1146 $1->file_flags = $3;
1147 $$ = $1;
1149 | fixedverinfo FILEOS numexpr
1151 $1->file_os = $3;
1152 $$ = $1;
1154 | fixedverinfo FILETYPE numexpr
1156 $1->file_type = $3;
1157 $$ = $1;
1159 | fixedverinfo FILESUBTYPE numexpr
1161 $1->file_subtype = $3;
1162 $$ = $1;
1166 /* To handle verblocks successfully, the lexer handles BLOCK
1167 specially. A BLOCK "StringFileInfo" is returned as
1168 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1169 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1170 with the string as the value. */
1172 verblocks:
1173 /* empty */
1175 $$ = NULL;
1177 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1179 $$ = append_ver_stringfileinfo ($1, $4, $6);
1181 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1183 $$ = append_ver_varfileinfo ($1, $5, $6);
1187 vervals:
1188 /* empty */
1190 $$ = NULL;
1192 | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
1194 $$ = append_verval ($1, $3, $5);
1198 vertrans:
1199 /* empty */
1201 $$ = NULL;
1203 | vertrans cnumexpr cnumexpr
1205 $$ = append_vertrans ($1, $2, $3);
1209 /* A resource ID. */
1212 posnumexpr
1214 $$.named = 0;
1215 $$.u.id = $1;
1217 | STRING
1219 char *copy, *s;
1221 /* It seems that resource ID's are forced to upper case. */
1222 copy = xstrdup ($1);
1223 for (s = copy; *s != '\0'; s++)
1224 if (islower (*s))
1225 *s = toupper (*s);
1226 res_string_to_id (&$$, copy);
1227 free (copy);
1231 /* Generic suboptions. These may appear before the BEGIN in any
1232 multiline statement. */
1234 suboptions:
1235 /* empty */
1237 memset (&$$, 0, sizeof (struct res_res_info));
1238 $$.language = language;
1239 /* FIXME: Is this the right default? */
1240 $$.memflags = MEMFLAG_MOVEABLE;
1242 | suboptions memflag
1244 $$ = $1;
1245 $$.memflags |= $2.on;
1246 $$.memflags &=~ $2.off;
1248 | suboptions CHARACTERISTICS numexpr
1250 $$ = $1;
1251 $$.characteristics = $3;
1253 | suboptions LANGUAGE numexpr cnumexpr
1255 $$ = $1;
1256 $$.language = $3 | ($4 << 8);
1258 | suboptions VERSION numexpr
1260 $$ = $1;
1261 $$.version = $3;
1265 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1267 memflags_move_discard:
1268 /* empty */
1270 memset (&$$, 0, sizeof (struct res_res_info));
1271 $$.language = language;
1272 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
1274 | memflags_move_discard memflag
1276 $$ = $1;
1277 $$.memflags |= $2.on;
1278 $$.memflags &=~ $2.off;
1282 /* Memory flags which default to MOVEABLE. */
1284 memflags_move:
1285 /* empty */
1287 memset (&$$, 0, sizeof (struct res_res_info));
1288 $$.language = language;
1289 $$.memflags = MEMFLAG_MOVEABLE;
1291 | memflags_move_discard memflag
1293 $$ = $1;
1294 $$.memflags |= $2.on;
1295 $$.memflags &=~ $2.off;
1299 /* Memory flags. This returns a struct with two integers, because we
1300 sometimes want to set bits and we sometimes want to clear them. */
1302 memflag:
1303 MOVEABLE
1305 $$.on = MEMFLAG_MOVEABLE;
1306 $$.off = 0;
1308 | FIXED
1310 $$.on = 0;
1311 $$.off = MEMFLAG_MOVEABLE;
1313 | PURE
1315 $$.on = MEMFLAG_PURE;
1316 $$.off = 0;
1318 | IMPURE
1320 $$.on = 0;
1321 $$.off = MEMFLAG_PURE;
1323 | PRELOAD
1325 $$.on = MEMFLAG_PRELOAD;
1326 $$.off = 0;
1328 | LOADONCALL
1330 $$.on = 0;
1331 $$.off = MEMFLAG_PRELOAD;
1333 | DISCARDABLE
1335 $$.on = MEMFLAG_DISCARDABLE;
1336 $$.off = 0;
1340 /* A file name. */
1342 file_name:
1343 QUOTEDSTRING
1345 $$ = $1;
1347 | STRING
1349 $$ = $1;
1353 /* A style expression. This changes the static variable STYLE. We do
1354 it this way because rc appears to permit a style to be set to
1355 something like
1356 WS_GROUP | NOT WS_TABSTOP
1357 to mean that a default of WS_TABSTOP should be removed. Anything
1358 which wants to accept a style must first set STYLE to the default
1359 value. The styleexpr nonterminal will change STYLE as specified by
1360 the user. Note that we do not accept arbitrary expressions here,
1361 just numbers separated by '|'. */
1363 styleexpr:
1364 parennumber
1366 style |= $1;
1368 | NOT parennumber
1370 style &=~ $2;
1372 | styleexpr '|' parennumber
1374 style |= $3;
1376 | styleexpr '|' NOT parennumber
1378 style &=~ $4;
1382 parennumber:
1383 NUMBER
1385 $$ = $1.val;
1387 | '(' numexpr ')'
1389 $$ = $2;
1393 /* An optional expression with a leading comma. */
1395 optcnumexpr:
1396 /* empty */
1398 $$ = 0;
1400 | cnumexpr
1402 $$ = $1;
1406 /* An expression with a leading comma. */
1408 cnumexpr:
1409 ',' numexpr
1411 $$ = $2;
1415 /* A possibly negated numeric expression. */
1417 numexpr:
1418 sizednumexpr
1420 $$ = $1.val;
1424 /* A possibly negated expression with a size. */
1426 sizednumexpr:
1427 NUMBER
1429 $$ = $1;
1431 | '(' sizednumexpr ')'
1433 $$ = $2;
1435 | '~' sizednumexpr %prec '~'
1437 $$.val = ~ $2.val;
1438 $$.dword = $2.dword;
1440 | '-' sizednumexpr %prec NEG
1442 $$.val = - $2.val;
1443 $$.dword = $2.dword;
1445 | sizednumexpr '*' sizednumexpr
1447 $$.val = $1.val * $3.val;
1448 $$.dword = $1.dword || $3.dword;
1450 | sizednumexpr '/' sizednumexpr
1452 $$.val = $1.val / $3.val;
1453 $$.dword = $1.dword || $3.dword;
1455 | sizednumexpr '%' sizednumexpr
1457 $$.val = $1.val % $3.val;
1458 $$.dword = $1.dword || $3.dword;
1460 | sizednumexpr '+' sizednumexpr
1462 $$.val = $1.val + $3.val;
1463 $$.dword = $1.dword || $3.dword;
1465 | sizednumexpr '-' sizednumexpr
1467 $$.val = $1.val - $3.val;
1468 $$.dword = $1.dword || $3.dword;
1470 | sizednumexpr '&' sizednumexpr
1472 $$.val = $1.val & $3.val;
1473 $$.dword = $1.dword || $3.dword;
1475 | sizednumexpr '^' sizednumexpr
1477 $$.val = $1.val ^ $3.val;
1478 $$.dword = $1.dword || $3.dword;
1480 | sizednumexpr '|' sizednumexpr
1482 $$.val = $1.val | $3.val;
1483 $$.dword = $1.dword || $3.dword;
1487 /* An expression with a leading comma which does not use unary
1488 negation. */
1490 cposnumexpr:
1491 ',' posnumexpr
1493 $$ = $2;
1497 /* An expression which does not use unary negation. */
1499 posnumexpr:
1500 sizedposnumexpr
1502 $$ = $1.val;
1506 /* An expression which does not use unary negation. We separate unary
1507 negation to avoid parsing conflicts when two numeric expressions
1508 appear consecutively. */
1510 sizedposnumexpr:
1511 NUMBER
1513 $$ = $1;
1515 | '(' sizednumexpr ')'
1517 $$ = $2;
1519 | '~' sizednumexpr %prec '~'
1521 $$.val = ~ $2.val;
1522 $$.dword = $2.dword;
1524 | sizedposnumexpr '*' sizednumexpr
1526 $$.val = $1.val * $3.val;
1527 $$.dword = $1.dword || $3.dword;
1529 | sizedposnumexpr '/' sizednumexpr
1531 $$.val = $1.val / $3.val;
1532 $$.dword = $1.dword || $3.dword;
1534 | sizedposnumexpr '%' sizednumexpr
1536 $$.val = $1.val % $3.val;
1537 $$.dword = $1.dword || $3.dword;
1539 | sizedposnumexpr '+' sizednumexpr
1541 $$.val = $1.val + $3.val;
1542 $$.dword = $1.dword || $3.dword;
1544 | sizedposnumexpr '-' sizednumexpr
1546 $$.val = $1.val - $3.val;
1547 $$.dword = $1.dword || $3.dword;
1549 | sizedposnumexpr '&' sizednumexpr
1551 $$.val = $1.val & $3.val;
1552 $$.dword = $1.dword || $3.dword;
1554 | sizedposnumexpr '^' sizednumexpr
1556 $$.val = $1.val ^ $3.val;
1557 $$.dword = $1.dword || $3.dword;
1559 | sizedposnumexpr '|' sizednumexpr
1561 $$.val = $1.val | $3.val;
1562 $$.dword = $1.dword || $3.dword;
1568 /* Set the language from the command line. */
1570 void
1571 rcparse_set_language (lang)
1572 int lang;
1574 language = lang;