1 %
{ /* rcparse.y -- parser for Windows rc files
2 Copyright (C) 1997-2022 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
4 Extended by Kai Tietz, Onevision.
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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA
24 /* This is a parser for Windows rc files. It is based on the parser
25 by Gunther Ebert <gunther.ebert@ixos-leipzig.de>. */
30 #include "libiberty.h"
32 #include "safe-ctype.h"
34 /* The current language. */
36 static unsigned short language
;
38 /* The resource information during a sub statement. */
40 static rc_res_res_info sub_res_info
;
42 /* Dialog information. This is built by the nonterminals styles and
45 static rc_dialog dialog
;
47 /* This is used when building a style. It is modified by the
48 nonterminal styleexpr. */
50 static unsigned long style
;
52 /* These are used when building a control. They are set before using
55 static rc_uint_type base_style
;
56 static rc_uint_type default_style
;
57 static rc_res_id class
;
58 static rc_res_id res_text_field
;
59 static unichar null_unichar
;
61 /* This is used for COMBOBOX, LISTBOX and EDITTEXT which
62 do not allow resource 'text' field in control definition. */
63 static const rc_res_id res_null_text
= { 1, {{0, &null_unichar
}}};
71 rc_dialog_control
*dialog_control
;
72 rc_menuitem
*menuitem
;
75 rc_rcdata_item
*first
;
78 rc_rcdata_item
*rcdata_item
;
79 rc_fixed_versioninfo
*fixver
;
81 rc_ver_stringtable
*verstringtable
;
82 rc_ver_stringinfo
*verstring
;
83 rc_ver_varinfo
*vervar
;
84 rc_toolbar_item
*toobar_item
;
86 rc_res_res_info res_info
;
95 /* Nonzero if this number was explicitly specified as long. */
115 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
118 %token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
119 %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
120 %token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
121 %token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
122 %token BEDIT HEDIT IEDIT
125 %token ANICURSOR ANIICON DLGINCLUDE DLGINIT FONTDIR HTML MANIFEST PLUGPLAY VXD TOOLBAR BUTTON
126 %token LANGUAGE CHARACTERISTICS VERSIONK
127 %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE OWNERDRAW
128 %token MENUBARBREAK MENUBREAK
132 %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
133 %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
136 %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
138 %token
<uni
> QUOTEDUNISTRING
139 %token
<s
> QUOTEDSTRING STRING
141 %token
<suni
> SIZEDUNISTRING
142 %token
<ss
> SIZEDSTRING
145 %type
<pacc
> acc_entries
146 %type
<acc
> acc_entry acc_event
147 %type
<dialog_control
> control control_params
148 %type
<menuitem
> menuitems menuitem menuexitems menuexitem
149 %type
<rcdata
> optrcdata_data optrcdata_data_int rcdata_data
150 %type
<rcdata_item
> opt_control_data
151 %type
<fixver
> fixedverinfo
152 %type
<verinfo
> verblocks
153 %type
<verstringtable
> verstringtables
154 %type
<verstring
> vervals
155 %type
<vervar
> vertrans
156 %type
<toobar_item
> toolbar_data
157 %type
<res_info
> suboptions memflags_move_discard memflags_move
158 %type
<memflags
> memflag
159 %type
<id
> id rcdata_id optresidc resref resid cresid
160 %type
<il
> exstyle parennumber
161 %type
<il
> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
162 %type
<is
> acc_options acc_option menuitem_flags menuitem_flag
164 %type
<uni
> res_unicode_string resname res_unicode_string_concat
165 %type
<ss
> sizedstring
166 %type
<suni
> sizedunistring res_unicode_sizedstring res_unicode_sizedstring_concat
167 %type
<i
> sizednumexpr sizedposnumexpr
194 | input IGNORED_TOKEN
197 /* Accelerator resources. */
200 id ACCELERATORS suboptions BEG acc_entries END
202 define_accelerator
($1, &$3, $5);
203 if
(yychar != YYEMPTY
)
205 rcparse_discard_strings
();
214 | acc_entries acc_entry
218 a
= (rc_accelerator
*) res_alloc
(sizeof
*a
);
226 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
235 acc_event cposnumexpr
240 | acc_event cposnumexpr
',' acc_options
245 if
(($$.flags
& ACC_VIRTKEY
) == 0
246 && ($$.flags
& (ACC_SHIFT | ACC_CONTROL
)) != 0)
247 rcparse_warning
(_
("inappropriate modifiers for non-VIRTKEY"));
264 $$.flags
= ACC_CONTROL | ACC_VIRTKEY
;
270 rcparse_warning
(_
("accelerator should only be one character"));
286 | acc_options
',' acc_option
290 /* I've had one report that the comma is optional. */
291 | acc_options acc_option
304 /* This is just the absence of VIRTKEY. */
325 /* Bitmap resources. */
328 id BITMAP memflags_move file_name
330 define_bitmap
($1, &$3, $4);
331 if
(yychar != YYEMPTY
)
333 rcparse_discard_strings
();
337 /* Cursor resources. */
340 id CURSOR memflags_move_discard file_name
342 define_cursor
($1, &$3, $4);
343 if
(yychar != YYEMPTY
)
345 rcparse_discard_strings
();
349 /* Dialog resources. */
352 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
355 memset
(&dialog
, 0, sizeof dialog
);
360 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
362 dialog.menu.named
= 1;
363 dialog.class.named
= 1;
366 dialog.controls
= NULL
;
370 styles BEG controls END
372 define_dialog
($1, &sub_res_info
, &dialog
);
373 if
(yychar != YYEMPTY
)
375 rcparse_discard_strings
();
377 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
380 memset
(&dialog
, 0, sizeof dialog
);
385 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
387 dialog.menu.named
= 1;
388 dialog.class.named
= 1;
390 dialog.ex
= ((rc_dialog_ex
*)
391 res_alloc
(sizeof
(rc_dialog_ex
)));
392 memset
(dialog.ex
, 0, sizeof
(rc_dialog_ex
));
393 dialog.controls
= NULL
;
397 styles BEG controls END
399 define_dialog
($1, &sub_res_info
, &dialog
);
400 if
(yychar != YYEMPTY
)
402 rcparse_discard_strings
();
404 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
407 memset
(&dialog
, 0, sizeof dialog
);
412 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
414 dialog.menu.named
= 1;
415 dialog.class.named
= 1;
417 dialog.ex
= ((rc_dialog_ex
*)
418 res_alloc
(sizeof
(rc_dialog_ex
)));
419 memset
(dialog.ex
, 0, sizeof
(rc_dialog_ex
));
420 dialog.ex
->help
= $9;
421 dialog.controls
= NULL
;
425 styles BEG controls END
427 define_dialog
($1, &sub_res_info
, &dialog
);
428 if
(yychar != YYEMPTY
)
430 rcparse_discard_strings
();
439 | EXSTYLE
'=' numexpr
447 | styles CAPTION res_unicode_string_concat
449 dialog.style |
= WS_CAPTION
;
460 dialog.style
= style
;
462 | styles EXSTYLE numexpr
466 | styles CLASS res_unicode_string_concat
468 res_unistring_to_id
(& dialog.class
, $3);
470 | styles FONT numexpr
',' res_unicode_string_concat
472 dialog.style |
= DS_SETFONT
;
474 dialog.pointsize
= $3;
476 if
(dialog.ex
!= NULL
)
478 dialog.ex
->weight
= 0;
479 dialog.ex
->italic
= 0;
480 dialog.ex
->charset
= 1;
483 | styles FONT numexpr
',' res_unicode_string_concat cnumexpr
485 dialog.style |
= DS_SETFONT
;
487 dialog.pointsize
= $3;
489 if
(dialog.ex
== NULL
)
490 rcparse_warning
(_
("extended FONT requires DIALOGEX"));
493 dialog.ex
->weight
= $6;
494 dialog.ex
->italic
= 0;
495 dialog.ex
->charset
= 1;
498 | styles FONT numexpr
',' res_unicode_string_concat cnumexpr cnumexpr
500 dialog.style |
= DS_SETFONT
;
502 dialog.pointsize
= $3;
504 if
(dialog.ex
== NULL
)
505 rcparse_warning
(_
("extended FONT requires DIALOGEX"));
508 dialog.ex
->weight
= $6;
509 dialog.ex
->italic
= $7;
510 dialog.ex
->charset
= 1;
513 | styles FONT numexpr
',' res_unicode_string_concat cnumexpr cnumexpr cnumexpr
515 dialog.style |
= DS_SETFONT
;
517 dialog.pointsize
= $3;
519 if
(dialog.ex
== NULL
)
520 rcparse_warning
(_
("extended FONT requires DIALOGEX"));
523 dialog.ex
->weight
= $6;
524 dialog.ex
->italic
= $7;
525 dialog.ex
->charset
= $8;
532 | styles CHARACTERISTICS numexpr
534 sub_res_info.characteristics
= $3;
536 | styles LANGUAGE numexpr cnumexpr
538 sub_res_info.language
= $3 |
($4 << SUBLANG_SHIFT
);
540 | styles VERSIONK numexpr
542 sub_res_info.version
= $3;
550 rc_dialog_control
**pp
;
552 for
(pp
= &dialog.controls
; *pp
!= NULL
; pp
= &(*pp
)->next
)
561 default_style
= BS_AUTO3STATE | WS_TABSTOP
;
562 base_style
= BS_AUTO3STATE
;
564 class.u.id
= CTL_BUTTON
;
571 | AUTOCHECKBOX optresidc
573 default_style
= BS_AUTOCHECKBOX | WS_TABSTOP
;
574 base_style
= BS_AUTOCHECKBOX | WS_TABSTOP
;
576 class.u.id
= CTL_BUTTON
;
583 | AUTORADIOBUTTON optresidc
585 default_style
= BS_AUTORADIOBUTTON | WS_TABSTOP
;
586 base_style
= BS_AUTORADIOBUTTON
;
588 class.u.id
= CTL_BUTTON
;
597 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
598 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
600 class.u.id
= CTL_EDIT
;
606 if
(dialog.ex
== NULL
)
607 rcparse_warning
(_
("BEDIT requires DIALOGEX"));
608 res_string_to_id
(&$$
->class
, "BEDIT");
612 default_style
= BS_CHECKBOX | WS_TABSTOP
;
613 base_style
= BS_CHECKBOX | WS_TABSTOP
;
615 class.u.id
= CTL_BUTTON
;
624 /* This is as per MSDN documentation. With some (???)
625 versions of MS rc.exe their is no default style. */
626 default_style
= CBS_SIMPLE | WS_TABSTOP
;
629 class.u.id
= CTL_COMBOBOX
;
630 res_text_field
= res_null_text
;
636 | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
637 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
639 $$
= define_control
($2, $3, $6, $7, $8, $9, $4, style
, $10);
642 if
(dialog.ex
== NULL
)
643 rcparse_warning
(_
("control data requires DIALOGEX"));
647 | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
648 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
650 $$
= define_control
($2, $3, $6, $7, $8, $9, $4, style
, $10);
651 if
(dialog.ex
== NULL
)
652 rcparse_warning
(_
("help ID requires DIALOGEX"));
658 default_style
= SS_CENTER | WS_GROUP
;
659 base_style
= SS_CENTER
;
661 class.u.id
= CTL_STATIC
;
668 | DEFPUSHBUTTON optresidc
670 default_style
= BS_DEFPUSHBUTTON | WS_TABSTOP
;
671 base_style
= BS_DEFPUSHBUTTON | WS_TABSTOP
;
673 class.u.id
= CTL_BUTTON
;
682 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
683 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
685 class.u.id
= CTL_EDIT
;
686 res_text_field
= res_null_text
;
694 default_style
= BS_GROUPBOX
;
695 base_style
= BS_GROUPBOX
;
697 class.u.id
= CTL_BUTTON
;
706 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
707 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
709 class.u.id
= CTL_EDIT
;
715 if
(dialog.ex
== NULL
)
716 rcparse_warning
(_
("IEDIT requires DIALOGEX"));
717 res_string_to_id
(&$$
->class
, "HEDIT");
719 | ICON resref numexpr cnumexpr cnumexpr opt_control_data
721 $$
= define_icon_control
($2, $3, $4, $5, 0, 0, 0, $6,
724 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
727 $$
= define_icon_control
($2, $3, $4, $5, 0, 0, 0, $8,
730 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
731 icon_styleexpr optcnumexpr opt_control_data
733 $$
= define_icon_control
($2, $3, $4, $5, style
, $9, 0, $10,
736 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
737 icon_styleexpr cnumexpr cnumexpr opt_control_data
739 $$
= define_icon_control
($2, $3, $4, $5, style
, $9, $10, $11,
744 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
745 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
747 class.u.id
= CTL_EDIT
;
753 if
(dialog.ex
== NULL
)
754 rcparse_warning
(_
("IEDIT requires DIALOGEX"));
755 res_string_to_id
(&$$
->class
, "IEDIT");
759 default_style
= LBS_NOTIFY | WS_BORDER
;
760 base_style
= LBS_NOTIFY | WS_BORDER
;
762 class.u.id
= CTL_LISTBOX
;
763 res_text_field
= res_null_text
;
771 default_style
= SS_LEFT | WS_GROUP
;
772 base_style
= SS_LEFT
;
774 class.u.id
= CTL_STATIC
;
783 default_style
= BS_PUSHBOX | WS_TABSTOP
;
784 base_style
= BS_PUSHBOX
;
786 class.u.id
= CTL_BUTTON
;
792 | PUSHBUTTON optresidc
794 default_style
= BS_PUSHBUTTON | WS_TABSTOP
;
795 base_style
= BS_PUSHBUTTON | WS_TABSTOP
;
797 class.u.id
= CTL_BUTTON
;
804 | RADIOBUTTON optresidc
806 default_style
= BS_RADIOBUTTON | WS_TABSTOP
;
807 base_style
= BS_RADIOBUTTON
;
809 class.u.id
= CTL_BUTTON
;
818 default_style
= SS_RIGHT | WS_GROUP
;
819 base_style
= SS_RIGHT
;
821 class.u.id
= CTL_STATIC
;
830 default_style
= SBS_HORZ
;
833 class.u.id
= CTL_SCROLLBAR
;
834 res_text_field
= res_null_text
;
842 default_style
= BS_3STATE | WS_TABSTOP
;
843 base_style
= BS_3STATE
;
845 class.u.id
= CTL_BUTTON
;
852 | USERBUTTON resref numexpr
',' numexpr
',' numexpr
','
853 numexpr
',' numexpr
','
854 { style
= WS_CHILD | WS_VISIBLE
; }
855 styleexpr optcnumexpr
859 cid.u.id
= CTL_BUTTON
;
860 $$
= define_control
($2, $3, $5, $7, $9, $11, cid
,
865 /* Parameters for a control. The static variables DEFAULT_STYLE,
866 BASE_STYLE, and CLASS must be initialized before this nonterminal
867 is used. DEFAULT_STYLE is the style to use if no style expression
868 is specified. BASE_STYLE is the base style to use if a style
869 expression is specified; the style expression modifies the base
870 style. CLASS is the class of the control. */
873 numexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
875 $$
= define_control
(res_text_field
, $1, $2, $3, $4, $5, class
,
876 default_style | WS_CHILD | WS_VISIBLE
, 0);
879 if
(dialog.ex
== NULL
)
880 rcparse_warning
(_
("control data requires DIALOGEX"));
884 | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
885 control_params_styleexpr optcnumexpr opt_control_data
887 $$
= define_control
(res_text_field
, $1, $2, $3, $4, $5, class
, style
, $7);
890 if
(dialog.ex
== NULL
)
891 rcparse_warning
(_
("control data requires DIALOGEX"));
895 | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
896 control_params_styleexpr cnumexpr cnumexpr opt_control_data
898 $$
= define_control
(res_text_field
, $1, $2, $3, $4, $5, class
, style
, $7);
899 if
(dialog.ex
== NULL
)
900 rcparse_warning
(_
("help ID requires DIALOGEX"));
910 res_unistring_to_id
(&$$
, $2.u.n.name
);
919 res_string_to_id
(&$$
, "");
921 | resid
',' { $$
=$1; }
930 | res_unicode_string_concat
934 $$.u.n.length
= unichar_len
($1);
943 | BEG optrcdata_data END
949 /* These only exist to parse a reduction out of a common case. */
953 { style
= WS_CHILD | WS_VISIBLE
; }
959 { style
= SS_ICON | WS_CHILD | WS_VISIBLE
; }
963 control_params_styleexpr:
965 { style
= base_style | WS_CHILD | WS_VISIBLE
; }
969 /* Font resources. */
972 id FONT memflags_move_discard file_name
974 define_font
($1, &$3, $4);
975 if
(yychar != YYEMPTY
)
977 rcparse_discard_strings
();
981 /* Icon resources. */
984 id ICON memflags_move_discard file_name
986 define_icon
($1, &$3, $4);
987 if
(yychar != YYEMPTY
)
989 rcparse_discard_strings
();
993 /* Language command. This changes the static variable language, which
994 affects all subsequent resources. */
997 LANGUAGE numexpr cnumexpr
999 language
= $2 |
($3 << SUBLANG_SHIFT
);
1003 /* Menu resources. */
1006 id MENU suboptions BEG menuitems END
1008 define_menu
($1, &$3, $5);
1009 if
(yychar != YYEMPTY
)
1011 rcparse_discard_strings
();
1020 | menuitems menuitem
1028 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
1037 MENUITEM res_unicode_string_concat cnumexpr menuitem_flags
1039 $$
= define_menuitem
($2, $3, $4, 0, 0, NULL
);
1041 | MENUITEM SEPARATOR
1043 $$
= define_menuitem
(NULL
, 0, 0, 0, 0, NULL
);
1045 | POPUP res_unicode_string_concat menuitem_flags BEG menuitems END
1047 $$
= define_menuitem
($2, 0, $3, 0, 0, $5);
1056 | menuitem_flags
',' menuitem_flag
1060 | menuitem_flags menuitem_flag
1069 $$
= MENUITEM_CHECKED
;
1073 $$
= MENUITEM_GRAYED
;
1081 $$
= MENUITEM_INACTIVE
;
1085 $$
= MENUITEM_MENUBARBREAK
;
1089 $$
= MENUITEM_MENUBREAK
;
1093 $$
= MENUITEM_BITMAP
;
1097 $$
= MENUITEM_OWNERDRAW
;
1101 /* Menuex resources. */
1104 id MENUEX suboptions BEG menuexitems END
1106 define_menu
($1, &$3, $5);
1107 if
(yychar != YYEMPTY
)
1109 rcparse_discard_strings
();
1118 | menuexitems menuexitem
1126 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
1135 MENUITEM res_unicode_string_concat
1137 $$
= define_menuitem
($2, 0, 0, 0, 0, NULL
);
1139 | MENUITEM res_unicode_string_concat cnumexpr
1141 $$
= define_menuitem
($2, $3, 0, 0, 0, NULL
);
1143 | MENUITEM res_unicode_string_concat cnumexpr cnumexpr optcnumexpr
1145 $$
= define_menuitem
($2, $3, $4, $5, 0, NULL
);
1147 | MENUITEM SEPARATOR
1149 $$
= define_menuitem
(NULL
, 0, 0, 0, 0, NULL
);
1151 | POPUP res_unicode_string_concat BEG menuexitems END
1153 $$
= define_menuitem
($2, 0, 0, 0, 0, $4);
1155 | POPUP res_unicode_string_concat cnumexpr BEG menuexitems END
1157 $$
= define_menuitem
($2, $3, 0, 0, 0, $5);
1159 | POPUP res_unicode_string_concat cnumexpr cnumexpr BEG menuexitems END
1161 $$
= define_menuitem
($2, $3, $4, 0, 0, $6);
1163 | POPUP res_unicode_string_concat cnumexpr cnumexpr cnumexpr optcnumexpr
1166 $$
= define_menuitem
($2, $3, $4, $5, $6, $8);
1170 /* Messagetable resources. */
1173 id MESSAGETABLE memflags_move file_name
1175 define_messagetable
($1, &$3, $4);
1176 if
(yychar != YYEMPTY
)
1178 rcparse_discard_strings
();
1182 /* We use a different lexing algorithm, because rcdata strings may
1183 contain embedded null bytes, and we need to know the length to use. */
1213 ri
= define_rcdata_string
($1.s
, $1.length
);
1221 ri
= define_rcdata_unistring
($1.s
, $1.length
);
1229 ri
= define_rcdata_number
($1.val
, $1.dword
);
1233 | rcdata_data
',' sizedstring
1237 ri
= define_rcdata_string
($3.s
, $3.length
);
1238 $$.first
= $1.first
;
1242 | rcdata_data
',' sizedunistring
1246 ri
= define_rcdata_unistring
($3.s
, $3.length
);
1247 $$.first
= $1.first
;
1251 | rcdata_data
',' sizednumexpr
1255 ri
= define_rcdata_number
($3.val
, $3.dword
);
1256 $$.first
= $1.first
;
1266 /* Stringtable resources. */
1269 STRINGTABLE suboptions BEG
1270 { sub_res_info
= $2; rcparse_rcdata
(); }
1271 string_data END
{ rcparse_normal
(); }
1276 | string_data numexpr res_unicode_sizedstring_concat
1278 define_stringtable
(&sub_res_info
, $2, $3.s
, $3.length
);
1279 rcparse_discard_strings
();
1281 | string_data numexpr
',' res_unicode_sizedstring_concat
1283 define_stringtable
(&sub_res_info
, $2, $4.s
, $4.length
);
1284 rcparse_discard_strings
();
1288 rcparse_warning
(_
("invalid stringtable resource."));
1306 $$.u.id
= RT_RCDATA
;
1311 $$.u.id
= RT_MANIFEST
;
1316 $$.u.id
= RT_PLUGPLAY
;
1326 $$.u.id
= RT_DLGINCLUDE
;
1331 $$.u.id
= RT_DLGINIT
;
1336 $$.u.id
= RT_ANICURSOR
;
1341 $$.u.id
= RT_ANIICON
;
1345 /* User defined resources. We accept general suboptions in the
1346 file_name case to keep the parser happy. */
1349 id rcdata_id suboptions BEG optrcdata_data END
1351 define_user_data
($1, $2, &$3, $5.first
);
1352 if
(yychar != YYEMPTY
)
1354 rcparse_discard_strings
();
1356 | id rcdata_id suboptions file_name
1358 define_user_file
($1, $2, &$3, $4);
1359 if
(yychar != YYEMPTY
)
1361 rcparse_discard_strings
();
1366 id TOOLBAR suboptions numexpr cnumexpr BEG toolbar_data END
1368 define_toolbar
($1, &$3, $4, $5, $7);
1372 toolbar_data: /* empty */ { $$
= NULL
; }
1373 | toolbar_data BUTTON id
1375 rc_toolbar_item
*c
,*n
;
1377 n
= (rc_toolbar_item
*)
1378 res_alloc
(sizeof
(rc_toolbar_item
));
1380 while
(c
->next
!= NULL
)
1392 | toolbar_data SEPARATOR
1394 rc_toolbar_item
*c
,*n
;
1396 n
= (rc_toolbar_item
*)
1397 res_alloc
(sizeof
(rc_toolbar_item
));
1399 while
(c
->next
!= NULL
)
1414 /* Versioninfo resources. */
1417 id VERSIONINFO fixedverinfo BEG verblocks END
1419 define_versioninfo
($1, language
, $3, $5);
1420 if
(yychar != YYEMPTY
)
1422 rcparse_discard_strings
();
1429 $$
= ((rc_fixed_versioninfo
*)
1430 res_alloc
(sizeof
(rc_fixed_versioninfo
)));
1431 memset
($$
, 0, sizeof
(rc_fixed_versioninfo
));
1433 | fixedverinfo FILEVERSION numexpr optcnumexpr optcnumexpr
1436 $1->file_version_ms
= ($3 << 16) |
($4 & 0xffff);
1437 $1->file_version_ls
= ($5 << 16) |
($6 & 0xffff);
1440 | fixedverinfo PRODUCTVERSION numexpr optcnumexpr optcnumexpr
1443 $1->product_version_ms
= ($3 << 16) |
($4 & 0xffff);
1444 $1->product_version_ls
= ($5 << 16) |
($6 & 0xffff);
1447 | fixedverinfo FILEFLAGSMASK numexpr
1449 $1->file_flags_mask
= $3;
1452 | fixedverinfo FILEFLAGS numexpr
1454 $1->file_flags
= $3;
1457 | fixedverinfo FILEOS numexpr
1462 | fixedverinfo FILETYPE numexpr
1467 | fixedverinfo FILESUBTYPE numexpr
1469 $1->file_subtype
= $3;
1474 /* To handle verblocks successfully, the lexer handles BLOCK
1475 specially. A BLOCK "StringFileInfo" is returned as
1476 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1477 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1478 with the string as the value. */
1485 | verblocks BLOCKSTRINGFILEINFO BEG verstringtables END
1487 $$
= append_ver_stringfileinfo
($1, $4);
1489 | verblocks BLOCKVARFILEINFO BEG VALUE res_unicode_string_concat vertrans END
1491 $$
= append_ver_varfileinfo
($1, $5, $6);
1500 | verstringtables BLOCK BEG vervals END
1502 $$
= append_ver_stringtable
($1, $2, $4);
1511 | vervals VALUE res_unicode_string_concat
',' res_unicode_string_concat
1513 $$
= append_verval
($1, $3, $5);
1522 | vertrans cnumexpr cnumexpr
1524 $$
= append_vertrans
($1, $2, $3);
1528 /* A resource ID. */
1538 res_unistring_to_id
(&$$
, $1);
1542 /* A resource reference. */
1552 unicode_from_ascii
((rc_uint_type
*) NULL
, &h
, $1);
1566 res_unistring_to_id
(&$$
, $1);
1570 res_unistring_to_id
(&$$
, $1);
1574 /* Generic suboptions. These may appear before the BEGIN in any
1575 multiline statement. */
1580 memset
(&$$
, 0, sizeof
(rc_res_res_info
));
1581 $$.language
= language
;
1582 /* FIXME: Is this the right default? */
1583 $$.memflags
= MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE
;
1585 | suboptions memflag
1588 $$.memflags |
= $2.on
;
1589 $$.memflags
&=~
$2.off
;
1591 | suboptions CHARACTERISTICS numexpr
1594 $$.characteristics
= $3;
1596 | suboptions LANGUAGE numexpr cnumexpr
1599 $$.language
= $3 |
($4 << SUBLANG_SHIFT
);
1601 | suboptions VERSIONK numexpr
1608 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1610 memflags_move_discard:
1613 memset
(&$$
, 0, sizeof
(rc_res_res_info
));
1614 $$.language
= language
;
1615 $$.memflags
= MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE
;
1617 | memflags_move_discard memflag
1620 $$.memflags |
= $2.on
;
1621 $$.memflags
&=~
$2.off
;
1625 /* Memory flags which default to MOVEABLE. */
1630 memset
(&$$
, 0, sizeof
(rc_res_res_info
));
1631 $$.language
= language
;
1632 $$.memflags
= MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE
;
1634 | memflags_move memflag
1637 $$.memflags |
= $2.on
;
1638 $$.memflags
&=~
$2.off
;
1642 /* Memory flags. This returns a struct with two integers, because we
1643 sometimes want to set bits and we sometimes want to clear them. */
1648 $$.on
= MEMFLAG_MOVEABLE
;
1654 $$.off
= MEMFLAG_MOVEABLE
;
1658 $$.on
= MEMFLAG_PURE
;
1664 $$.off
= MEMFLAG_PURE
;
1668 $$.on
= MEMFLAG_PRELOAD
;
1674 $$.off
= MEMFLAG_PRELOAD
;
1678 $$.on
= MEMFLAG_DISCARDABLE
;
1697 res_unicode_string_concat:
1703 res_unicode_string_concat res_unicode_string
1705 rc_uint_type l1
= unichar_len
($1);
1706 rc_uint_type l2
= unichar_len
($2);
1707 unichar
*h
= (unichar
*) res_alloc
((l1
+ l2
+ 1) * sizeof
(unichar
));
1709 memcpy
(h
, $1, l1
* sizeof
(unichar
));
1711 memcpy
(h
+ l1
, $2, l2
* sizeof
(unichar
));
1720 $$
= unichar_dup
($1);
1725 unicode_from_ascii
((rc_uint_type
*) NULL
, &h
, $1);
1730 res_unicode_sizedstring:
1739 unicode_from_ascii_len
(&l
, &h
, $1.s
, $1.length
);
1746 res_unicode_sizedstring_concat:
1747 res_unicode_sizedstring
1752 res_unicode_sizedstring_concat res_unicode_sizedstring
1754 rc_uint_type l1
= $1.length
;
1755 rc_uint_type l2
= $2.length
;
1756 unichar
*h
= (unichar
*) res_alloc
((l1
+ l2
+ 1) * sizeof
(unichar
));
1758 memcpy
(h
, $1.s
, l1
* sizeof
(unichar
));
1760 memcpy
(h
+ l1
, $2.s
, l2
* sizeof
(unichar
));
1762 $$.length
= l1
+ l2
;
1772 | sizedstring SIZEDSTRING
1774 rc_uint_type l
= $1.length
+ $2.length
;
1775 char *h
= (char *) res_alloc
(l
);
1776 memcpy
(h
, $1.s
, $1.length
);
1777 memcpy
(h
+ $1.length
, $2.s
, $2.length
);
1788 | sizedunistring SIZEDUNISTRING
1790 rc_uint_type l
= $1.length
+ $2.length
;
1791 unichar
*h
= (unichar
*) res_alloc
(l
* sizeof
(unichar
));
1792 memcpy
(h
, $1.s
, $1.length
* sizeof
(unichar
));
1793 memcpy
(h
+ $1.length
, $2.s
, $2.length
* sizeof
(unichar
));
1799 /* A style expression. This changes the static variable STYLE. We do
1800 it this way because rc appears to permit a style to be set to
1802 WS_GROUP | NOT WS_TABSTOP
1803 to mean that a default of WS_TABSTOP should be removed. Anything
1804 which wants to accept a style must first set STYLE to the default
1805 value. The styleexpr nonterminal will change STYLE as specified by
1806 the user. Note that we do not accept arbitrary expressions here,
1807 just numbers separated by '|'. */
1818 | styleexpr
'|' parennumber
1822 | styleexpr
'|' NOT parennumber
1839 /* An optional expression with a leading comma. */
1852 /* An expression with a leading comma. */
1861 /* A possibly negated numeric expression. */
1870 /* A possibly negated expression with a size. */
1877 |
'(' sizednumexpr
')'
1881 |
'~' sizednumexpr %prec
'~'
1884 $$.dword
= $2.dword
;
1886 |
'-' sizednumexpr %prec NEG
1889 $$.dword
= $2.dword
;
1891 | sizednumexpr
'*' sizednumexpr
1893 $$.val
= $1.val
* $3.val
;
1894 $$.dword
= $1.dword ||
$3.dword
;
1896 | sizednumexpr
'/' sizednumexpr
1898 $$.val
= $1.val
/ ($3.val ?
$3.val
: 1);
1899 $$.dword
= $1.dword ||
$3.dword
;
1901 | sizednumexpr
'%' sizednumexpr
1903 $$.val
= $1.val %
($3.val ?
$3.val
: 1);
1904 $$.dword
= $1.dword ||
$3.dword
;
1906 | sizednumexpr
'+' sizednumexpr
1908 $$.val
= $1.val
+ $3.val
;
1909 $$.dword
= $1.dword ||
$3.dword
;
1911 | sizednumexpr
'-' sizednumexpr
1913 $$.val
= $1.val
- $3.val
;
1914 $$.dword
= $1.dword ||
$3.dword
;
1916 | sizednumexpr
'&' sizednumexpr
1918 $$.val
= $1.val
& $3.val
;
1919 $$.dword
= $1.dword ||
$3.dword
;
1921 | sizednumexpr
'^' sizednumexpr
1923 $$.val
= $1.val ^
$3.val
;
1924 $$.dword
= $1.dword ||
$3.dword
;
1926 | sizednumexpr
'|' sizednumexpr
1928 $$.val
= $1.val |
$3.val
;
1929 $$.dword
= $1.dword ||
$3.dword
;
1933 /* An expression with a leading comma which does not use unary
1943 /* An expression which does not use unary negation. */
1952 /* An expression which does not use unary negation. We separate unary
1953 negation to avoid parsing conflicts when two numeric expressions
1954 appear consecutively. */
1961 |
'(' sizednumexpr
')'
1965 |
'~' sizednumexpr %prec
'~'
1968 $$.dword
= $2.dword
;
1970 | sizedposnumexpr
'*' sizednumexpr
1972 $$.val
= $1.val
* $3.val
;
1973 $$.dword
= $1.dword ||
$3.dword
;
1975 | sizedposnumexpr
'/' sizednumexpr
1977 $$.val
= $1.val
/ ($3.val ?
$3.val
: 1);
1978 $$.dword
= $1.dword ||
$3.dword
;
1980 | sizedposnumexpr
'%' sizednumexpr
1982 /* PR 17512: file: 89105a25. */
1983 $$.val
= $1.val %
($3.val ?
$3.val
: 1);
1984 $$.dword
= $1.dword ||
$3.dword
;
1986 | sizedposnumexpr
'+' sizednumexpr
1988 $$.val
= $1.val
+ $3.val
;
1989 $$.dword
= $1.dword ||
$3.dword
;
1991 | sizedposnumexpr
'-' sizednumexpr
1993 $$.val
= $1.val
- $3.val
;
1994 $$.dword
= $1.dword ||
$3.dword
;
1996 | sizedposnumexpr
'&' sizednumexpr
1998 $$.val
= $1.val
& $3.val
;
1999 $$.dword
= $1.dword ||
$3.dword
;
2001 | sizedposnumexpr
'^' sizednumexpr
2003 $$.val
= $1.val ^
$3.val
;
2004 $$.dword
= $1.dword ||
$3.dword
;
2006 | sizedposnumexpr
'|' sizednumexpr
2008 $$.val
= $1.val |
$3.val
;
2009 $$.dword
= $1.dword ||
$3.dword
;
2015 /* Set the language from the command line. */
2018 rcparse_set_language
(int lang
)