ChangeLog binutils
[deliverable/binutils-gdb.git] / binutils / defparse.y
CommitLineData
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;
aa83d1ec 31 const char *id_const;
252b5132
RH
32 int number;
33};
34
74aba8aa
DS
35%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
36%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
7aa52b1f 37%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
d7ec8102 38%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
bf201fdd 39%token EQUAL
252b5132
RH
40%token <id> ID
41%token <number> NUMBER
7aa52b1f 42%type <number> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
252b5132 43%type <number> attr attr_list opt_number
aa83d1ec
KT
44%type <id> opt_name opt_name2 opt_equal_name opt_import_name
45%type <id_const> keyword_as_name
252b5132
RH
46
47%%
48
49start: start command
50 | command
51 ;
52
53command:
54 NAME opt_name opt_base { def_name ($2, $3); }
d7ec8102 55 | LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
252b5132
RH
56 | EXPORTS explist
57 | DESCRIPTION ID { def_description ($2);}
58 | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
59 | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
60 | CODE attr_list { def_code ($2);}
61 | DATA attr_list { def_data ($2);}
62 | SECTIONS seclist
63 | IMPORTS implist
64 | VERSIONK NUMBER { def_version ($2,0);}
65 | VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);}
66 ;
67
68
69explist:
70 /* EMPTY */
252b5132
RH
71 | explist expline
72 ;
73
74expline:
7aa52b1f 75 ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
bf201fdd
KT
76 opt_import_name
77 { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);}
252b5132
RH
78 ;
79implist:
80 implist impline
81 | impline
82 ;
83
84impline:
bf201fdd
KT
85 ID '=' ID '.' ID '.' ID opt_import_name
86 { def_import ($1,$3,$5,$7, 0, $8); }
87 | ID '=' ID '.' ID '.' NUMBER opt_import_name
88 { def_import ($1,$3,$5, 0,$7, $8); }
89 | ID '=' ID '.' ID opt_import_name
90 { def_import ($1,$3, 0,$5, 0, $6); }
91 | ID '=' ID '.' NUMBER opt_import_name
92 { def_import ($1,$3, 0, 0,$5, $6); }
93 | ID '.' ID '.' ID opt_import_name
94 { def_import ( 0,$1,$3,$5, 0, $6); }
95 | ID '.' ID '.' NUMBER opt_import_name
96 { def_import ( 0,$1,$3, 0,$5, $6); }
97 | ID '.' ID opt_import_name
98 { def_import ( 0,$1, 0,$3, 0, $4); }
99 | ID '.' NUMBER opt_import_name
100 { def_import ( 0,$1, 0, 0,$3, $4); }
252b5132
RH
101;
102
103seclist:
104 seclist secline
105 | secline
106 ;
107
108secline:
109 ID attr_list { def_section ($1,$2);}
110 ;
111
112attr_list:
113 attr_list opt_comma attr
114 | attr
115 ;
116
117opt_comma:
118 ','
119 |
120 ;
121opt_number: ',' NUMBER { $$=$2;}
122 | { $$=-1;}
123 ;
124
125attr:
d7ec8102
ILT
126 READ { $$ = 1; }
127 | WRITE { $$ = 2; }
128 | EXECUTE { $$ = 4; }
129 | SHARED { $$ = 8; }
130 | NONSHARED { $$ = 0; }
131 | SINGLE { $$ = 0; }
132 | MULTIPLE { $$ = 0; }
252b5132
RH
133 ;
134
135opt_CONSTANT:
136 CONSTANT {$$=1;}
137 | {$$=0;}
138 ;
139
140opt_NONAME:
141 NONAME {$$=1;}
142 | {$$=0;}
143 ;
144
145opt_DATA:
146 DATA { $$ = 1; }
147 | { $$ = 0; }
148 ;
149
7aa52b1f
NC
150opt_PRIVATE:
151 PRIVATE { $$ = 1; }
152 | { $$ = 0; }
153 ;
154
aa83d1ec
KT
155keyword_as_name: NAME { $$ = "NAME"; }
156 | LIBRARY { $$ = "LIBRARY"; }
157 | DESCRIPTION { $$ = "DESCRIPTION"; }
158 | STACKSIZE { $$ = "STACKSIZE"; }
159 | HEAPSIZE { $$ = "HEAPSIZE"; }
160 | CODE { $$ = "CODE"; }
161 | DATA { $$ = "DATA"; }
162 | SECTIONS { $$ = "SECTIONS"; }
163 | EXPORTS { $$ = "EXPORTS"; }
164 | IMPORTS { $$ = "IMPORTS"; }
165 | VERSIONK { $$ = "VERSION"; }
166 | BASE { $$ = "BASE"; }
167 | CONSTANT { $$ = "CONSTANT"; }
168 | NONAME { $$ = "NONAME"; }
169 | PRIVATE { $$ = "PRIVATE"; }
170 | READ { $$ = "READ"; }
171 | WRITE { $$ = "WRITE"; }
172 | EXECUTE { $$ = "EXECUTE"; }
173 | SHARED { $$ = "SHARED"; }
174 | NONSHARED { $$ = "NONSHARED"; }
175 | SINGLE { $$ = "SINGLE"; }
176 | MULTIPLE { $$ = "MULTIPLE"; }
177 | INITINSTANCE { $$ = "INITINSTANCE"; }
178 | INITGLOBAL { $$ = "INITGLOBAL"; }
179 | TERMINSTANCE { $$ = "TERMINSTANCE"; }
180 | TERMGLOBAL { $$ = "TERMGLOBAL"; }
181 ;
182
183opt_name2: ID { $$ = $1; }
184 | '.' keyword_as_name
185 {
186 char *name = xmalloc (strlen ($2) + 2);
187 sprintf (name, ".%s", $2);
188 $$ = name;
189 }
190 | '.' opt_name2
191 {
192 char *name = xmalloc (strlen ($2) + 2);
193 sprintf (name, ".%s", $2);
194 $$ = name;
195 }
196 | keyword_as_name '.' opt_name2
197 {
198 char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
199 sprintf (name, "%s.%s", $1, $3);
200 $$ = name;
201 }
202 | ID '.' opt_name2
252b5132
RH
203 {
204 char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
205 sprintf (name, "%s.%s", $1, $3);
206 $$ = name;
207 }
aa83d1ec
KT
208 ;
209opt_name: opt_name2 { $$ =$1; }
252b5132
RH
210 | { $$=""; }
211 ;
212
213opt_ordinal:
214 '@' NUMBER { $$=$2;}
215 | { $$=-1;}
216 ;
217
bf201fdd 218opt_import_name:
aa83d1ec 219 EQUAL opt_name2 { $$ = $2; }
bf201fdd
KT
220 | { $$ = 0; }
221 ;
222
252b5132 223opt_equal_name:
aa83d1ec 224 '=' opt_name2 { $$ = $2; }
252b5132
RH
225 | { $$ = 0; }
226 ;
227
228opt_base: BASE '=' NUMBER { $$= $3;}
229 | { $$=-1;}
230 ;
231
d7ec8102
ILT
232option_list:
233 /* empty */
234 | option_list opt_comma option
235 ;
252b5132 236
d7ec8102
ILT
237option:
238 INITINSTANCE
239 | INITGLOBAL
240 | TERMINSTANCE
241 | TERMGLOBAL
242 ;
This page took 0.480201 seconds and 4 git commands to generate.