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;
344 styles BEG controls END
346 define_dialog ($1, &sub_res_info, &dialog);
348 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
351 memset (&dialog, 0, sizeof dialog);
356 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
358 dialog.menu.named = 1;
359 dialog.class.named = 1;
361 dialog.ex = ((struct dialog_ex *)
362 res_alloc (sizeof (struct dialog_ex)));
363 memset (dialog.ex, 0, sizeof (struct dialog_ex));
364 dialog.controls = NULL;
367 styles BEG controls END
369 define_dialog ($1, &sub_res_info, &dialog);
371 | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
374 memset (&dialog, 0, sizeof dialog);
379 dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
381 dialog.menu.named = 1;
382 dialog.class.named = 1;
384 dialog.ex = ((struct dialog_ex *)
385 res_alloc (sizeof (struct dialog_ex)));
386 memset (dialog.ex, 0, sizeof (struct dialog_ex));
387 dialog.ex->help = $9;
388 dialog.controls = NULL;
391 styles BEG controls END
393 define_dialog ($1, &sub_res_info, &dialog);
402 | EXSTYLE '=' numexpr
410 | styles CAPTION QUOTEDSTRING
412 unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
419 { style = dialog.style; }
422 dialog.style = style;
424 | styles EXSTYLE numexpr
428 | styles CLASS QUOTEDSTRING
430 res_string_to_id (& dialog.class, $3);
432 | styles FONT numexpr ',' QUOTEDSTRING
434 dialog.style |= DS_SETFONT;
435 dialog.pointsize = $3;
436 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
438 | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
440 dialog.style |= DS_SETFONT;
441 dialog.pointsize = $3;
442 unicode_from_ascii ((int *) NULL, &dialog.font, $5);
443 if (dialog.ex == NULL)
444 rcparse_warning (_("extended FONT requires DIALOGEX"));
447 dialog.ex->weight = $6;
448 dialog.ex->italic = $7;
455 | styles CHARACTERISTICS numexpr
457 sub_res_info.characteristics = $3;
459 | styles LANGUAGE numexpr cnumexpr
461 sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT);
463 | styles VERSIONK numexpr
465 sub_res_info.version = $3;
473 struct dialog_control **pp;
475 for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
484 default_style = BS_AUTO3STATE | WS_TABSTOP;
485 base_style = BS_AUTO3STATE;
494 default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
495 base_style = BS_AUTOCHECKBOX;
504 default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
505 base_style = BS_AUTORADIOBUTTON;
514 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
515 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
521 if (dialog.ex == NULL)
522 rcparse_warning (_("BEDIT requires DIALOGEX"));
523 res_string_to_id (&$$->class, "BEDIT");
527 default_style = BS_CHECKBOX | WS_TABSTOP;
528 base_style = BS_CHECKBOX | WS_TABSTOP;
537 default_style = CBS_SIMPLE | WS_TABSTOP;
539 class = CTL_COMBOBOX;
545 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
546 cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
548 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
551 if (dialog.ex == NULL)
552 rcparse_warning (_("control data requires DIALOGEX"));
556 | CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
557 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
559 $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
560 if (dialog.ex == NULL)
561 rcparse_warning (_("help ID requires DIALOGEX"));
565 | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
566 cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
568 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
571 if (dialog.ex == NULL)
572 rcparse_warning ("control data requires DIALOGEX");
576 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
578 | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
579 cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
581 $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
582 if (dialog.ex == NULL)
583 rcparse_warning ("help ID requires DIALOGEX");
587 unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
591 default_style = SS_CENTER | WS_GROUP;
592 base_style = SS_CENTER;
601 default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
602 base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
611 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
612 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
621 default_style = BS_GROUPBOX;
622 base_style = BS_GROUPBOX;
631 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
632 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
638 if (dialog.ex == NULL)
639 rcparse_warning (_("IEDIT requires DIALOGEX"));
640 res_string_to_id (&$$->class, "HEDIT");
642 | ICON resref numexpr cnumexpr cnumexpr opt_control_data
644 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
647 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
650 $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
653 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
654 icon_styleexpr optcnumexpr opt_control_data
656 $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
659 | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
660 icon_styleexpr cnumexpr cnumexpr opt_control_data
662 $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
667 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
668 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
674 if (dialog.ex == NULL)
675 rcparse_warning (_("IEDIT requires DIALOGEX"));
676 res_string_to_id (&$$->class, "IEDIT");
680 default_style = LBS_NOTIFY | WS_BORDER;
681 base_style = LBS_NOTIFY | WS_BORDER;
690 default_style = SS_LEFT | WS_GROUP;
691 base_style = SS_LEFT;
700 default_style = BS_PUSHBOX | WS_TABSTOP;
701 base_style = BS_PUSHBOX;
710 default_style = BS_PUSHBUTTON | WS_TABSTOP;
711 base_style = BS_PUSHBUTTON | WS_TABSTOP;
720 default_style = BS_RADIOBUTTON | WS_TABSTOP;
721 base_style = BS_RADIOBUTTON;
730 default_style = SS_RIGHT | WS_GROUP;
731 base_style = SS_RIGHT;
740 default_style = SBS_HORZ;
742 class = CTL_SCROLLBAR;
750 default_style = BS_3STATE | WS_TABSTOP;
751 base_style = BS_3STATE;
758 | USERBUTTON QUOTEDSTRING ',' numexpr ',' numexpr ',' numexpr ','
759 numexpr ',' numexpr ','
760 { style = WS_CHILD | WS_VISIBLE; }
761 styleexpr optcnumexpr
763 $$ = define_control ($2, $4, $6, $8, $10, $12, CTL_BUTTON,
768 /* Parameters for a control. The static variables DEFAULT_STYLE,
769 BASE_STYLE, and CLASS must be initialized before this nonterminal
770 is used. DEFAULT_STYLE is the style to use if no style expression
771 is specified. BASE_STYLE is the base style to use if a style
772 expression is specified; the style expression modifies the base
773 style. CLASS is the class of the control. */
776 optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
779 $$ = define_control ($1, $2, $3, $4, $5, $6, class,
780 default_style | WS_CHILD | WS_VISIBLE, 0);
783 if (dialog.ex == NULL)
784 rcparse_warning (_("control data requires DIALOGEX"));
788 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
789 control_params_styleexpr optcnumexpr opt_control_data
791 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
794 if (dialog.ex == NULL)
795 rcparse_warning (_("control data requires DIALOGEX"));
799 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
800 control_params_styleexpr cnumexpr cnumexpr opt_control_data
802 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
803 if (dialog.ex == NULL)
804 rcparse_warning (_("help ID requires DIALOGEX"));
830 | BEG optrcdata_data END
836 /* These only exist to parse a reduction out of a common case. */
840 { style = WS_CHILD | WS_VISIBLE; }
846 { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
850 control_params_styleexpr:
852 { style = base_style | WS_CHILD | WS_VISIBLE; }
856 /* Font resources. */
859 id FONT memflags_move_discard file_name
861 define_font ($1, &$3, $4);
865 /* Icon resources. */
868 id ICON memflags_move_discard file_name
870 define_icon ($1, &$3, $4);
874 /* Language command. This changes the static variable language, which
875 affects all subsequent resources. */
878 LANGUAGE numexpr cnumexpr
880 language = $2 | ($3 << SUBLANG_SHIFT);
884 /* Menu resources. */
887 id MENU suboptions BEG menuitems END
889 define_menu ($1, &$3, $5);
904 struct menuitem **pp;
906 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
915 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
917 $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
921 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
923 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
925 $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
934 | menuitem_flags ',' menuitem_flag
938 | menuitem_flags menuitem_flag
947 $$ = MENUITEM_CHECKED;
951 $$ = MENUITEM_GRAYED;
959 $$ = MENUITEM_INACTIVE;
963 $$ = MENUITEM_MENUBARBREAK;
967 $$ = MENUITEM_MENUBREAK;
971 /* Menuex resources. */
974 id MENUEX suboptions BEG menuexitems END
976 define_menu ($1, &$3, $5);
985 | menuexitems menuexitem
991 struct menuitem **pp;
993 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
1002 MENUITEM QUOTEDSTRING
1004 $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
1006 | MENUITEM QUOTEDSTRING cnumexpr
1008 $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
1010 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
1012 $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
1014 | MENUITEM SEPARATOR
1016 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
1018 | POPUP QUOTEDSTRING BEG menuexitems END
1020 $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
1022 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
1024 $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
1026 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
1028 $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
1030 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
1033 $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
1037 /* Messagetable resources. */
1040 id MESSAGETABLE memflags_move file_name
1042 define_messagetable ($1, &$3, $4);
1046 /* Rcdata resources. */
1049 id RCDATA suboptions BEG optrcdata_data END
1051 define_rcdata ($1, &$3, $5.first);
1055 /* We use a different lexing algorithm, because rcdata strings may
1056 contain embedded null bytes, and we need to know the length to use. */
1084 struct rcdata_item *ri;
1086 ri = define_rcdata_string ($1.s, $1.length);
1092 struct rcdata_item *ri;
1094 ri = define_rcdata_number ($1.val, $1.dword);
1098 | rcdata_data ',' SIZEDSTRING
1100 struct rcdata_item *ri;
1102 ri = define_rcdata_string ($3.s, $3.length);
1103 $$.first = $1.first;
1107 | rcdata_data ',' sizednumexpr
1109 struct rcdata_item *ri;
1111 ri = define_rcdata_number ($3.val, $3.dword);
1112 $$.first = $1.first;
1118 /* Stringtable resources. */
1121 STRINGTABLE suboptions BEG
1122 { sub_res_info = $2; }
1128 | string_data numexpr QUOTEDSTRING
1130 define_stringtable (&sub_res_info, $2, $3);
1132 | string_data numexpr ',' QUOTEDSTRING
1134 define_stringtable (&sub_res_info, $2, $4);
1138 /* User defined resources. We accept general suboptions in the
1139 file_name case to keep the parser happy. */
1142 id id suboptions BEG optrcdata_data END
1144 define_user_data ($1, $2, &$3, $5.first);
1146 | id id suboptions file_name
1148 define_user_file ($1, $2, &$3, $4);
1152 /* Versioninfo resources. */
1155 id VERSIONINFO fixedverinfo BEG verblocks END
1157 define_versioninfo ($1, language, $3, $5);
1164 $$ = ((struct fixed_versioninfo *)
1165 res_alloc (sizeof (struct fixed_versioninfo)));
1166 memset ($$, 0, sizeof (struct fixed_versioninfo));
1168 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1170 $1->file_version_ms = ($3 << 16) | $4;
1171 $1->file_version_ls = ($5 << 16) | $6;
1174 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1176 $1->product_version_ms = ($3 << 16) | $4;
1177 $1->product_version_ls = ($5 << 16) | $6;
1180 | fixedverinfo FILEFLAGSMASK numexpr
1182 $1->file_flags_mask = $3;
1185 | fixedverinfo FILEFLAGS numexpr
1187 $1->file_flags = $3;
1190 | fixedverinfo FILEOS numexpr
1195 | fixedverinfo FILETYPE numexpr
1200 | fixedverinfo FILESUBTYPE numexpr
1202 $1->file_subtype = $3;
1207 /* To handle verblocks successfully, the lexer handles BLOCK
1208 specially. A BLOCK "StringFileInfo" is returned as
1209 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1210 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1211 with the string as the value. */
1218 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1220 $$ = append_ver_stringfileinfo ($1, $4, $6);
1222 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1224 $$ = append_ver_varfileinfo ($1, $5, $6);
1233 | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
1235 $$ = append_verval ($1, $3, $5);
1244 | vertrans cnumexpr cnumexpr
1246 $$ = append_vertrans ($1, $2, $3);
1250 /* A resource ID. */
1262 /* It seems that resource ID's are forced to upper case. */
1263 copy = xstrdup ($1);
1264 for (s = copy; *s != '\0'; s++)
1266 res_string_to_id (&$$, copy);
1271 /* A resource reference. */
1299 /* It seems that resource ID's are forced to upper case. */
1300 copy = xstrdup ($1);
1301 for (s = copy; *s != '\0'; s++)
1303 res_string_to_id (&$$, copy);
1308 /* Generic suboptions. These may appear before the BEGIN in any
1309 multiline statement. */
1314 memset (&$$, 0, sizeof (struct res_res_info));
1315 $$.language = language;
1316 /* FIXME: Is this the right default? */
1317 $$.memflags = MEMFLAG_MOVEABLE;
1319 | suboptions memflag
1322 $$.memflags |= $2.on;
1323 $$.memflags &=~ $2.off;
1325 | suboptions CHARACTERISTICS numexpr
1328 $$.characteristics = $3;
1330 | suboptions LANGUAGE numexpr cnumexpr
1333 $$.language = $3 | ($4 << SUBLANG_SHIFT);
1335 | suboptions VERSIONK numexpr
1342 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1344 memflags_move_discard:
1347 memset (&$$, 0, sizeof (struct res_res_info));
1348 $$.language = language;
1349 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
1351 | memflags_move_discard memflag
1354 $$.memflags |= $2.on;
1355 $$.memflags &=~ $2.off;
1359 /* Memory flags which default to MOVEABLE. */
1364 memset (&$$, 0, sizeof (struct res_res_info));
1365 $$.language = language;
1366 $$.memflags = MEMFLAG_MOVEABLE;
1368 | memflags_move memflag
1371 $$.memflags |= $2.on;
1372 $$.memflags &=~ $2.off;
1376 /* Memory flags. This returns a struct with two integers, because we
1377 sometimes want to set bits and we sometimes want to clear them. */
1382 $$.on = MEMFLAG_MOVEABLE;
1388 $$.off = MEMFLAG_MOVEABLE;
1392 $$.on = MEMFLAG_PURE;
1398 $$.off = MEMFLAG_PURE;
1402 $$.on = MEMFLAG_PRELOAD;
1408 $$.off = MEMFLAG_PRELOAD;
1412 $$.on = MEMFLAG_DISCARDABLE;
1430 /* A style expression. This changes the static variable STYLE. We do
1431 it this way because rc appears to permit a style to be set to
1433 WS_GROUP | NOT WS_TABSTOP
1434 to mean that a default of WS_TABSTOP should be removed. Anything
1435 which wants to accept a style must first set STYLE to the default
1436 value. The styleexpr nonterminal will change STYLE as specified by
1437 the user. Note that we do not accept arbitrary expressions here,
1438 just numbers separated by '|'. */
1449 | styleexpr '|' parennumber
1453 | styleexpr '|' NOT parennumber
1470 /* An optional expression with a leading comma. */
1483 /* An expression with a leading comma. */
1492 /* A possibly negated numeric expression. */
1501 /* A possibly negated expression with a size. */
1508 | '(' sizednumexpr ')'
1512 | '~' sizednumexpr %prec '~'
1515 $$.dword = $2.dword;
1517 | '-' sizednumexpr %prec NEG
1520 $$.dword = $2.dword;
1522 | sizednumexpr '*' sizednumexpr
1524 $$.val = $1.val * $3.val;
1525 $$.dword = $1.dword || $3.dword;
1527 | sizednumexpr '/' sizednumexpr
1529 $$.val = $1.val / $3.val;
1530 $$.dword = $1.dword || $3.dword;
1532 | sizednumexpr '%' sizednumexpr
1534 $$.val = $1.val % $3.val;
1535 $$.dword = $1.dword || $3.dword;
1537 | sizednumexpr '+' sizednumexpr
1539 $$.val = $1.val + $3.val;
1540 $$.dword = $1.dword || $3.dword;
1542 | sizednumexpr '-' sizednumexpr
1544 $$.val = $1.val - $3.val;
1545 $$.dword = $1.dword || $3.dword;
1547 | sizednumexpr '&' sizednumexpr
1549 $$.val = $1.val & $3.val;
1550 $$.dword = $1.dword || $3.dword;
1552 | sizednumexpr '^' sizednumexpr
1554 $$.val = $1.val ^ $3.val;
1555 $$.dword = $1.dword || $3.dword;
1557 | sizednumexpr '|' sizednumexpr
1559 $$.val = $1.val | $3.val;
1560 $$.dword = $1.dword || $3.dword;
1564 /* An expression with a leading comma which does not use unary
1574 /* An expression which does not use unary negation. */
1583 /* An expression which does not use unary negation. We separate unary
1584 negation to avoid parsing conflicts when two numeric expressions
1585 appear consecutively. */
1592 | '(' sizednumexpr ')'
1596 | '~' sizednumexpr %prec '~'
1599 $$.dword = $2.dword;
1601 | sizedposnumexpr '*' sizednumexpr
1603 $$.val = $1.val * $3.val;
1604 $$.dword = $1.dword || $3.dword;
1606 | sizedposnumexpr '/' sizednumexpr
1608 $$.val = $1.val / $3.val;
1609 $$.dword = $1.dword || $3.dword;
1611 | sizedposnumexpr '%' sizednumexpr
1613 $$.val = $1.val % $3.val;
1614 $$.dword = $1.dword || $3.dword;
1616 | sizedposnumexpr '+' sizednumexpr
1618 $$.val = $1.val + $3.val;
1619 $$.dword = $1.dword || $3.dword;
1621 | sizedposnumexpr '-' sizednumexpr
1623 $$.val = $1.val - $3.val;
1624 $$.dword = $1.dword || $3.dword;
1626 | sizedposnumexpr '&' sizednumexpr
1628 $$.val = $1.val & $3.val;
1629 $$.dword = $1.dword || $3.dword;
1631 | sizedposnumexpr '^' sizednumexpr
1633 $$.val = $1.val ^ $3.val;
1634 $$.dword = $1.dword || $3.dword;
1636 | sizedposnumexpr '|' sizednumexpr
1638 $$.val = $1.val | $3.val;
1639 $$.dword = $1.dword || $3.dword;
1645 /* Set the language from the command line. */
1648 rcparse_set_language (lang)