1 %
{ /* defparse.y - parser for .def files */
3 /* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2005, 2007
4 Free Software Foundation, Inc.
6 This file is part of GNU Binutils.
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.
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.
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. */
25 #include "libiberty.h"
35 %token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
36 %token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
37 %token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
38 %token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
41 %token
<number
> NUMBER
42 %type
<number
> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
43 %type
<number
> attr attr_list opt_number
44 %type
<id
> opt_name opt_name2 opt_equal_name opt_import_name
45 %type
<id_const
> keyword_as_name
54 NAME opt_name opt_base
{ def_name
($2, $3); }
55 | LIBRARY opt_name opt_base option_list
{ def_library
($2, $3); }
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);}
64 | VERSIONK NUMBER
{ def_version
($2,0);}
65 | VERSIONK NUMBER
'.' NUMBER
{ def_version
($2,$4);}
75 ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
77 { def_exports
($1, $2, $3, $4, $5, $6, $7, $8);}
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); }
109 ID attr_list
{ def_section
($1,$2);}
113 attr_list opt_comma attr
121 opt_number: ',' NUMBER
{ $$
=$2;}
128 | EXECUTE
{ $$
= 4; }
130 | NONSHARED
{ $$
= 0; }
132 | MULTIPLE
{ $$
= 0; }
155 keyword_as_name: NAME
{ $$
= "NAME"; }
156 /* Disabled LIBRARY keyword for a quirk in libtool. It places LIBRARY
157 command after EXPORTS list, which is illegal by specification.
158 See PR binutils/13710
159 | LIBRARY { $$ = "LIBRARY"; } */
160 | DESCRIPTION
{ $$
= "DESCRIPTION"; }
161 | STACKSIZE
{ $$
= "STACKSIZE"; }
162 | HEAPSIZE
{ $$
= "HEAPSIZE"; }
163 | CODE
{ $$
= "CODE"; }
164 | DATA
{ $$
= "DATA"; }
165 | SECTIONS
{ $$
= "SECTIONS"; }
166 | EXPORTS
{ $$
= "EXPORTS"; }
167 | IMPORTS
{ $$
= "IMPORTS"; }
168 | VERSIONK
{ $$
= "VERSION"; }
169 | BASE
{ $$
= "BASE"; }
170 | CONSTANT
{ $$
= "CONSTANT"; }
171 | NONAME
{ $$
= "NONAME"; }
172 | PRIVATE
{ $$
= "PRIVATE"; }
173 | READ
{ $$
= "READ"; }
174 | WRITE
{ $$
= "WRITE"; }
175 | EXECUTE
{ $$
= "EXECUTE"; }
176 | SHARED
{ $$
= "SHARED"; }
177 | NONSHARED
{ $$
= "NONSHARED"; }
178 | SINGLE
{ $$
= "SINGLE"; }
179 | MULTIPLE
{ $$
= "MULTIPLE"; }
180 | INITINSTANCE
{ $$
= "INITINSTANCE"; }
181 | INITGLOBAL
{ $$
= "INITGLOBAL"; }
182 | TERMINSTANCE
{ $$
= "TERMINSTANCE"; }
183 | TERMGLOBAL
{ $$
= "TERMGLOBAL"; }
186 opt_name2: ID
{ $$
= $1; }
187 |
'.' keyword_as_name
189 char *name
= xmalloc
(strlen
($2) + 2);
190 sprintf
(name
, ".%s", $2);
195 char *name
= xmalloc
(strlen
($2) + 2);
196 sprintf
(name
, ".%s", $2);
199 | keyword_as_name
'.' opt_name2
201 char *name
= xmalloc
(strlen
($1) + 1 + strlen
($3) + 1);
202 sprintf
(name
, "%s.%s", $1, $3);
207 char *name
= xmalloc
(strlen
($1) + 1 + strlen
($3) + 1);
208 sprintf
(name
, "%s.%s", $1, $3);
212 opt_name: opt_name2
{ $$
=$1; }
222 EQUAL opt_name2
{ $$
= $2; }
227 '=' opt_name2
{ $$
= $2; }
231 opt_base: BASE
'=' NUMBER
{ $$
= $3;}
237 | option_list opt_comma option