Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | %{ /* defparse.y - parser for .def files */ |
2 | ||
aa820537 | 3 | /* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2005, 2007 |
32866df7 NC |
4 | Free Software Foundation, Inc. |
5 | ||
6 | This file is part of GNU Binutils. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
21 | MA 02110-1301, USA. */ | |
252b5132 | 22 | |
3db64b00 | 23 | #include "sysdep.h" |
252b5132 | 24 | #include "bfd.h" |
3db64b00 | 25 | #include "libiberty.h" |
252b5132 RH |
26 | #include "dlltool.h" |
27 | %} | |
28 | ||
29 | %union { | |
30 | char *id; | |
31 | int number; | |
32 | }; | |
33 | ||
74aba8aa DS |
34 | %token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA |
35 | %token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT | |
7aa52b1f | 36 | %token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE |
d7ec8102 | 37 | %token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL |
bf201fdd | 38 | %token EQUAL |
252b5132 RH |
39 | %token <id> ID |
40 | %token <number> NUMBER | |
7aa52b1f | 41 | %type <number> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE |
252b5132 | 42 | %type <number> attr attr_list opt_number |
bf201fdd | 43 | %type <id> opt_name opt_equal_name opt_import_name |
252b5132 RH |
44 | |
45 | %% | |
46 | ||
47 | start: start command | |
48 | | command | |
49 | ; | |
50 | ||
51 | command: | |
52 | NAME opt_name opt_base { def_name ($2, $3); } | |
d7ec8102 | 53 | | LIBRARY opt_name opt_base option_list { def_library ($2, $3); } |
252b5132 RH |
54 | | EXPORTS explist |
55 | | DESCRIPTION ID { def_description ($2);} | |
56 | | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);} | |
57 | | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);} | |
58 | | CODE attr_list { def_code ($2);} | |
59 | | DATA attr_list { def_data ($2);} | |
60 | | SECTIONS seclist | |
61 | | IMPORTS implist | |
62 | | VERSIONK NUMBER { def_version ($2,0);} | |
63 | | VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);} | |
64 | ; | |
65 | ||
66 | ||
67 | explist: | |
68 | /* EMPTY */ | |
252b5132 RH |
69 | | explist expline |
70 | ; | |
71 | ||
72 | expline: | |
7aa52b1f | 73 | ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE |
bf201fdd KT |
74 | opt_import_name |
75 | { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);} | |
252b5132 RH |
76 | ; |
77 | implist: | |
78 | implist impline | |
79 | | impline | |
80 | ; | |
81 | ||
82 | impline: | |
bf201fdd KT |
83 | ID '=' ID '.' ID '.' ID opt_import_name |
84 | { def_import ($1,$3,$5,$7, 0, $8); } | |
85 | | ID '=' ID '.' ID '.' NUMBER opt_import_name | |
86 | { def_import ($1,$3,$5, 0,$7, $8); } | |
87 | | ID '=' ID '.' ID opt_import_name | |
88 | { def_import ($1,$3, 0,$5, 0, $6); } | |
89 | | ID '=' ID '.' NUMBER opt_import_name | |
90 | { def_import ($1,$3, 0, 0,$5, $6); } | |
91 | | ID '.' ID '.' ID opt_import_name | |
92 | { def_import ( 0,$1,$3,$5, 0, $6); } | |
93 | | ID '.' ID '.' NUMBER opt_import_name | |
94 | { def_import ( 0,$1,$3, 0,$5, $6); } | |
95 | | ID '.' ID opt_import_name | |
96 | { def_import ( 0,$1, 0,$3, 0, $4); } | |
97 | | ID '.' NUMBER opt_import_name | |
98 | { def_import ( 0,$1, 0, 0,$3, $4); } | |
252b5132 RH |
99 | ; |
100 | ||
101 | seclist: | |
102 | seclist secline | |
103 | | secline | |
104 | ; | |
105 | ||
106 | secline: | |
107 | ID attr_list { def_section ($1,$2);} | |
108 | ; | |
109 | ||
110 | attr_list: | |
111 | attr_list opt_comma attr | |
112 | | attr | |
113 | ; | |
114 | ||
115 | opt_comma: | |
116 | ',' | |
117 | | | |
118 | ; | |
119 | opt_number: ',' NUMBER { $$=$2;} | |
120 | | { $$=-1;} | |
121 | ; | |
122 | ||
123 | attr: | |
d7ec8102 ILT |
124 | READ { $$ = 1; } |
125 | | WRITE { $$ = 2; } | |
126 | | EXECUTE { $$ = 4; } | |
127 | | SHARED { $$ = 8; } | |
128 | | NONSHARED { $$ = 0; } | |
129 | | SINGLE { $$ = 0; } | |
130 | | MULTIPLE { $$ = 0; } | |
252b5132 RH |
131 | ; |
132 | ||
133 | opt_CONSTANT: | |
134 | CONSTANT {$$=1;} | |
135 | | {$$=0;} | |
136 | ; | |
137 | ||
138 | opt_NONAME: | |
139 | NONAME {$$=1;} | |
140 | | {$$=0;} | |
141 | ; | |
142 | ||
143 | opt_DATA: | |
144 | DATA { $$ = 1; } | |
145 | | { $$ = 0; } | |
146 | ; | |
147 | ||
7aa52b1f NC |
148 | opt_PRIVATE: |
149 | PRIVATE { $$ = 1; } | |
150 | | { $$ = 0; } | |
151 | ; | |
152 | ||
252b5132 RH |
153 | opt_name: ID { $$ =$1; } |
154 | | ID '.' ID | |
155 | { | |
156 | char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1); | |
157 | sprintf (name, "%s.%s", $1, $3); | |
158 | $$ = name; | |
159 | } | |
160 | | { $$=""; } | |
161 | ; | |
162 | ||
163 | opt_ordinal: | |
164 | '@' NUMBER { $$=$2;} | |
165 | | { $$=-1;} | |
166 | ; | |
167 | ||
bf201fdd KT |
168 | opt_import_name: |
169 | EQUAL ID { $$ = $2; } | |
170 | | { $$ = 0; } | |
171 | ; | |
172 | ||
252b5132 RH |
173 | opt_equal_name: |
174 | '=' ID { $$ = $2; } | |
04847a4d CF |
175 | | '=' ID '.' ID |
176 | { | |
177 | char *name = xmalloc (strlen ($2) + 1 + strlen ($4) + 1); | |
178 | sprintf (name, "%s.%s", $2, $4); | |
179 | $$ = name; | |
180 | } | |
252b5132 RH |
181 | | { $$ = 0; } |
182 | ; | |
183 | ||
184 | opt_base: BASE '=' NUMBER { $$= $3;} | |
185 | | { $$=-1;} | |
186 | ; | |
187 | ||
d7ec8102 ILT |
188 | option_list: |
189 | /* empty */ | |
190 | | option_list opt_comma option | |
191 | ; | |
252b5132 | 192 | |
d7ec8102 ILT |
193 | option: |
194 | INITINSTANCE | |
195 | | INITGLOBAL | |
196 | | TERMINSTANCE | |
197 | | TERMGLOBAL | |
198 | ; |