-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrcparse.y
1961 lines (1820 loc) · 39 KB
/
rcparse.y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%{ /* rcparse.y -- parser for Windows rc files
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
Extended by Kai Tietz, Onevision.
This file is part of GNU Binutils.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
/* This is a parser for Windows rc files. It is based on the parser
by Gunther Ebert <[email protected]>. */
#include "sysdep.h"
#include "bfd.h"
#include "bucomm.h"
#include "libiberty.h"
#include "windres.h"
#include "safe-ctype.h"
/* The current language. */
static unsigned short language;
/* The resource information during a sub statement. */
static rc_res_res_info sub_res_info;
/* Dialog information. This is built by the nonterminals styles and
controls. */
static rc_dialog dialog;
/* This is used when building a style. It is modified by the
nonterminal styleexpr. */
static unsigned long style;
/* These are used when building a control. They are set before using
control_params. */
static rc_uint_type base_style;
static rc_uint_type default_style;
static rc_res_id class;
static rc_res_id res_text_field;
static unichar null_unichar;
/* This is used for COMBOBOX, LISTBOX and EDITTEXT which
do not allow resource 'text' field in control definition. */
static const rc_res_id res_null_text = { 1, {{0, &null_unichar}}};
%}
%union
{
rc_accelerator acc;
rc_accelerator *pacc;
rc_dialog_control *dialog_control;
rc_menuitem *menuitem;
struct
{
rc_rcdata_item *first;
rc_rcdata_item *last;
} rcdata;
rc_rcdata_item *rcdata_item;
rc_fixed_versioninfo *fixver;
rc_ver_info *verinfo;
rc_ver_stringinfo *verstring;
rc_ver_varinfo *vervar;
rc_toolbar_item *toobar_item;
rc_res_id id;
rc_res_res_info res_info;
struct
{
rc_uint_type on;
rc_uint_type off;
} memflags;
struct
{
rc_uint_type val;
/* Nonzero if this number was explicitly specified as long. */
int dword;
} i;
rc_uint_type il;
rc_uint_type is;
const char *s;
struct
{
rc_uint_type length;
const char *s;
} ss;
unichar *uni;
struct
{
rc_uint_type length;
const unichar *s;
} suni;
};
%token BEG END
%token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
%token BITMAP
%token CURSOR
%token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
%token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
%token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
%token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
%token BEDIT HEDIT IEDIT
%token FONT
%token ICON
%token ANICURSOR ANIICON DLGINCLUDE DLGINIT FONTDIR HTML MANIFEST PLUGPLAY VXD TOOLBAR BUTTON
%token LANGUAGE CHARACTERISTICS VERSIONK
%token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
%token MENUBARBREAK MENUBREAK
%token MESSAGETABLE
%token RCDATA
%token STRINGTABLE
%token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
%token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
%token VALUE
%token <s> BLOCK
%token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
%token NOT
%token <uni> QUOTEDUNISTRING
%token <s> QUOTEDSTRING STRING
%token <i> NUMBER
%token <suni> SIZEDUNISTRING
%token <ss> SIZEDSTRING
%token IGNORED_TOKEN
%type <pacc> acc_entries
%type <acc> acc_entry acc_event
%type <dialog_control> control control_params
%type <menuitem> menuitems menuitem menuexitems menuexitem
%type <rcdata> optrcdata_data optrcdata_data_int rcdata_data
%type <rcdata_item> opt_control_data
%type <fixver> fixedverinfo
%type <verinfo> verblocks
%type <verstring> vervals
%type <vervar> vertrans
%type <toobar_item> toolbar_data
%type <res_info> suboptions memflags_move_discard memflags_move
%type <memflags> memflag
%type <id> id rcdata_id optresidc resref resid cresid
%type <il> exstyle parennumber
%type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
%type <is> acc_options acc_option menuitem_flags menuitem_flag
%type <s> file_name
%type <uni> res_unicode_string resname res_unicode_string_concat
%type <ss> sizedstring
%type <suni> sizedunistring
%type <i> sizednumexpr sizedposnumexpr
%left '|'
%left '^'
%left '&'
%left '+' '-'
%left '*' '/' '%'
%right '~' NEG
%%
input:
/* empty */
| input accelerator
| input bitmap
| input cursor
| input dialog
| input font
| input icon
| input language
| input menu
| input menuex
| input messagetable
| input stringtable
| input toolbar
| input user
| input versioninfo
| input IGNORED_TOKEN
;
/* Accelerator resources. */
accelerator:
id ACCELERATORS suboptions BEG acc_entries END
{
define_accelerator ($1, &$3, $5);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
;
acc_entries:
/* empty */
{
$$ = NULL;
}
| acc_entries acc_entry
{
rc_accelerator *a;
a = (rc_accelerator *) res_alloc (sizeof *a);
*a = $2;
if ($1 == NULL)
$$ = a;
else
{
rc_accelerator **pp;
for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
;
*pp = a;
$$ = $1;
}
}
;
acc_entry:
acc_event cposnumexpr
{
$$ = $1;
$$.id = $2;
}
| acc_event cposnumexpr ',' acc_options
{
$$ = $1;
$$.id = $2;
$$.flags |= $4;
if (($$.flags & ACC_VIRTKEY) == 0
&& ($$.flags & (ACC_SHIFT | ACC_CONTROL)) != 0)
rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
}
;
acc_event:
QUOTEDSTRING
{
const char *s = $1;
char ch;
$$.next = NULL;
$$.id = 0;
ch = *s;
if (ch != '^')
$$.flags = 0;
else
{
$$.flags = ACC_CONTROL | ACC_VIRTKEY;
++s;
ch = TOUPPER (s[0]);
}
$$.key = ch;
if (s[1] != '\0')
rcparse_warning (_("accelerator should only be one character"));
}
| posnumexpr
{
$$.next = NULL;
$$.flags = 0;
$$.id = 0;
$$.key = $1;
}
;
acc_options:
acc_option
{
$$ = $1;
}
| acc_options ',' acc_option
{
$$ = $1 | $3;
}
/* I've had one report that the comma is optional. */
| acc_options acc_option
{
$$ = $1 | $2;
}
;
acc_option:
VIRTKEY
{
$$ = ACC_VIRTKEY;
}
| ASCII
{
/* This is just the absence of VIRTKEY. */
$$ = 0;
}
| NOINVERT
{
$$ = ACC_NOINVERT;
}
| SHIFT
{
$$ = ACC_SHIFT;
}
| CONTROL
{
$$ = ACC_CONTROL;
}
| ALT
{
$$ = ACC_ALT;
}
;
/* Bitmap resources. */
bitmap:
id BITMAP memflags_move file_name
{
define_bitmap ($1, &$3, $4);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
;
/* Cursor resources. */
cursor:
id CURSOR memflags_move_discard file_name
{
define_cursor ($1, &$3, $4);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
;
/* Dialog resources. */
dialog:
id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
cnumexpr
{
memset (&dialog, 0, sizeof dialog);
dialog.x = $5;
dialog.y = $6;
dialog.width = $7;
dialog.height = $8;
dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
dialog.exstyle = $4;
dialog.menu.named = 1;
dialog.class.named = 1;
dialog.font = NULL;
dialog.ex = NULL;
dialog.controls = NULL;
sub_res_info = $3;
style = 0;
}
styles BEG controls END
{
define_dialog ($1, &sub_res_info, &dialog);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
| id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
cnumexpr
{
memset (&dialog, 0, sizeof dialog);
dialog.x = $5;
dialog.y = $6;
dialog.width = $7;
dialog.height = $8;
dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
dialog.exstyle = $4;
dialog.menu.named = 1;
dialog.class.named = 1;
dialog.font = NULL;
dialog.ex = ((rc_dialog_ex *)
res_alloc (sizeof (rc_dialog_ex)));
memset (dialog.ex, 0, sizeof (rc_dialog_ex));
dialog.controls = NULL;
sub_res_info = $3;
style = 0;
}
styles BEG controls END
{
define_dialog ($1, &sub_res_info, &dialog);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
| id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
cnumexpr cnumexpr
{
memset (&dialog, 0, sizeof dialog);
dialog.x = $5;
dialog.y = $6;
dialog.width = $7;
dialog.height = $8;
dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
dialog.exstyle = $4;
dialog.menu.named = 1;
dialog.class.named = 1;
dialog.font = NULL;
dialog.ex = ((rc_dialog_ex *)
res_alloc (sizeof (rc_dialog_ex)));
memset (dialog.ex, 0, sizeof (rc_dialog_ex));
dialog.ex->help = $9;
dialog.controls = NULL;
sub_res_info = $3;
style = 0;
}
styles BEG controls END
{
define_dialog ($1, &sub_res_info, &dialog);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
;
exstyle:
/* empty */
{
$$ = 0;
}
| EXSTYLE '=' numexpr
{
$$ = $3;
}
;
styles:
/* empty */
| styles CAPTION res_unicode_string_concat
{
dialog.style |= WS_CAPTION;
style |= WS_CAPTION;
dialog.caption = $3;
}
| styles CLASS id
{
dialog.class = $3;
}
| styles STYLE
styleexpr
{
dialog.style = style;
}
| styles EXSTYLE numexpr
{
dialog.exstyle = $3;
}
| styles CLASS res_unicode_string_concat
{
res_unistring_to_id (& dialog.class, $3);
}
| styles FONT numexpr ',' res_unicode_string_concat
{
dialog.style |= DS_SETFONT;
style |= DS_SETFONT;
dialog.pointsize = $3;
dialog.font = $5;
if (dialog.ex != NULL)
{
dialog.ex->weight = 0;
dialog.ex->italic = 0;
dialog.ex->charset = 1;
}
}
| styles FONT numexpr ',' res_unicode_string_concat cnumexpr
{
dialog.style |= DS_SETFONT;
style |= DS_SETFONT;
dialog.pointsize = $3;
dialog.font = $5;
if (dialog.ex == NULL)
rcparse_warning (_("extended FONT requires DIALOGEX"));
else
{
dialog.ex->weight = $6;
dialog.ex->italic = 0;
dialog.ex->charset = 1;
}
}
| styles FONT numexpr ',' res_unicode_string_concat cnumexpr cnumexpr
{
dialog.style |= DS_SETFONT;
style |= DS_SETFONT;
dialog.pointsize = $3;
dialog.font = $5;
if (dialog.ex == NULL)
rcparse_warning (_("extended FONT requires DIALOGEX"));
else
{
dialog.ex->weight = $6;
dialog.ex->italic = $7;
dialog.ex->charset = 1;
}
}
| styles FONT numexpr ',' res_unicode_string_concat cnumexpr cnumexpr cnumexpr
{
dialog.style |= DS_SETFONT;
style |= DS_SETFONT;
dialog.pointsize = $3;
dialog.font = $5;
if (dialog.ex == NULL)
rcparse_warning (_("extended FONT requires DIALOGEX"));
else
{
dialog.ex->weight = $6;
dialog.ex->italic = $7;
dialog.ex->charset = $8;
}
}
| styles MENU id
{
dialog.menu = $3;
}
| styles CHARACTERISTICS numexpr
{
sub_res_info.characteristics = $3;
}
| styles LANGUAGE numexpr cnumexpr
{
sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT);
}
| styles VERSIONK numexpr
{
sub_res_info.version = $3;
}
;
controls:
/* empty */
| controls control
{
rc_dialog_control **pp;
for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
;
*pp = $2;
}
;
control:
AUTO3STATE optresidc
{
default_style = BS_AUTO3STATE | WS_TABSTOP;
base_style = BS_AUTO3STATE;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| AUTOCHECKBOX optresidc
{
default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
base_style = BS_AUTOCHECKBOX;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| AUTORADIOBUTTON optresidc
{
default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
base_style = BS_AUTORADIOBUTTON;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| BEDIT optresidc
{
default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
class.named = 0;
class.u.id = CTL_EDIT;
res_text_field = $2;
}
control_params
{
$$ = $4;
if (dialog.ex == NULL)
rcparse_warning (_("BEDIT requires DIALOGEX"));
res_string_to_id (&$$->class, "BEDIT");
}
| CHECKBOX optresidc
{
default_style = BS_CHECKBOX | WS_TABSTOP;
base_style = BS_CHECKBOX | WS_TABSTOP;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| COMBOBOX
{
/* This is as per MSDN documentation. With some (???)
versions of MS rc.exe their is no default style. */
default_style = CBS_SIMPLE | WS_TABSTOP;
base_style = 0;
class.named = 0;
class.u.id = CTL_COMBOBOX;
res_text_field = res_null_text;
}
control_params
{
$$ = $3;
}
| CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
{
$$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
if ($11 != NULL)
{
if (dialog.ex == NULL)
rcparse_warning (_("control data requires DIALOGEX"));
$$->data = $11;
}
}
| CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
{
$$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
if (dialog.ex == NULL)
rcparse_warning (_("help ID requires DIALOGEX"));
$$->help = $11;
$$->data = $12;
}
| CTEXT optresidc
{
default_style = SS_CENTER | WS_GROUP;
base_style = SS_CENTER;
class.named = 0;
class.u.id = CTL_STATIC;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| DEFPUSHBUTTON optresidc
{
default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| EDITTEXT
{
default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
class.named = 0;
class.u.id = CTL_EDIT;
res_text_field = res_null_text;
}
control_params
{
$$ = $3;
}
| GROUPBOX optresidc
{
default_style = BS_GROUPBOX;
base_style = BS_GROUPBOX;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| HEDIT optresidc
{
default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
class.named = 0;
class.u.id = CTL_EDIT;
res_text_field = $2;
}
control_params
{
$$ = $4;
if (dialog.ex == NULL)
rcparse_warning (_("IEDIT requires DIALOGEX"));
res_string_to_id (&$$->class, "HEDIT");
}
| ICON resref numexpr cnumexpr cnumexpr opt_control_data
{
$$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
dialog.ex);
}
| ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
opt_control_data
{
$$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
dialog.ex);
}
| ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
icon_styleexpr optcnumexpr opt_control_data
{
$$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
dialog.ex);
}
| ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
icon_styleexpr cnumexpr cnumexpr opt_control_data
{
$$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
dialog.ex);
}
| IEDIT optresidc
{
default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
class.named = 0;
class.u.id = CTL_EDIT;
res_text_field = $2;
}
control_params
{
$$ = $4;
if (dialog.ex == NULL)
rcparse_warning (_("IEDIT requires DIALOGEX"));
res_string_to_id (&$$->class, "IEDIT");
}
| LISTBOX
{
default_style = LBS_NOTIFY | WS_BORDER;
base_style = LBS_NOTIFY | WS_BORDER;
class.named = 0;
class.u.id = CTL_LISTBOX;
res_text_field = res_null_text;
}
control_params
{
$$ = $3;
}
| LTEXT optresidc
{
default_style = SS_LEFT | WS_GROUP;
base_style = SS_LEFT;
class.named = 0;
class.u.id = CTL_STATIC;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| PUSHBOX optresidc
{
default_style = BS_PUSHBOX | WS_TABSTOP;
base_style = BS_PUSHBOX;
class.named = 0;
class.u.id = CTL_BUTTON;
}
control_params
{
$$ = $4;
}
| PUSHBUTTON optresidc
{
default_style = BS_PUSHBUTTON | WS_TABSTOP;
base_style = BS_PUSHBUTTON | WS_TABSTOP;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| RADIOBUTTON optresidc
{
default_style = BS_RADIOBUTTON | WS_TABSTOP;
base_style = BS_RADIOBUTTON;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| RTEXT optresidc
{
default_style = SS_RIGHT | WS_GROUP;
base_style = SS_RIGHT;
class.named = 0;
class.u.id = CTL_STATIC;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| SCROLLBAR
{
default_style = SBS_HORZ;
base_style = 0;
class.named = 0;
class.u.id = CTL_SCROLLBAR;
res_text_field = res_null_text;
}
control_params
{
$$ = $3;
}
| STATE3 optresidc
{
default_style = BS_3STATE | WS_TABSTOP;
base_style = BS_3STATE;
class.named = 0;
class.u.id = CTL_BUTTON;
res_text_field = $2;
}
control_params
{
$$ = $4;
}
| USERBUTTON resref numexpr ',' numexpr ',' numexpr ','
numexpr ',' numexpr ','
{ style = WS_CHILD | WS_VISIBLE; }
styleexpr optcnumexpr
{
rc_res_id cid;
cid.named = 0;
cid.u.id = CTL_BUTTON;
$$ = define_control ($2, $3, $5, $7, $9, $11, cid,
style, $15);
}
;
/* Parameters for a control. The static variables DEFAULT_STYLE,
BASE_STYLE, and CLASS must be initialized before this nonterminal
is used. DEFAULT_STYLE is the style to use if no style expression
is specified. BASE_STYLE is the base style to use if a style
expression is specified; the style expression modifies the base
style. CLASS is the class of the control. */
control_params:
numexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
{
$$ = define_control (res_text_field, $1, $2, $3, $4, $5, class,
default_style | WS_CHILD | WS_VISIBLE, 0);
if ($6 != NULL)
{
if (dialog.ex == NULL)
rcparse_warning (_("control data requires DIALOGEX"));
$$->data = $6;
}
}
| numexpr cnumexpr cnumexpr cnumexpr cnumexpr
control_params_styleexpr optcnumexpr opt_control_data
{
$$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
if ($8 != NULL)
{
if (dialog.ex == NULL)
rcparse_warning (_("control data requires DIALOGEX"));
$$->data = $8;
}
}
| numexpr cnumexpr cnumexpr cnumexpr cnumexpr
control_params_styleexpr cnumexpr cnumexpr opt_control_data
{
$$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
if (dialog.ex == NULL)
rcparse_warning (_("help ID requires DIALOGEX"));
$$->help = $8;
$$->data = $9;
}
;
cresid:
',' resid
{
if ($2.named)
res_unistring_to_id (&$$, $2.u.n.name);
else
$$=$2;
}
;
optresidc:
/* empty */
{
res_string_to_id (&$$, "");
}
| resid ',' { $$=$1; }
;
resid:
posnumexpr
{
$$.named = 0;
$$.u.id = $1;
}
| res_unicode_string_concat
{
$$.named = 1;
$$.u.n.name = $1;
$$.u.n.length = unichar_len ($1);
}
;
opt_control_data:
/* empty */
{
$$ = NULL;
}
| BEG optrcdata_data END
{
$$ = $2.first;
}
;
/* These only exist to parse a reduction out of a common case. */
control_styleexpr:
','
{ style = WS_CHILD | WS_VISIBLE; }
styleexpr
;
icon_styleexpr:
','
{ style = SS_ICON | WS_CHILD | WS_VISIBLE; }
styleexpr
;
control_params_styleexpr:
','
{ style = base_style | WS_CHILD | WS_VISIBLE; }
styleexpr
;
/* Font resources. */
font:
id FONT memflags_move_discard file_name
{
define_font ($1, &$3, $4);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
;
/* Icon resources. */
icon:
id ICON memflags_move_discard file_name
{
define_icon ($1, &$3, $4);
if (yychar != YYEMPTY)
YYERROR;
rcparse_discard_strings ();
}
;
/* Language command. This changes the static variable language, which
affects all subsequent resources. */
language:
LANGUAGE numexpr cnumexpr
{
language = $2 | ($3 << SUBLANG_SHIFT);
}
;