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

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

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