PageRenderTime 55ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/binutils-2.17/binutils/rcparse.y

http://android-gcc-objc2-0.googlecode.com/
Happy | 1777 lines | 1644 code | 133 blank | 0 comment | 0 complexity | b10d07611fd2b92aaaee84b9382489a3 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, CC-BY-SA-3.0, GPL-2.0, LGPL-2.0
  1. %{ /* rcparse.y -- parser for Windows rc files
  2. Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
  3. Free Software Foundation, Inc.
  4. Written by Ian Lance Taylor, Cygnus Support.
  5. This file is part of GNU Binutils.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
  17. 02110-1301, USA. */
  18. /* This is a parser for Windows rc files. It is based on the parser
  19. by Gunther Ebert <gunther.ebert@ixos-leipzig.de>. */
  20. #include "bfd.h"
  21. #include "bucomm.h"
  22. #include "libiberty.h"
  23. #include "windres.h"
  24. #include "safe-ctype.h"
  25. /* The current language. */
  26. static unsigned short language;
  27. /* The resource information during a sub statement. */
  28. static struct res_res_info sub_res_info;
  29. /* Dialog information. This is built by the nonterminals styles and
  30. controls. */
  31. static struct dialog dialog;
  32. /* This is used when building a style. It is modified by the
  33. nonterminal styleexpr. */
  34. static unsigned long style;
  35. /* These are used when building a control. They are set before using
  36. control_params. */
  37. static unsigned long base_style;
  38. static unsigned long default_style;
  39. static unsigned long class;
  40. static struct res_id res_text_field;
  41. static unichar null_unichar;
  42. /* This is used for COMBOBOX, LISTBOX and EDITTEXT which
  43. do not allow resource 'text' field in control definition. */
  44. static const struct res_id res_null_text = { 1, {{0, &null_unichar}}};
  45. %}
  46. %union
  47. {
  48. struct accelerator acc;
  49. struct accelerator *pacc;
  50. struct dialog_control *dialog_control;
  51. struct menuitem *menuitem;
  52. struct
  53. {
  54. struct rcdata_item *first;
  55. struct rcdata_item *last;
  56. } rcdata;
  57. struct rcdata_item *rcdata_item;
  58. struct stringtable_data *stringtable;
  59. struct fixed_versioninfo *fixver;
  60. struct ver_info *verinfo;
  61. struct ver_stringinfo *verstring;
  62. struct ver_varinfo *vervar;
  63. struct res_id id;
  64. struct res_res_info res_info;
  65. struct
  66. {
  67. unsigned short on;
  68. unsigned short off;
  69. } memflags;
  70. struct
  71. {
  72. unsigned long val;
  73. /* Nonzero if this number was explicitly specified as long. */
  74. int dword;
  75. } i;
  76. unsigned long il;
  77. unsigned short is;
  78. const char *s;
  79. struct
  80. {
  81. unsigned long length;
  82. const char *s;
  83. } ss;
  84. };
  85. %token BEG END
  86. %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
  87. %token BITMAP
  88. %token CURSOR
  89. %token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
  90. %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
  91. %token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
  92. %token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
  93. %token BEDIT HEDIT IEDIT
  94. %token FONT
  95. %token ICON
  96. %token LANGUAGE CHARACTERISTICS VERSIONK
  97. %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
  98. %token MENUBARBREAK MENUBREAK
  99. %token MESSAGETABLE
  100. %token RCDATA
  101. %token STRINGTABLE
  102. %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
  103. %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
  104. %token VALUE
  105. %token <s> BLOCK
  106. %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
  107. %token NOT
  108. %token <s> QUOTEDSTRING STRING
  109. %token <i> NUMBER
  110. %token <ss> SIZEDSTRING
  111. %token IGNORED_TOKEN
  112. %type <pacc> acc_entries
  113. %type <acc> acc_entry acc_event
  114. %type <dialog_control> control control_params
  115. %type <menuitem> menuitems menuitem menuexitems menuexitem
  116. %type <rcdata> optrcdata_data optrcdata_data_int rcdata_data
  117. %type <rcdata_item> opt_control_data
  118. %type <fixver> fixedverinfo
  119. %type <verinfo> verblocks
  120. %type <verstring> vervals
  121. %type <vervar> vertrans
  122. %type <res_info> suboptions memflags_move_discard memflags_move
  123. %type <memflags> memflag
  124. %type <id> id optresidc resref
  125. %type <il> exstyle parennumber
  126. %type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
  127. %type <is> acc_options acc_option menuitem_flags menuitem_flag
  128. %type <s> file_name resname
  129. %type <i> sizednumexpr sizedposnumexpr
  130. %left '|'
  131. %left '^'
  132. %left '&'
  133. %left '+' '-'
  134. %left '*' '/' '%'
  135. %right '~' NEG
  136. %%
  137. input:
  138. /* empty */
  139. | input accelerator
  140. | input bitmap
  141. | input cursor
  142. | input dialog
  143. | input font
  144. | input icon
  145. | input language
  146. | input menu
  147. | input menuex
  148. | input messagetable
  149. | input rcdata
  150. | input stringtable
  151. | input user
  152. | input versioninfo
  153. | input IGNORED_TOKEN
  154. ;
  155. /* Accelerator resources. */
  156. accelerator:
  157. id ACCELERATORS suboptions BEG acc_entries END
  158. {
  159. define_accelerator ($1, &$3, $5);
  160. if (yychar != YYEMPTY)
  161. YYERROR;
  162. rcparse_discard_strings ();
  163. }
  164. ;
  165. acc_entries:
  166. /* empty */
  167. {
  168. $$ = NULL;
  169. }
  170. | acc_entries acc_entry
  171. {
  172. struct accelerator *a;
  173. a = (struct accelerator *) res_alloc (sizeof *a);
  174. *a = $2;
  175. if ($1 == NULL)
  176. $$ = a;
  177. else
  178. {
  179. struct accelerator **pp;
  180. for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
  181. ;
  182. *pp = a;
  183. $$ = $1;
  184. }
  185. }
  186. ;
  187. acc_entry:
  188. acc_event cposnumexpr
  189. {
  190. $$ = $1;
  191. $$.id = $2;
  192. }
  193. | acc_event cposnumexpr ',' acc_options
  194. {
  195. $$ = $1;
  196. $$.id = $2;
  197. $$.flags |= $4;
  198. if (($$.flags & ACC_VIRTKEY) == 0
  199. && ($$.flags & (ACC_SHIFT | ACC_CONTROL)) != 0)
  200. rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
  201. }
  202. ;
  203. acc_event:
  204. QUOTEDSTRING
  205. {
  206. const char *s = $1;
  207. char ch;
  208. $$.next = NULL;
  209. $$.id = 0;
  210. ch = *s;
  211. if (ch != '^')
  212. $$.flags = 0;
  213. else
  214. {
  215. $$.flags = ACC_CONTROL | ACC_VIRTKEY;
  216. ++s;
  217. ch = *s;
  218. ch = TOUPPER (ch);
  219. }
  220. $$.key = ch;
  221. if (s[1] != '\0')
  222. rcparse_warning (_("accelerator should only be one character"));
  223. }
  224. | posnumexpr
  225. {
  226. $$.next = NULL;
  227. $$.flags = 0;
  228. $$.id = 0;
  229. $$.key = $1;
  230. }
  231. ;
  232. acc_options:
  233. acc_option
  234. {
  235. $$ = $1;
  236. }
  237. | acc_options ',' acc_option
  238. {
  239. $$ = $1 | $3;
  240. }
  241. /* I've had one report that the comma is optional. */
  242. | acc_options acc_option
  243. {
  244. $$ = $1 | $2;
  245. }
  246. ;
  247. acc_option:
  248. VIRTKEY
  249. {
  250. $$ = ACC_VIRTKEY;
  251. }
  252. | ASCII
  253. {
  254. /* This is just the absence of VIRTKEY. */
  255. $$ = 0;
  256. }
  257. | NOINVERT
  258. {
  259. $$ = ACC_NOINVERT;
  260. }
  261. | SHIFT
  262. {
  263. $$ = ACC_SHIFT;
  264. }
  265. | CONTROL
  266. {
  267. $$ = ACC_CONTROL;
  268. }
  269. | ALT
  270. {
  271. $$ = ACC_ALT;
  272. }
  273. ;
  274. /* Bitmap resources. */
  275. bitmap:
  276. id BITMAP memflags_move file_name
  277. {
  278. define_bitmap ($1, &$3, $4);
  279. if (yychar != YYEMPTY)
  280. YYERROR;
  281. rcparse_discard_strings ();
  282. }
  283. ;
  284. /* Cursor resources. */
  285. cursor:
  286. id CURSOR memflags_move_discard file_name
  287. {
  288. define_cursor ($1, &$3, $4);
  289. if (yychar != YYEMPTY)
  290. YYERROR;
  291. rcparse_discard_strings ();
  292. }
  293. ;
  294. /* Dialog resources. */
  295. dialog:
  296. id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
  297. cnumexpr
  298. {
  299. memset (&dialog, 0, sizeof dialog);
  300. dialog.x = $5;
  301. dialog.y = $6;
  302. dialog.width = $7;
  303. dialog.height = $8;
  304. dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
  305. dialog.exstyle = $4;
  306. dialog.menu.named = 1;
  307. dialog.class.named = 1;
  308. dialog.font = NULL;
  309. dialog.ex = NULL;
  310. dialog.controls = NULL;
  311. sub_res_info = $3;
  312. style = 0;
  313. }
  314. styles BEG controls END
  315. {
  316. define_dialog ($1, &sub_res_info, &dialog);
  317. if (yychar != YYEMPTY)
  318. YYERROR;
  319. rcparse_discard_strings ();
  320. }
  321. | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
  322. cnumexpr
  323. {
  324. memset (&dialog, 0, sizeof dialog);
  325. dialog.x = $5;
  326. dialog.y = $6;
  327. dialog.width = $7;
  328. dialog.height = $8;
  329. dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
  330. dialog.exstyle = $4;
  331. dialog.menu.named = 1;
  332. dialog.class.named = 1;
  333. dialog.font = NULL;
  334. dialog.ex = ((struct dialog_ex *)
  335. res_alloc (sizeof (struct dialog_ex)));
  336. memset (dialog.ex, 0, sizeof (struct dialog_ex));
  337. dialog.controls = NULL;
  338. sub_res_info = $3;
  339. style = 0;
  340. }
  341. styles BEG controls END
  342. {
  343. define_dialog ($1, &sub_res_info, &dialog);
  344. if (yychar != YYEMPTY)
  345. YYERROR;
  346. rcparse_discard_strings ();
  347. }
  348. | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
  349. cnumexpr cnumexpr
  350. {
  351. memset (&dialog, 0, sizeof dialog);
  352. dialog.x = $5;
  353. dialog.y = $6;
  354. dialog.width = $7;
  355. dialog.height = $8;
  356. dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
  357. dialog.exstyle = $4;
  358. dialog.menu.named = 1;
  359. dialog.class.named = 1;
  360. dialog.font = NULL;
  361. dialog.ex = ((struct dialog_ex *)
  362. res_alloc (sizeof (struct dialog_ex)));
  363. memset (dialog.ex, 0, sizeof (struct dialog_ex));
  364. dialog.ex->help = $9;
  365. dialog.controls = NULL;
  366. sub_res_info = $3;
  367. style = 0;
  368. }
  369. styles BEG controls END
  370. {
  371. define_dialog ($1, &sub_res_info, &dialog);
  372. if (yychar != YYEMPTY)
  373. YYERROR;
  374. rcparse_discard_strings ();
  375. }
  376. ;
  377. exstyle:
  378. /* empty */
  379. {
  380. $$ = 0;
  381. }
  382. | EXSTYLE '=' numexpr
  383. {
  384. $$ = $3;
  385. }
  386. ;
  387. styles:
  388. /* empty */
  389. | styles CAPTION QUOTEDSTRING
  390. {
  391. dialog.style |= WS_CAPTION;
  392. style |= WS_CAPTION;
  393. unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
  394. }
  395. | styles CLASS id
  396. {
  397. dialog.class = $3;
  398. }
  399. | styles STYLE
  400. styleexpr
  401. {
  402. dialog.style = style;
  403. }
  404. | styles EXSTYLE numexpr
  405. {
  406. dialog.exstyle = $3;
  407. }
  408. | styles CLASS QUOTEDSTRING
  409. {
  410. res_string_to_id (& dialog.class, $3);
  411. }
  412. | styles FONT numexpr ',' QUOTEDSTRING
  413. {
  414. dialog.style |= DS_SETFONT;
  415. style |= DS_SETFONT;
  416. dialog.pointsize = $3;
  417. unicode_from_ascii ((int *) NULL, &dialog.font, $5);
  418. if (dialog.ex != NULL)
  419. {
  420. dialog.ex->weight = 0;
  421. dialog.ex->italic = 0;
  422. dialog.ex->charset = 1;
  423. }
  424. }
  425. | styles FONT numexpr ',' QUOTEDSTRING cnumexpr
  426. {
  427. dialog.style |= DS_SETFONT;
  428. style |= DS_SETFONT;
  429. dialog.pointsize = $3;
  430. unicode_from_ascii ((int *) NULL, &dialog.font, $5);
  431. if (dialog.ex == NULL)
  432. rcparse_warning (_("extended FONT requires DIALOGEX"));
  433. else
  434. {
  435. dialog.ex->weight = $6;
  436. dialog.ex->italic = 0;
  437. dialog.ex->charset = 1;
  438. }
  439. }
  440. | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
  441. {
  442. dialog.style |= DS_SETFONT;
  443. style |= DS_SETFONT;
  444. dialog.pointsize = $3;
  445. unicode_from_ascii ((int *) NULL, &dialog.font, $5);
  446. if (dialog.ex == NULL)
  447. rcparse_warning (_("extended FONT requires DIALOGEX"));
  448. else
  449. {
  450. dialog.ex->weight = $6;
  451. dialog.ex->italic = $7;
  452. dialog.ex->charset = 1;
  453. }
  454. }
  455. | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr
  456. {
  457. dialog.style |= DS_SETFONT;
  458. style |= DS_SETFONT;
  459. dialog.pointsize = $3;
  460. unicode_from_ascii ((int *) NULL, &dialog.font, $5);
  461. if (dialog.ex == NULL)
  462. rcparse_warning (_("extended FONT requires DIALOGEX"));
  463. else
  464. {
  465. dialog.ex->weight = $6;
  466. dialog.ex->italic = $7;
  467. dialog.ex->charset = $8;
  468. }
  469. }
  470. | styles MENU id
  471. {
  472. dialog.menu = $3;
  473. }
  474. | styles CHARACTERISTICS numexpr
  475. {
  476. sub_res_info.characteristics = $3;
  477. }
  478. | styles LANGUAGE numexpr cnumexpr
  479. {
  480. sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT);
  481. }
  482. | styles VERSIONK numexpr
  483. {
  484. sub_res_info.version = $3;
  485. }
  486. ;
  487. controls:
  488. /* empty */
  489. | controls control
  490. {
  491. struct dialog_control **pp;
  492. for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
  493. ;
  494. *pp = $2;
  495. }
  496. ;
  497. control:
  498. AUTO3STATE optresidc
  499. {
  500. default_style = BS_AUTO3STATE | WS_TABSTOP;
  501. base_style = BS_AUTO3STATE;
  502. class = CTL_BUTTON;
  503. res_text_field = $2;
  504. }
  505. control_params
  506. {
  507. $$ = $4;
  508. }
  509. | AUTOCHECKBOX optresidc
  510. {
  511. default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
  512. base_style = BS_AUTOCHECKBOX;
  513. class = CTL_BUTTON;
  514. res_text_field = $2;
  515. }
  516. control_params
  517. {
  518. $$ = $4;
  519. }
  520. | AUTORADIOBUTTON optresidc
  521. {
  522. default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
  523. base_style = BS_AUTORADIOBUTTON;
  524. class = CTL_BUTTON;
  525. res_text_field = $2;
  526. }
  527. control_params
  528. {
  529. $$ = $4;
  530. }
  531. | BEDIT optresidc
  532. {
  533. default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  534. base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  535. class = CTL_EDIT;
  536. res_text_field = $2;
  537. }
  538. control_params
  539. {
  540. $$ = $4;
  541. if (dialog.ex == NULL)
  542. rcparse_warning (_("BEDIT requires DIALOGEX"));
  543. res_string_to_id (&$$->class, "BEDIT");
  544. }
  545. | CHECKBOX optresidc
  546. {
  547. default_style = BS_CHECKBOX | WS_TABSTOP;
  548. base_style = BS_CHECKBOX | WS_TABSTOP;
  549. class = CTL_BUTTON;
  550. res_text_field = $2;
  551. }
  552. control_params
  553. {
  554. $$ = $4;
  555. }
  556. | COMBOBOX
  557. {
  558. /* This is as per MSDN documentation. With some (???)
  559. versions of MS rc.exe their is no default style. */
  560. default_style = CBS_SIMPLE | WS_TABSTOP;
  561. base_style = 0;
  562. class = CTL_COMBOBOX;
  563. res_text_field = res_null_text;
  564. }
  565. control_params
  566. {
  567. $$ = $3;
  568. }
  569. | CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
  570. cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
  571. {
  572. $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
  573. if ($11 != NULL)
  574. {
  575. if (dialog.ex == NULL)
  576. rcparse_warning (_("control data requires DIALOGEX"));
  577. $$->data = $11;
  578. }
  579. }
  580. | CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
  581. cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
  582. {
  583. $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
  584. if (dialog.ex == NULL)
  585. rcparse_warning (_("help ID requires DIALOGEX"));
  586. $$->help = $11;
  587. $$->data = $12;
  588. }
  589. | CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
  590. cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
  591. {
  592. $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
  593. if ($12 != NULL)
  594. {
  595. if (dialog.ex == NULL)
  596. rcparse_warning ("control data requires DIALOGEX");
  597. $$->data = $12;
  598. }
  599. $$->class.named = 1;
  600. unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
  601. }
  602. | CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
  603. cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
  604. {
  605. $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
  606. if (dialog.ex == NULL)
  607. rcparse_warning ("help ID requires DIALOGEX");
  608. $$->help = $12;
  609. $$->data = $13;
  610. $$->class.named = 1;
  611. unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
  612. }
  613. | CTEXT optresidc
  614. {
  615. default_style = SS_CENTER | WS_GROUP;
  616. base_style = SS_CENTER;
  617. class = CTL_STATIC;
  618. res_text_field = $2;
  619. }
  620. control_params
  621. {
  622. $$ = $4;
  623. }
  624. | DEFPUSHBUTTON optresidc
  625. {
  626. default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
  627. base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
  628. class = CTL_BUTTON;
  629. res_text_field = $2;
  630. }
  631. control_params
  632. {
  633. $$ = $4;
  634. }
  635. | EDITTEXT
  636. {
  637. default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  638. base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  639. class = CTL_EDIT;
  640. res_text_field = res_null_text;
  641. }
  642. control_params
  643. {
  644. $$ = $3;
  645. }
  646. | GROUPBOX optresidc
  647. {
  648. default_style = BS_GROUPBOX;
  649. base_style = BS_GROUPBOX;
  650. class = CTL_BUTTON;
  651. res_text_field = $2;
  652. }
  653. control_params
  654. {
  655. $$ = $4;
  656. }
  657. | HEDIT optresidc
  658. {
  659. default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  660. base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  661. class = CTL_EDIT;
  662. res_text_field = $2;
  663. }
  664. control_params
  665. {
  666. $$ = $4;
  667. if (dialog.ex == NULL)
  668. rcparse_warning (_("IEDIT requires DIALOGEX"));
  669. res_string_to_id (&$$->class, "HEDIT");
  670. }
  671. | ICON resref numexpr cnumexpr cnumexpr opt_control_data
  672. {
  673. $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
  674. dialog.ex);
  675. }
  676. | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
  677. opt_control_data
  678. {
  679. $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
  680. dialog.ex);
  681. }
  682. | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
  683. icon_styleexpr optcnumexpr opt_control_data
  684. {
  685. $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
  686. dialog.ex);
  687. }
  688. | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
  689. icon_styleexpr cnumexpr cnumexpr opt_control_data
  690. {
  691. $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
  692. dialog.ex);
  693. }
  694. | IEDIT optresidc
  695. {
  696. default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  697. base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
  698. class = CTL_EDIT;
  699. res_text_field = $2;
  700. }
  701. control_params
  702. {
  703. $$ = $4;
  704. if (dialog.ex == NULL)
  705. rcparse_warning (_("IEDIT requires DIALOGEX"));
  706. res_string_to_id (&$$->class, "IEDIT");
  707. }
  708. | LISTBOX
  709. {
  710. default_style = LBS_NOTIFY | WS_BORDER;
  711. base_style = LBS_NOTIFY | WS_BORDER;
  712. class = CTL_LISTBOX;
  713. res_text_field = res_null_text;
  714. }
  715. control_params
  716. {
  717. $$ = $3;
  718. }
  719. | LTEXT optresidc
  720. {
  721. default_style = SS_LEFT | WS_GROUP;
  722. base_style = SS_LEFT;
  723. class = CTL_STATIC;
  724. res_text_field = $2;
  725. }
  726. control_params
  727. {
  728. $$ = $4;
  729. }
  730. | PUSHBOX optresidc
  731. {
  732. default_style = BS_PUSHBOX | WS_TABSTOP;
  733. base_style = BS_PUSHBOX;
  734. class = CTL_BUTTON;
  735. }
  736. control_params
  737. {
  738. $$ = $4;
  739. }
  740. | PUSHBUTTON optresidc
  741. {
  742. default_style = BS_PUSHBUTTON | WS_TABSTOP;
  743. base_style = BS_PUSHBUTTON | WS_TABSTOP;
  744. class = CTL_BUTTON;
  745. res_text_field = $2;
  746. }
  747. control_params
  748. {
  749. $$ = $4;
  750. }
  751. | RADIOBUTTON optresidc
  752. {
  753. default_style = BS_RADIOBUTTON | WS_TABSTOP;
  754. base_style = BS_RADIOBUTTON;
  755. class = CTL_BUTTON;
  756. res_text_field = $2;
  757. }
  758. control_params
  759. {
  760. $$ = $4;
  761. }
  762. | RTEXT optresidc
  763. {
  764. default_style = SS_RIGHT | WS_GROUP;
  765. base_style = SS_RIGHT;
  766. class = CTL_STATIC;
  767. res_text_field = $2;
  768. }
  769. control_params
  770. {
  771. $$ = $4;
  772. }
  773. | SCROLLBAR
  774. {
  775. default_style = SBS_HORZ;
  776. base_style = 0;
  777. class = CTL_SCROLLBAR;
  778. res_text_field = res_null_text;
  779. }
  780. control_params
  781. {
  782. $$ = $3;
  783. }
  784. | STATE3 optresidc
  785. {
  786. default_style = BS_3STATE | WS_TABSTOP;
  787. base_style = BS_3STATE;
  788. class = CTL_BUTTON;
  789. res_text_field = $2;
  790. }
  791. control_params
  792. {
  793. $$ = $4;
  794. }
  795. | USERBUTTON resref numexpr ',' numexpr ',' numexpr ','
  796. numexpr ',' numexpr ','
  797. { style = WS_CHILD | WS_VISIBLE; }
  798. styleexpr optcnumexpr
  799. {
  800. $$ = define_control ($2, $3, $5, $7, $9, $11, CTL_BUTTON,
  801. style, $15);
  802. }
  803. ;
  804. /* Parameters for a control. The static variables DEFAULT_STYLE,
  805. BASE_STYLE, and CLASS must be initialized before this nonterminal
  806. is used. DEFAULT_STYLE is the style to use if no style expression
  807. is specified. BASE_STYLE is the base style to use if a style
  808. expression is specified; the style expression modifies the base
  809. style. CLASS is the class of the control. */
  810. control_params:
  811. numexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
  812. {
  813. $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class,
  814. default_style | WS_CHILD | WS_VISIBLE, 0);
  815. if ($6 != NULL)
  816. {
  817. if (dialog.ex == NULL)
  818. rcparse_warning (_("control data requires DIALOGEX"));
  819. $$->data = $6;
  820. }
  821. }
  822. | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
  823. control_params_styleexpr optcnumexpr opt_control_data
  824. {
  825. $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
  826. if ($8 != NULL)
  827. {
  828. if (dialog.ex == NULL)
  829. rcparse_warning (_("control data requires DIALOGEX"));
  830. $$->data = $8;
  831. }
  832. }
  833. | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
  834. control_params_styleexpr cnumexpr cnumexpr opt_control_data
  835. {
  836. $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
  837. if (dialog.ex == NULL)
  838. rcparse_warning (_("help ID requires DIALOGEX"));
  839. $$->help = $8;
  840. $$->data = $9;
  841. }
  842. ;
  843. optresidc:
  844. /* empty */
  845. {
  846. res_string_to_id (&$$, "");
  847. }
  848. | posnumexpr ','
  849. {
  850. $$.named = 0;
  851. $$.u.id = $1;
  852. }
  853. | QUOTEDSTRING
  854. {
  855. res_string_to_id (&$$, $1);
  856. }
  857. | QUOTEDSTRING ','
  858. {
  859. res_string_to_id (&$$, $1);
  860. }
  861. ;
  862. opt_control_data:
  863. /* empty */
  864. {
  865. $$ = NULL;
  866. }
  867. | BEG optrcdata_data END
  868. {
  869. $$ = $2.first;
  870. }
  871. ;
  872. /* These only exist to parse a reduction out of a common case. */
  873. control_styleexpr:
  874. ','
  875. { style = WS_CHILD | WS_VISIBLE; }
  876. styleexpr
  877. ;
  878. icon_styleexpr:
  879. ','
  880. { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
  881. styleexpr
  882. ;
  883. control_params_styleexpr:
  884. ','
  885. { style = base_style | WS_CHILD | WS_VISIBLE; }
  886. styleexpr
  887. ;
  888. /* Font resources. */
  889. font:
  890. id FONT memflags_move_discard file_name
  891. {
  892. define_font ($1, &$3, $4);
  893. if (yychar != YYEMPTY)
  894. YYERROR;
  895. rcparse_discard_strings ();
  896. }
  897. ;
  898. /* Icon resources. */
  899. icon:
  900. id ICON memflags_move_discard file_name
  901. {
  902. define_icon ($1, &$3, $4);
  903. if (yychar != YYEMPTY)
  904. YYERROR;
  905. rcparse_discard_strings ();
  906. }
  907. ;
  908. /* Language command. This changes the static variable language, which
  909. affects all subsequent resources. */
  910. language:
  911. LANGUAGE numexpr cnumexpr
  912. {
  913. language = $2 | ($3 << SUBLANG_SHIFT);
  914. }
  915. ;
  916. /* Menu resources. */
  917. menu:
  918. id MENU suboptions BEG menuitems END
  919. {
  920. define_menu ($1, &$3, $5);
  921. if (yychar != YYEMPTY)
  922. YYERROR;
  923. rcparse_discard_strings ();
  924. }
  925. ;
  926. menuitems:
  927. /* empty */
  928. {
  929. $$ = NULL;
  930. }
  931. | menuitems menuitem
  932. {
  933. if ($1 == NULL)
  934. $$ = $2;
  935. else
  936. {
  937. struct menuitem **pp;
  938. for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
  939. ;
  940. *pp = $2;
  941. $$ = $1;
  942. }
  943. }
  944. ;
  945. menuitem:
  946. MENUITEM QUOTEDSTRING cnumexpr menuitem_flags
  947. {
  948. $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
  949. }
  950. | MENUITEM SEPARATOR
  951. {
  952. $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
  953. }
  954. | POPUP QUOTEDSTRING menuitem_flags BEG menuitems END
  955. {
  956. $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
  957. }
  958. ;
  959. menuitem_flags:
  960. /* empty */
  961. {
  962. $$ = 0;
  963. }
  964. | menuitem_flags ',' menuitem_flag
  965. {
  966. $$ = $1 | $3;
  967. }
  968. | menuitem_flags menuitem_flag
  969. {
  970. $$ = $1 | $2;
  971. }
  972. ;
  973. menuitem_flag:
  974. CHECKED
  975. {
  976. $$ = MENUITEM_CHECKED;
  977. }
  978. | GRAYED
  979. {
  980. $$ = MENUITEM_GRAYED;
  981. }
  982. | HELP
  983. {
  984. $$ = MENUITEM_HELP;
  985. }
  986. | INACTIVE
  987. {
  988. $$ = MENUITEM_INACTIVE;
  989. }
  990. | MENUBARBREAK
  991. {
  992. $$ = MENUITEM_MENUBARBREAK;
  993. }
  994. | MENUBREAK
  995. {
  996. $$ = MENUITEM_MENUBREAK;
  997. }
  998. ;
  999. /* Menuex resources. */
  1000. menuex:
  1001. id MENUEX suboptions BEG menuexitems END
  1002. {
  1003. define_menu ($1, &$3, $5);
  1004. if (yychar != YYEMPTY)
  1005. YYERROR;
  1006. rcparse_discard_strings ();
  1007. }
  1008. ;
  1009. menuexitems:
  1010. /* empty */
  1011. {
  1012. $$ = NULL;
  1013. }
  1014. | menuexitems menuexitem
  1015. {
  1016. if ($1 == NULL)
  1017. $$ = $2;
  1018. else
  1019. {
  1020. struct menuitem **pp;
  1021. for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
  1022. ;
  1023. *pp = $2;
  1024. $$ = $1;
  1025. }
  1026. }
  1027. ;
  1028. menuexitem:
  1029. MENUITEM QUOTEDSTRING
  1030. {
  1031. $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
  1032. }
  1033. | MENUITEM QUOTEDSTRING cnumexpr
  1034. {
  1035. $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
  1036. }
  1037. | MENUITEM QUOTEDSTRING cnumexpr cnumexpr optcnumexpr
  1038. {
  1039. $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
  1040. }
  1041. | MENUITEM SEPARATOR
  1042. {
  1043. $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
  1044. }
  1045. | POPUP QUOTEDSTRING BEG menuexitems END
  1046. {
  1047. $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
  1048. }
  1049. | POPUP QUOTEDSTRING cnumexpr BEG menuexitems END
  1050. {
  1051. $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
  1052. }
  1053. | POPUP QUOTEDSTRING cnumexpr cnumexpr BEG menuexitems END
  1054. {
  1055. $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
  1056. }
  1057. | POPUP QUOTEDSTRING cnumexpr cnumexpr cnumexpr optcnumexpr
  1058. BEG menuexitems END
  1059. {
  1060. $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
  1061. }
  1062. ;
  1063. /* Messagetable resources. */
  1064. messagetable:
  1065. id MESSAGETABLE memflags_move file_name
  1066. {
  1067. define_messagetable ($1, &$3, $4);
  1068. if (yychar != YYEMPTY)
  1069. YYERROR;
  1070. rcparse_discard_strings ();
  1071. }
  1072. ;
  1073. /* Rcdata resources. */
  1074. rcdata:
  1075. id RCDATA suboptions BEG optrcdata_data END
  1076. {
  1077. define_rcdata ($1, &$3, $5.first);
  1078. if (yychar != YYEMPTY)
  1079. YYERROR;
  1080. rcparse_discard_strings ();
  1081. }
  1082. | id RCDATA suboptions file_name
  1083. {
  1084. define_rcdata_file ($1, &$3, $4);
  1085. if (yychar != YYEMPTY)
  1086. YYERROR;
  1087. rcparse_discard_strings ();
  1088. }
  1089. ;
  1090. /* We use a different lexing algorithm, because rcdata strings may
  1091. contain embedded null bytes, and we need to know the length to use. */
  1092. optrcdata_data:
  1093. {
  1094. rcparse_rcdata ();
  1095. }
  1096. optrcdata_data_int
  1097. {
  1098. rcparse_normal ();
  1099. $$ = $2;
  1100. }
  1101. ;
  1102. optrcdata_data_int:
  1103. /* empty */
  1104. {
  1105. $$.first = NULL;
  1106. $$.last = NULL;
  1107. }
  1108. | rcdata_data
  1109. {
  1110. $$ = $1;
  1111. }
  1112. ;
  1113. rcdata_data:
  1114. SIZEDSTRING
  1115. {
  1116. struct rcdata_item *ri;
  1117. ri = define_rcdata_string ($1.s, $1.length);
  1118. $$.first = ri;
  1119. $$.last = ri;
  1120. }
  1121. | sizednumexpr
  1122. {
  1123. struct rcdata_item *ri;
  1124. ri = define_rcdata_number ($1.val, $1.dword);
  1125. $$.first = ri;
  1126. $$.last = ri;
  1127. }
  1128. | rcdata_data ',' SIZEDSTRING
  1129. {
  1130. struct rcdata_item *ri;
  1131. ri = define_rcdata_string ($3.s, $3.length);
  1132. $$.first = $1.first;
  1133. $1.last->next = ri;
  1134. $$.last = ri;
  1135. }
  1136. | rcdata_data ',' sizednumexpr
  1137. {
  1138. struct rcdata_item *ri;
  1139. ri = define_rcdata_number ($3.val, $3.dword);
  1140. $$.first = $1.first;
  1141. $1.last->next = ri;
  1142. $$.last = ri;
  1143. }
  1144. ;
  1145. /* Stringtable resources. */
  1146. stringtable:
  1147. STRINGTABLE suboptions BEG
  1148. { sub_res_info = $2; }
  1149. string_data END
  1150. ;
  1151. string_data:
  1152. /* empty */
  1153. | string_data numexpr QUOTEDSTRING
  1154. {
  1155. define_stringtable (&sub_res_info, $2, $3);
  1156. if (yychar != YYEMPTY)
  1157. YYERROR;
  1158. rcparse_discard_strings ();
  1159. }
  1160. | string_data numexpr ',' QUOTEDSTRING
  1161. {
  1162. define_stringtable (&sub_res_info, $2, $4);
  1163. if (yychar != YYEMPTY)
  1164. YYERROR;
  1165. rcparse_discard_strings ();
  1166. }
  1167. ;
  1168. /* User defined resources. We accept general suboptions in the
  1169. file_name case to keep the parser happy. */
  1170. user:
  1171. id id suboptions BEG optrcdata_data END
  1172. {
  1173. define_user_data ($1, $2, &$3, $5.first);
  1174. if (yychar != YYEMPTY)
  1175. YYERROR;
  1176. rcparse_discard_strings ();
  1177. }
  1178. | id id suboptions file_name
  1179. {
  1180. define_user_file ($1, $2, &$3, $4);
  1181. if (yychar != YYEMPTY)
  1182. YYERROR;
  1183. rcparse_discard_strings ();
  1184. }
  1185. ;
  1186. /* Versioninfo resources. */
  1187. versioninfo:
  1188. id VERSIONINFO fixedverinfo BEG verblocks END
  1189. {
  1190. define_versioninfo ($1, language, $3, $5);
  1191. if (yychar != YYEMPTY)
  1192. YYERROR;
  1193. rcparse_discard_strings ();
  1194. }
  1195. ;
  1196. fixedverinfo:
  1197. /* empty */
  1198. {
  1199. $$ = ((struct fixed_versioninfo *)
  1200. res_alloc (sizeof (struct fixed_versioninfo)));
  1201. memset ($$, 0, sizeof (struct fixed_versioninfo));
  1202. }
  1203. | fixedverinfo FILEVERSION numexpr cnumexpr cnumexpr cnumexpr
  1204. {
  1205. $1->file_version_ms = ($3 << 16) | $4;
  1206. $1->file_version_ls = ($5 << 16) | $6;
  1207. $$ = $1;
  1208. }
  1209. | fixedverinfo PRODUCTVERSION numexpr cnumexpr cnumexpr cnumexpr
  1210. {
  1211. $1->product_version_ms = ($3 << 16) | $4;
  1212. $1->product_version_ls = ($5 << 16) | $6;
  1213. $$ = $1;
  1214. }
  1215. | fixedverinfo FILEFLAGSMASK numexpr
  1216. {
  1217. $1->file_flags_mask = $3;
  1218. $$ = $1;
  1219. }
  1220. | fixedverinfo FILEFLAGS numexpr
  1221. {
  1222. $1->file_flags = $3;
  1223. $$ = $1;
  1224. }
  1225. | fixedverinfo FILEOS numexpr
  1226. {
  1227. $1->file_os = $3;
  1228. $$ = $1;
  1229. }
  1230. | fixedverinfo FILETYPE numexpr
  1231. {
  1232. $1->file_type = $3;
  1233. $$ = $1;
  1234. }
  1235. | fixedverinfo FILESUBTYPE numexpr
  1236. {
  1237. $1->file_subtype = $3;
  1238. $$ = $1;
  1239. }
  1240. ;
  1241. /* To handle verblocks successfully, the lexer handles BLOCK
  1242. specially. A BLOCK "StringFileInfo" is returned as
  1243. BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
  1244. BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
  1245. with the string as the value. */
  1246. verblocks:
  1247. /* empty */
  1248. {
  1249. $$ = NULL;
  1250. }
  1251. | verblocks BLOCKSTRINGFILEINFO BEG BLOCK BEG vervals END END
  1252. {
  1253. $$ = append_ver_stringfileinfo ($1, $4, $6);
  1254. }
  1255. | verblocks BLOCKVARFILEINFO BEG VALUE QUOTEDSTRING vertrans END
  1256. {
  1257. $$ = append_ver_varfileinfo ($1, $5, $6);
  1258. }
  1259. ;
  1260. vervals:
  1261. /* empty */
  1262. {
  1263. $$ = NULL;
  1264. }
  1265. | vervals VALUE QUOTEDSTRING ',' QUOTEDSTRING
  1266. {
  1267. $$ = append_verval ($1, $3, $5);
  1268. }
  1269. ;
  1270. vertrans:
  1271. /* empty */
  1272. {
  1273. $$ = NULL;
  1274. }
  1275. | vertrans cnumexpr cnumexpr
  1276. {
  1277. $$ = append_vertrans ($1, $2, $3);
  1278. }
  1279. ;
  1280. /* A resource ID. */
  1281. id:
  1282. posnumexpr
  1283. {
  1284. $$.named = 0;
  1285. $$.u.id = $1;
  1286. }
  1287. | STRING
  1288. {
  1289. char *copy, *s;
  1290. /* It seems that resource ID's are forced to upper case. */
  1291. copy = xstrdup ($1);
  1292. for (s = copy; *s != '\0'; s++)
  1293. *s = TOUPPER (*s);
  1294. res_string_to_id (&$$, copy);
  1295. free (copy);
  1296. }
  1297. ;
  1298. /* A resource reference. */
  1299. resname:
  1300. QUOTEDSTRING
  1301. {
  1302. $$ = $1;
  1303. }
  1304. | QUOTEDSTRING ','
  1305. {
  1306. $$ = $1;
  1307. }
  1308. | STRING ','
  1309. {
  1310. $$ = $1;
  1311. }
  1312. ;
  1313. resref:
  1314. posnumexpr ','
  1315. {
  1316. $$.named = 0;
  1317. $$.u.id = $1;
  1318. }
  1319. | resname
  1320. {
  1321. char *copy, *s;
  1322. /* It seems that resource ID's are forced to upper case. */
  1323. copy = xstrdup ($1);
  1324. for (s = copy; *s != '\0'; s++)
  1325. *s = TOUPPER (*s);
  1326. res_string_to_id (&$$, copy);
  1327. free (copy);
  1328. }
  1329. ;
  1330. /* Generic suboptions. These may appear before the BEGIN in any
  1331. multiline statement. */
  1332. suboptions:
  1333. /* empty */
  1334. {
  1335. memset (&$$, 0, sizeof (struct res_res_info));
  1336. $$.language = language;
  1337. /* FIXME: Is this the right default? */
  1338. $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
  1339. }
  1340. | suboptions memflag
  1341. {
  1342. $$ = $1;
  1343. $$.memflags |= $2.on;
  1344. $$.memflags &=~ $2.off;
  1345. }
  1346. | suboptions CHARACTERISTICS numexpr
  1347. {
  1348. $$ = $1;
  1349. $$.characteristics = $3;
  1350. }
  1351. | suboptions LANGUAGE numexpr cnumexpr
  1352. {
  1353. $$ = $1;
  1354. $$.language = $3 | ($4 << SUBLANG_SHIFT);
  1355. }
  1356. | suboptions VERSIONK numexpr
  1357. {
  1358. $$ = $1;
  1359. $$.version = $3;
  1360. }
  1361. ;
  1362. /* Memory flags which default to MOVEABLE and DISCARDABLE. */
  1363. memflags_move_discard:
  1364. /* empty */
  1365. {
  1366. memset (&$$, 0, sizeof (struct res_res_info));
  1367. $$.language = language;
  1368. $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
  1369. }
  1370. | memflags_move_discard memflag
  1371. {
  1372. $$ = $1;
  1373. $$.memflags |= $2.on;
  1374. $$.memflags &=~ $2.off;
  1375. }
  1376. ;
  1377. /* Memory flags which default to MOVEABLE. */
  1378. memflags_move:
  1379. /* empty */
  1380. {
  1381. memset (&$$, 0, sizeof (struct res_res_info));
  1382. $$.language = language;
  1383. $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
  1384. }
  1385. | memflags_move memflag
  1386. {
  1387. $$ = $1;
  1388. $$.memflags |= $2.on;
  1389. $$.memflags &=~ $2.off;
  1390. }
  1391. ;
  1392. /* Memory flags. This returns a struct with two integers, because we
  1393. sometimes want to set bits and we sometimes want to clear them. */
  1394. memflag:
  1395. MOVEABLE
  1396. {
  1397. $$.on = MEMFLAG_MOVEABLE;
  1398. $$.off = 0;
  1399. }
  1400. | FIXED
  1401. {
  1402. $$.on = 0;
  1403. $$.off = MEMFLAG_MOVEABLE;
  1404. }
  1405. | PURE
  1406. {
  1407. $$.on = MEMFLAG_PURE;
  1408. $$.off = 0;
  1409. }
  1410. | IMPURE
  1411. {
  1412. $$.on = 0;
  1413. $$.off = MEMFLAG_PURE;
  1414. }
  1415. | PRELOAD
  1416. {
  1417. $$.on = MEMFLAG_PRELOAD;
  1418. $$.off = 0;
  1419. }
  1420. | LOADONCALL
  1421. {
  1422. $$.on = 0;
  1423. $$.off = MEMFLAG_PRELOAD;
  1424. }
  1425. | DISCARDABLE
  1426. {
  1427. $$.on = MEMFLAG_DISCARDABLE;
  1428. $$.off = 0;
  1429. }
  1430. ;
  1431. /* A file name. */
  1432. file_name:
  1433. QUOTEDSTRING
  1434. {
  1435. $$ = $1;
  1436. }
  1437. | STRING
  1438. {
  1439. $$ = $1;
  1440. }
  1441. ;
  1442. /* A style expression. This changes the static variable STYLE. We do
  1443. it this way because rc appears to permit a style to be set to
  1444. something like
  1445. WS_GROUP | NOT WS_TABSTOP
  1446. to mean that a default of WS_TABSTOP should be removed. Anything
  1447. which wants to accept a style must first set STYLE to the default
  1448. value. The styleexpr nonterminal will change STYLE as specified by
  1449. the user. Note that we do not accept arbitrary expressions here,
  1450. just numbers separated by '|'. */
  1451. styleexpr:
  1452. parennumber
  1453. {
  1454. style |= $1;
  1455. }
  1456. | NOT parennumber
  1457. {
  1458. style &=~ $2;
  1459. }
  1460. | styleexpr '|' parennumber
  1461. {
  1462. style |= $3;
  1463. }
  1464. | styleexpr '|' NOT parennumber
  1465. {
  1466. style &=~ $4;
  1467. }
  1468. ;
  1469. parennumber:
  1470. NUMBER
  1471. {
  1472. $$ = $1.val;
  1473. }
  1474. | '(' numexpr ')'
  1475. {
  1476. $$ = $2;
  1477. }
  1478. ;
  1479. /* An optional expression with a leading comma. */
  1480. optcnumexpr:
  1481. /* empty */
  1482. {
  1483. $$ = 0;
  1484. }
  1485. | cnumexpr
  1486. {
  1487. $$ = $1;
  1488. }
  1489. ;
  1490. /* An expression with a leading comma. */
  1491. cnumexpr:
  1492. ',' numexpr
  1493. {
  1494. $$ = $2;
  1495. }
  1496. ;
  1497. /* A possibly negated numeric expression. */
  1498. numexpr:
  1499. sizednumexpr
  1500. {
  1501. $$ = $1.val;
  1502. }
  1503. ;
  1504. /* A possibly negated expression with a size. */
  1505. sizednumexpr:
  1506. NUMBER
  1507. {
  1508. $$ = $1;
  1509. }
  1510. | '(' sizednumexpr ')'
  1511. {
  1512. $$ = $2;
  1513. }
  1514. | '~' sizednumexpr %prec '~'
  1515. {
  1516. $$.val = ~ $2.val;
  1517. $$.dword = $2.dword;
  1518. }
  1519. | '-' sizednumexpr %prec NEG
  1520. {
  1521. $$.val = - $2.val;
  1522. $$.dword = $2.dword;
  1523. }
  1524. | sizednumexpr '*' sizednumexpr
  1525. {
  1526. $$.val = $1.val * $3.val;
  1527. $$.dword = $1.dword || $3.dword;
  1528. }
  1529. | sizednumexpr '/' sizednumexpr
  1530. {
  1531. $$.val = $1.val / $3.val;
  1532. $$.dword = $1.dword || $3.dword;
  1533. }
  1534. | sizednumexpr '%' sizednumexpr
  1535. {
  1536. $$.val = $1.val % $3.val;
  1537. $$.dword = $1.dword || $3.dword;
  1538. }
  1539. | sizednumexpr '+' sizednumexpr
  1540. {
  1541. $$.val = $1.val + $3.val;
  1542. $$.dword = $1.dword || $3.dword;
  1543. }
  1544. | sizednumexpr '-' sizednumexpr
  1545. {
  1546. $$.val = $1.val - $3.val;
  1547. $$.dword = $1.dword || $3.dword;
  1548. }
  1549. | sizednumexpr '&' sizednumexpr
  1550. {
  1551. $$.val = $1.val & $3.val;
  1552. $$.dword = $1.dword || $3.dword;
  1553. }
  1554. | sizednumexpr '^' sizednumexpr
  1555. {
  1556. $$.val = $1.val ^ $3.val;
  1557. $$.dword = $1.dword || $3.dword;
  1558. }
  1559. | sizednumexpr '|' sizednumexpr
  1560. {
  1561. $$.val = $1.val | $3.val;
  1562. $$.dword = $1.dword || $3.dword;
  1563. }
  1564. ;
  1565. /* An expression with a leading comma which does not use unary
  1566. negation. */
  1567. cposnumexpr:
  1568. ',' posnumexpr
  1569. {
  1570. $$ = $2;
  1571. }
  1572. ;
  1573. /* An expression which does not use unary negation. */
  1574. posnumexpr:
  1575. sizedposnumexpr
  1576. {
  1577. $$ = $1.val;
  1578. }
  1579. ;
  1580. /* An expression which does not use unary negation. We separate unary
  1581. negation to avoid parsing conflicts when two numeric expressions
  1582. appear consecutively. */
  1583. sizedposnumexpr:
  1584. NUMBER
  1585. {
  1586. $$ = $1;
  1587. }
  1588. | '(' sizednumexpr ')'
  1589. {
  1590. $$ = $2;
  1591. }
  1592. | '~' sizednumexpr %prec '~'
  1593. {
  1594. $$.val = ~ $2.val;
  1595. $$.dword = $2.dword;
  1596. }
  1597. | sizedposnumexpr '*' sizednumexpr
  1598. {
  1599. $$.val = $1.val * $3.val;
  1600. $$.dword = $1.dword || $3.dword;
  1601. }
  1602. | sizedposnumexpr '/' sizednumexpr
  1603. {
  1604. $$.val = $1.val / $3.val;
  1605. $$.dword = $1.dword || $3.dword;
  1606. }
  1607. | sizedposnumexpr '%' sizednumexpr
  1608. {
  1609. $$.val = $1.val % $3.val;
  1610. $$.dword = $1.dword || $3.dword;
  1611. }
  1612. | sizedposnumexpr '+' sizednumexpr
  1613. {
  1614. $$.val = $1.val + $3.val;
  1615. $$.dword = $1.dword || $3.dword;
  1616. }
  1617. | sizedposnumexpr '-' sizednumexpr
  1618. {
  1619. $$.val = $1.val - $3.val;
  1620. $$.dword = $1.dword || $3.dword;
  1621. }
  1622. | sizedposnumexpr '&' sizednumexpr
  1623. {
  1624. $$.val = $1.val & $3.val;
  1625. $$.dword = $1.dword || $3.dword;
  1626. }
  1627. | sizedposnumexpr '^' sizednumexpr
  1628. {
  1629. $$.val = $1.val ^ $3.val;
  1630. $$.dword = $1.dword || $3.dword;
  1631. }
  1632. | sizedposnumexpr '|' sizednumexpr
  1633. {
  1634. $$.val = $1.val | $3.val;
  1635. $$.dword = $1.dword || $3.dword;
  1636. }
  1637. ;
  1638. %%
  1639. /* Set the language from the command line. */
  1640. void
  1641. rcparse_set_language (int lang)
  1642. {
  1643. language = lang;
  1644. }