1 %{ /* rcparse.y -- parser for Windows rc files
2 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support.
6 This file is part of GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 /* This is a parser for Windows rc files. It is based on the parser
28 #include "libiberty.h"
30 #include "safe-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
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
53 static unsigned long base_style;
54 static unsigned long default_style;
55 static unsigned long class;
56 static struct res_id res_text_field;
58 /* This is used for COMBOBOX, LISTBOX and EDITTEXT which
59 do not allow resource 'text' field in control definition. */
60 static const struct res_id res_null_text = { 1, {{0, L""}}};
66 struct accelerator acc;
67 struct accelerator *pacc;
68 struct dialog_control *dialog_control;
69 struct menuitem *menuitem;
72 struct rcdata_item *first;
73 struct rcdata_item *last;
75 struct rcdata_item *rcdata_item;
76 struct stringtable_data *stringtable;
77 struct fixed_versioninfo *fixver;
78 struct ver_info *verinfo;
79 struct ver_stringinfo *verstring;
80 struct ver_varinfo *vervar;
82 struct res_res_info res_info;
91 /* Nonzero if this number was explicitly specified as long. */
105 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
108 %token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
109 %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
110 %token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
111 %token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
112 %token BEDIT HEDIT IEDIT
115 %token LANGUAGE CHARACTERISTICS VERSIONK
116 %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
117 %token MENUBARBREAK MENUBREAK
121 %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
122 %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
125 %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
127 %token <s> QUOTEDSTRING STRING
129 %token <ss> SIZEDSTRING
132 %type <pacc> acc_entries
133 %type <acc> acc_entry acc_event
134 %type <dialog_control> control control_params
135 %type <menuitem> menuitems menuitem menuexitems menuexitem
136 %type <rcdata> optrcdata_data optrcdata_data_int rcdata_data
137 %type <rcdata_item> opt_control_data
138 %type <fixver> fixedverinfo
139 %type <verinfo> verblocks
140 %type <verstring> vervals
141 %type <vervar> vertrans
142 %type <res_info> suboptions memflags_move_discard memflags_move
143 %type <memflags> memflag
144 %type <id> id optresidc resref
145 %type <il> exstyle parennumber
146 %type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
147 %type <is> acc_options acc_option menuitem_flags menuitem_flag
148 %type <s> file_name resname
149 %type <i> sizednumexpr sizedposnumexpr
176 | input IGNORED_TOKEN
179 /* Accelerator resources. */
182 id ACCELERATORS suboptions BEG acc_entries END
184 define_accelerator ($1, &$3, $5);
185 if (yychar != YYEMPTY)
187 rcparse_discard_strings ();
196 | acc_entries acc_entry
198 struct accelerator *a;
200 a = (struct accelerator *) res_alloc (sizeof *a);
206 struct accelerator **pp;
208 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
217 acc_event cposnumexpr
222 | acc_event cposnumexpr ',' acc_options
227 if (($$.flags & ACC_VIRTKEY) == 0
228 && ($$.flags & (ACC_SHIFT | ACC_CONTROL)) != 0)
229 rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
246 $$.flags = ACC_CONTROL | ACC_VIRTKEY;
253 rcparse_warning (_("accelerator should only be one character"));
269 | acc_options ',' acc_option
273 /* I've had one report that the comma is optional. */
274 | acc_options acc_option
287 /* This is just the absence of VIRTKEY. */
308 /* Bitmap resources. */
311 id BITMAP memflags_move file_name
313 define_bitmap ($1, &$3, $4);
314 if (yychar != YYEMPTY)
316 rcparse_discard_strings ();
320 /* Cursor resources. */
323 id CURSOR memflags_move_discard file_name
325 define_cursor ($1, &$3, $4);
326 if (yychar != YYEMPTY)
328 rcparse_discard_strings ();
332 /* Dialog resources. */
335 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
338 memset (&dialog, 0, sizeof dialog);
343 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
345 dialog.menu.named = 1;
346 dialog.class.named = 1;
349 dialog.controls = NULL;
353 styles BEG controls END
355 define_dialog ($1, &sub_res_info, &dialog);
356 if (yychar != YYEMPTY)
358 rcparse_discard_strings ();
360 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
363 memset (&dialog, 0, sizeof dialog);
368 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
370 dialog.menu.named = 1;
371 dialog.class.named = 1;
373 dialog.ex = ((struct dialog_ex *)
374 res_alloc (sizeof (struct dialog_ex)));
375 memset (dialog.ex, 0, sizeof (struct dialog_ex));
376 dialog.controls = NULL;
380 styles BEG controls END
382 define_dialog ($1, &sub_res_info, &dialog);
383 if (yychar != YYEMPTY)
385 rcparse_discard_strings ();
387 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
390 memset (&dialog, 0, sizeof dialog);
395 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
397 dialog.menu.named = 1;
398 dialog.class.named = 1;
400 dialog.ex = ((struct dialog_ex *)
401 res_alloc (sizeof (struct dialog_ex)));
402 memset (dialog.ex, 0, sizeof (struct dialog_ex));
403 dialog.ex->help = $9;
404 dialog.controls = NULL;
408 styles BEG controls END
410 define_dialog ($1, &sub_res_info, &dialog);
411 if (yychar != YYEMPTY)
413 rcparse_discard_strings ();
422 | EXSTYLE '=' numexpr
430 | styles CAPTION QUOTEDSTRING
432 dialog.style |= WS_CAPTION;
434 unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
443 dialog.style = style;
445 | styles EXSTYLE numexpr
449 | styles CLASS QUOTEDSTRING
451 res_string_to_id (& dialog.class, $3);
453 | styles FONT numexpr ',' QUOTEDSTRING
455 dialog.style |= DS_SETFONT;
457 dialog.pointsize = $3;
458 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
459 if (dialog.ex != NULL)
461 dialog.ex->weight = 0;
462 dialog.ex->italic = 0;
463 dialog.ex->charset = 1;
466 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr
468 dialog.style |= DS_SETFONT;
470 dialog.pointsize = $3;
471 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
472 if (dialog.ex == NULL)
473 rcparse_warning (_("extended FONT requires DIALOGEX"));
476 dialog.ex->weight = $6;
477 dialog.ex->italic = 0;
478 dialog.ex->charset = 1;
481 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
483 dialog.style |= DS_SETFONT;
485 dialog.pointsize = $3;
486 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
487 if (dialog.ex == NULL)
488 rcparse_warning (_("extended FONT requires DIALOGEX"));
491 dialog.ex->weight = $6;
492 dialog.ex->italic = $7;
493 dialog.ex->charset = 1;
496 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr
498 dialog.style |= DS_SETFONT;
500 dialog.pointsize = $3;
501 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
502 if (dialog.ex == NULL)
503 rcparse_warning (_("extended FONT requires DIALOGEX"));
506 dialog.ex->weight = $6;
507 dialog.ex->italic = $7;
508 dialog.ex->charset = $8;
515 | styles CHARACTERISTICS numexpr
517 sub_res_info.characteristics = $3;
519 | styles LANGUAGE numexpr cnumexpr
521 sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT);
523 | styles VERSIONK numexpr
525 sub_res_info.version = $3;
533 struct dialog_control **pp;
535 for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
544 default_style = BS_AUTO3STATE | WS_TABSTOP;
545 base_style = BS_AUTO3STATE;
553 | AUTOCHECKBOX optresidc
555 default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
556 base_style = BS_AUTOCHECKBOX;
564 | AUTORADIOBUTTON optresidc
566 default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
567 base_style = BS_AUTORADIOBUTTON;
577 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
578 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
585 if (dialog.ex == NULL)
586 rcparse_warning (_("BEDIT requires DIALOGEX"));
587 res_string_to_id (&$$->class, "BEDIT");
591 default_style = BS_CHECKBOX | WS_TABSTOP;
592 base_style = BS_CHECKBOX | WS_TABSTOP;
602 /* This is as per MSDN documentation. With some (???)
603 versions of MS rc.exe their is no default style. */
604 default_style = CBS_SIMPLE | WS_TABSTOP;
606 class = CTL_COMBOBOX;
607 res_text_field = res_null_text;
613 | CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
614 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
616 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
619 if (dialog.ex == NULL)
620 rcparse_warning (_("control data requires DIALOGEX"));
624 | CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
625 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
627 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
628 if (dialog.ex == NULL)
629 rcparse_warning (_("help ID requires DIALOGEX"));
633 | CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
634 cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
636 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
639 if (dialog.ex == NULL)
640 rcparse_warning ("control data requires DIALOGEX");
644 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
646 | CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
647 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
649 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
650 if (dialog.ex == NULL)
651 rcparse_warning ("help ID requires DIALOGEX");
655 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
659 default_style = SS_CENTER | WS_GROUP;
660 base_style = SS_CENTER;
668 | DEFPUSHBUTTON optresidc
670 default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
671 base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
681 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
682 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
684 res_text_field = res_null_text;
692 default_style = BS_GROUPBOX;
693 base_style = BS_GROUPBOX;
703 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
704 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
711 if (dialog.ex == NULL)
712 rcparse_warning (_("IEDIT requires DIALOGEX"));
713 res_string_to_id (&$$->class, "HEDIT");
715 | ICON resref numexpr cnumexpr cnumexpr opt_control_data
717 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
720 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
723 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
726 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
727 icon_styleexpr optcnumexpr opt_control_data
729 $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
732 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
733 icon_styleexpr cnumexpr cnumexpr opt_control_data
735 $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
740 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
741 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
748 if (dialog.ex == NULL)
749 rcparse_warning (_("IEDIT requires DIALOGEX"));
750 res_string_to_id (&$$->class, "IEDIT");
754 default_style = LBS_NOTIFY | WS_BORDER;
755 base_style = LBS_NOTIFY | WS_BORDER;
757 res_text_field = res_null_text;
765 default_style = SS_LEFT | WS_GROUP;
766 base_style = SS_LEFT;
776 default_style = BS_PUSHBOX | WS_TABSTOP;
777 base_style = BS_PUSHBOX;
784 | PUSHBUTTON optresidc
786 default_style = BS_PUSHBUTTON | WS_TABSTOP;
787 base_style = BS_PUSHBUTTON | WS_TABSTOP;
795 | RADIOBUTTON optresidc
797 default_style = BS_RADIOBUTTON | WS_TABSTOP;
798 base_style = BS_RADIOBUTTON;
808 default_style = SS_RIGHT | WS_GROUP;
809 base_style = SS_RIGHT;
819 default_style = SBS_HORZ;
821 class = CTL_SCROLLBAR;
822 res_text_field = res_null_text;
830 default_style = BS_3STATE | WS_TABSTOP;
831 base_style = BS_3STATE;
839 | USERBUTTON resref numexpr ',' numexpr ',' numexpr ','
840 numexpr ',' numexpr ','
841 { style = WS_CHILD | WS_VISIBLE; }
842 styleexpr optcnumexpr
844 $$ = define_control ($2, $3, $5, $7, $9, $11, CTL_BUTTON,
849 /* Parameters for a control. The static variables DEFAULT_STYLE,
850 BASE_STYLE, and CLASS must be initialized before this nonterminal
851 is used. DEFAULT_STYLE is the style to use if no style expression
852 is specified. BASE_STYLE is the base style to use if a style
853 expression is specified; the style expression modifies the base
854 style. CLASS is the class of the control. */
857 numexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
859 $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class,
860 default_style | WS_CHILD | WS_VISIBLE, 0);
863 if (dialog.ex == NULL)
864 rcparse_warning (_("control data requires DIALOGEX"));
868 | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
869 control_params_styleexpr optcnumexpr opt_control_data
871 $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
874 if (dialog.ex == NULL)
875 rcparse_warning (_("control data requires DIALOGEX"));
879 | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
880 control_params_styleexpr cnumexpr cnumexpr opt_control_data
882 $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
883 if (dialog.ex == NULL)
884 rcparse_warning (_("help ID requires DIALOGEX"));
893 res_string_to_id (&$$, "");
902 res_string_to_id (&$$, $1);
906 res_string_to_id (&$$, $1);
915 | BEG optrcdata_data END
921 /* These only exist to parse a reduction out of a common case. */
925 { style = WS_CHILD | WS_VISIBLE; }
931 { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
935 control_params_styleexpr:
937 { style = base_style | WS_CHILD | WS_VISIBLE; }
941 /* Font resources. */
944 id FONT memflags_move_discard file_name
946 define_font ($1, &$3, $4);
947 if (yychar != YYEMPTY)
949 rcparse_discard_strings ();
953 /* Icon resources. */
956 id ICON memflags_move_discard file_name
958 define_icon ($1, &$3, $4);
959 if (yychar != YYEMPTY)
961 rcparse_discard_strings ();
965 /* Language command. This changes the static variable language, which
966 affects all subsequent resources. */
969 LANGUAGE numexpr cnumexpr
971 language = $2 | ($3 << SUBLANG_SHIFT);
975 /* Menu resources. */
978 id MENU suboptions BEG menuitems END
980 define_menu ($1, &$3, $5);
981 if (yychar != YYEMPTY)
983 rcparse_discard_strings ();
998 struct menuitem **pp;
1000 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
1009 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
1011 $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
1013 | MENUITEM SEPARATOR
1015 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
1017 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
1019 $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
1028 | menuitem_flags ',' menuitem_flag
1032 | menuitem_flags menuitem_flag
1041 $$ = MENUITEM_CHECKED;
1045 $$ = MENUITEM_GRAYED;
1053 $$ = MENUITEM_INACTIVE;
1057 $$ = MENUITEM_MENUBARBREAK;
1061 $$ = MENUITEM_MENUBREAK;
1065 /* Menuex resources. */
1068 id MENUEX suboptions BEG menuexitems END
1070 define_menu ($1, &$3, $5);
1071 if (yychar != YYEMPTY)
1073 rcparse_discard_strings ();
1082 | menuexitems menuexitem
1088 struct menuitem **pp;
1090 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
1099 MENUITEM QUOTEDSTRING
1101 $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
1103 | MENUITEM QUOTEDSTRING cnumexpr
1105 $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
1107 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
1109 $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
1111 | MENUITEM SEPARATOR
1113 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
1115 | POPUP QUOTEDSTRING BEG menuexitems END
1117 $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
1119 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
1121 $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
1123 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
1125 $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
1127 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
1130 $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
1134 /* Messagetable resources. */
1137 id MESSAGETABLE memflags_move file_name
1139 define_messagetable ($1, &$3, $4);
1140 if (yychar != YYEMPTY)
1142 rcparse_discard_strings ();
1146 /* Rcdata resources. */
1149 id RCDATA suboptions BEG optrcdata_data END
1151 define_rcdata ($1, &$3, $5.first);
1152 if (yychar != YYEMPTY)
1154 rcparse_discard_strings ();
1156 | id RCDATA suboptions file_name
1158 define_rcdata_file ($1, &$3, $4);
1159 if (yychar != YYEMPTY)
1161 rcparse_discard_strings ();
1165 /* We use a different lexing algorithm, because rcdata strings may
1166 contain embedded null bytes, and we need to know the length to use. */
1194 struct rcdata_item *ri;
1196 ri = define_rcdata_string ($1.s, $1.length);
1202 struct rcdata_item *ri;
1204 ri = define_rcdata_number ($1.val, $1.dword);
1208 | rcdata_data ',' SIZEDSTRING
1210 struct rcdata_item *ri;
1212 ri = define_rcdata_string ($3.s, $3.length);
1213 $$.first = $1.first;
1217 | rcdata_data ',' sizednumexpr
1219 struct rcdata_item *ri;
1221 ri = define_rcdata_number ($3.val, $3.dword);
1222 $$.first = $1.first;
1228 /* Stringtable resources. */
1231 STRINGTABLE suboptions BEG
1232 { sub_res_info = $2; }
1238 | string_data numexpr QUOTEDSTRING
1240 define_stringtable (&sub_res_info, $2, $3);
1241 if (yychar != YYEMPTY)
1243 rcparse_discard_strings ();
1245 | string_data numexpr ',' QUOTEDSTRING
1247 define_stringtable (&sub_res_info, $2, $4);
1248 if (yychar != YYEMPTY)
1250 rcparse_discard_strings ();
1254 /* User defined resources. We accept general suboptions in the
1255 file_name case to keep the parser happy. */
1258 id id suboptions BEG optrcdata_data END
1260 define_user_data ($1, $2, &$3, $5.first);
1261 if (yychar != YYEMPTY)
1263 rcparse_discard_strings ();
1265 | id id suboptions file_name
1267 define_user_file ($1, $2, &$3, $4);
1268 if (yychar != YYEMPTY)
1270 rcparse_discard_strings ();
1274 /* Versioninfo resources. */
1277 id VERSIONINFO fixedverinfo BEG verblocks END
1279 define_versioninfo ($1, language, $3, $5);
1280 if (yychar != YYEMPTY)
1282 rcparse_discard_strings ();
1289 $$ = ((struct fixed_versioninfo *)
1290 res_alloc (sizeof (struct fixed_versioninfo)));
1291 memset ($$, 0, sizeof (struct fixed_versioninfo));
1293 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1295 $1->file_version_ms = ($3 << 16) | $4;
1296 $1->file_version_ls = ($5 << 16) | $6;
1299 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1301 $1->product_version_ms = ($3 << 16) | $4;
1302 $1->product_version_ls = ($5 << 16) | $6;
1305 | fixedverinfo FILEFLAGSMASK numexpr
1307 $1->file_flags_mask = $3;
1310 | fixedverinfo FILEFLAGS numexpr
1312 $1->file_flags = $3;
1315 | fixedverinfo FILEOS numexpr
1320 | fixedverinfo FILETYPE numexpr
1325 | fixedverinfo FILESUBTYPE numexpr
1327 $1->file_subtype = $3;
1332 /* To handle verblocks successfully, the lexer handles BLOCK
1333 specially. A BLOCK "StringFileInfo" is returned as
1334 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1335 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1336 with the string as the value. */
1343 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1345 $$ = append_ver_stringfileinfo ($1, $4, $6);
1347 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1349 $$ = append_ver_varfileinfo ($1, $5, $6);
1358 | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
1360 $$ = append_verval ($1, $3, $5);
1369 | vertrans cnumexpr cnumexpr
1371 $$ = append_vertrans ($1, $2, $3);
1375 /* A resource ID. */
1387 /* It seems that resource ID's are forced to upper case. */
1388 copy = xstrdup ($1);
1389 for (s = copy; *s != '\0'; s++)
1391 res_string_to_id (&$$, copy);
1396 /* A resource reference. */
1424 /* It seems that resource ID's are forced to upper case. */
1425 copy = xstrdup ($1);
1426 for (s = copy; *s != '\0'; s++)
1428 res_string_to_id (&$$, copy);
1433 /* Generic suboptions. These may appear before the BEGIN in any
1434 multiline statement. */
1439 memset (&$$, 0, sizeof (struct res_res_info));
1440 $$.language = language;
1441 /* FIXME: Is this the right default? */
1442 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
1444 | suboptions memflag
1447 $$.memflags |= $2.on;
1448 $$.memflags &=~ $2.off;
1450 | suboptions CHARACTERISTICS numexpr
1453 $$.characteristics = $3;
1455 | suboptions LANGUAGE numexpr cnumexpr
1458 $$.language = $3 | ($4 << SUBLANG_SHIFT);
1460 | suboptions VERSIONK numexpr
1467 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1469 memflags_move_discard:
1472 memset (&$$, 0, sizeof (struct res_res_info));
1473 $$.language = language;
1474 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
1476 | memflags_move_discard memflag
1479 $$.memflags |= $2.on;
1480 $$.memflags &=~ $2.off;
1484 /* Memory flags which default to MOVEABLE. */
1489 memset (&$$, 0, sizeof (struct res_res_info));
1490 $$.language = language;
1491 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
1493 | memflags_move memflag
1496 $$.memflags |= $2.on;
1497 $$.memflags &=~ $2.off;
1501 /* Memory flags. This returns a struct with two integers, because we
1502 sometimes want to set bits and we sometimes want to clear them. */
1507 $$.on = MEMFLAG_MOVEABLE;
1513 $$.off = MEMFLAG_MOVEABLE;
1517 $$.on = MEMFLAG_PURE;
1523 $$.off = MEMFLAG_PURE;
1527 $$.on = MEMFLAG_PRELOAD;
1533 $$.off = MEMFLAG_PRELOAD;
1537 $$.on = MEMFLAG_DISCARDABLE;
1555 /* A style expression. This changes the static variable STYLE. We do
1556 it this way because rc appears to permit a style to be set to
1558 WS_GROUP | NOT WS_TABSTOP
1559 to mean that a default of WS_TABSTOP should be removed. Anything
1560 which wants to accept a style must first set STYLE to the default
1561 value. The styleexpr nonterminal will change STYLE as specified by
1562 the user. Note that we do not accept arbitrary expressions here,
1563 just numbers separated by '|'. */
1574 | styleexpr '|' parennumber
1578 | styleexpr '|' NOT parennumber
1595 /* An optional expression with a leading comma. */
1608 /* An expression with a leading comma. */
1617 /* A possibly negated numeric expression. */
1626 /* A possibly negated expression with a size. */
1633 | '(' sizednumexpr ')'
1637 | '~' sizednumexpr %prec '~'
1640 $$.dword = $2.dword;
1642 | '-' sizednumexpr %prec NEG
1645 $$.dword = $2.dword;
1647 | sizednumexpr '*' sizednumexpr
1649 $$.val = $1.val * $3.val;
1650 $$.dword = $1.dword || $3.dword;
1652 | sizednumexpr '/' sizednumexpr
1654 $$.val = $1.val / $3.val;
1655 $$.dword = $1.dword || $3.dword;
1657 | sizednumexpr '%' sizednumexpr
1659 $$.val = $1.val % $3.val;
1660 $$.dword = $1.dword || $3.dword;
1662 | sizednumexpr '+' sizednumexpr
1664 $$.val = $1.val + $3.val;
1665 $$.dword = $1.dword || $3.dword;
1667 | sizednumexpr '-' sizednumexpr
1669 $$.val = $1.val - $3.val;
1670 $$.dword = $1.dword || $3.dword;
1672 | sizednumexpr '&' sizednumexpr
1674 $$.val = $1.val & $3.val;
1675 $$.dword = $1.dword || $3.dword;
1677 | sizednumexpr '^' sizednumexpr
1679 $$.val = $1.val ^ $3.val;
1680 $$.dword = $1.dword || $3.dword;
1682 | sizednumexpr '|' sizednumexpr
1684 $$.val = $1.val | $3.val;
1685 $$.dword = $1.dword || $3.dword;
1689 /* An expression with a leading comma which does not use unary
1699 /* An expression which does not use unary negation. */
1708 /* An expression which does not use unary negation. We separate unary
1709 negation to avoid parsing conflicts when two numeric expressions
1710 appear consecutively. */
1717 | '(' sizednumexpr ')'
1721 | '~' sizednumexpr %prec '~'
1724 $$.dword = $2.dword;
1726 | sizedposnumexpr '*' sizednumexpr
1728 $$.val = $1.val * $3.val;
1729 $$.dword = $1.dword || $3.dword;
1731 | sizedposnumexpr '/' sizednumexpr
1733 $$.val = $1.val / $3.val;
1734 $$.dword = $1.dword || $3.dword;
1736 | sizedposnumexpr '%' sizednumexpr
1738 $$.val = $1.val % $3.val;
1739 $$.dword = $1.dword || $3.dword;
1741 | sizedposnumexpr '+' sizednumexpr
1743 $$.val = $1.val + $3.val;
1744 $$.dword = $1.dword || $3.dword;
1746 | sizedposnumexpr '-' sizednumexpr
1748 $$.val = $1.val - $3.val;
1749 $$.dword = $1.dword || $3.dword;
1751 | sizedposnumexpr '&' sizednumexpr
1753 $$.val = $1.val & $3.val;
1754 $$.dword = $1.dword || $3.dword;
1756 | sizedposnumexpr '^' sizednumexpr
1758 $$.val = $1.val ^ $3.val;
1759 $$.dword = $1.dword || $3.dword;
1761 | sizedposnumexpr '|' sizednumexpr
1763 $$.val = $1.val | $3.val;
1764 $$.dword = $1.dword || $3.dword;
1770 /* Set the language from the command line. */
1773 rcparse_set_language (int lang)