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 | 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"; }
183 opt_name2: ID { $$ = $1; }
184 | '.' keyword_as_name
186 char *name = xmalloc (strlen ($2) + 2);
187 sprintf (name, ".%s", $2);
192 char *name = xmalloc (strlen ($2) + 2);
193 sprintf (name, ".%s", $2);
196 | keyword_as_name '.' opt_name2
198 char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
199 sprintf (name, "%s.%s", $1, $3);
204 char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
205 sprintf (name, "%s.%s", $1, $3);
209 opt_name: opt_name2 { $$ =$1; }
219 EQUAL opt_name2 { $$ = $2; }
224 '=' opt_name2 { $$ = $2; }
228 opt_base: BASE '=' NUMBER { $$= $3;}
234 | option_list opt_comma option