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