gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / binutils / defparse.y
CommitLineData
252b5132
RH
1%{ /* defparse.y - parser for .def files */
2
b3adc24a 3/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
3aade688 4
32866df7 5 This file is part of GNU Binutils.
3aade688 6
32866df7
NC
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 3 of the License, or
10 (at your option) any later version.
3aade688 11
32866df7
NC
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.
3aade688 16
32866df7
NC
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., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
252b5132 21
3db64b00 22#include "sysdep.h"
252b5132 23#include "bfd.h"
3db64b00 24#include "libiberty.h"
252b5132
RH
25#include "dlltool.h"
26%}
27
28%union {
29 char *id;
aa83d1ec 30 const char *id_const;
252b5132
RH
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
aa83d1ec
KT
43%type <id> opt_name opt_name2 opt_equal_name opt_import_name
44%type <id_const> keyword_as_name
252b5132
RH
45
46%%
47
48start: start command
49 | command
50 ;
51
3aade688 52command:
252b5132 53 NAME opt_name opt_base { def_name ($2, $3); }
d7ec8102 54 | LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
3aade688 55 | EXPORTS explist
252b5132
RH
56 | DESCRIPTION ID { def_description ($2);}
57 | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
58 | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
59 | CODE attr_list { def_code ($2);}
60 | DATA attr_list { def_data ($2);}
61 | SECTIONS seclist
62 | IMPORTS implist
63 | VERSIONK NUMBER { def_version ($2,0);}
64 | VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);}
65 ;
66
67
68explist:
69 /* EMPTY */
252b5132
RH
70 | explist expline
71 ;
72
73expline:
7aa52b1f 74 ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
bf201fdd
KT
75 opt_import_name
76 { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);}
252b5132 77 ;
3aade688 78implist:
252b5132
RH
79 implist impline
80 | impline
81 ;
82
83impline:
bf201fdd
KT
84 ID '=' ID '.' ID '.' ID opt_import_name
85 { def_import ($1,$3,$5,$7, 0, $8); }
86 | ID '=' ID '.' ID '.' NUMBER opt_import_name
87 { def_import ($1,$3,$5, 0,$7, $8); }
88 | ID '=' ID '.' ID opt_import_name
89 { def_import ($1,$3, 0,$5, 0, $6); }
90 | ID '=' ID '.' NUMBER opt_import_name
91 { def_import ($1,$3, 0, 0,$5, $6); }
92 | ID '.' ID '.' ID opt_import_name
93 { def_import ( 0,$1,$3,$5, 0, $6); }
94 | ID '.' ID '.' NUMBER opt_import_name
95 { def_import ( 0,$1,$3, 0,$5, $6); }
96 | ID '.' ID opt_import_name
97 { def_import ( 0,$1, 0,$3, 0, $4); }
98 | ID '.' NUMBER opt_import_name
99 { def_import ( 0,$1, 0, 0,$3, $4); }
252b5132
RH
100;
101
102seclist:
103 seclist secline
104 | secline
105 ;
106
107secline:
108 ID attr_list { def_section ($1,$2);}
109 ;
110
111attr_list:
112 attr_list opt_comma attr
113 | attr
114 ;
115
116opt_comma:
117 ','
3aade688 118 |
252b5132
RH
119 ;
120opt_number: ',' NUMBER { $$=$2;}
121 | { $$=-1;}
122 ;
3aade688 123
252b5132 124attr:
d7ec8102
ILT
125 READ { $$ = 1; }
126 | WRITE { $$ = 2; }
127 | EXECUTE { $$ = 4; }
128 | SHARED { $$ = 8; }
129 | NONSHARED { $$ = 0; }
130 | SINGLE { $$ = 0; }
131 | MULTIPLE { $$ = 0; }
252b5132
RH
132 ;
133
134opt_CONSTANT:
135 CONSTANT {$$=1;}
136 | {$$=0;}
137 ;
138
139opt_NONAME:
140 NONAME {$$=1;}
141 | {$$=0;}
142 ;
143
144opt_DATA:
145 DATA { $$ = 1; }
146 | { $$ = 0; }
147 ;
148
7aa52b1f
NC
149opt_PRIVATE:
150 PRIVATE { $$ = 1; }
151 | { $$ = 0; }
152 ;
153
aa83d1ec 154keyword_as_name: NAME { $$ = "NAME"; }
5b3d386e
KT
155/* Disabled LIBRARY keyword for a quirk in libtool. It places LIBRARY
156 command after EXPORTS list, which is illegal by specification.
157 See PR binutils/13710
158 | LIBRARY { $$ = "LIBRARY"; } */
aa83d1ec
KT
159 | DESCRIPTION { $$ = "DESCRIPTION"; }
160 | STACKSIZE { $$ = "STACKSIZE"; }
161 | HEAPSIZE { $$ = "HEAPSIZE"; }
162 | CODE { $$ = "CODE"; }
163 | DATA { $$ = "DATA"; }
164 | SECTIONS { $$ = "SECTIONS"; }
165 | EXPORTS { $$ = "EXPORTS"; }
166 | IMPORTS { $$ = "IMPORTS"; }
167 | VERSIONK { $$ = "VERSION"; }
168 | BASE { $$ = "BASE"; }
169 | CONSTANT { $$ = "CONSTANT"; }
170 | NONAME { $$ = "NONAME"; }
171 | PRIVATE { $$ = "PRIVATE"; }
172 | READ { $$ = "READ"; }
173 | WRITE { $$ = "WRITE"; }
174 | EXECUTE { $$ = "EXECUTE"; }
175 | SHARED { $$ = "SHARED"; }
176 | NONSHARED { $$ = "NONSHARED"; }
177 | SINGLE { $$ = "SINGLE"; }
178 | MULTIPLE { $$ = "MULTIPLE"; }
179 | INITINSTANCE { $$ = "INITINSTANCE"; }
180 | INITGLOBAL { $$ = "INITGLOBAL"; }
181 | TERMINSTANCE { $$ = "TERMINSTANCE"; }
182 | TERMGLOBAL { $$ = "TERMGLOBAL"; }
183 ;
184
185opt_name2: ID { $$ = $1; }
186 | '.' keyword_as_name
187 {
188 char *name = xmalloc (strlen ($2) + 2);
189 sprintf (name, ".%s", $2);
190 $$ = name;
191 }
192 | '.' opt_name2
3aade688 193 {
aa83d1ec
KT
194 char *name = xmalloc (strlen ($2) + 2);
195 sprintf (name, ".%s", $2);
196 $$ = name;
197 }
198 | keyword_as_name '.' opt_name2
3aade688 199 {
aa83d1ec
KT
200 char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
201 sprintf (name, "%s.%s", $1, $3);
202 $$ = name;
203 }
204 | ID '.' opt_name2
3aade688 205 {
252b5132
RH
206 char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
207 sprintf (name, "%s.%s", $1, $3);
208 $$ = name;
209 }
aa83d1ec
KT
210 ;
211opt_name: opt_name2 { $$ =$1; }
252b5132
RH
212 | { $$=""; }
213 ;
214
3aade688 215opt_ordinal:
252b5132
RH
216 '@' NUMBER { $$=$2;}
217 | { $$=-1;}
218 ;
219
bf201fdd 220opt_import_name:
aa83d1ec 221 EQUAL opt_name2 { $$ = $2; }
bf201fdd
KT
222 | { $$ = 0; }
223 ;
224
252b5132 225opt_equal_name:
aa83d1ec 226 '=' opt_name2 { $$ = $2; }
3aade688 227 | { $$ = 0; }
252b5132
RH
228 ;
229
230opt_base: BASE '=' NUMBER { $$= $3;}
231 | { $$=-1;}
232 ;
233
d7ec8102
ILT
234option_list:
235 /* empty */
236 | option_list opt_comma option
237 ;
252b5132 238
d7ec8102
ILT
239option:
240 INITINSTANCE
241 | INITGLOBAL
242 | TERMINSTANCE
243 | TERMGLOBAL
244 ;
This page took 0.85749 seconds and 4 git commands to generate.