PageRenderTime 61ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/opensource.apple.com/source/gdb/gdb-413/src/binutils/rcparse.y

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