1 %{ /* rcparse.y -- parser for Windows rc files
2 Copyright 1997, 1998, 1999, 2000, 2001, 2002 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"
29 #include "safe-ctype.h"
31 /* The current language. */
33 static unsigned short language;
35 /* The resource information during a sub statement. */
37 static struct res_res_info sub_res_info;
39 /* Dialog information. This is built by the nonterminals styles and
42 static struct dialog dialog;
44 /* This is used when building a style. It is modified by the
45 nonterminal styleexpr. */
47 static unsigned long style;
49 /* These are used when building a control. They are set before using
52 static unsigned long base_style;
53 static unsigned long default_style;
54 static unsigned long class;
60 struct accelerator acc;
61 struct accelerator *pacc;
62 struct dialog_control *dialog_control;
63 struct menuitem *menuitem;
66 struct rcdata_item *first;
67 struct rcdata_item *last;
69 struct rcdata_item *rcdata_item;
70 struct stringtable_data *stringtable;
71 struct fixed_versioninfo *fixver;
72 struct ver_info *verinfo;
73 struct ver_stringinfo *verstring;
74 struct ver_varinfo *vervar;
76 struct res_res_info res_info;
85 /* Nonzero if this number was explicitly specified as long. */
99 %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
102 %token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
103 %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
104 %token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
105 %token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
106 %token BEDIT HEDIT IEDIT
109 %token LANGUAGE CHARACTERISTICS VERSIONK
110 %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
111 %token MENUBARBREAK MENUBREAK
115 %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
116 %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
119 %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
121 %token <s> QUOTEDSTRING STRING
123 %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 resname
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
170 | input newcmd IGNORED_TOKEN
176 rcparse_discard_strings ();
180 /* Accelerator resources. */
183 id ACCELERATORS suboptions BEG acc_entries END
185 define_accelerator ($1, &$3, $5);
194 | acc_entries acc_entry
196 struct accelerator *a;
198 a = (struct accelerator *) res_alloc (sizeof *a);
204 struct accelerator **pp;
206 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
215 acc_event cposnumexpr
220 | acc_event cposnumexpr ',' acc_options
225 if (($$.flags & ACC_VIRTKEY) == 0
226 && ($$.flags & (ACC_SHIFT | ACC_CONTROL | ACC_ALT)) != 0)
227 rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
244 $$.flags = ACC_CONTROL | ACC_VIRTKEY;
251 rcparse_warning (_("accelerator should only be one character"));
267 | acc_options ',' acc_option
271 /* I've had one report that the comma is optional. */
272 | acc_options acc_option
285 /* This is just the absence of VIRTKEY. */
306 /* Bitmap resources. */
309 id BITMAP memflags_move file_name
311 define_bitmap ($1, &$3, $4);
315 /* Cursor resources. */
318 id CURSOR memflags_move_discard file_name
320 define_cursor ($1, &$3, $4);
324 /* Dialog resources. */
327 id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
330 memset (&dialog, 0, sizeof dialog);
335 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
337 dialog.menu.named = 1;
338 dialog.class.named = 1;
341 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;
369 styles BEG controls END
371 define_dialog ($1, &sub_res_info, &dialog);
373 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
376 memset (&dialog, 0, sizeof dialog);
381 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
383 dialog.menu.named = 1;
384 dialog.class.named = 1;
386 dialog.ex = ((struct dialog_ex *)
387 res_alloc (sizeof (struct dialog_ex)));
388 memset (dialog.ex, 0, sizeof (struct dialog_ex));
389 dialog.ex->help = $9;
390 dialog.controls = NULL;
394 styles BEG controls END
396 define_dialog ($1, &sub_res_info, &dialog);
405 | EXSTYLE '=' numexpr
413 | styles CAPTION QUOTEDSTRING
415 dialog.style |= WS_CAPTION;
417 unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
426 dialog.style = style;
428 | styles EXSTYLE numexpr
432 | styles CLASS QUOTEDSTRING
434 res_string_to_id (& dialog.class, $3);
436 | styles FONT numexpr ',' QUOTEDSTRING
438 dialog.style |= DS_SETFONT;
440 dialog.pointsize = $3;
441 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
443 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
445 dialog.style |= DS_SETFONT;
447 dialog.pointsize = $3;
448 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
449 if (dialog.ex == NULL)
450 rcparse_warning (_("extended FONT requires DIALOGEX"));
453 dialog.ex->weight = $6;
454 dialog.ex->italic = $7;
461 | styles CHARACTERISTICS numexpr
463 sub_res_info.characteristics = $3;
465 | styles LANGUAGE numexpr cnumexpr
467 sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT);
469 | styles VERSIONK numexpr
471 sub_res_info.version = $3;
479 struct dialog_control **pp;
481 for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
490 default_style = BS_AUTO3STATE | WS_TABSTOP;
491 base_style = BS_AUTO3STATE;
500 default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
501 base_style = BS_AUTOCHECKBOX;
510 default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
511 base_style = BS_AUTORADIOBUTTON;
520 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
521 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
527 if (dialog.ex == NULL)
528 rcparse_warning (_("BEDIT requires DIALOGEX"));
529 res_string_to_id (&$$->class, "BEDIT");
533 default_style = BS_CHECKBOX | WS_TABSTOP;
534 base_style = BS_CHECKBOX | WS_TABSTOP;
543 default_style = CBS_SIMPLE | WS_TABSTOP;
545 class = CTL_COMBOBOX;
551 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
552 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
554 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
557 if (dialog.ex == NULL)
558 rcparse_warning (_("control data requires DIALOGEX"));
562 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
563 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
565 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
566 if (dialog.ex == NULL)
567 rcparse_warning (_("help ID requires DIALOGEX"));
571 | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
572 cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
574 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
577 if (dialog.ex == NULL)
578 rcparse_warning ("control data requires DIALOGEX");
582 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
584 | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
585 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
587 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
588 if (dialog.ex == NULL)
589 rcparse_warning ("help ID requires DIALOGEX");
593 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
597 default_style = SS_CENTER | WS_GROUP;
598 base_style = SS_CENTER;
607 default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
608 base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
617 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
618 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
627 default_style = BS_GROUPBOX;
628 base_style = BS_GROUPBOX;
637 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
638 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
644 if (dialog.ex == NULL)
645 rcparse_warning (_("IEDIT requires DIALOGEX"));
646 res_string_to_id (&$$->class, "HEDIT");
648 | ICON resref numexpr cnumexpr cnumexpr opt_control_data
650 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
653 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
656 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
659 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
660 icon_styleexpr optcnumexpr opt_control_data
662 $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
665 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
666 icon_styleexpr cnumexpr cnumexpr opt_control_data
668 $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
673 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
674 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
680 if (dialog.ex == NULL)
681 rcparse_warning (_("IEDIT requires DIALOGEX"));
682 res_string_to_id (&$$->class, "IEDIT");
686 default_style = LBS_NOTIFY | WS_BORDER;
687 base_style = LBS_NOTIFY | WS_BORDER;
696 default_style = SS_LEFT | WS_GROUP;
697 base_style = SS_LEFT;
706 default_style = BS_PUSHBOX | WS_TABSTOP;
707 base_style = BS_PUSHBOX;
716 default_style = BS_PUSHBUTTON | WS_TABSTOP;
717 base_style = BS_PUSHBUTTON | WS_TABSTOP;
726 default_style = BS_RADIOBUTTON | WS_TABSTOP;
727 base_style = BS_RADIOBUTTON;
736 default_style = SS_RIGHT | WS_GROUP;
737 base_style = SS_RIGHT;
746 default_style = SBS_HORZ;
748 class = CTL_SCROLLBAR;
756 default_style = BS_3STATE | WS_TABSTOP;
757 base_style = BS_3STATE;
764 | USERBUTTON QUOTEDSTRING ',' numexpr ',' numexpr ',' numexpr ','
765 numexpr ',' numexpr ','
766 { style = WS_CHILD | WS_VISIBLE; }
767 styleexpr optcnumexpr
769 $$ = define_control ($2, $4, $6, $8, $10, $12, CTL_BUTTON,
774 /* Parameters for a control. The static variables DEFAULT_STYLE,
775 BASE_STYLE, and CLASS must be initialized before this nonterminal
776 is used. DEFAULT_STYLE is the style to use if no style expression
777 is specified. BASE_STYLE is the base style to use if a style
778 expression is specified; the style expression modifies the base
779 style. CLASS is the class of the control. */
782 optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
785 $$ = define_control ($1, $2, $3, $4, $5, $6, class,
786 default_style | WS_CHILD | WS_VISIBLE, 0);
789 if (dialog.ex == NULL)
790 rcparse_warning (_("control data requires DIALOGEX"));
794 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
795 control_params_styleexpr optcnumexpr opt_control_data
797 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
800 if (dialog.ex == NULL)
801 rcparse_warning (_("control data requires DIALOGEX"));
805 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
806 control_params_styleexpr cnumexpr cnumexpr opt_control_data
808 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
809 if (dialog.ex == NULL)
810 rcparse_warning (_("help ID requires DIALOGEX"));
836 | BEG optrcdata_data END
842 /* These only exist to parse a reduction out of a common case. */
846 { style = WS_CHILD | WS_VISIBLE; }
852 { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
856 control_params_styleexpr:
858 { style = base_style | WS_CHILD | WS_VISIBLE; }
862 /* Font resources. */
865 id FONT memflags_move_discard file_name
867 define_font ($1, &$3, $4);
871 /* Icon resources. */
874 id ICON memflags_move_discard file_name
876 define_icon ($1, &$3, $4);
880 /* Language command. This changes the static variable language, which
881 affects all subsequent resources. */
884 LANGUAGE numexpr cnumexpr
886 language = $2 | ($3 << SUBLANG_SHIFT);
890 /* Menu resources. */
893 id MENU suboptions BEG menuitems END
895 define_menu ($1, &$3, $5);
910 struct menuitem **pp;
912 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
921 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
923 $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
927 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
929 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
931 $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
940 | menuitem_flags ',' menuitem_flag
944 | menuitem_flags menuitem_flag
953 $$ = MENUITEM_CHECKED;
957 $$ = MENUITEM_GRAYED;
965 $$ = MENUITEM_INACTIVE;
969 $$ = MENUITEM_MENUBARBREAK;
973 $$ = MENUITEM_MENUBREAK;
977 /* Menuex resources. */
980 id MENUEX suboptions BEG menuexitems END
982 define_menu ($1, &$3, $5);
991 | menuexitems menuexitem
997 struct menuitem **pp;
999 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
1008 MENUITEM QUOTEDSTRING
1010 $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
1012 | MENUITEM QUOTEDSTRING cnumexpr
1014 $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
1016 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
1018 $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
1020 | MENUITEM SEPARATOR
1022 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
1024 | POPUP QUOTEDSTRING BEG menuexitems END
1026 $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
1028 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
1030 $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
1032 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
1034 $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
1036 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
1039 $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
1043 /* Messagetable resources. */
1046 id MESSAGETABLE memflags_move file_name
1048 define_messagetable ($1, &$3, $4);
1052 /* Rcdata resources. */
1055 id RCDATA suboptions BEG optrcdata_data END
1057 define_rcdata ($1, &$3, $5.first);
1061 /* We use a different lexing algorithm, because rcdata strings may
1062 contain embedded null bytes, and we need to know the length to use. */
1090 struct rcdata_item *ri;
1092 ri = define_rcdata_string ($1.s, $1.length);
1098 struct rcdata_item *ri;
1100 ri = define_rcdata_number ($1.val, $1.dword);
1104 | rcdata_data ',' SIZEDSTRING
1106 struct rcdata_item *ri;
1108 ri = define_rcdata_string ($3.s, $3.length);
1109 $$.first = $1.first;
1113 | rcdata_data ',' sizednumexpr
1115 struct rcdata_item *ri;
1117 ri = define_rcdata_number ($3.val, $3.dword);
1118 $$.first = $1.first;
1124 /* Stringtable resources. */
1127 STRINGTABLE suboptions BEG
1128 { sub_res_info = $2; }
1134 | string_data numexpr QUOTEDSTRING
1136 define_stringtable (&sub_res_info, $2, $3);
1138 | string_data numexpr ',' QUOTEDSTRING
1140 define_stringtable (&sub_res_info, $2, $4);
1144 /* User defined resources. We accept general suboptions in the
1145 file_name case to keep the parser happy. */
1148 id id suboptions BEG optrcdata_data END
1150 define_user_data ($1, $2, &$3, $5.first);
1152 | id id suboptions file_name
1154 define_user_file ($1, $2, &$3, $4);
1158 /* Versioninfo resources. */
1161 id VERSIONINFO fixedverinfo BEG verblocks END
1163 define_versioninfo ($1, language, $3, $5);
1170 $$ = ((struct fixed_versioninfo *)
1171 res_alloc (sizeof (struct fixed_versioninfo)));
1172 memset ($$, 0, sizeof (struct fixed_versioninfo));
1174 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1176 $1->file_version_ms = ($3 << 16) | $4;
1177 $1->file_version_ls = ($5 << 16) | $6;
1180 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1182 $1->product_version_ms = ($3 << 16) | $4;
1183 $1->product_version_ls = ($5 << 16) | $6;
1186 | fixedverinfo FILEFLAGSMASK numexpr
1188 $1->file_flags_mask = $3;
1191 | fixedverinfo FILEFLAGS numexpr
1193 $1->file_flags = $3;
1196 | fixedverinfo FILEOS numexpr
1201 | fixedverinfo FILETYPE numexpr
1206 | fixedverinfo FILESUBTYPE numexpr
1208 $1->file_subtype = $3;
1213 /* To handle verblocks successfully, the lexer handles BLOCK
1214 specially. A BLOCK "StringFileInfo" is returned as
1215 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1216 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1217 with the string as the value. */
1224 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1226 $$ = append_ver_stringfileinfo ($1, $4, $6);
1228 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1230 $$ = append_ver_varfileinfo ($1, $5, $6);
1239 | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
1241 $$ = append_verval ($1, $3, $5);
1250 | vertrans cnumexpr cnumexpr
1252 $$ = append_vertrans ($1, $2, $3);
1256 /* A resource ID. */
1268 /* It seems that resource ID's are forced to upper case. */
1269 copy = xstrdup ($1);
1270 for (s = copy; *s != '\0'; s++)
1272 res_string_to_id (&$$, copy);
1277 /* A resource reference. */
1305 /* It seems that resource ID's are forced to upper case. */
1306 copy = xstrdup ($1);
1307 for (s = copy; *s != '\0'; s++)
1309 res_string_to_id (&$$, copy);
1314 /* Generic suboptions. These may appear before the BEGIN in any
1315 multiline statement. */
1320 memset (&$$, 0, sizeof (struct res_res_info));
1321 $$.language = language;
1322 /* FIXME: Is this the right default? */
1323 $$.memflags = MEMFLAG_MOVEABLE;
1325 | suboptions memflag
1328 $$.memflags |= $2.on;
1329 $$.memflags &=~ $2.off;
1331 | suboptions CHARACTERISTICS numexpr
1334 $$.characteristics = $3;
1336 | suboptions LANGUAGE numexpr cnumexpr
1339 $$.language = $3 | ($4 << SUBLANG_SHIFT);
1341 | suboptions VERSIONK numexpr
1348 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1350 memflags_move_discard:
1353 memset (&$$, 0, sizeof (struct res_res_info));
1354 $$.language = language;
1355 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
1357 | memflags_move_discard memflag
1360 $$.memflags |= $2.on;
1361 $$.memflags &=~ $2.off;
1365 /* Memory flags which default to MOVEABLE. */
1370 memset (&$$, 0, sizeof (struct res_res_info));
1371 $$.language = language;
1372 $$.memflags = MEMFLAG_MOVEABLE;
1374 | memflags_move memflag
1377 $$.memflags |= $2.on;
1378 $$.memflags &=~ $2.off;
1382 /* Memory flags. This returns a struct with two integers, because we
1383 sometimes want to set bits and we sometimes want to clear them. */
1388 $$.on = MEMFLAG_MOVEABLE;
1394 $$.off = MEMFLAG_MOVEABLE;
1398 $$.on = MEMFLAG_PURE;
1404 $$.off = MEMFLAG_PURE;
1408 $$.on = MEMFLAG_PRELOAD;
1414 $$.off = MEMFLAG_PRELOAD;
1418 $$.on = MEMFLAG_DISCARDABLE;
1436 /* A style expression. This changes the static variable STYLE. We do
1437 it this way because rc appears to permit a style to be set to
1439 WS_GROUP | NOT WS_TABSTOP
1440 to mean that a default of WS_TABSTOP should be removed. Anything
1441 which wants to accept a style must first set STYLE to the default
1442 value. The styleexpr nonterminal will change STYLE as specified by
1443 the user. Note that we do not accept arbitrary expressions here,
1444 just numbers separated by '|'. */
1455 | styleexpr '|' parennumber
1459 | styleexpr '|' NOT parennumber
1476 /* An optional expression with a leading comma. */
1489 /* An expression with a leading comma. */
1498 /* A possibly negated numeric expression. */
1507 /* A possibly negated expression with a size. */
1514 | '(' sizednumexpr ')'
1518 | '~' sizednumexpr %prec '~'
1521 $$.dword = $2.dword;
1523 | '-' sizednumexpr %prec NEG
1526 $$.dword = $2.dword;
1528 | sizednumexpr '*' sizednumexpr
1530 $$.val = $1.val * $3.val;
1531 $$.dword = $1.dword || $3.dword;
1533 | sizednumexpr '/' sizednumexpr
1535 $$.val = $1.val / $3.val;
1536 $$.dword = $1.dword || $3.dword;
1538 | sizednumexpr '%' sizednumexpr
1540 $$.val = $1.val % $3.val;
1541 $$.dword = $1.dword || $3.dword;
1543 | sizednumexpr '+' sizednumexpr
1545 $$.val = $1.val + $3.val;
1546 $$.dword = $1.dword || $3.dword;
1548 | sizednumexpr '-' sizednumexpr
1550 $$.val = $1.val - $3.val;
1551 $$.dword = $1.dword || $3.dword;
1553 | sizednumexpr '&' sizednumexpr
1555 $$.val = $1.val & $3.val;
1556 $$.dword = $1.dword || $3.dword;
1558 | sizednumexpr '^' sizednumexpr
1560 $$.val = $1.val ^ $3.val;
1561 $$.dword = $1.dword || $3.dword;
1563 | sizednumexpr '|' sizednumexpr
1565 $$.val = $1.val | $3.val;
1566 $$.dword = $1.dword || $3.dword;
1570 /* An expression with a leading comma which does not use unary
1580 /* An expression which does not use unary negation. */
1589 /* An expression which does not use unary negation. We separate unary
1590 negation to avoid parsing conflicts when two numeric expressions
1591 appear consecutively. */
1598 | '(' sizednumexpr ')'
1602 | '~' sizednumexpr %prec '~'
1605 $$.dword = $2.dword;
1607 | sizedposnumexpr '*' sizednumexpr
1609 $$.val = $1.val * $3.val;
1610 $$.dword = $1.dword || $3.dword;
1612 | sizedposnumexpr '/' sizednumexpr
1614 $$.val = $1.val / $3.val;
1615 $$.dword = $1.dword || $3.dword;
1617 | sizedposnumexpr '%' sizednumexpr
1619 $$.val = $1.val % $3.val;
1620 $$.dword = $1.dword || $3.dword;
1622 | sizedposnumexpr '+' sizednumexpr
1624 $$.val = $1.val + $3.val;
1625 $$.dword = $1.dword || $3.dword;
1627 | sizedposnumexpr '-' sizednumexpr
1629 $$.val = $1.val - $3.val;
1630 $$.dword = $1.dword || $3.dword;
1632 | sizedposnumexpr '&' sizednumexpr
1634 $$.val = $1.val & $3.val;
1635 $$.dword = $1.dword || $3.dword;
1637 | sizedposnumexpr '^' sizednumexpr
1639 $$.val = $1.val ^ $3.val;
1640 $$.dword = $1.dword || $3.dword;
1642 | sizedposnumexpr '|' sizednumexpr
1644 $$.val = $1.val | $3.val;
1645 $$.dword = $1.dword || $3.dword;
1651 /* Set the language from the command line. */
1654 rcparse_set_language (lang)