rcparse.y 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. %{ /* rcparse.y -- parser for Windows rc files
  2. Copyright (C) 1997-2022 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 OWNERDRAW
  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 | WS_TABSTOP;
  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. | BITMAP
  1023. {
  1024. $$ = MENUITEM_BITMAP;
  1025. }
  1026. | OWNERDRAW
  1027. {
  1028. $$ = MENUITEM_OWNERDRAW;
  1029. }
  1030. ;
  1031. /* Menuex resources. */
  1032. menuex:
  1033. id MENUEX suboptions BEG menuexitems END
  1034. {
  1035. define_menu ($1, &$3, $5);
  1036. if (yychar != YYEMPTY)
  1037. YYERROR;
  1038. rcparse_discard_strings ();
  1039. }
  1040. ;
  1041. menuexitems:
  1042. /* empty */
  1043. {
  1044. $$ = NULL;
  1045. }
  1046. | menuexitems menuexitem
  1047. {
  1048. if ($1 == NULL)
  1049. $$ = $2;
  1050. else
  1051. {
  1052. rc_menuitem **pp;
  1053. for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
  1054. ;
  1055. *pp = $2;
  1056. $$ = $1;
  1057. }
  1058. }
  1059. ;
  1060. menuexitem:
  1061. MENUITEM res_unicode_string_concat
  1062. {
  1063. $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
  1064. }
  1065. | MENUITEM res_unicode_string_concat cnumexpr
  1066. {
  1067. $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
  1068. }
  1069. | MENUITEM res_unicode_string_concat cnumexpr cnumexpr optcnumexpr
  1070. {
  1071. $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
  1072. }
  1073. | MENUITEM SEPARATOR
  1074. {
  1075. $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
  1076. }
  1077. | POPUP res_unicode_string_concat BEG menuexitems END
  1078. {
  1079. $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
  1080. }
  1081. | POPUP res_unicode_string_concat cnumexpr BEG menuexitems END
  1082. {
  1083. $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
  1084. }
  1085. | POPUP res_unicode_string_concat cnumexpr cnumexpr BEG menuexitems END
  1086. {
  1087. $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
  1088. }
  1089. | POPUP res_unicode_string_concat cnumexpr cnumexpr cnumexpr optcnumexpr
  1090. BEG menuexitems END
  1091. {
  1092. $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
  1093. }
  1094. ;
  1095. /* Messagetable resources. */
  1096. messagetable:
  1097. id MESSAGETABLE memflags_move file_name
  1098. {
  1099. define_messagetable ($1, &$3, $4);
  1100. if (yychar != YYEMPTY)
  1101. YYERROR;
  1102. rcparse_discard_strings ();
  1103. }
  1104. ;
  1105. /* We use a different lexing algorithm, because rcdata strings may
  1106. contain embedded null bytes, and we need to know the length to use. */
  1107. optrcdata_data:
  1108. {
  1109. rcparse_rcdata ();
  1110. }
  1111. optrcdata_data_int
  1112. {
  1113. rcparse_normal ();
  1114. $$ = $2;
  1115. }
  1116. ;
  1117. optrcdata_data_int:
  1118. /* empty */
  1119. {
  1120. $$.first = NULL;
  1121. $$.last = NULL;
  1122. }
  1123. | rcdata_data
  1124. {
  1125. $$ = $1;
  1126. }
  1127. ;
  1128. rcdata_data:
  1129. sizedstring
  1130. {
  1131. rc_rcdata_item *ri;
  1132. ri = define_rcdata_string ($1.s, $1.length);
  1133. $$.first = ri;
  1134. $$.last = ri;
  1135. }
  1136. | sizedunistring
  1137. {
  1138. rc_rcdata_item *ri;
  1139. ri = define_rcdata_unistring ($1.s, $1.length);
  1140. $$.first = ri;
  1141. $$.last = ri;
  1142. }
  1143. | sizednumexpr
  1144. {
  1145. rc_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. rc_rcdata_item *ri;
  1153. ri = define_rcdata_string ($3.s, $3.length);
  1154. $$.first = $1.first;
  1155. $1.last->next = ri;
  1156. $$.last = ri;
  1157. }
  1158. | rcdata_data ',' sizedunistring
  1159. {
  1160. rc_rcdata_item *ri;
  1161. ri = define_rcdata_unistring ($3.s, $3.length);
  1162. $$.first = $1.first;
  1163. $1.last->next = ri;
  1164. $$.last = ri;
  1165. }
  1166. | rcdata_data ',' sizednumexpr
  1167. {
  1168. rc_rcdata_item *ri;
  1169. ri = define_rcdata_number ($3.val, $3.dword);
  1170. $$.first = $1.first;
  1171. $1.last->next = ri;
  1172. $$.last = ri;
  1173. }
  1174. | rcdata_data ','
  1175. {
  1176. $$=$1;
  1177. }
  1178. ;
  1179. /* Stringtable resources. */
  1180. stringtable:
  1181. STRINGTABLE suboptions BEG
  1182. { sub_res_info = $2; rcparse_rcdata (); }
  1183. string_data END { rcparse_normal (); }
  1184. ;
  1185. string_data:
  1186. /* empty */
  1187. | string_data numexpr res_unicode_sizedstring_concat
  1188. {
  1189. define_stringtable (&sub_res_info, $2, $3.s, $3.length);
  1190. rcparse_discard_strings ();
  1191. }
  1192. | string_data numexpr ',' res_unicode_sizedstring_concat
  1193. {
  1194. define_stringtable (&sub_res_info, $2, $4.s, $4.length);
  1195. rcparse_discard_strings ();
  1196. }
  1197. | string_data error
  1198. {
  1199. rcparse_warning (_("invalid stringtable resource."));
  1200. abort ();
  1201. }
  1202. ;
  1203. rcdata_id:
  1204. id
  1205. {
  1206. $$=$1;
  1207. }
  1208. | HTML
  1209. {
  1210. $$.named = 0;
  1211. $$.u.id = 23;
  1212. }
  1213. | RCDATA
  1214. {
  1215. $$.named = 0;
  1216. $$.u.id = RT_RCDATA;
  1217. }
  1218. | MANIFEST
  1219. {
  1220. $$.named = 0;
  1221. $$.u.id = RT_MANIFEST;
  1222. }
  1223. | PLUGPLAY
  1224. {
  1225. $$.named = 0;
  1226. $$.u.id = RT_PLUGPLAY;
  1227. }
  1228. | VXD
  1229. {
  1230. $$.named = 0;
  1231. $$.u.id = RT_VXD;
  1232. }
  1233. | DLGINCLUDE
  1234. {
  1235. $$.named = 0;
  1236. $$.u.id = RT_DLGINCLUDE;
  1237. }
  1238. | DLGINIT
  1239. {
  1240. $$.named = 0;
  1241. $$.u.id = RT_DLGINIT;
  1242. }
  1243. | ANICURSOR
  1244. {
  1245. $$.named = 0;
  1246. $$.u.id = RT_ANICURSOR;
  1247. }
  1248. | ANIICON
  1249. {
  1250. $$.named = 0;
  1251. $$.u.id = RT_ANIICON;
  1252. }
  1253. ;
  1254. /* User defined resources. We accept general suboptions in the
  1255. file_name case to keep the parser happy. */
  1256. user:
  1257. id rcdata_id suboptions BEG optrcdata_data END
  1258. {
  1259. define_user_data ($1, $2, &$3, $5.first);
  1260. if (yychar != YYEMPTY)
  1261. YYERROR;
  1262. rcparse_discard_strings ();
  1263. }
  1264. | id rcdata_id suboptions file_name
  1265. {
  1266. define_user_file ($1, $2, &$3, $4);
  1267. if (yychar != YYEMPTY)
  1268. YYERROR;
  1269. rcparse_discard_strings ();
  1270. }
  1271. ;
  1272. toolbar:
  1273. id TOOLBAR suboptions numexpr cnumexpr BEG toolbar_data END
  1274. {
  1275. define_toolbar ($1, &$3, $4, $5, $7);
  1276. }
  1277. ;
  1278. toolbar_data: /* empty */ { $$= NULL; }
  1279. | toolbar_data BUTTON id
  1280. {
  1281. rc_toolbar_item *c,*n;
  1282. c = $1;
  1283. n= (rc_toolbar_item *)
  1284. res_alloc (sizeof (rc_toolbar_item));
  1285. if (c != NULL)
  1286. while (c->next != NULL)
  1287. c = c->next;
  1288. n->prev = c;
  1289. n->next = NULL;
  1290. if (c != NULL)
  1291. c->next = n;
  1292. n->id = $3;
  1293. if ($1 == NULL)
  1294. $$ = n;
  1295. else
  1296. $$ = $1;
  1297. }
  1298. | toolbar_data SEPARATOR
  1299. {
  1300. rc_toolbar_item *c,*n;
  1301. c = $1;
  1302. n= (rc_toolbar_item *)
  1303. res_alloc (sizeof (rc_toolbar_item));
  1304. if (c != NULL)
  1305. while (c->next != NULL)
  1306. c = c->next;
  1307. n->prev = c;
  1308. n->next = NULL;
  1309. if (c != NULL)
  1310. c->next = n;
  1311. n->id.named = 0;
  1312. n->id.u.id = 0;
  1313. if ($1 == NULL)
  1314. $$ = n;
  1315. else
  1316. $$ = $1;
  1317. }
  1318. ;
  1319. /* Versioninfo resources. */
  1320. versioninfo:
  1321. id VERSIONINFO fixedverinfo BEG verblocks END
  1322. {
  1323. define_versioninfo ($1, language, $3, $5);
  1324. if (yychar != YYEMPTY)
  1325. YYERROR;
  1326. rcparse_discard_strings ();
  1327. }
  1328. ;
  1329. fixedverinfo:
  1330. /* empty */
  1331. {
  1332. $$ = ((rc_fixed_versioninfo *)
  1333. res_alloc (sizeof (rc_fixed_versioninfo)));
  1334. memset ($$, 0, sizeof (rc_fixed_versioninfo));
  1335. }
  1336. | fixedverinfo FILEVERSION numexpr optcnumexpr optcnumexpr
  1337. optcnumexpr
  1338. {
  1339. $1->file_version_ms = ($3 << 16) | ($4 & 0xffff);
  1340. $1->file_version_ls = ($5 << 16) | ($6 & 0xffff);
  1341. $$ = $1;
  1342. }
  1343. | fixedverinfo PRODUCTVERSION numexpr optcnumexpr optcnumexpr
  1344. optcnumexpr
  1345. {
  1346. $1->product_version_ms = ($3 << 16) | ($4 & 0xffff);
  1347. $1->product_version_ls = ($5 << 16) | ($6 & 0xffff);
  1348. $$ = $1;
  1349. }
  1350. | fixedverinfo FILEFLAGSMASK numexpr
  1351. {
  1352. $1->file_flags_mask = $3;
  1353. $$ = $1;
  1354. }
  1355. | fixedverinfo FILEFLAGS numexpr
  1356. {
  1357. $1->file_flags = $3;
  1358. $$ = $1;
  1359. }
  1360. | fixedverinfo FILEOS numexpr
  1361. {
  1362. $1->file_os = $3;
  1363. $$ = $1;
  1364. }
  1365. | fixedverinfo FILETYPE numexpr
  1366. {
  1367. $1->file_type = $3;
  1368. $$ = $1;
  1369. }
  1370. | fixedverinfo FILESUBTYPE numexpr
  1371. {
  1372. $1->file_subtype = $3;
  1373. $$ = $1;
  1374. }
  1375. ;
  1376. /* To handle verblocks successfully, the lexer handles BLOCK
  1377. specially. A BLOCK "StringFileInfo" is returned as
  1378. BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
  1379. BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
  1380. with the string as the value. */
  1381. verblocks:
  1382. /* empty */
  1383. {
  1384. $$ = NULL;
  1385. }
  1386. | verblocks BLOCKSTRINGFILEINFO BEG verstringtables END
  1387. {
  1388. $$ = append_ver_stringfileinfo ($1, $4);
  1389. }
  1390. | verblocks BLOCKVARFILEINFO BEG VALUE res_unicode_string_concat vertrans END
  1391. {
  1392. $$ = append_ver_varfileinfo ($1, $5, $6);
  1393. }
  1394. ;
  1395. verstringtables:
  1396. /* empty */
  1397. {
  1398. $$ = NULL;
  1399. }
  1400. | verstringtables BLOCK BEG vervals END
  1401. {
  1402. $$ = append_ver_stringtable ($1, $2, $4);
  1403. }
  1404. ;
  1405. vervals:
  1406. /* empty */
  1407. {
  1408. $$ = NULL;
  1409. }
  1410. | vervals VALUE res_unicode_string_concat ',' res_unicode_string_concat
  1411. {
  1412. $$ = append_verval ($1, $3, $5);
  1413. }
  1414. ;
  1415. vertrans:
  1416. /* empty */
  1417. {
  1418. $$ = NULL;
  1419. }
  1420. | vertrans cnumexpr cnumexpr
  1421. {
  1422. $$ = append_vertrans ($1, $2, $3);
  1423. }
  1424. ;
  1425. /* A resource ID. */
  1426. id:
  1427. posnumexpr
  1428. {
  1429. $$.named = 0;
  1430. $$.u.id = $1;
  1431. }
  1432. | resname
  1433. {
  1434. res_unistring_to_id (&$$, $1);
  1435. }
  1436. ;
  1437. /* A resource reference. */
  1438. resname:
  1439. res_unicode_string
  1440. {
  1441. $$ = $1;
  1442. }
  1443. | STRING
  1444. {
  1445. unichar *h = NULL;
  1446. unicode_from_ascii ((rc_uint_type *) NULL, &h, $1);
  1447. $$ = h;
  1448. }
  1449. ;
  1450. resref:
  1451. posnumexpr ','
  1452. {
  1453. $$.named = 0;
  1454. $$.u.id = $1;
  1455. }
  1456. | resname
  1457. {
  1458. res_unistring_to_id (&$$, $1);
  1459. }
  1460. | resname ','
  1461. {
  1462. res_unistring_to_id (&$$, $1);
  1463. }
  1464. ;
  1465. /* Generic suboptions. These may appear before the BEGIN in any
  1466. multiline statement. */
  1467. suboptions:
  1468. /* empty */
  1469. {
  1470. memset (&$$, 0, sizeof (rc_res_res_info));
  1471. $$.language = language;
  1472. /* FIXME: Is this the right default? */
  1473. $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
  1474. }
  1475. | suboptions memflag
  1476. {
  1477. $$ = $1;
  1478. $$.memflags |= $2.on;
  1479. $$.memflags &=~ $2.off;
  1480. }
  1481. | suboptions CHARACTERISTICS numexpr
  1482. {
  1483. $$ = $1;
  1484. $$.characteristics = $3;
  1485. }
  1486. | suboptions LANGUAGE numexpr cnumexpr
  1487. {
  1488. $$ = $1;
  1489. $$.language = $3 | ($4 << SUBLANG_SHIFT);
  1490. }
  1491. | suboptions VERSIONK numexpr
  1492. {
  1493. $$ = $1;
  1494. $$.version = $3;
  1495. }
  1496. ;
  1497. /* Memory flags which default to MOVEABLE and DISCARDABLE. */
  1498. memflags_move_discard:
  1499. /* empty */
  1500. {
  1501. memset (&$$, 0, sizeof (rc_res_res_info));
  1502. $$.language = language;
  1503. $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
  1504. }
  1505. | memflags_move_discard memflag
  1506. {
  1507. $$ = $1;
  1508. $$.memflags |= $2.on;
  1509. $$.memflags &=~ $2.off;
  1510. }
  1511. ;
  1512. /* Memory flags which default to MOVEABLE. */
  1513. memflags_move:
  1514. /* empty */
  1515. {
  1516. memset (&$$, 0, sizeof (rc_res_res_info));
  1517. $$.language = language;
  1518. $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
  1519. }
  1520. | memflags_move memflag
  1521. {
  1522. $$ = $1;
  1523. $$.memflags |= $2.on;
  1524. $$.memflags &=~ $2.off;
  1525. }
  1526. ;
  1527. /* Memory flags. This returns a struct with two integers, because we
  1528. sometimes want to set bits and we sometimes want to clear them. */
  1529. memflag:
  1530. MOVEABLE
  1531. {
  1532. $$.on = MEMFLAG_MOVEABLE;
  1533. $$.off = 0;
  1534. }
  1535. | FIXED
  1536. {
  1537. $$.on = 0;
  1538. $$.off = MEMFLAG_MOVEABLE;
  1539. }
  1540. | PURE
  1541. {
  1542. $$.on = MEMFLAG_PURE;
  1543. $$.off = 0;
  1544. }
  1545. | IMPURE
  1546. {
  1547. $$.on = 0;
  1548. $$.off = MEMFLAG_PURE;
  1549. }
  1550. | PRELOAD
  1551. {
  1552. $$.on = MEMFLAG_PRELOAD;
  1553. $$.off = 0;
  1554. }
  1555. | LOADONCALL
  1556. {
  1557. $$.on = 0;
  1558. $$.off = MEMFLAG_PRELOAD;
  1559. }
  1560. | DISCARDABLE
  1561. {
  1562. $$.on = MEMFLAG_DISCARDABLE;
  1563. $$.off = 0;
  1564. }
  1565. ;
  1566. /* A file name. */
  1567. file_name:
  1568. QUOTEDSTRING
  1569. {
  1570. $$ = $1;
  1571. }
  1572. | STRING
  1573. {
  1574. $$ = $1;
  1575. }
  1576. ;
  1577. /* Concat string */
  1578. res_unicode_string_concat:
  1579. res_unicode_string
  1580. {
  1581. $$ = $1;
  1582. }
  1583. |
  1584. res_unicode_string_concat res_unicode_string
  1585. {
  1586. rc_uint_type l1 = unichar_len ($1);
  1587. rc_uint_type l2 = unichar_len ($2);
  1588. unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar));
  1589. if (l1 != 0)
  1590. memcpy (h, $1, l1 * sizeof (unichar));
  1591. if (l2 != 0)
  1592. memcpy (h + l1, $2, l2 * sizeof (unichar));
  1593. h[l1 + l2] = 0;
  1594. $$ = h;
  1595. }
  1596. ;
  1597. res_unicode_string:
  1598. QUOTEDUNISTRING
  1599. {
  1600. $$ = unichar_dup ($1);
  1601. }
  1602. | QUOTEDSTRING
  1603. {
  1604. unichar *h = NULL;
  1605. unicode_from_ascii ((rc_uint_type *) NULL, &h, $1);
  1606. $$ = h;
  1607. }
  1608. ;
  1609. res_unicode_sizedstring:
  1610. sizedunistring
  1611. {
  1612. $$ = $1;
  1613. }
  1614. | sizedstring
  1615. {
  1616. unichar *h = NULL;
  1617. rc_uint_type l = 0;
  1618. unicode_from_ascii_len (&l, &h, $1.s, $1.length);
  1619. $$.s = h;
  1620. $$.length = l;
  1621. }
  1622. ;
  1623. /* Concat string */
  1624. res_unicode_sizedstring_concat:
  1625. res_unicode_sizedstring
  1626. {
  1627. $$ = $1;
  1628. }
  1629. |
  1630. res_unicode_sizedstring_concat res_unicode_sizedstring
  1631. {
  1632. rc_uint_type l1 = $1.length;
  1633. rc_uint_type l2 = $2.length;
  1634. unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar));
  1635. if (l1 != 0)
  1636. memcpy (h, $1.s, l1 * sizeof (unichar));
  1637. if (l2 != 0)
  1638. memcpy (h + l1, $2.s, l2 * sizeof (unichar));
  1639. h[l1 + l2] = 0;
  1640. $$.length = l1 + l2;
  1641. $$.s = h;
  1642. }
  1643. ;
  1644. sizedstring:
  1645. SIZEDSTRING
  1646. {
  1647. $$ = $1;
  1648. }
  1649. | sizedstring SIZEDSTRING
  1650. {
  1651. rc_uint_type l = $1.length + $2.length;
  1652. char *h = (char *) res_alloc (l);
  1653. memcpy (h, $1.s, $1.length);
  1654. memcpy (h + $1.length, $2.s, $2.length);
  1655. $$.s = h;
  1656. $$.length = l;
  1657. }
  1658. ;
  1659. sizedunistring:
  1660. SIZEDUNISTRING
  1661. {
  1662. $$ = $1;
  1663. }
  1664. | sizedunistring SIZEDUNISTRING
  1665. {
  1666. rc_uint_type l = $1.length + $2.length;
  1667. unichar *h = (unichar *) res_alloc (l * sizeof (unichar));
  1668. memcpy (h, $1.s, $1.length * sizeof (unichar));
  1669. memcpy (h + $1.length, $2.s, $2.length * sizeof (unichar));
  1670. $$.s = h;
  1671. $$.length = l;
  1672. }
  1673. ;
  1674. /* A style expression. This changes the static variable STYLE. We do
  1675. it this way because rc appears to permit a style to be set to
  1676. something like
  1677. WS_GROUP | NOT WS_TABSTOP
  1678. to mean that a default of WS_TABSTOP should be removed. Anything
  1679. which wants to accept a style must first set STYLE to the default
  1680. value. The styleexpr nonterminal will change STYLE as specified by
  1681. the user. Note that we do not accept arbitrary expressions here,
  1682. just numbers separated by '|'. */
  1683. styleexpr:
  1684. parennumber
  1685. {
  1686. style |= $1;
  1687. }
  1688. | NOT parennumber
  1689. {
  1690. style &=~ $2;
  1691. }
  1692. | styleexpr '|' parennumber
  1693. {
  1694. style |= $3;
  1695. }
  1696. | styleexpr '|' NOT parennumber
  1697. {
  1698. style &=~ $4;
  1699. }
  1700. ;
  1701. parennumber:
  1702. NUMBER
  1703. {
  1704. $$ = $1.val;
  1705. }
  1706. | '(' numexpr ')'
  1707. {
  1708. $$ = $2;
  1709. }
  1710. ;
  1711. /* An optional expression with a leading comma. */
  1712. optcnumexpr:
  1713. /* empty */
  1714. {
  1715. $$ = 0;
  1716. }
  1717. | cnumexpr
  1718. {
  1719. $$ = $1;
  1720. }
  1721. ;
  1722. /* An expression with a leading comma. */
  1723. cnumexpr:
  1724. ',' numexpr
  1725. {
  1726. $$ = $2;
  1727. }
  1728. ;
  1729. /* A possibly negated numeric expression. */
  1730. numexpr:
  1731. sizednumexpr
  1732. {
  1733. $$ = $1.val;
  1734. }
  1735. ;
  1736. /* A possibly negated expression with a size. */
  1737. sizednumexpr:
  1738. NUMBER
  1739. {
  1740. $$ = $1;
  1741. }
  1742. | '(' sizednumexpr ')'
  1743. {
  1744. $$ = $2;
  1745. }
  1746. | '~' sizednumexpr %prec '~'
  1747. {
  1748. $$.val = ~ $2.val;
  1749. $$.dword = $2.dword;
  1750. }
  1751. | '-' sizednumexpr %prec NEG
  1752. {
  1753. $$.val = - $2.val;
  1754. $$.dword = $2.dword;
  1755. }
  1756. | sizednumexpr '*' sizednumexpr
  1757. {
  1758. $$.val = $1.val * $3.val;
  1759. $$.dword = $1.dword || $3.dword;
  1760. }
  1761. | sizednumexpr '/' sizednumexpr
  1762. {
  1763. $$.val = $1.val / ($3.val ? $3.val : 1);
  1764. $$.dword = $1.dword || $3.dword;
  1765. }
  1766. | sizednumexpr '%' sizednumexpr
  1767. {
  1768. $$.val = $1.val % ($3.val ? $3.val : 1);
  1769. $$.dword = $1.dword || $3.dword;
  1770. }
  1771. | sizednumexpr '+' sizednumexpr
  1772. {
  1773. $$.val = $1.val + $3.val;
  1774. $$.dword = $1.dword || $3.dword;
  1775. }
  1776. | sizednumexpr '-' sizednumexpr
  1777. {
  1778. $$.val = $1.val - $3.val;
  1779. $$.dword = $1.dword || $3.dword;
  1780. }
  1781. | sizednumexpr '&' sizednumexpr
  1782. {
  1783. $$.val = $1.val & $3.val;
  1784. $$.dword = $1.dword || $3.dword;
  1785. }
  1786. | sizednumexpr '^' sizednumexpr
  1787. {
  1788. $$.val = $1.val ^ $3.val;
  1789. $$.dword = $1.dword || $3.dword;
  1790. }
  1791. | sizednumexpr '|' sizednumexpr
  1792. {
  1793. $$.val = $1.val | $3.val;
  1794. $$.dword = $1.dword || $3.dword;
  1795. }
  1796. ;
  1797. /* An expression with a leading comma which does not use unary
  1798. negation. */
  1799. cposnumexpr:
  1800. ',' posnumexpr
  1801. {
  1802. $$ = $2;
  1803. }
  1804. ;
  1805. /* An expression which does not use unary negation. */
  1806. posnumexpr:
  1807. sizedposnumexpr
  1808. {
  1809. $$ = $1.val;
  1810. }
  1811. ;
  1812. /* An expression which does not use unary negation. We separate unary
  1813. negation to avoid parsing conflicts when two numeric expressions
  1814. appear consecutively. */
  1815. sizedposnumexpr:
  1816. NUMBER
  1817. {
  1818. $$ = $1;
  1819. }
  1820. | '(' sizednumexpr ')'
  1821. {
  1822. $$ = $2;
  1823. }
  1824. | '~' sizednumexpr %prec '~'
  1825. {
  1826. $$.val = ~ $2.val;
  1827. $$.dword = $2.dword;
  1828. }
  1829. | sizedposnumexpr '*' sizednumexpr
  1830. {
  1831. $$.val = $1.val * $3.val;
  1832. $$.dword = $1.dword || $3.dword;
  1833. }
  1834. | sizedposnumexpr '/' sizednumexpr
  1835. {
  1836. $$.val = $1.val / ($3.val ? $3.val : 1);
  1837. $$.dword = $1.dword || $3.dword;
  1838. }
  1839. | sizedposnumexpr '%' sizednumexpr
  1840. {
  1841. /* PR 17512: file: 89105a25. */
  1842. $$.val = $1.val % ($3.val ? $3.val : 1);
  1843. $$.dword = $1.dword || $3.dword;
  1844. }
  1845. | sizedposnumexpr '+' sizednumexpr
  1846. {
  1847. $$.val = $1.val + $3.val;
  1848. $$.dword = $1.dword || $3.dword;
  1849. }
  1850. | sizedposnumexpr '-' sizednumexpr
  1851. {
  1852. $$.val = $1.val - $3.val;
  1853. $$.dword = $1.dword || $3.dword;
  1854. }
  1855. | sizedposnumexpr '&' sizednumexpr
  1856. {
  1857. $$.val = $1.val & $3.val;
  1858. $$.dword = $1.dword || $3.dword;
  1859. }
  1860. | sizedposnumexpr '^' sizednumexpr
  1861. {
  1862. $$.val = $1.val ^ $3.val;
  1863. $$.dword = $1.dword || $3.dword;
  1864. }
  1865. | sizedposnumexpr '|' sizednumexpr
  1866. {
  1867. $$.val = $1.val | $3.val;
  1868. $$.dword = $1.dword || $3.dword;
  1869. }
  1870. ;
  1871. %%
  1872. /* Set the language from the command line. */
  1873. void
  1874. rcparse_set_language (int lang)
  1875. {
  1876. language = lang;
  1877. }