rcparse.y 40 KB

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