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