1 %
{ /* rcparse.y -- parser for Windows rc files
2 Copyright 1997, 1998 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
22 /* This is a parser for Windows rc files. It is based on the parser
23 by Gunther Ebert <gunther.ebert@ixos-leipzig.de>. */
27 #include "libiberty.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
;
61 struct accelerator acc
;
62 struct accelerator
*pacc
;
63 struct dialog_control
*dialog_control
;
64 struct menuitem
*menuitem
;
67 struct rcdata_item
*first
;
68 struct rcdata_item
*last
;
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
;
77 struct res_res_info res_info
;
86 /* Nonzero if this number was explicitly specified as long. */
100 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
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
110 %token LANGUAGE CHARACTERISTICS VERSIONK
111 %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
112 %token MENUBARBREAK MENUBREAK
116 %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
117 %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
120 %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
122 %token
<s
> QUOTEDSTRING STRING
124 %token
<ss
> SIZEDSTRING
127 %type
<pacc
> acc_entries
128 %type
<acc
> acc_entry acc_event
129 %type
<dialog_control
> control control_params
130 %type
<menuitem
> menuitems menuitem menuexitems menuexitem
131 %type
<rcdata
> optrcdata_data optrcdata_data_int rcdata_data
132 %type
<rcdata_item
> opt_control_data
133 %type
<fixver
> fixedverinfo
134 %type
<verinfo
> verblocks
135 %type
<verstring
> vervals
136 %type
<vervar
> vertrans
137 %type
<res_info
> suboptions memflags_move_discard memflags_move
138 %type
<memflags
> memflag
140 %type
<il
> exstyle parennumber
141 %type
<il
> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
142 %type
<is
> acc_options acc_option menuitem_flags menuitem_flag
143 %type
<s
> optstringc file_name resname
144 %type
<i
> sizednumexpr sizedposnumexpr
157 | input newcmd accelerator
158 | input newcmd bitmap
159 | input newcmd cursor
160 | input newcmd dialog
163 | input newcmd language
165 | input newcmd menuex
166 | input newcmd messagetable
167 | input newcmd rcdata
168 | input newcmd stringtable
170 | input newcmd versioninfo
171 | input newcmd IGNORED_TOKEN
177 rcparse_discard_strings
();
181 /* Accelerator resources. */
184 id ACCELERATORS suboptions BEG acc_entries END
186 define_accelerator
($1, &$3, $5);
195 | acc_entries acc_entry
197 struct accelerator
*a
;
199 a
= (struct accelerator
*) res_alloc
(sizeof
*a
);
205 struct accelerator
**pp
;
207 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
216 acc_event cposnumexpr
221 | acc_event cposnumexpr
',' acc_options
226 if
(($$.flags
& ACC_VIRTKEY
) == 0
227 && ($$.flags
& (ACC_SHIFT | ACC_CONTROL | ACC_ALT
)) != 0)
228 rcparse_warning
(_
("inappropriate modifiers for non-VIRTKEY"));
245 $$.flags
= ACC_CONTROL | ACC_VIRTKEY
;
248 ch
= toupper
((unsigned char) ch
);
252 rcparse_warning
(_
("accelerator should only be one character"));
268 | acc_options
',' acc_option
272 /* I've had one report that the comma is optional. */
273 | acc_options acc_option
286 /* This is just the absence of VIRTKEY. */
307 /* Bitmap resources. */
310 id BITMAP memflags_move file_name
312 define_bitmap
($1, &$3, $4);
316 /* Cursor resources. */
319 id CURSOR memflags_move_discard file_name
321 define_cursor
($1, &$3, $4);
325 /* Dialog resources. */
328 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
331 memset
(&dialog
, 0, sizeof dialog
);
336 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
338 dialog.menu.named
= 1;
339 dialog.class.named
= 1;
342 dialog.controls
= NULL
;
345 styles BEG controls END
347 define_dialog
($1, &sub_res_info
, &dialog
);
349 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
352 memset
(&dialog
, 0, sizeof dialog
);
357 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
359 dialog.menu.named
= 1;
360 dialog.class.named
= 1;
362 dialog.ex
= ((struct dialog_ex
*)
363 res_alloc
(sizeof
(struct dialog_ex
)));
364 memset
(dialog.ex
, 0, sizeof
(struct dialog_ex
));
365 dialog.controls
= NULL
;
368 styles BEG controls END
370 define_dialog
($1, &sub_res_info
, &dialog
);
372 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
375 memset
(&dialog
, 0, sizeof dialog
);
380 dialog.style
= WS_POPUP | WS_BORDER | WS_SYSMENU
;
382 dialog.menu.named
= 1;
383 dialog.class.named
= 1;
385 dialog.ex
= ((struct dialog_ex
*)
386 res_alloc
(sizeof
(struct dialog_ex
)));
387 memset
(dialog.ex
, 0, sizeof
(struct dialog_ex
));
388 dialog.ex
->help
= $9;
389 dialog.controls
= NULL
;
392 styles BEG controls END
394 define_dialog
($1, &sub_res_info
, &dialog
);
403 | EXSTYLE
'=' numexpr
411 | styles CAPTION QUOTEDSTRING
413 unicode_from_ascii
((int *) NULL
, &dialog.caption
, $3);
420 { style
= dialog.style
; }
423 dialog.style
= style
;
425 | styles EXSTYLE numexpr
429 | styles FONT numexpr
',' QUOTEDSTRING
431 dialog.style |
= DS_SETFONT
;
432 dialog.pointsize
= $3;
433 unicode_from_ascii
((int *) NULL
, &dialog.font
, $5);
435 | styles FONT numexpr
',' QUOTEDSTRING cnumexpr cnumexpr
437 dialog.style |
= DS_SETFONT
;
438 dialog.pointsize
= $3;
439 unicode_from_ascii
((int *) NULL
, &dialog.font
, $5);
440 if
(dialog.ex
== NULL
)
441 rcparse_warning
(_
("extended FONT requires DIALOGEX"));
444 dialog.ex
->weight
= $6;
445 dialog.ex
->italic
= $7;
452 | styles CHARACTERISTICS numexpr
454 sub_res_info.characteristics
= $3;
456 | styles LANGUAGE numexpr cnumexpr
458 sub_res_info.language
= $3 |
($4 << 8);
460 | styles VERSIONK numexpr
462 sub_res_info.version
= $3;
470 struct dialog_control
**pp
;
472 for
(pp
= &dialog.controls
; *pp
!= NULL
; pp
= &(*pp
)->next
)
481 default_style
= BS_AUTO3STATE | WS_TABSTOP
;
482 base_style
= BS_AUTO3STATE
;
491 default_style
= BS_AUTOCHECKBOX | WS_TABSTOP
;
492 base_style
= BS_AUTOCHECKBOX
;
501 default_style
= BS_AUTORADIOBUTTON | WS_TABSTOP
;
502 base_style
= BS_AUTORADIOBUTTON
;
511 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
512 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
518 if
(dialog.ex
== NULL
)
519 rcparse_warning
(_
("IEDIT requires DIALOGEX"));
520 res_string_to_id
(&$$
->class
, "BEDIT");
524 default_style
= BS_CHECKBOX | WS_TABSTOP
;
525 base_style
= BS_CHECKBOX | WS_TABSTOP
;
534 default_style
= CBS_SIMPLE | WS_TABSTOP
;
536 class
= CTL_COMBOBOX
;
542 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
543 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
545 $$
= define_control
($2, $3, $6, $7, $8, $9, $4, style
, $10);
548 if
(dialog.ex
== NULL
)
549 rcparse_warning
(_
("control data requires DIALOGEX"));
553 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
554 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
556 $$
= define_control
($2, $3, $6, $7, $8, $9, $4, style
, $10);
557 if
(dialog.ex
== NULL
)
558 rcparse_warning
(_
("help ID requires DIALOGEX"));
562 | CONTROL optstringc numexpr
',' QUOTEDSTRING control_styleexpr
563 cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
565 $$
= define_control
($2, $3, $7, $8, $9, $10, 0, style
, $11);
568 if
(dialog.ex
== NULL
)
569 rcparse_warning
("control data requires DIALOGEX");
573 unicode_from_ascii
(&$$
->class.u.n.length
, &$$
->class.u.n.name
, $5);
575 | CONTROL optstringc numexpr
',' QUOTEDSTRING control_styleexpr
576 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
578 $$
= define_control
($2, $3, $7, $8, $9, $10, 0, style
, $11);
579 if
(dialog.ex
== NULL
)
580 rcparse_warning
("help ID requires DIALOGEX");
584 unicode_from_ascii
(&$$
->class.u.n.length
, &$$
->class.u.n.name
, $5);
588 default_style
= SS_CENTER | WS_GROUP
;
589 base_style
= SS_CENTER
;
598 default_style
= BS_DEFPUSHBUTTON | WS_TABSTOP
;
599 base_style
= BS_DEFPUSHBUTTON | WS_TABSTOP
;
608 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
609 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
618 default_style
= BS_GROUPBOX
;
619 base_style
= BS_GROUPBOX
;
628 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
629 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
635 if
(dialog.ex
== NULL
)
636 rcparse_warning
(_
("IEDIT requires DIALOGEX"));
637 res_string_to_id
(&$$
->class
, "HEDIT");
639 | ICON resref numexpr cnumexpr cnumexpr opt_control_data
641 $$
= define_icon_control
($2, $3, $4, $5, 0, 0, 0, $6,
644 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
647 $$
= define_icon_control
($2, $3, $4, $5, 0, 0, 0, $8,
650 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
651 icon_styleexpr optcnumexpr opt_control_data
653 $$
= define_icon_control
($2, $3, $4, $5, style
, $9, 0, $10,
656 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
657 icon_styleexpr cnumexpr cnumexpr opt_control_data
659 $$
= define_icon_control
($2, $3, $4, $5, style
, $9, $10, $11,
664 default_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
665 base_style
= ES_LEFT | WS_BORDER | WS_TABSTOP
;
671 if
(dialog.ex
== NULL
)
672 rcparse_warning
(_
("IEDIT requires DIALOGEX"));
673 res_string_to_id
(&$$
->class
, "IEDIT");
677 default_style
= LBS_NOTIFY | WS_BORDER
;
678 base_style
= LBS_NOTIFY | WS_BORDER
;
687 default_style
= SS_LEFT | WS_GROUP
;
688 base_style
= SS_LEFT
;
697 default_style
= BS_PUSHBOX | WS_TABSTOP
;
698 base_style
= BS_PUSHBOX
;
707 default_style
= BS_PUSHBUTTON | WS_TABSTOP
;
708 base_style
= BS_PUSHBUTTON | WS_TABSTOP
;
717 default_style
= BS_RADIOBUTTON | WS_TABSTOP
;
718 base_style
= BS_RADIOBUTTON
;
727 default_style
= SS_RIGHT | WS_GROUP
;
728 base_style
= SS_RIGHT
;
737 default_style
= SBS_HORZ
;
739 class
= CTL_SCROLLBAR
;
747 default_style
= BS_3STATE | WS_TABSTOP
;
748 base_style
= BS_3STATE
;
755 | USERBUTTON QUOTEDSTRING
',' numexpr
',' numexpr
',' numexpr
','
756 numexpr
',' numexpr
','
757 { style
= WS_CHILD | WS_VISIBLE
; }
758 styleexpr optcnumexpr
760 $$
= define_control
($2, $4, $6, $8, $10, $12, CTL_BUTTON
,
765 /* Parameters for a control. The static variables DEFAULT_STYLE,
766 BASE_STYLE, and CLASS must be initialized before this nonterminal
767 is used. DEFAULT_STYLE is the style to use if no style expression
768 is specified. BASE_STYLE is the base style to use if a style
769 expression is specified; the style expression modifies the base
770 style. CLASS is the class of the control. */
773 optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
776 $$
= define_control
($1, $2, $3, $4, $5, $6, class
,
777 default_style | WS_CHILD | WS_VISIBLE
, 0);
780 if
(dialog.ex
== NULL
)
781 rcparse_warning
(_
("control data requires DIALOGEX"));
785 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
786 control_params_styleexpr optcnumexpr opt_control_data
788 $$
= define_control
($1, $2, $3, $4, $5, $6, class
, style
, $8);
791 if
(dialog.ex
== NULL
)
792 rcparse_warning
(_
("control data requires DIALOGEX"));
796 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
797 control_params_styleexpr cnumexpr cnumexpr opt_control_data
799 $$
= define_control
($1, $2, $3, $4, $5, $6, class
, style
, $8);
800 if
(dialog.ex
== NULL
)
801 rcparse_warning
(_
("help ID requires DIALOGEX"));
827 | BEG optrcdata_data END
833 /* These only exist to parse a reduction out of a common case. */
837 { style
= WS_CHILD | WS_VISIBLE
; }
843 { style
= SS_ICON | WS_CHILD | WS_VISIBLE
; }
847 control_params_styleexpr:
849 { style
= base_style | WS_CHILD | WS_VISIBLE
; }
853 /* Font resources. */
856 id FONT memflags_move_discard file_name
858 define_font
($1, &$3, $4);
862 /* Icon resources. */
865 id ICON memflags_move_discard file_name
867 define_icon
($1, &$3, $4);
871 /* Language command. This changes the static variable language, which
872 affects all subsequent resources. */
875 LANGUAGE numexpr cnumexpr
877 language
= $2 |
($3 << 8);
881 /* Menu resources. */
884 id MENU suboptions BEG menuitems END
886 define_menu
($1, &$3, $5);
901 struct menuitem
**pp
;
903 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
912 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
914 $$
= define_menuitem
($2, $3, $4, 0, 0, NULL
);
918 $$
= define_menuitem
(NULL
, 0, 0, 0, 0, NULL
);
920 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
922 $$
= define_menuitem
($2, 0, $3, 0, 0, $5);
931 | menuitem_flags
',' menuitem_flag
935 | menuitem_flags menuitem_flag
944 $$
= MENUITEM_CHECKED
;
948 $$
= MENUITEM_GRAYED
;
956 $$
= MENUITEM_INACTIVE
;
960 $$
= MENUITEM_MENUBARBREAK
;
964 $$
= MENUITEM_MENUBREAK
;
968 /* Menuex resources. */
971 id MENUEX suboptions BEG menuexitems END
973 define_menu
($1, &$3, $5);
982 | menuexitems menuexitem
988 struct menuitem
**pp
;
990 for
(pp
= &$1->next
; *pp
!= NULL
; pp
= &(*pp
)->next
)
999 MENUITEM QUOTEDSTRING
1001 $$
= define_menuitem
($2, 0, 0, 0, 0, NULL
);
1003 | MENUITEM QUOTEDSTRING cnumexpr
1005 $$
= define_menuitem
($2, $3, 0, 0, 0, NULL
);
1007 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
1009 $$
= define_menuitem
($2, $3, $4, $5, 0, NULL
);
1011 | MENUITEM SEPARATOR
1013 $$
= define_menuitem
(NULL
, 0, 0, 0, 0, NULL
);
1015 | POPUP QUOTEDSTRING BEG menuexitems END
1017 $$
= define_menuitem
($2, 0, 0, 0, 0, $4);
1019 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
1021 $$
= define_menuitem
($2, $3, 0, 0, 0, $5);
1023 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
1025 $$
= define_menuitem
($2, $3, $4, 0, 0, $6);
1027 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
1030 $$
= define_menuitem
($2, $3, $4, $5, $6, $8);
1034 /* Messagetable resources. */
1037 id MESSAGETABLE memflags_move file_name
1039 define_messagetable
($1, &$3, $4);
1043 /* Rcdata resources. */
1046 id RCDATA suboptions BEG optrcdata_data END
1048 define_rcdata
($1, &$3, $5.first
);
1052 /* We use a different lexing algorithm, because rcdata strings may
1053 contain embedded null bytes, and we need to know the length to use. */
1081 struct rcdata_item
*ri
;
1083 ri
= define_rcdata_string
($1.s
, $1.length
);
1089 struct rcdata_item
*ri
;
1091 ri
= define_rcdata_number
($1.val
, $1.dword
);
1095 | rcdata_data
',' SIZEDSTRING
1097 struct rcdata_item
*ri
;
1099 ri
= define_rcdata_string
($3.s
, $3.length
);
1100 $$.first
= $1.first
;
1104 | rcdata_data
',' sizednumexpr
1106 struct rcdata_item
*ri
;
1108 ri
= define_rcdata_number
($3.val
, $3.dword
);
1109 $$.first
= $1.first
;
1115 /* Stringtable resources. */
1118 STRINGTABLE suboptions BEG
1119 { sub_res_info
= $2; }
1125 | string_data numexpr QUOTEDSTRING
1127 define_stringtable
(&sub_res_info
, $2, $3);
1129 | string_data numexpr
',' QUOTEDSTRING
1131 define_stringtable
(&sub_res_info
, $2, $4);
1135 /* User defined resources. We accept general suboptions in the
1136 file_name case to keep the parser happy. */
1139 id id suboptions BEG optrcdata_data END
1141 define_user_data
($1, $2, &$3, $5.first
);
1143 | id id suboptions file_name
1145 define_user_file
($1, $2, &$3, $4);
1149 /* Versioninfo resources. */
1152 id VERSIONINFO fixedverinfo BEG verblocks END
1154 define_versioninfo
($1, language
, $3, $5);
1161 $$
= ((struct fixed_versioninfo
*)
1162 res_alloc
(sizeof
(struct fixed_versioninfo
)));
1163 memset
($$
, 0, sizeof
(struct fixed_versioninfo
));
1165 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1167 $1->file_version_ms
= ($3 << 16) |
$4;
1168 $1->file_version_ls
= ($5 << 16) |
$6;
1171 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1173 $1->product_version_ms
= ($3 << 16) |
$4;
1174 $1->product_version_ls
= ($5 << 16) |
$6;
1177 | fixedverinfo FILEFLAGSMASK numexpr
1179 $1->file_flags_mask
= $3;
1182 | fixedverinfo FILEFLAGS numexpr
1184 $1->file_flags
= $3;
1187 | fixedverinfo FILEOS numexpr
1192 | fixedverinfo FILETYPE numexpr
1197 | fixedverinfo FILESUBTYPE numexpr
1199 $1->file_subtype
= $3;
1204 /* To handle verblocks successfully, the lexer handles BLOCK
1205 specially. A BLOCK "StringFileInfo" is returned as
1206 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1207 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1208 with the string as the value. */
1215 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1217 $$
= append_ver_stringfileinfo
($1, $4, $6);
1219 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1221 $$
= append_ver_varfileinfo
($1, $5, $6);
1230 | vervals VALUE QUOTEDSTRING
',' QUOTEDSTRING
1232 $$
= append_verval
($1, $3, $5);
1241 | vertrans cnumexpr cnumexpr
1243 $$
= append_vertrans
($1, $2, $3);
1247 /* A resource ID. */
1259 /* It seems that resource ID's are forced to upper case. */
1260 copy
= xstrdup
($1);
1261 for
(s
= copy
; *s
!= '\0'; s
++)
1262 if
(islower
((unsigned char) *s
))
1263 *s
= toupper
((unsigned char) *s
);
1264 res_string_to_id
(&$$
, copy
);
1269 /* A resource reference. */
1297 /* It seems that resource ID's are forced to upper case. */
1298 copy
= xstrdup
($1);
1299 for
(s
= copy
; *s
!= '\0'; s
++)
1300 if
(islower
((unsigned char) *s
))
1301 *s
= toupper
((unsigned char) *s
);
1302 res_string_to_id
(&$$
, copy
);
1307 /* Generic suboptions. These may appear before the BEGIN in any
1308 multiline statement. */
1313 memset
(&$$
, 0, sizeof
(struct res_res_info
));
1314 $$.language
= language
;
1315 /* FIXME: Is this the right default? */
1316 $$.memflags
= MEMFLAG_MOVEABLE
;
1318 | suboptions memflag
1321 $$.memflags |
= $2.on
;
1322 $$.memflags
&=~
$2.off
;
1324 | suboptions CHARACTERISTICS numexpr
1327 $$.characteristics
= $3;
1329 | suboptions LANGUAGE numexpr cnumexpr
1332 $$.language
= $3 |
($4 << 8);
1334 | suboptions VERSIONK numexpr
1341 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1343 memflags_move_discard:
1346 memset
(&$$
, 0, sizeof
(struct res_res_info
));
1347 $$.language
= language
;
1348 $$.memflags
= MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE
;
1350 | memflags_move_discard memflag
1353 $$.memflags |
= $2.on
;
1354 $$.memflags
&=~
$2.off
;
1358 /* Memory flags which default to MOVEABLE. */
1363 memset
(&$$
, 0, sizeof
(struct res_res_info
));
1364 $$.language
= language
;
1365 $$.memflags
= MEMFLAG_MOVEABLE
;
1367 | memflags_move memflag
1370 $$.memflags |
= $2.on
;
1371 $$.memflags
&=~
$2.off
;
1375 /* Memory flags. This returns a struct with two integers, because we
1376 sometimes want to set bits and we sometimes want to clear them. */
1381 $$.on
= MEMFLAG_MOVEABLE
;
1387 $$.off
= MEMFLAG_MOVEABLE
;
1391 $$.on
= MEMFLAG_PURE
;
1397 $$.off
= MEMFLAG_PURE
;
1401 $$.on
= MEMFLAG_PRELOAD
;
1407 $$.off
= MEMFLAG_PRELOAD
;
1411 $$.on
= MEMFLAG_DISCARDABLE
;
1429 /* A style expression. This changes the static variable STYLE. We do
1430 it this way because rc appears to permit a style to be set to
1432 WS_GROUP | NOT WS_TABSTOP
1433 to mean that a default of WS_TABSTOP should be removed. Anything
1434 which wants to accept a style must first set STYLE to the default
1435 value. The styleexpr nonterminal will change STYLE as specified by
1436 the user. Note that we do not accept arbitrary expressions here,
1437 just numbers separated by '|'. */
1448 | styleexpr
'|' parennumber
1452 | styleexpr
'|' NOT parennumber
1469 /* An optional expression with a leading comma. */
1482 /* An expression with a leading comma. */
1491 /* A possibly negated numeric expression. */
1500 /* A possibly negated expression with a size. */
1507 |
'(' sizednumexpr
')'
1511 |
'~' sizednumexpr %prec
'~'
1514 $$.dword
= $2.dword
;
1516 |
'-' sizednumexpr %prec NEG
1519 $$.dword
= $2.dword
;
1521 | sizednumexpr
'*' sizednumexpr
1523 $$.val
= $1.val
* $3.val
;
1524 $$.dword
= $1.dword ||
$3.dword
;
1526 | sizednumexpr
'/' sizednumexpr
1528 $$.val
= $1.val
/ $3.val
;
1529 $$.dword
= $1.dword ||
$3.dword
;
1531 | sizednumexpr
'%' sizednumexpr
1533 $$.val
= $1.val %
$3.val
;
1534 $$.dword
= $1.dword ||
$3.dword
;
1536 | sizednumexpr
'+' sizednumexpr
1538 $$.val
= $1.val
+ $3.val
;
1539 $$.dword
= $1.dword ||
$3.dword
;
1541 | sizednumexpr
'-' sizednumexpr
1543 $$.val
= $1.val
- $3.val
;
1544 $$.dword
= $1.dword ||
$3.dword
;
1546 | sizednumexpr
'&' sizednumexpr
1548 $$.val
= $1.val
& $3.val
;
1549 $$.dword
= $1.dword ||
$3.dword
;
1551 | sizednumexpr
'^' sizednumexpr
1553 $$.val
= $1.val ^
$3.val
;
1554 $$.dword
= $1.dword ||
$3.dword
;
1556 | sizednumexpr
'|' sizednumexpr
1558 $$.val
= $1.val |
$3.val
;
1559 $$.dword
= $1.dword ||
$3.dword
;
1563 /* An expression with a leading comma which does not use unary
1573 /* An expression which does not use unary negation. */
1582 /* An expression which does not use unary negation. We separate unary
1583 negation to avoid parsing conflicts when two numeric expressions
1584 appear consecutively. */
1591 |
'(' sizednumexpr
')'
1595 |
'~' sizednumexpr %prec
'~'
1598 $$.dword
= $2.dword
;
1600 | sizedposnumexpr
'*' sizednumexpr
1602 $$.val
= $1.val
* $3.val
;
1603 $$.dword
= $1.dword ||
$3.dword
;
1605 | sizedposnumexpr
'/' sizednumexpr
1607 $$.val
= $1.val
/ $3.val
;
1608 $$.dword
= $1.dword ||
$3.dword
;
1610 | sizedposnumexpr
'%' sizednumexpr
1612 $$.val
= $1.val %
$3.val
;
1613 $$.dword
= $1.dword ||
$3.dword
;
1615 | sizedposnumexpr
'+' sizednumexpr
1617 $$.val
= $1.val
+ $3.val
;
1618 $$.dword
= $1.dword ||
$3.dword
;
1620 | sizedposnumexpr
'-' sizednumexpr
1622 $$.val
= $1.val
- $3.val
;
1623 $$.dword
= $1.dword ||
$3.dword
;
1625 | sizedposnumexpr
'&' sizednumexpr
1627 $$.val
= $1.val
& $3.val
;
1628 $$.dword
= $1.dword ||
$3.dword
;
1630 | sizedposnumexpr
'^' sizednumexpr
1632 $$.val
= $1.val ^
$3.val
;
1633 $$.dword
= $1.dword ||
$3.dword
;
1635 | sizedposnumexpr
'|' sizednumexpr
1637 $$.val
= $1.val |
$3.val
;
1638 $$.dword
= $1.dword ||
$3.dword
;
1644 /* Set the language from the command line. */
1647 rcparse_set_language
(lang
)