PageRenderTime 54ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

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

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