1 %
{ /* rcparse.y -- parser for Windows rc files
2 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support.
5 Extended by Kai Tietz, Onevision.
7 This file is part of GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
25 /* This is a parser for Windows rc files. It is based on the parser
26 by Gunther Ebert <gunther.ebert@ixos-leipzig.de>. */
31 #include "libiberty.h"
33 #include "safe-ctype.h"
35 /* The current language. */
37 static unsigned short language
;
39 /* The resource information during a sub statement. */
41 static rc_res_res_info sub_res_info
;
43 /* Dialog information. This is built by the nonterminals styles and
46 static rc_dialog dialog
;
48 /* This is used when building a style. It is modified by the
49 nonterminal styleexpr. */
51 static unsigned long style
;
53 /* These are used when building a control. They are set before using
56 static rc_uint_type base_style
;
57 static rc_uint_type default_style
;
58 static rc_res_id class
;
59 static rc_res_id res_text_field
;
60 static unichar null_unichar
;
62 /* This is used for COMBOBOX, LISTBOX and EDITTEXT which
63 do not allow resource 'text' field in control definition. */
64 static const rc_res_id res_null_text
= { 1, {{0, &null_unichar
}}};
72 rc_dialog_control
*dialog_control
;
73 rc_menuitem
*menuitem
;
76 rc_rcdata_item
*first
;
79 rc_rcdata_item
*rcdata_item
;
80 rc_fixed_versioninfo
*fixver
;
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
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
<verstring
> vervals
154 %type
<vervar
> vertrans
155 %type
<toobar_item
> toolbar_data
156 %type
<res_info
> suboptions memflags_move_discard memflags_move
157 %type
<memflags
> memflag
158 %type
<id
> id rcdata_id optresidc resref resid cresid
159 %type
<il
> exstyle parennumber
160 %type
<il
> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
161 %type
<is
> acc_options acc_option menuitem_flags menuitem_flag
163 %type
<uni
> res_unicode_string resname res_unicode_string_concat
164 %type
<ss
> sizedstring
165 %type
<suni
> sizedunistring
166 %type
<i
> sizednumexpr sizedposnumexpr
193 | input IGNORED_TOKEN
196 /* Accelerator resources. */
199 id ACCELERATORS suboptions BEG acc_entries END
201 define_accelerator
($1, &$3, $5);
202 if
(yychar != YYEMPTY
)
204 rcparse_discard_strings
();
213 | acc_entries acc_entry
217 a
= (rc_accelerator
*) res_alloc
(sizeof
*a
);
225 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
234 acc_event cposnumexpr
239 | acc_event cposnumexpr
',' acc_options
244 if
(($$.flags
& ACC_VIRTKEY
) == 0
245 && ($$.flags
& (ACC_SHIFT | ACC_CONTROL
)) != 0)
246 rcparse_warning
(_
("inappropriate modifiers for non-VIRTKEY"));
263 $$.flags
= ACC_CONTROL | ACC_VIRTKEY
;
269 rcparse_warning
(_
("accelerator should only be one character"));
285 | acc_options
',' acc_option
289 /* I've had one report that the comma is optional. */
290 | acc_options acc_option
303 /* This is just the absence of VIRTKEY. */
324 /* Bitmap resources. */
327 id BITMAP memflags_move file_name
329 define_bitmap
($1, &$3, $4);
330 if
(yychar != YYEMPTY
)
332 rcparse_discard_strings
();
336 /* Cursor resources. */
339 id CURSOR memflags_move_discard file_name
341 define_cursor
($1, &$3, $4);
342 if
(yychar != YYEMPTY
)
344 rcparse_discard_strings
();
348 /* Dialog resources. */
351 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
354 memset
(&dialog
, 0, sizeof dialog
);
359 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
361 dialog.menu.named
= 1;
362 dialog.class.named
= 1;
365 dialog.controls
= NULL
;
369 styles BEG controls END
371 define_dialog
($1, &sub_res_info
, &dialog
);
372 if
(yychar != YYEMPTY
)
374 rcparse_discard_strings
();
376 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
379 memset
(&dialog
, 0, sizeof dialog
);
384 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
386 dialog.menu.named
= 1;
387 dialog.class.named
= 1;
389 dialog.ex
= ((rc_dialog_ex
*)
390 res_alloc
(sizeof
(rc_dialog_ex
)));
391 memset
(dialog.ex
, 0, sizeof
(rc_dialog_ex
));
392 dialog.controls
= NULL
;
396 styles BEG controls END
398 define_dialog
($1, &sub_res_info
, &dialog
);
399 if
(yychar != YYEMPTY
)
401 rcparse_discard_strings
();
403 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
406 memset
(&dialog
, 0, sizeof dialog
);
411 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
413 dialog.menu.named
= 1;
414 dialog.class.named
= 1;
416 dialog.ex
= ((rc_dialog_ex
*)
417 res_alloc
(sizeof
(rc_dialog_ex
)));
418 memset
(dialog.ex
, 0, sizeof
(rc_dialog_ex
));
419 dialog.ex
->help
= $9;
420 dialog.controls
= NULL
;
424 styles BEG controls END
426 define_dialog
($1, &sub_res_info
, &dialog
);
427 if
(yychar != YYEMPTY
)
429 rcparse_discard_strings
();
438 | EXSTYLE
'=' numexpr
446 | styles CAPTION res_unicode_string_concat
448 dialog.style |
= WS_CAPTION
;
459 dialog.style
= style
;
461 | styles EXSTYLE numexpr
465 | styles CLASS res_unicode_string_concat
467 res_unistring_to_id
(& dialog.class
, $3);
469 | styles FONT numexpr
',' res_unicode_string_concat
471 dialog.style |
= DS_SETFONT
;
473 dialog.pointsize
= $3;
475 if
(dialog.ex
!= NULL
)
477 dialog.ex
->weight
= 0;
478 dialog.ex
->italic
= 0;
479 dialog.ex
->charset
= 1;
482 | styles FONT numexpr
',' res_unicode_string_concat cnumexpr
484 dialog.style |
= DS_SETFONT
;
486 dialog.pointsize
= $3;
488 if
(dialog.ex
== NULL
)
489 rcparse_warning
(_
("extended FONT requires DIALOGEX"));
492 dialog.ex
->weight
= $6;
493 dialog.ex
->italic
= 0;
494 dialog.ex
->charset
= 1;
497 | styles FONT numexpr
',' res_unicode_string_concat cnumexpr cnumexpr
499 dialog.style |
= DS_SETFONT
;
501 dialog.pointsize
= $3;
503 if
(dialog.ex
== NULL
)
504 rcparse_warning
(_
("extended FONT requires DIALOGEX"));
507 dialog.ex
->weight
= $6;
508 dialog.ex
->italic
= $7;
509 dialog.ex
->charset
= 1;
512 | styles FONT numexpr
',' res_unicode_string_concat cnumexpr cnumexpr cnumexpr
514 dialog.style |
= DS_SETFONT
;
516 dialog.pointsize
= $3;
518 if
(dialog.ex
== NULL
)
519 rcparse_warning
(_
("extended FONT requires DIALOGEX"));
522 dialog.ex
->weight
= $6;
523 dialog.ex
->italic
= $7;
524 dialog.ex
->charset
= $8;
531 | styles CHARACTERISTICS numexpr
533 sub_res_info.characteristics
= $3;
535 | styles LANGUAGE numexpr cnumexpr
537 sub_res_info.language
= $3 |
($4 << SUBLANG_SHIFT
);
539 | styles VERSIONK numexpr
541 sub_res_info.version
= $3;
549 rc_dialog_control
**pp
;
551 for
(pp
= &dialog.controls
; *pp
!= NULL
; pp
= &(*pp
)->next
)
560 default_style
= BS_AUTO3STATE | WS_TABSTOP
;
561 base_style
= BS_AUTO3STATE
;
563 class.u.id
= CTL_BUTTON
;
570 | AUTOCHECKBOX optresidc
572 default_style
= BS_AUTOCHECKBOX | WS_TABSTOP
;
573 base_style
= BS_AUTOCHECKBOX
;
575 class.u.id
= CTL_BUTTON
;
582 | AUTORADIOBUTTON optresidc
584 default_style
= BS_AUTORADIOBUTTON | WS_TABSTOP
;
585 base_style
= BS_AUTORADIOBUTTON
;
587 class.u.id
= CTL_BUTTON
;
596 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
597 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
599 class.u.id
= CTL_EDIT
;
605 if
(dialog.ex
== NULL
)
606 rcparse_warning
(_
("BEDIT requires DIALOGEX"));
607 res_string_to_id
(&$$
->class
, "BEDIT");
611 default_style
= BS_CHECKBOX | WS_TABSTOP
;
612 base_style
= BS_CHECKBOX | WS_TABSTOP
;
614 class.u.id
= CTL_BUTTON
;
623 /* This is as per MSDN documentation. With some (???)
624 versions of MS rc.exe their is no default style. */
625 default_style
= CBS_SIMPLE | WS_TABSTOP
;
628 class.u.id
= CTL_COMBOBOX
;
629 res_text_field
= res_null_text
;
635 | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
636 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
638 $$
= define_control
($2, $3, $6, $7, $8, $9, $4, style
, $10);
641 if
(dialog.ex
== NULL
)
642 rcparse_warning
(_
("control data requires DIALOGEX"));
646 | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
647 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
649 $$
= define_control
($2, $3, $6, $7, $8, $9, $4, style
, $10);
650 if
(dialog.ex
== NULL
)
651 rcparse_warning
(_
("help ID requires DIALOGEX"));
657 default_style
= SS_CENTER | WS_GROUP
;
658 base_style
= SS_CENTER
;
660 class.u.id
= CTL_STATIC
;
667 | DEFPUSHBUTTON optresidc
669 default_style
= BS_DEFPUSHBUTTON | WS_TABSTOP
;
670 base_style
= BS_DEFPUSHBUTTON | WS_TABSTOP
;
672 class.u.id
= CTL_BUTTON
;
681 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
682 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
684 class.u.id
= CTL_EDIT
;
685 res_text_field
= res_null_text
;
693 default_style
= BS_GROUPBOX
;
694 base_style
= BS_GROUPBOX
;
696 class.u.id
= CTL_BUTTON
;
705 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
706 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
708 class.u.id
= CTL_EDIT
;
714 if
(dialog.ex
== NULL
)
715 rcparse_warning
(_
("IEDIT requires DIALOGEX"));
716 res_string_to_id
(&$$
->class
, "HEDIT");
718 | ICON resref numexpr cnumexpr cnumexpr opt_control_data
720 $$
= define_icon_control
($2, $3, $4, $5, 0, 0, 0, $6,
723 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
726 $$
= define_icon_control
($2, $3, $4, $5, 0, 0, 0, $8,
729 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
730 icon_styleexpr optcnumexpr opt_control_data
732 $$
= define_icon_control
($2, $3, $4, $5, style
, $9, 0, $10,
735 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
736 icon_styleexpr cnumexpr cnumexpr opt_control_data
738 $$
= define_icon_control
($2, $3, $4, $5, style
, $9, $10, $11,
743 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
744 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
746 class.u.id
= CTL_EDIT
;
752 if
(dialog.ex
== NULL
)
753 rcparse_warning
(_
("IEDIT requires DIALOGEX"));
754 res_string_to_id
(&$$
->class
, "IEDIT");
758 default_style
= LBS_NOTIFY | WS_BORDER
;
759 base_style
= LBS_NOTIFY | WS_BORDER
;
761 class.u.id
= CTL_LISTBOX
;
762 res_text_field
= res_null_text
;
770 default_style
= SS_LEFT | WS_GROUP
;
771 base_style
= SS_LEFT
;
773 class.u.id
= CTL_STATIC
;
782 default_style
= BS_PUSHBOX | WS_TABSTOP
;
783 base_style
= BS_PUSHBOX
;
785 class.u.id
= CTL_BUTTON
;
791 | PUSHBUTTON optresidc
793 default_style
= BS_PUSHBUTTON | WS_TABSTOP
;
794 base_style
= BS_PUSHBUTTON | WS_TABSTOP
;
796 class.u.id
= CTL_BUTTON
;
803 | RADIOBUTTON optresidc
805 default_style
= BS_RADIOBUTTON | WS_TABSTOP
;
806 base_style
= BS_RADIOBUTTON
;
808 class.u.id
= CTL_BUTTON
;
817 default_style
= SS_RIGHT | WS_GROUP
;
818 base_style
= SS_RIGHT
;
820 class.u.id
= CTL_STATIC
;
829 default_style
= SBS_HORZ
;
832 class.u.id
= CTL_SCROLLBAR
;
833 res_text_field
= res_null_text
;
841 default_style
= BS_3STATE | WS_TABSTOP
;
842 base_style
= BS_3STATE
;
844 class.u.id
= CTL_BUTTON
;
851 | USERBUTTON resref numexpr
',' numexpr
',' numexpr
','
852 numexpr
',' numexpr
','
853 { style
= WS_CHILD | WS_VISIBLE
; }
854 styleexpr optcnumexpr
858 cid.u.id
= CTL_BUTTON
;
859 $$
= define_control
($2, $3, $5, $7, $9, $11, cid
,
864 /* Parameters for a control. The static variables DEFAULT_STYLE,
865 BASE_STYLE, and CLASS must be initialized before this nonterminal
866 is used. DEFAULT_STYLE is the style to use if no style expression
867 is specified. BASE_STYLE is the base style to use if a style
868 expression is specified; the style expression modifies the base
869 style. CLASS is the class of the control. */
872 numexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
874 $$
= define_control
(res_text_field
, $1, $2, $3, $4, $5, class
,
875 default_style | WS_CHILD | WS_VISIBLE
, 0);
878 if
(dialog.ex
== NULL
)
879 rcparse_warning
(_
("control data requires DIALOGEX"));
883 | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
884 control_params_styleexpr optcnumexpr opt_control_data
886 $$
= define_control
(res_text_field
, $1, $2, $3, $4, $5, class
, style
, $7);
889 if
(dialog.ex
== NULL
)
890 rcparse_warning
(_
("control data requires DIALOGEX"));
894 | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
895 control_params_styleexpr cnumexpr cnumexpr opt_control_data
897 $$
= define_control
(res_text_field
, $1, $2, $3, $4, $5, class
, style
, $7);
898 if
(dialog.ex
== NULL
)
899 rcparse_warning
(_
("help ID requires DIALOGEX"));
909 res_unistring_to_id
(&$$
, $2.u.n.name
);
918 res_string_to_id
(&$$
, "");
920 | resid
',' { $$
=$1; }
929 | res_unicode_string_concat
933 $$.u.n.length
= unichar_len
($1);
942 | BEG optrcdata_data END
948 /* These only exist to parse a reduction out of a common case. */
952 { style
= WS_CHILD | WS_VISIBLE
; }
958 { style
= SS_ICON | WS_CHILD | WS_VISIBLE
; }
962 control_params_styleexpr:
964 { style
= base_style | WS_CHILD | WS_VISIBLE
; }
968 /* Font resources. */
971 id FONT memflags_move_discard file_name
973 define_font
($1, &$3, $4);
974 if
(yychar != YYEMPTY
)
976 rcparse_discard_strings
();
980 /* Icon resources. */
983 id ICON memflags_move_discard file_name
985 define_icon
($1, &$3, $4);
986 if
(yychar != YYEMPTY
)
988 rcparse_discard_strings
();
992 /* Language command. This changes the static variable language, which
993 affects all subsequent resources. */
996 LANGUAGE numexpr cnumexpr
998 language
= $2 |
($3 << SUBLANG_SHIFT
);
1002 /* Menu resources. */
1005 id MENU suboptions BEG menuitems END
1007 define_menu
($1, &$3, $5);
1008 if
(yychar != YYEMPTY
)
1010 rcparse_discard_strings
();
1019 | menuitems menuitem
1027 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
1036 MENUITEM res_unicode_string_concat cnumexpr menuitem_flags
1038 $$
= define_menuitem
($2, $3, $4, 0, 0, NULL
);
1040 | MENUITEM SEPARATOR
1042 $$
= define_menuitem
(NULL
, 0, 0, 0, 0, NULL
);
1044 | POPUP res_unicode_string_concat menuitem_flags BEG menuitems END
1046 $$
= define_menuitem
($2, 0, $3, 0, 0, $5);
1055 | menuitem_flags
',' menuitem_flag
1059 | menuitem_flags menuitem_flag
1068 $$
= MENUITEM_CHECKED
;
1072 $$
= MENUITEM_GRAYED
;
1080 $$
= MENUITEM_INACTIVE
;
1084 $$
= MENUITEM_MENUBARBREAK
;
1088 $$
= MENUITEM_MENUBREAK
;
1092 /* Menuex resources. */
1095 id MENUEX suboptions BEG menuexitems END
1097 define_menu
($1, &$3, $5);
1098 if
(yychar != YYEMPTY
)
1100 rcparse_discard_strings
();
1109 | menuexitems menuexitem
1117 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
1126 MENUITEM res_unicode_string_concat
1128 $$
= define_menuitem
($2, 0, 0, 0, 0, NULL
);
1130 | MENUITEM res_unicode_string_concat cnumexpr
1132 $$
= define_menuitem
($2, $3, 0, 0, 0, NULL
);
1134 | MENUITEM res_unicode_string_concat cnumexpr cnumexpr optcnumexpr
1136 $$
= define_menuitem
($2, $3, $4, $5, 0, NULL
);
1138 | MENUITEM SEPARATOR
1140 $$
= define_menuitem
(NULL
, 0, 0, 0, 0, NULL
);
1142 | POPUP res_unicode_string_concat BEG menuexitems END
1144 $$
= define_menuitem
($2, 0, 0, 0, 0, $4);
1146 | POPUP res_unicode_string_concat cnumexpr BEG menuexitems END
1148 $$
= define_menuitem
($2, $3, 0, 0, 0, $5);
1150 | POPUP res_unicode_string_concat cnumexpr cnumexpr BEG menuexitems END
1152 $$
= define_menuitem
($2, $3, $4, 0, 0, $6);
1154 | POPUP res_unicode_string_concat cnumexpr cnumexpr cnumexpr optcnumexpr
1157 $$
= define_menuitem
($2, $3, $4, $5, $6, $8);
1161 /* Messagetable resources. */
1164 id MESSAGETABLE memflags_move file_name
1166 define_messagetable
($1, &$3, $4);
1167 if
(yychar != YYEMPTY
)
1169 rcparse_discard_strings
();
1173 /* We use a different lexing algorithm, because rcdata strings may
1174 contain embedded null bytes, and we need to know the length to use. */
1204 ri
= define_rcdata_string
($1.s
, $1.length
);
1212 ri
= define_rcdata_unistring
($1.s
, $1.length
);
1220 ri
= define_rcdata_number
($1.val
, $1.dword
);
1224 | rcdata_data
',' sizedstring
1228 ri
= define_rcdata_string
($3.s
, $3.length
);
1229 $$.first
= $1.first
;
1233 | rcdata_data
',' sizedunistring
1237 ri
= define_rcdata_unistring
($3.s
, $3.length
);
1238 $$.first
= $1.first
;
1242 | rcdata_data
',' sizednumexpr
1246 ri
= define_rcdata_number
($3.val
, $3.dword
);
1247 $$.first
= $1.first
;
1257 /* Stringtable resources. */
1260 STRINGTABLE suboptions BEG
1261 { sub_res_info
= $2; }
1267 | string_data numexpr res_unicode_string_concat
1269 define_stringtable
(&sub_res_info
, $2, $3);
1270 rcparse_discard_strings
();
1272 | string_data numexpr
',' res_unicode_string_concat
1274 define_stringtable
(&sub_res_info
, $2, $4);
1275 rcparse_discard_strings
();
1279 rcparse_warning
(_
("invalid stringtable resource."));
1297 $$.u.id
= RT_RCDATA
;
1302 $$.u.id
= RT_MANIFEST
;
1307 $$.u.id
= RT_PLUGPLAY
;
1317 $$.u.id
= RT_DLGINCLUDE
;
1322 $$.u.id
= RT_DLGINIT
;
1327 $$.u.id
= RT_ANICURSOR
;
1332 $$.u.id
= RT_ANIICON
;
1336 /* User defined resources. We accept general suboptions in the
1337 file_name case to keep the parser happy. */
1340 id rcdata_id suboptions BEG optrcdata_data END
1342 define_user_data
($1, $2, &$3, $5.first
);
1343 if
(yychar != YYEMPTY
)
1345 rcparse_discard_strings
();
1347 | id rcdata_id suboptions file_name
1349 define_user_file
($1, $2, &$3, $4);
1350 if
(yychar != YYEMPTY
)
1352 rcparse_discard_strings
();
1357 id TOOLBAR suboptions numexpr cnumexpr BEG toolbar_data END
1359 define_toolbar
($1, &$3, $4, $5, $7);
1363 toolbar_data: /* empty */ { $$
= NULL
; }
1364 | toolbar_data BUTTON id
1366 rc_toolbar_item
*c
,*n
;
1368 n
= (rc_toolbar_item
*)
1369 res_alloc
(sizeof
(rc_toolbar_item
));
1371 while
(c
->next
!= NULL
)
1383 | toolbar_data SEPARATOR
1385 rc_toolbar_item
*c
,*n
;
1387 n
= (rc_toolbar_item
*)
1388 res_alloc
(sizeof
(rc_toolbar_item
));
1390 while
(c
->next
!= NULL
)
1405 /* Versioninfo resources. */
1408 id VERSIONINFO fixedverinfo BEG verblocks END
1410 define_versioninfo
($1, language
, $3, $5);
1411 if
(yychar != YYEMPTY
)
1413 rcparse_discard_strings
();
1420 $$
= ((rc_fixed_versioninfo
*)
1421 res_alloc
(sizeof
(rc_fixed_versioninfo
)));
1422 memset
($$
, 0, sizeof
(rc_fixed_versioninfo
));
1424 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1426 $1->file_version_ms
= ($3 << 16) |
$4;
1427 $1->file_version_ls
= ($5 << 16) |
$6;
1430 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1432 $1->product_version_ms
= ($3 << 16) |
$4;
1433 $1->product_version_ls
= ($5 << 16) |
$6;
1436 | fixedverinfo FILEFLAGSMASK numexpr
1438 $1->file_flags_mask
= $3;
1441 | fixedverinfo FILEFLAGS numexpr
1443 $1->file_flags
= $3;
1446 | fixedverinfo FILEOS numexpr
1451 | fixedverinfo FILETYPE numexpr
1456 | fixedverinfo FILESUBTYPE numexpr
1458 $1->file_subtype
= $3;
1463 /* To handle verblocks successfully, the lexer handles BLOCK
1464 specially. A BLOCK "StringFileInfo" is returned as
1465 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1466 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1467 with the string as the value. */
1474 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1476 $$
= append_ver_stringfileinfo
($1, $4, $6);
1478 | verblocks BLOCKVARFILEINFO BEG VALUE res_unicode_string_concat vertrans END
1480 $$
= append_ver_varfileinfo
($1, $5, $6);
1489 | vervals VALUE res_unicode_string_concat
',' res_unicode_string_concat
1491 $$
= append_verval
($1, $3, $5);
1500 | vertrans cnumexpr cnumexpr
1502 $$
= append_vertrans
($1, $2, $3);
1506 /* A resource ID. */
1516 res_unistring_to_id
(&$$
, $1);
1520 /* A resource reference. */
1530 unicode_from_ascii
((rc_uint_type
*) NULL
, &h
, $1);
1544 res_unistring_to_id
(&$$
, $1);
1548 res_unistring_to_id
(&$$
, $1);
1552 /* Generic suboptions. These may appear before the BEGIN in any
1553 multiline statement. */
1558 memset
(&$$
, 0, sizeof
(rc_res_res_info
));
1559 $$.language
= language
;
1560 /* FIXME: Is this the right default? */
1561 $$.memflags
= MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE
;
1563 | suboptions memflag
1566 $$.memflags |
= $2.on
;
1567 $$.memflags
&=~
$2.off
;
1569 | suboptions CHARACTERISTICS numexpr
1572 $$.characteristics
= $3;
1574 | suboptions LANGUAGE numexpr cnumexpr
1577 $$.language
= $3 |
($4 << SUBLANG_SHIFT
);
1579 | suboptions VERSIONK numexpr
1586 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1588 memflags_move_discard:
1591 memset
(&$$
, 0, sizeof
(rc_res_res_info
));
1592 $$.language
= language
;
1593 $$.memflags
= MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE
;
1595 | memflags_move_discard memflag
1598 $$.memflags |
= $2.on
;
1599 $$.memflags
&=~
$2.off
;
1603 /* Memory flags which default to MOVEABLE. */
1608 memset
(&$$
, 0, sizeof
(rc_res_res_info
));
1609 $$.language
= language
;
1610 $$.memflags
= MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE
;
1612 | memflags_move memflag
1615 $$.memflags |
= $2.on
;
1616 $$.memflags
&=~
$2.off
;
1620 /* Memory flags. This returns a struct with two integers, because we
1621 sometimes want to set bits and we sometimes want to clear them. */
1626 $$.on
= MEMFLAG_MOVEABLE
;
1632 $$.off
= MEMFLAG_MOVEABLE
;
1636 $$.on
= MEMFLAG_PURE
;
1642 $$.off
= MEMFLAG_PURE
;
1646 $$.on
= MEMFLAG_PRELOAD
;
1652 $$.off
= MEMFLAG_PRELOAD
;
1656 $$.on
= MEMFLAG_DISCARDABLE
;
1675 res_unicode_string_concat:
1681 res_unicode_string_concat res_unicode_string
1683 rc_uint_type l1
= unichar_len
($1);
1684 rc_uint_type l2
= unichar_len
($2);
1685 unichar
*h
= (unichar
*) res_alloc
((l1
+ l2
+ 1) * sizeof
(unichar
));
1687 memcpy
(h
, $1, l1
* sizeof
(unichar
));
1689 memcpy
(h
+ l1
, $2, l2
* sizeof
(unichar
));
1698 $$
= unichar_dup
($1);
1703 unicode_from_ascii
((rc_uint_type
*) NULL
, &h
, $1);
1713 | sizedstring SIZEDSTRING
1715 rc_uint_type l
= $1.length
+ $2.length
;
1716 char *h
= (char *) res_alloc
(l
);
1717 memcpy
(h
, $1.s
, $1.length
);
1718 memcpy
(h
+ $1.length
, $2.s
, $2.length
);
1729 | sizedunistring SIZEDUNISTRING
1731 rc_uint_type l
= $1.length
+ $2.length
;
1732 unichar
*h
= (unichar
*) res_alloc
(l
* sizeof
(unichar
));
1733 memcpy
(h
, $1.s
, $1.length
* sizeof
(unichar
));
1734 memcpy
(h
+ $1.length
, $2.s
, $2.length
* sizeof
(unichar
));
1740 /* A style expression. This changes the static variable STYLE. We do
1741 it this way because rc appears to permit a style to be set to
1743 WS_GROUP | NOT WS_TABSTOP
1744 to mean that a default of WS_TABSTOP should be removed. Anything
1745 which wants to accept a style must first set STYLE to the default
1746 value. The styleexpr nonterminal will change STYLE as specified by
1747 the user. Note that we do not accept arbitrary expressions here,
1748 just numbers separated by '|'. */
1759 | styleexpr
'|' parennumber
1763 | styleexpr
'|' NOT parennumber
1780 /* An optional expression with a leading comma. */
1793 /* An expression with a leading comma. */
1802 /* A possibly negated numeric expression. */
1811 /* A possibly negated expression with a size. */
1818 |
'(' sizednumexpr
')'
1822 |
'~' sizednumexpr %prec
'~'
1825 $$.dword
= $2.dword
;
1827 |
'-' sizednumexpr %prec NEG
1830 $$.dword
= $2.dword
;
1832 | sizednumexpr
'*' sizednumexpr
1834 $$.val
= $1.val
* $3.val
;
1835 $$.dword
= $1.dword ||
$3.dword
;
1837 | sizednumexpr
'/' sizednumexpr
1839 $$.val
= $1.val
/ $3.val
;
1840 $$.dword
= $1.dword ||
$3.dword
;
1842 | sizednumexpr
'%' sizednumexpr
1844 $$.val
= $1.val %
$3.val
;
1845 $$.dword
= $1.dword ||
$3.dword
;
1847 | sizednumexpr
'+' sizednumexpr
1849 $$.val
= $1.val
+ $3.val
;
1850 $$.dword
= $1.dword ||
$3.dword
;
1852 | sizednumexpr
'-' sizednumexpr
1854 $$.val
= $1.val
- $3.val
;
1855 $$.dword
= $1.dword ||
$3.dword
;
1857 | sizednumexpr
'&' sizednumexpr
1859 $$.val
= $1.val
& $3.val
;
1860 $$.dword
= $1.dword ||
$3.dword
;
1862 | sizednumexpr
'^' sizednumexpr
1864 $$.val
= $1.val ^
$3.val
;
1865 $$.dword
= $1.dword ||
$3.dword
;
1867 | sizednumexpr
'|' sizednumexpr
1869 $$.val
= $1.val |
$3.val
;
1870 $$.dword
= $1.dword ||
$3.dword
;
1874 /* An expression with a leading comma which does not use unary
1884 /* An expression which does not use unary negation. */
1893 /* An expression which does not use unary negation. We separate unary
1894 negation to avoid parsing conflicts when two numeric expressions
1895 appear consecutively. */
1902 |
'(' sizednumexpr
')'
1906 |
'~' sizednumexpr %prec
'~'
1909 $$.dword
= $2.dword
;
1911 | sizedposnumexpr
'*' sizednumexpr
1913 $$.val
= $1.val
* $3.val
;
1914 $$.dword
= $1.dword ||
$3.dword
;
1916 | sizedposnumexpr
'/' sizednumexpr
1918 $$.val
= $1.val
/ $3.val
;
1919 $$.dword
= $1.dword ||
$3.dword
;
1921 | sizedposnumexpr
'%' sizednumexpr
1923 $$.val
= $1.val %
$3.val
;
1924 $$.dword
= $1.dword ||
$3.dword
;
1926 | sizedposnumexpr
'+' sizednumexpr
1928 $$.val
= $1.val
+ $3.val
;
1929 $$.dword
= $1.dword ||
$3.dword
;
1931 | sizedposnumexpr
'-' sizednumexpr
1933 $$.val
= $1.val
- $3.val
;
1934 $$.dword
= $1.dword ||
$3.dword
;
1936 | sizedposnumexpr
'&' sizednumexpr
1938 $$.val
= $1.val
& $3.val
;
1939 $$.dword
= $1.dword ||
$3.dword
;
1941 | sizedposnumexpr
'^' sizednumexpr
1943 $$.val
= $1.val ^
$3.val
;
1944 $$.dword
= $1.dword ||
$3.dword
;
1946 | sizedposnumexpr
'|' sizednumexpr
1948 $$.val
= $1.val |
$3.val
;
1949 $$.dword
= $1.dword ||
$3.dword
;
1955 /* Set the language from the command line. */
1958 rcparse_set_language
(int lang
)