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
126 %type <pacc> acc_entries
127 %type <acc> acc_entry acc_event
128 %type <dialog_control> control control_params
129 %type <menuitem> menuitems menuitem menuexitems menuexitem
130 %type <rcdata> optrcdata_data optrcdata_data_int rcdata_data
131 %type <rcdata_item> opt_control_data
132 %type <fixver> fixedverinfo
133 %type <verinfo> verblocks
134 %type <verstring> vervals
135 %type <vervar> vertrans
136 %type <res_info> suboptions memflags_move_discard memflags_move
137 %type <memflags> memflag
139 %type <il> exstyle parennumber
140 %type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
141 %type <is> acc_options acc_option menuitem_flags menuitem_flag
142 %type <s> optstringc file_name
143 %type <i> sizednumexpr sizedposnumexpr
156 | input newcmd accelerator
157 | input newcmd bitmap
158 | input newcmd cursor
159 | input newcmd dialog
162 | input newcmd language
164 | input newcmd menuex
165 | input newcmd messagetable
166 | input newcmd rcdata
167 | input newcmd stringtable
169 | input newcmd versioninfo
175 rcparse_discard_strings ();
179 /* Accelerator resources. */
182 id ACCELERATORS suboptions BEG acc_entries END
184 define_accelerator ($1, &$3, $5);
193 | acc_entries acc_entry
195 struct accelerator *a;
197 a = (struct accelerator *) res_alloc (sizeof *a);
203 struct accelerator **pp;
205 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
214 acc_event cposnumexpr
219 | acc_event cposnumexpr ',' acc_options
224 if (($$.flags & ACC_VIRTKEY) == 0
225 && ($$.flags & (ACC_SHIFT | ACC_CONTROL | ACC_ALT)) != 0)
226 rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
243 $$.flags = ACC_CONTROL | ACC_VIRTKEY;
246 ch = toupper ((unsigned char) ch);
250 rcparse_warning (_("accelerator should only be one character"));
266 | acc_options ',' acc_option
270 /* I've had one report that the comma is optional. */
271 | acc_options acc_option
284 /* This is just the absence of VIRTKEY. */
305 /* Bitmap resources. */
308 id BITMAP memflags_move file_name
310 define_bitmap ($1, &$3, $4);
314 /* Cursor resources. */
317 id CURSOR memflags_move_discard file_name
319 define_cursor ($1, &$3, $4);
323 /* Dialog resources. */
326 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
329 memset (&dialog, 0, sizeof dialog);
334 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
336 dialog.menu.named = 1;
337 dialog.class.named = 1;
340 dialog.controls = NULL;
343 styles BEG controls END
345 define_dialog ($1, &sub_res_info, &dialog);
347 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
350 memset (&dialog, 0, sizeof dialog);
355 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
357 dialog.menu.named = 1;
358 dialog.class.named = 1;
360 dialog.ex = ((struct dialog_ex *)
361 res_alloc (sizeof (struct dialog_ex)));
362 memset (dialog.ex, 0, sizeof (struct dialog_ex));
363 dialog.controls = NULL;
366 styles BEG controls END
368 define_dialog ($1, &sub_res_info, &dialog);
370 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
373 memset (&dialog, 0, sizeof dialog);
378 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
380 dialog.menu.named = 1;
381 dialog.class.named = 1;
383 dialog.ex = ((struct dialog_ex *)
384 res_alloc (sizeof (struct dialog_ex)));
385 memset (dialog.ex, 0, sizeof (struct dialog_ex));
386 dialog.ex->help = $9;
387 dialog.controls = NULL;
390 styles BEG controls END
392 define_dialog ($1, &sub_res_info, &dialog);
401 | EXSTYLE '=' numexpr
409 | styles CAPTION QUOTEDSTRING
411 unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
418 { style = dialog.style; }
421 dialog.style = style;
423 | styles EXSTYLE numexpr
427 | styles FONT numexpr ',' QUOTEDSTRING
429 dialog.style |= DS_SETFONT;
430 dialog.pointsize = $3;
431 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
433 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
435 dialog.style |= DS_SETFONT;
436 dialog.pointsize = $3;
437 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
438 if (dialog.ex == NULL)
439 rcparse_warning (_("extended FONT requires DIALOGEX"));
442 dialog.ex->weight = $6;
443 dialog.ex->italic = $7;
450 | styles CHARACTERISTICS numexpr
452 sub_res_info.characteristics = $3;
454 | styles LANGUAGE numexpr cnumexpr
456 sub_res_info.language = $3 | ($4 << 8);
458 | styles VERSIONK numexpr
460 sub_res_info.version = $3;
468 struct dialog_control **pp;
470 for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
479 default_style = BS_AUTO3STATE | WS_TABSTOP;
480 base_style = BS_AUTO3STATE;
489 default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
490 base_style = BS_AUTOCHECKBOX;
499 default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
500 base_style = BS_AUTORADIOBUTTON;
509 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
510 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
516 if (dialog.ex == NULL)
517 rcparse_warning (_("IEDIT requires DIALOGEX"));
518 res_string_to_id (&$$->class, "BEDIT");
522 default_style = BS_CHECKBOX | WS_TABSTOP;
523 base_style = BS_CHECKBOX | WS_TABSTOP;
532 default_style = CBS_SIMPLE | WS_TABSTOP;
534 class = CTL_COMBOBOX;
540 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
541 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
543 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
546 if (dialog.ex == NULL)
547 rcparse_warning (_("control data requires DIALOGEX"));
551 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
552 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
554 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
555 if (dialog.ex == NULL)
556 rcparse_warning (_("help ID requires DIALOGEX"));
560 | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
561 cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
563 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
566 if (dialog.ex == NULL)
567 rcparse_warning ("control data requires DIALOGEX");
571 unicode_from_ascii(&$$->class.u.n.length, &$$->class.u.n.name, $5);
573 | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
574 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
576 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
577 if (dialog.ex == NULL)
578 rcparse_warning ("help ID requires DIALOGEX");
582 unicode_from_ascii(&$$->class.u.n.length, &$$->class.u.n.name, $5);
586 default_style = SS_CENTER | WS_GROUP;
587 base_style = SS_CENTER;
596 default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
597 base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
606 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
607 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
616 default_style = BS_GROUPBOX;
617 base_style = BS_GROUPBOX;
626 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
627 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
633 if (dialog.ex == NULL)
634 rcparse_warning (_("IEDIT requires DIALOGEX"));
635 res_string_to_id (&$$->class, "HEDIT");
637 | ICON optstringc numexpr cnumexpr cnumexpr opt_control_data
639 $$ = define_control ($2, $3, $4, $5, 0, 0, CTL_STATIC,
640 SS_ICON | WS_CHILD | WS_VISIBLE, 0);
643 if (dialog.ex == NULL)
644 rcparse_warning (_("control data requires DIALOGEX"));
648 | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
649 icon_styleexpr optcnumexpr opt_control_data
651 $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
655 if (dialog.ex == NULL)
656 rcparse_warning (_("control data requires DIALOGEX"));
660 | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
661 icon_styleexpr cnumexpr cnumexpr opt_control_data
663 $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
665 if (dialog.ex == NULL)
666 rcparse_warning (_("help ID requires DIALOGEX"));
672 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
673 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
679 if (dialog.ex == NULL)
680 rcparse_warning (_("IEDIT requires DIALOGEX"));
681 res_string_to_id (&$$->class, "IEDIT");
685 default_style = LBS_NOTIFY | WS_BORDER;
686 base_style = LBS_NOTIFY | WS_BORDER;
695 default_style = SS_LEFT | WS_GROUP;
696 base_style = SS_LEFT;
705 default_style = BS_PUSHBOX | WS_TABSTOP;
706 base_style = BS_PUSHBOX;
715 default_style = BS_PUSHBUTTON | WS_TABSTOP;
716 base_style = BS_PUSHBUTTON | WS_TABSTOP;
725 default_style = BS_RADIOBUTTON | WS_TABSTOP;
726 base_style = BS_RADIOBUTTON;
735 default_style = SS_RIGHT | WS_GROUP;
736 base_style = SS_RIGHT;
745 default_style = SBS_HORZ;
747 class = CTL_SCROLLBAR;
755 default_style = BS_3STATE | WS_TABSTOP;
756 base_style = BS_3STATE;
763 | USERBUTTON QUOTEDSTRING ',' numexpr ',' numexpr ',' numexpr ','
764 numexpr ',' numexpr ','
765 { style = WS_CHILD | WS_VISIBLE; }
766 styleexpr optcnumexpr
768 $$ = define_control ($2, $4, $6, $8, $10, $12, CTL_BUTTON,
773 /* Parameters for a control. The static variables DEFAULT_STYLE,
774 BASE_STYLE, and CLASS must be initialized before this nonterminal
775 is used. DEFAULT_STYLE is the style to use if no style expression
776 is specified. BASE_STYLE is the base style to use if a style
777 expression is specified; the style expression modifies the base
778 style. CLASS is the class of the control. */
781 optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
784 $$ = define_control ($1, $2, $3, $4, $5, $6, class,
785 default_style | WS_CHILD | WS_VISIBLE, 0);
788 if (dialog.ex == NULL)
789 rcparse_warning (_("control data requires DIALOGEX"));
793 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
794 control_params_styleexpr optcnumexpr opt_control_data
796 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
799 if (dialog.ex == NULL)
800 rcparse_warning (_("control data requires DIALOGEX"));
804 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
805 control_params_styleexpr cnumexpr cnumexpr opt_control_data
807 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
808 if (dialog.ex == NULL)
809 rcparse_warning (_("help ID requires DIALOGEX"));
831 | BEG optrcdata_data END
837 /* These only exist to parse a reduction out of a common case. */
841 { style = WS_CHILD | WS_VISIBLE; }
847 { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
851 control_params_styleexpr:
853 { style = base_style | WS_CHILD | WS_VISIBLE; }
857 /* Font resources. */
860 id FONT memflags_move_discard file_name
862 define_font ($1, &$3, $4);
866 /* Icon resources. */
869 id ICON memflags_move_discard file_name
871 define_icon ($1, &$3, $4);
875 /* Language command. This changes the static variable language, which
876 affects all subsequent resources. */
879 LANGUAGE numexpr cnumexpr
881 language = $2 | ($3 << 8);
885 /* Menu resources. */
888 id MENU suboptions BEG menuitems END
890 define_menu ($1, &$3, $5);
905 struct menuitem **pp;
907 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
916 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
918 $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
922 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
924 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
926 $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
935 | menuitem_flags ',' menuitem_flag
939 | menuitem_flags menuitem_flag
948 $$ = MENUITEM_CHECKED;
952 $$ = MENUITEM_GRAYED;
960 $$ = MENUITEM_INACTIVE;
964 $$ = MENUITEM_MENUBARBREAK;
968 $$ = MENUITEM_MENUBREAK;
972 /* Menuex resources. */
975 id MENUEX suboptions BEG menuexitems END
977 define_menu ($1, &$3, $5);
986 | menuexitems menuexitem
992 struct menuitem **pp;
994 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
1003 MENUITEM QUOTEDSTRING
1005 $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
1007 | MENUITEM QUOTEDSTRING cnumexpr
1009 $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
1011 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
1013 $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
1015 | MENUITEM SEPARATOR
1017 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
1019 | POPUP QUOTEDSTRING BEG menuexitems END
1021 $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
1023 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
1025 $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
1027 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
1029 $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
1031 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
1034 $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
1038 /* Messagetable resources. */
1041 id MESSAGETABLE memflags_move file_name
1043 define_messagetable ($1, &$3, $4);
1047 /* Rcdata resources. */
1050 id RCDATA suboptions BEG optrcdata_data END
1052 define_rcdata ($1, &$3, $5.first);
1056 /* We use a different lexing algorithm, because rcdata strings may
1057 contain embedded null bytes, and we need to know the length to use. */
1085 struct rcdata_item *ri;
1087 ri = define_rcdata_string ($1.s, $1.length);
1093 struct rcdata_item *ri;
1095 ri = define_rcdata_number ($1.val, $1.dword);
1099 | rcdata_data ',' SIZEDSTRING
1101 struct rcdata_item *ri;
1103 ri = define_rcdata_string ($3.s, $3.length);
1104 $$.first = $1.first;
1108 | rcdata_data ',' sizednumexpr
1110 struct rcdata_item *ri;
1112 ri = define_rcdata_number ($3.val, $3.dword);
1113 $$.first = $1.first;
1119 /* Stringtable resources. */
1122 STRINGTABLE suboptions BEG
1123 { sub_res_info = $2; }
1129 | string_data numexpr QUOTEDSTRING
1131 define_stringtable (&sub_res_info, $2, $3);
1133 | string_data numexpr ',' QUOTEDSTRING
1135 define_stringtable (&sub_res_info, $2, $4);
1139 /* User defined resources. We accept general suboptions in the
1140 file_name case to keep the parser happy. */
1143 id id suboptions BEG optrcdata_data END
1145 define_user_data ($1, $2, &$3, $5.first);
1147 | id id suboptions file_name
1149 define_user_file ($1, $2, &$3, $4);
1153 /* Versioninfo resources. */
1156 id VERSIONINFO fixedverinfo BEG verblocks END
1158 define_versioninfo ($1, language, $3, $5);
1165 $$ = ((struct fixed_versioninfo *)
1166 res_alloc (sizeof (struct fixed_versioninfo)));
1167 memset ($$, 0, sizeof (struct fixed_versioninfo));
1169 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1171 $1->file_version_ms = ($3 << 16) | $4;
1172 $1->file_version_ls = ($5 << 16) | $6;
1175 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1177 $1->product_version_ms = ($3 << 16) | $4;
1178 $1->product_version_ls = ($5 << 16) | $6;
1181 | fixedverinfo FILEFLAGSMASK numexpr
1183 $1->file_flags_mask = $3;
1186 | fixedverinfo FILEFLAGS numexpr
1188 $1->file_flags = $3;
1191 | fixedverinfo FILEOS numexpr
1196 | fixedverinfo FILETYPE numexpr
1201 | fixedverinfo FILESUBTYPE numexpr
1203 $1->file_subtype = $3;
1208 /* To handle verblocks successfully, the lexer handles BLOCK
1209 specially. A BLOCK "StringFileInfo" is returned as
1210 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1211 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1212 with the string as the value. */
1219 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1221 $$ = append_ver_stringfileinfo ($1, $4, $6);
1223 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1225 $$ = append_ver_varfileinfo ($1, $5, $6);
1234 | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
1236 $$ = append_verval ($1, $3, $5);
1245 | vertrans cnumexpr cnumexpr
1247 $$ = append_vertrans ($1, $2, $3);
1251 /* A resource ID. */
1263 /* It seems that resource ID's are forced to upper case. */
1264 copy = xstrdup ($1);
1265 for (s = copy; *s != '\0'; s++)
1266 if (islower ((unsigned char) *s))
1267 *s = toupper ((unsigned char) *s);
1268 res_string_to_id (&$$, copy);
1273 /* Generic suboptions. These may appear before the BEGIN in any
1274 multiline statement. */
1279 memset (&$$, 0, sizeof (struct res_res_info));
1280 $$.language = language;
1281 /* FIXME: Is this the right default? */
1282 $$.memflags = MEMFLAG_MOVEABLE;
1284 | suboptions memflag
1287 $$.memflags |= $2.on;
1288 $$.memflags &=~ $2.off;
1290 | suboptions CHARACTERISTICS numexpr
1293 $$.characteristics = $3;
1295 | suboptions LANGUAGE numexpr cnumexpr
1298 $$.language = $3 | ($4 << 8);
1300 | suboptions VERSIONK numexpr
1307 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1309 memflags_move_discard:
1312 memset (&$$, 0, sizeof (struct res_res_info));
1313 $$.language = language;
1314 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
1316 | memflags_move_discard memflag
1319 $$.memflags |= $2.on;
1320 $$.memflags &=~ $2.off;
1324 /* Memory flags which default to MOVEABLE. */
1329 memset (&$$, 0, sizeof (struct res_res_info));
1330 $$.language = language;
1331 $$.memflags = MEMFLAG_MOVEABLE;
1333 | memflags_move memflag
1336 $$.memflags |= $2.on;
1337 $$.memflags &=~ $2.off;
1341 /* Memory flags. This returns a struct with two integers, because we
1342 sometimes want to set bits and we sometimes want to clear them. */
1347 $$.on = MEMFLAG_MOVEABLE;
1353 $$.off = MEMFLAG_MOVEABLE;
1357 $$.on = MEMFLAG_PURE;
1363 $$.off = MEMFLAG_PURE;
1367 $$.on = MEMFLAG_PRELOAD;
1373 $$.off = MEMFLAG_PRELOAD;
1377 $$.on = MEMFLAG_DISCARDABLE;
1395 /* A style expression. This changes the static variable STYLE. We do
1396 it this way because rc appears to permit a style to be set to
1398 WS_GROUP | NOT WS_TABSTOP
1399 to mean that a default of WS_TABSTOP should be removed. Anything
1400 which wants to accept a style must first set STYLE to the default
1401 value. The styleexpr nonterminal will change STYLE as specified by
1402 the user. Note that we do not accept arbitrary expressions here,
1403 just numbers separated by '|'. */
1414 | styleexpr '|' parennumber
1418 | styleexpr '|' NOT parennumber
1435 /* An optional expression with a leading comma. */
1448 /* An expression with a leading comma. */
1457 /* A possibly negated numeric expression. */
1466 /* A possibly negated expression with a size. */
1473 | '(' sizednumexpr ')'
1477 | '~' sizednumexpr %prec '~'
1480 $$.dword = $2.dword;
1482 | '-' sizednumexpr %prec NEG
1485 $$.dword = $2.dword;
1487 | sizednumexpr '*' sizednumexpr
1489 $$.val = $1.val * $3.val;
1490 $$.dword = $1.dword || $3.dword;
1492 | sizednumexpr '/' sizednumexpr
1494 $$.val = $1.val / $3.val;
1495 $$.dword = $1.dword || $3.dword;
1497 | sizednumexpr '%' sizednumexpr
1499 $$.val = $1.val % $3.val;
1500 $$.dword = $1.dword || $3.dword;
1502 | sizednumexpr '+' sizednumexpr
1504 $$.val = $1.val + $3.val;
1505 $$.dword = $1.dword || $3.dword;
1507 | sizednumexpr '-' sizednumexpr
1509 $$.val = $1.val - $3.val;
1510 $$.dword = $1.dword || $3.dword;
1512 | sizednumexpr '&' sizednumexpr
1514 $$.val = $1.val & $3.val;
1515 $$.dword = $1.dword || $3.dword;
1517 | sizednumexpr '^' sizednumexpr
1519 $$.val = $1.val ^ $3.val;
1520 $$.dword = $1.dword || $3.dword;
1522 | sizednumexpr '|' sizednumexpr
1524 $$.val = $1.val | $3.val;
1525 $$.dword = $1.dword || $3.dword;
1529 /* An expression with a leading comma which does not use unary
1539 /* An expression which does not use unary negation. */
1548 /* An expression which does not use unary negation. We separate unary
1549 negation to avoid parsing conflicts when two numeric expressions
1550 appear consecutively. */
1557 | '(' sizednumexpr ')'
1561 | '~' sizednumexpr %prec '~'
1564 $$.dword = $2.dword;
1566 | sizedposnumexpr '*' sizednumexpr
1568 $$.val = $1.val * $3.val;
1569 $$.dword = $1.dword || $3.dword;
1571 | sizedposnumexpr '/' sizednumexpr
1573 $$.val = $1.val / $3.val;
1574 $$.dword = $1.dword || $3.dword;
1576 | sizedposnumexpr '%' sizednumexpr
1578 $$.val = $1.val % $3.val;
1579 $$.dword = $1.dword || $3.dword;
1581 | sizedposnumexpr '+' sizednumexpr
1583 $$.val = $1.val + $3.val;
1584 $$.dword = $1.dword || $3.dword;
1586 | sizedposnumexpr '-' sizednumexpr
1588 $$.val = $1.val - $3.val;
1589 $$.dword = $1.dword || $3.dword;
1591 | sizedposnumexpr '&' sizednumexpr
1593 $$.val = $1.val & $3.val;
1594 $$.dword = $1.dword || $3.dword;
1596 | sizedposnumexpr '^' sizednumexpr
1598 $$.val = $1.val ^ $3.val;
1599 $$.dword = $1.dword || $3.dword;
1601 | sizedposnumexpr '|' sizednumexpr
1603 $$.val = $1.val | $3.val;
1604 $$.dword = $1.dword || $3.dword;
1610 /* Set the language from the command line. */
1613 rcparse_set_language (lang)