1 %{ /* rcparse.y -- parser for Windows rc files
2 Copyright 1997 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"));
562 default_style = SS_CENTER | WS_GROUP;
563 base_style = SS_CENTER;
572 default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
573 base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
582 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
583 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
592 default_style = BS_GROUPBOX;
593 base_style = BS_GROUPBOX;
602 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
603 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
609 if (dialog.ex == NULL)
610 rcparse_warning (_("IEDIT requires DIALOGEX"));
611 res_string_to_id (&$$->class, "HEDIT");
613 | ICON optstringc numexpr cnumexpr cnumexpr opt_control_data
615 $$ = define_control ($2, $3, $4, $5, 0, 0, CTL_STATIC,
616 SS_ICON | WS_CHILD | WS_VISIBLE, 0);
619 if (dialog.ex == NULL)
620 rcparse_warning (_("control data requires DIALOGEX"));
624 | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
625 icon_styleexpr optcnumexpr opt_control_data
627 $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
631 if (dialog.ex == NULL)
632 rcparse_warning (_("control data requires DIALOGEX"));
636 | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
637 icon_styleexpr cnumexpr cnumexpr opt_control_data
639 $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
641 if (dialog.ex == NULL)
642 rcparse_warning (_("help ID requires DIALOGEX"));
648 default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
649 base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
655 if (dialog.ex == NULL)
656 rcparse_warning (_("IEDIT requires DIALOGEX"));
657 res_string_to_id (&$$->class, "IEDIT");
661 default_style = LBS_NOTIFY | WS_BORDER;
662 base_style = LBS_NOTIFY | WS_BORDER;
671 default_style = SS_LEFT | WS_GROUP;
672 base_style = SS_LEFT;
681 default_style = BS_PUSHBOX | WS_TABSTOP;
682 base_style = BS_PUSHBOX;
691 default_style = BS_PUSHBUTTON | WS_TABSTOP;
692 base_style = BS_PUSHBUTTON | WS_TABSTOP;
701 default_style = BS_RADIOBUTTON | WS_TABSTOP;
702 base_style = BS_RADIOBUTTON;
711 default_style = SS_RIGHT | WS_GROUP;
712 base_style = SS_RIGHT;
721 default_style = SBS_HORZ;
723 class = CTL_SCROLLBAR;
731 default_style = BS_3STATE | WS_TABSTOP;
732 base_style = BS_3STATE;
739 | USERBUTTON QUOTEDSTRING ',' numexpr ',' numexpr ',' numexpr ','
740 numexpr ',' numexpr ','
741 { style = WS_CHILD | WS_VISIBLE; }
742 styleexpr optcnumexpr
744 $$ = define_control ($2, $4, $6, $8, $10, $12, CTL_BUTTON,
749 /* Parameters for a control. The static variables DEFAULT_STYLE,
750 BASE_STYLE, and CLASS must be initialized before this nonterminal
751 is used. DEFAULT_STYLE is the style to use if no style expression
752 is specified. BASE_STYLE is the base style to use if a style
753 expression is specified; the style expression modifies the base
754 style. CLASS is the class of the control. */
757 optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
760 $$ = define_control ($1, $2, $3, $4, $5, $6, class,
761 default_style | WS_CHILD | WS_VISIBLE, 0);
764 if (dialog.ex == NULL)
765 rcparse_warning (_("control data requires DIALOGEX"));
769 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
770 control_params_styleexpr optcnumexpr opt_control_data
772 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
775 if (dialog.ex == NULL)
776 rcparse_warning (_("control data requires DIALOGEX"));
780 | optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
781 control_params_styleexpr cnumexpr cnumexpr opt_control_data
783 $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
784 if (dialog.ex == NULL)
785 rcparse_warning (_("help ID requires DIALOGEX"));
807 | BEG optrcdata_data END
813 /* These only exist to parse a reduction out of a common case. */
817 { style = WS_CHILD | WS_VISIBLE; }
823 { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
827 control_params_styleexpr:
829 { style = base_style | WS_CHILD | WS_VISIBLE; }
833 /* Font resources. */
836 id FONT memflags_move_discard file_name
838 define_font ($1, &$3, $4);
842 /* Icon resources. */
845 id ICON memflags_move_discard file_name
847 define_icon ($1, &$3, $4);
851 /* Language command. This changes the static variable language, which
852 affects all subsequent resources. */
855 LANGUAGE numexpr cnumexpr
857 language = $2 | ($3 << 8);
861 /* Menu resources. */
864 id MENU suboptions BEG menuitems END
866 define_menu ($1, &$3, $5);
881 struct menuitem **pp;
883 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
892 MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
894 $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
898 $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
900 | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
902 $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
911 | menuitem_flags ',' menuitem_flag
915 | menuitem_flags menuitem_flag
924 $$ = MENUITEM_CHECKED;
928 $$ = MENUITEM_GRAYED;
936 $$ = MENUITEM_INACTIVE;
940 $$ = MENUITEM_MENUBARBREAK;
944 $$ = MENUITEM_MENUBREAK;
948 /* Menuex resources. */
951 id MENUEX suboptions BEG menuexitems END
953 define_menu ($1, &$3, $5);
962 | menuexitems menuexitem
968 struct menuitem **pp;
970 for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
979 MENUITEM QUOTEDSTRING
981 $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
983 | MENUITEM QUOTEDSTRING cnumexpr
985 $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
987 | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
989 $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
991 | POPUP QUOTEDSTRING BEG menuexitems END
993 $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
995 | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
997 $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
999 | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
1001 $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
1003 | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
1006 $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
1010 /* Messagetable resources. */
1013 id MESSAGETABLE memflags_move file_name
1015 define_messagetable ($1, &$3, $4);
1019 /* Rcdata resources. */
1022 id RCDATA suboptions BEG optrcdata_data END
1024 define_rcdata ($1, &$3, $5.first);
1028 /* We use a different lexing algorithm, because rcdata strings may
1029 contain embedded null bytes, and we need to know the length to use. */
1057 struct rcdata_item *ri;
1059 ri = define_rcdata_string ($1.s, $1.length);
1065 struct rcdata_item *ri;
1067 ri = define_rcdata_number ($1.val, $1.dword);
1071 | rcdata_data ',' SIZEDSTRING
1073 struct rcdata_item *ri;
1075 ri = define_rcdata_string ($3.s, $3.length);
1076 $$.first = $1.first;
1080 | rcdata_data ',' sizednumexpr
1082 struct rcdata_item *ri;
1084 ri = define_rcdata_number ($3.val, $3.dword);
1085 $$.first = $1.first;
1091 /* Stringtable resources. */
1094 STRINGTABLE suboptions BEG
1095 { sub_res_info = $2; }
1101 | string_data numexpr QUOTEDSTRING
1103 define_stringtable (&sub_res_info, $2, $3);
1105 | string_data numexpr ',' QUOTEDSTRING
1107 define_stringtable (&sub_res_info, $2, $4);
1111 /* User defined resources. We accept general suboptions in the
1112 file_name case to keep the parser happy. */
1115 id id suboptions BEG optrcdata_data END
1117 define_user_data ($1, $2, &$3, $5.first);
1119 | id id suboptions file_name
1121 define_user_file ($1, $2, &$3, $4);
1125 /* Versioninfo resources. */
1128 id VERSIONINFO fixedverinfo BEG verblocks END
1130 define_versioninfo ($1, language, $3, $5);
1137 $$ = ((struct fixed_versioninfo *)
1138 res_alloc (sizeof (struct fixed_versioninfo)));
1139 memset ($$, 0, sizeof (struct fixed_versioninfo));
1141 | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
1143 $1->file_version_ms = ($3 << 16) | $4;
1144 $1->file_version_ls = ($5 << 16) | $6;
1147 | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
1149 $1->product_version_ms = ($3 << 16) | $4;
1150 $1->product_version_ls = ($5 << 16) | $6;
1153 | fixedverinfo FILEFLAGSMASK numexpr
1155 $1->file_flags_mask = $3;
1158 | fixedverinfo FILEFLAGS numexpr
1160 $1->file_flags = $3;
1163 | fixedverinfo FILEOS numexpr
1168 | fixedverinfo FILETYPE numexpr
1173 | fixedverinfo FILESUBTYPE numexpr
1175 $1->file_subtype = $3;
1180 /* To handle verblocks successfully, the lexer handles BLOCK
1181 specially. A BLOCK "StringFileInfo" is returned as
1182 BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
1183 BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
1184 with the string as the value. */
1191 | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
1193 $$ = append_ver_stringfileinfo ($1, $4, $6);
1195 | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
1197 $$ = append_ver_varfileinfo ($1, $5, $6);
1206 | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
1208 $$ = append_verval ($1, $3, $5);
1217 | vertrans cnumexpr cnumexpr
1219 $$ = append_vertrans ($1, $2, $3);
1223 /* A resource ID. */
1235 /* It seems that resource ID's are forced to upper case. */
1236 copy = xstrdup ($1);
1237 for (s = copy; *s != '\0'; s++)
1238 if (islower ((unsigned char) *s))
1239 *s = toupper ((unsigned char) *s);
1240 res_string_to_id (&$$, copy);
1245 /* Generic suboptions. These may appear before the BEGIN in any
1246 multiline statement. */
1251 memset (&$$, 0, sizeof (struct res_res_info));
1252 $$.language = language;
1253 /* FIXME: Is this the right default? */
1254 $$.memflags = MEMFLAG_MOVEABLE;
1256 | suboptions memflag
1259 $$.memflags |= $2.on;
1260 $$.memflags &=~ $2.off;
1262 | suboptions CHARACTERISTICS numexpr
1265 $$.characteristics = $3;
1267 | suboptions LANGUAGE numexpr cnumexpr
1270 $$.language = $3 | ($4 << 8);
1272 | suboptions VERSIONK numexpr
1279 /* Memory flags which default to MOVEABLE and DISCARDABLE. */
1281 memflags_move_discard:
1284 memset (&$$, 0, sizeof (struct res_res_info));
1285 $$.language = language;
1286 $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
1288 | memflags_move_discard memflag
1291 $$.memflags |= $2.on;
1292 $$.memflags &=~ $2.off;
1296 /* Memory flags which default to MOVEABLE. */
1301 memset (&$$, 0, sizeof (struct res_res_info));
1302 $$.language = language;
1303 $$.memflags = MEMFLAG_MOVEABLE;
1305 | memflags_move_discard memflag
1308 $$.memflags |= $2.on;
1309 $$.memflags &=~ $2.off;
1313 /* Memory flags. This returns a struct with two integers, because we
1314 sometimes want to set bits and we sometimes want to clear them. */
1319 $$.on = MEMFLAG_MOVEABLE;
1325 $$.off = MEMFLAG_MOVEABLE;
1329 $$.on = MEMFLAG_PURE;
1335 $$.off = MEMFLAG_PURE;
1339 $$.on = MEMFLAG_PRELOAD;
1345 $$.off = MEMFLAG_PRELOAD;
1349 $$.on = MEMFLAG_DISCARDABLE;
1367 /* A style expression. This changes the static variable STYLE. We do
1368 it this way because rc appears to permit a style to be set to
1370 WS_GROUP | NOT WS_TABSTOP
1371 to mean that a default of WS_TABSTOP should be removed. Anything
1372 which wants to accept a style must first set STYLE to the default
1373 value. The styleexpr nonterminal will change STYLE as specified by
1374 the user. Note that we do not accept arbitrary expressions here,
1375 just numbers separated by '|'. */
1386 | styleexpr '|' parennumber
1390 | styleexpr '|' NOT parennumber
1407 /* An optional expression with a leading comma. */
1420 /* An expression with a leading comma. */
1429 /* A possibly negated numeric expression. */
1438 /* A possibly negated expression with a size. */
1445 | '(' sizednumexpr ')'
1449 | '~' sizednumexpr %prec '~'
1452 $$.dword = $2.dword;
1454 | '-' sizednumexpr %prec NEG
1457 $$.dword = $2.dword;
1459 | sizednumexpr '*' sizednumexpr
1461 $$.val = $1.val * $3.val;
1462 $$.dword = $1.dword || $3.dword;
1464 | sizednumexpr '/' sizednumexpr
1466 $$.val = $1.val / $3.val;
1467 $$.dword = $1.dword || $3.dword;
1469 | sizednumexpr '%' sizednumexpr
1471 $$.val = $1.val % $3.val;
1472 $$.dword = $1.dword || $3.dword;
1474 | sizednumexpr '+' sizednumexpr
1476 $$.val = $1.val + $3.val;
1477 $$.dword = $1.dword || $3.dword;
1479 | sizednumexpr '-' sizednumexpr
1481 $$.val = $1.val - $3.val;
1482 $$.dword = $1.dword || $3.dword;
1484 | sizednumexpr '&' sizednumexpr
1486 $$.val = $1.val & $3.val;
1487 $$.dword = $1.dword || $3.dword;
1489 | sizednumexpr '^' sizednumexpr
1491 $$.val = $1.val ^ $3.val;
1492 $$.dword = $1.dword || $3.dword;
1494 | sizednumexpr '|' sizednumexpr
1496 $$.val = $1.val | $3.val;
1497 $$.dword = $1.dword || $3.dword;
1501 /* An expression with a leading comma which does not use unary
1511 /* An expression which does not use unary negation. */
1520 /* An expression which does not use unary negation. We separate unary
1521 negation to avoid parsing conflicts when two numeric expressions
1522 appear consecutively. */
1529 | '(' sizednumexpr ')'
1533 | '~' sizednumexpr %prec '~'
1536 $$.dword = $2.dword;
1538 | sizedposnumexpr '*' sizednumexpr
1540 $$.val = $1.val * $3.val;
1541 $$.dword = $1.dword || $3.dword;
1543 | sizedposnumexpr '/' sizednumexpr
1545 $$.val = $1.val / $3.val;
1546 $$.dword = $1.dword || $3.dword;
1548 | sizedposnumexpr '%' sizednumexpr
1550 $$.val = $1.val % $3.val;
1551 $$.dword = $1.dword || $3.dword;
1553 | sizedposnumexpr '+' sizednumexpr
1555 $$.val = $1.val + $3.val;
1556 $$.dword = $1.dword || $3.dword;
1558 | sizedposnumexpr '-' sizednumexpr
1560 $$.val = $1.val - $3.val;
1561 $$.dword = $1.dword || $3.dword;
1563 | sizedposnumexpr '&' sizednumexpr
1565 $$.val = $1.val & $3.val;
1566 $$.dword = $1.dword || $3.dword;
1568 | sizedposnumexpr '^' sizednumexpr
1570 $$.val = $1.val ^ $3.val;
1571 $$.dword = $1.dword || $3.dword;
1573 | sizedposnumexpr '|' sizednumexpr
1575 $$.val = $1.val | $3.val;
1576 $$.dword = $1.dword || $3.dword;
1582 /* Set the language from the command line. */
1585 rcparse_set_language (lang)