4 * Copyright Martin von Loewis, 1994
15 struct rc_style
*style
;
18 %token
<str
> STRING SINGLE_QUOTED IDENT
19 %token ACCELERATORS ALT ASCII tBEGIN tBITMAP CAPTION CHECKBOX CHECKED
20 %token CLASS COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG
21 %token DISCARDABLE EDITTEXT tEND FIXED FONT GRAYED GROUPBOX HELP ICON
22 %token IDENT INACTIVE LISTBOX LTEXT MENU MENUBARBREAK MENUBREAK MENUITEM
23 %token MOVEABLE LOADONCALL NOINVERT NOT NOT_SUPPORTED POPUP PRELOAD
24 %token PURE PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SHIFT SEPARATOR
25 %token SINGLE_QUOTED STRING STRINGTABLE STYLE VERSIONINFO VIRTKEY
26 %type
<res
> resource_file resource resources resource_definition accelerators
27 %type
<res
> events bitmap cursor dialog dlg_attributes controls
28 %type
<res
> generic_control labeled_control control_desc font icon
29 %type
<res
> iconinfo menu menu_body item_definitions rcdata raw_data raw_elements
30 %type
<res
> stringtable strings versioninfo
31 %type
<num
> acc_options item_options
32 %type
<style
> style optional_style
35 resource_file: resources
{create_output
($1);}
37 /*resources are put into a linked list*/
39 |resource resources
{$$
=add_resource
($1,$2);}
42 /* get the name for a single resource*/
43 resource: NUMBER resource_definition
44 {$$
=$2;$$
->n.i_name
=$1;$$
->n_type
=0;
45 if
(verbose
)fprintf
(stderr
,"Got %s %d\n",get_typename
($2),$1);
47 | IDENT resource_definition
48 {$$
=$2;$$
->n.s_name
=$1;$$
->n_type
=1;
49 if
(verbose
)fprintf
(stderr
,"Got %s %s\n",get_typename
($2),$1);
52 /* get the value for a single resource*/
53 resource_definition: accelerators
{$$
=$1;}
61 | stringtable
{$$
=$1;}
62 | versioninfo
{$$
=$1;}
64 /* have to use tBEGIN because BEGIN is predefined */
65 accelerators: ACCELERATORS tBEGIN events tEND
{$$
=$3;$$
->type
=acc
;}
66 /* the events are collected in a gen_res, as the accelerator resource is just
68 events: {$$
=new_res
();}
69 | STRING
',' NUMBER acc_options events
70 {$$
=add_string_accelerator
($1,$3,$4,$5);}
71 | NUMBER
',' NUMBER
',' ASCII acc_options events
72 {$$
=add_ascii_accelerator
($1,$3,$6,$7);}
73 | NUMBER
',' NUMBER
',' VIRTKEY acc_options events
74 {$$
=add_vk_accelerator
($1,$3,$6,$7);}
76 |
',' NOINVERT acc_options
{$$
=$3|
2;}
77 |
',' ALT acc_options
{$$
=$3|
16;}
78 |
',' SHIFT acc_options
{$$
=$3|
4;}
79 |
',' CONTROL acc_options
{$$
=$3|
8;}
81 bitmap: tBITMAP load_and_memoption STRING
{$$
=make_bitmap
(load_file
($3));}
82 | tBITMAP load_and_memoption raw_data
{$$
=make_bitmap
($3);}
84 /* load and memory options are ignored */
85 load_and_memoption: | lamo load_and_memoption
86 lamo: PRELOAD | LOADONCALL | FIXED | MOVEABLE | DISCARDABLE | PURE
88 cursor: CURSOR load_and_memoption STRING
{$$
=make_cursor
(load_file
($3));}
89 |CURSOR load_and_memoption raw_data
{$$
=make_cursor
($3);}
91 dialog: DIALOG load_and_memoption NUMBER
',' NUMBER
',' NUMBER
',' NUMBER
94 {$$
=make_dialog
($10,$3,$5,$7,$9,$12);}
96 dlg_attributes: {$$
=new_dialog
();}
97 | STYLE style dlg_attributes
98 {$$
=dialog_style
($2,$3);}
99 | CAPTION STRING dlg_attributes
100 {$$
=dialog_caption
($2,$3);}
101 | FONT NUMBER
',' STRING dlg_attributes
102 {$$
=dialog_font
($2,$4,$5);}
103 | CLASS STRING dlg_attributes
104 {$$
=dialog_class
($2,$3);}
105 | MENU STRING dlg_attributes
106 {$$
=dialog_menu
($2,$3);}
108 /* the controls are collected into a gen_res, and finally the dialog header
109 is put at the beginning */
110 controls: {$$
=new_res
();}
111 | CHECKBOX labeled_control controls
112 {$$
=add_control
(CT_BUTTON
, BS_CHECKBOX
, $2, $3);}
113 | COMBOBOX control_desc controls
114 {$$
=add_control
(CT_COMBOBOX
, 0, $2, $3);}
115 | CONTROL generic_control controls
116 {$$
=add_generic_control
($2, $3);}
117 | CTEXT labeled_control controls
118 {$$
=add_control
(CT_STATIC
, SS_CENTER
, $2, $3);}
119 | DEFPUSHBUTTON labeled_control controls
120 {$$
=add_control
(CT_BUTTON
, BS_DEFPUSHBUTTON
, $2, $3);}
121 | EDITTEXT control_desc controls
122 {$$
=add_control
(CT_EDIT
, 0, $2, $3);}
123 | GROUPBOX labeled_control controls
124 {$$
=add_control
(CT_BUTTON
, BS_GROUPBOX
, $2, $3);}
125 /*special treatment for icons, as the extent is optional*/
126 | ICON STRING
',' NUMBER
',' NUMBER
',' NUMBER iconinfo controls
127 {$$
=add_icon
($2, $4, $6, $8, $9, $10);}
128 | LISTBOX control_desc controls
129 {$$
=add_control
(CT_LISTBOX
, 0, $2, $3);}
130 | LTEXT labeled_control controls
131 {$$
=add_control
(CT_STATIC
, SS_LEFT
, $2, $3);}
132 | PUSHBUTTON labeled_control controls
133 {$$
=add_control
(CT_BUTTON
, BS_PUSHBUTTON
, $2, $3);}
134 | RADIOBUTTON labeled_control controls
135 {$$
=add_control
(CT_BUTTON
, BS_RADIOBUTTON
, $2, $3);}
136 | RTEXT labeled_control controls
137 {$$
=add_control
(CT_STATIC
, SS_RIGHT
, $2, $3);}
138 | SCROLLBAR control_desc controls
139 {$$
=add_control
(CT_SCROLLBAR
, 0, $2, $3);}
142 labeled_control: STRING
',' control_desc
{$$
=label_control_desc
($1,$3);}
143 control_desc: NUMBER
',' NUMBER
',' NUMBER
',' NUMBER
',' NUMBER optional_style
144 {$$
=create_control_desc
($1,$3,$5,$7,$9,$10);}
146 optional_style: {$$
=0;}|
149 iconinfo: /*set extent and style to 0 if they are not provided */
150 {$$
=create_control_desc
(0,0,0,0,0,0);}
151 /* x and y are overwritten later */
152 |
',' NUMBER
',' NUMBER optional_style
153 {$$
=create_control_desc
(0,0,0,$2,$4,$5);}
155 generic_control: STRING
',' NUMBER
',' STRING
',' style
',' NUMBER
156 ',' NUMBER
',' NUMBER
',' NUMBER
157 {$$
=create_generic_control
($1,$3,$5,$7,$9,$11,$13,$15);}
159 font: FONT load_and_memoption STRING
{$$
=make_font
(load_file
($3));}
161 icon: ICON load_and_memoption STRING
{$$
=make_icon
(load_file
($3));}
162 | ICON load_and_memoption raw_data
{$$
=make_icon
($3);}
164 menu: MENU load_and_memoption menu_body
{$$
=make_menu
($3);}
165 /* menu items are collected in a gen_res and prefixed with the menu header*/
166 menu_body: tBEGIN item_definitions tEND
{$$
=$2;}
167 item_definitions: {$$
=new_res
();}
168 | MENUITEM STRING
',' NUMBER item_options item_definitions
169 {$$
=add_menuitem
($2,$4,$5,$6);}
170 | MENUITEM SEPARATOR item_definitions
171 {$$
=add_menuitem
("",0,0,$3);}
172 | POPUP STRING item_options menu_body item_definitions
173 {$$
=add_popup
($2,$3,$4,$5);}
174 item_options: {$$
=0;}
175 |
',' CHECKED item_options
{$$
=$3|MF_CHECKED
;}
176 |
',' GRAYED item_options
{$$
=$3|MF_GRAYED
;}
177 |
',' HELP item_options
{$$
=$3|MF_HELP
;}
178 |
',' INACTIVE item_options
{$$
=$3|MF_DISABLED
;}
179 |
',' MENUBARBREAK item_options
{$$
=$3|MF_MENUBARBREAK
;}
180 |
',' MENUBREAK item_options
{$$
=$3|MF_MENUBREAK
;}
182 rcdata: RCDATA load_and_memoption raw_data
{$$
=make_raw
($3);}
184 raw_data: tBEGIN raw_elements tEND
{$$
=$2;}
185 raw_elements: SINGLE_QUOTED
{$$
=hex_to_raw
($1,new_res
());}
186 | NUMBER
{$$
=int_to_raw
($1,new_res
());}
187 | SINGLE_QUOTED raw_elements
{$$
=hex_to_raw
($1,$2);}
188 | NUMBER
',' raw_elements
{$$
=int_to_raw
($1,$3);}
190 stringtable: STRINGTABLE load_and_memoption tBEGIN strings tEND
193 NUMBER STRING strings
{$$
=0;}
195 versioninfo: VERSIONINFO NOT_SUPPORTED
{$$
=0;}
197 /* NOT x | NOT y | a | b means (a|b)& ~x & ~y
198 NOT is used to disable default styles */
199 style: NUMBER
{$$
=new_style
();$$
->or
=$1;}
200 | NOT NUMBER
{$$
=new_style
();$$
->and
=~
($2);}
201 |
'(' style
')' {$$
=$2;}
202 | style
'|' style
{$$
=$1;$$
->or|
=$3->or
;$$
->and
&=$3->and
;}