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