deffilep.c revision 1.8 1 1.8 christos /* A Bison parser, made by GNU Bison 3.8.2. */
2 1.1 christos
3 1.6 christos /* Bison implementation for Yacc-like parsers in C
4 1.1 christos
5 1.8 christos Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 1.8 christos Inc.
7 1.1 christos
8 1.6 christos This program is free software: you can redistribute it and/or modify
9 1.1 christos it under the terms of the GNU General Public License as published by
10 1.6 christos the Free Software Foundation, either version 3 of the License, or
11 1.6 christos (at your option) any later version.
12 1.1 christos
13 1.1 christos This program is distributed in the hope that it will be useful,
14 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
15 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 1.1 christos GNU General Public License for more details.
17 1.1 christos
18 1.1 christos You should have received a copy of the GNU General Public License
19 1.8 christos along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 1.1 christos
21 1.1 christos /* As a special exception, you may create a larger work that contains
22 1.1 christos part or all of the Bison parser skeleton and distribute that work
23 1.1 christos under terms of your choice, so long as that work isn't itself a
24 1.1 christos parser generator using the skeleton or a modified version thereof
25 1.1 christos as a parser skeleton. Alternatively, if you modify or redistribute
26 1.1 christos the parser skeleton itself, you may (at your option) remove this
27 1.1 christos special exception, which will cause the skeleton and the resulting
28 1.1 christos Bison output files to be licensed under the GNU General Public
29 1.1 christos License without this special exception.
30 1.1 christos
31 1.1 christos This special exception was added by the Free Software Foundation in
32 1.1 christos version 2.2 of Bison. */
33 1.1 christos
34 1.1 christos /* C LALR(1) parser skeleton written by Richard Stallman, by
35 1.1 christos simplifying the original so-called "semantic" parser. */
36 1.1 christos
37 1.8 christos /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 1.8 christos especially those whose name start with YY_ or yy_. They are
39 1.8 christos private implementation details that can be changed or removed. */
40 1.8 christos
41 1.1 christos /* All symbols defined below should begin with yy or YY, to avoid
42 1.1 christos infringing on user name space. This should be done even for local
43 1.1 christos variables, as they might otherwise be expanded by user macros.
44 1.1 christos There are some unavoidable exceptions within include files to
45 1.1 christos define necessary library symbols; they are noted "INFRINGES ON
46 1.1 christos USER NAME SPACE" below. */
47 1.1 christos
48 1.8 christos /* Identify Bison output, and Bison version. */
49 1.8 christos #define YYBISON 30802
50 1.1 christos
51 1.8 christos /* Bison version string. */
52 1.8 christos #define YYBISON_VERSION "3.8.2"
53 1.1 christos
54 1.1 christos /* Skeleton name. */
55 1.1 christos #define YYSKELETON_NAME "yacc.c"
56 1.1 christos
57 1.1 christos /* Pure parsers. */
58 1.1 christos #define YYPURE 0
59 1.1 christos
60 1.6 christos /* Push parsers. */
61 1.6 christos #define YYPUSH 0
62 1.1 christos
63 1.6 christos /* Pull parsers. */
64 1.6 christos #define YYPULL 1
65 1.1 christos
66 1.1 christos
67 1.1 christos
68 1.1 christos
69 1.8 christos /* First part of user prologue. */
70 1.8 christos #line 1 "deffilep.y"
71 1.1 christos /* deffilep.y - parser for .def files */
72 1.1 christos
73 1.8 christos /* Copyright (C) 1995-2022 Free Software Foundation, Inc.
74 1.1 christos
75 1.1 christos This file is part of GNU Binutils.
76 1.1 christos
77 1.1 christos This program is free software; you can redistribute it and/or modify
78 1.1 christos it under the terms of the GNU General Public License as published by
79 1.1 christos the Free Software Foundation; either version 3 of the License, or
80 1.1 christos (at your option) any later version.
81 1.1 christos
82 1.1 christos This program is distributed in the hope that it will be useful,
83 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
84 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85 1.1 christos GNU General Public License for more details.
86 1.1 christos
87 1.1 christos You should have received a copy of the GNU General Public License
88 1.1 christos along with this program; if not, write to the Free Software
89 1.1 christos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
90 1.1 christos MA 02110-1301, USA. */
91 1.1 christos
92 1.1 christos #include "sysdep.h"
93 1.1 christos #include "libiberty.h"
94 1.1 christos #include "safe-ctype.h"
95 1.1 christos #include "bfd.h"
96 1.7 christos #include "bfdlink.h"
97 1.1 christos #include "ld.h"
98 1.1 christos #include "ldmisc.h"
99 1.1 christos #include "deffile.h"
100 1.1 christos
101 1.1 christos #define TRACE 0
102 1.1 christos
103 1.1 christos #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1))
104 1.1 christos
105 1.1 christos /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
106 1.1 christos as well as gratuitiously global symbol names, so we can have multiple
107 1.1 christos yacc generated parsers in ld. Note that these are only the variables
108 1.1 christos produced by yacc. If other parser generators (bison, byacc, etc) produce
109 1.1 christos additional global names that conflict at link time, then those parser
110 1.1 christos generators need to be fixed instead of adding those names to this list. */
111 1.1 christos
112 1.1 christos #define yymaxdepth def_maxdepth
113 1.1 christos #define yyparse def_parse
114 1.1 christos #define yylex def_lex
115 1.1 christos #define yyerror def_error
116 1.1 christos #define yylval def_lval
117 1.1 christos #define yychar def_char
118 1.1 christos #define yydebug def_debug
119 1.3 christos #define yypact def_pact
120 1.3 christos #define yyr1 def_r1
121 1.3 christos #define yyr2 def_r2
122 1.3 christos #define yydef def_def
123 1.3 christos #define yychk def_chk
124 1.3 christos #define yypgo def_pgo
125 1.3 christos #define yyact def_act
126 1.1 christos #define yyexca def_exca
127 1.1 christos #define yyerrflag def_errflag
128 1.1 christos #define yynerrs def_nerrs
129 1.1 christos #define yyps def_ps
130 1.1 christos #define yypv def_pv
131 1.1 christos #define yys def_s
132 1.1 christos #define yy_yys def_yys
133 1.1 christos #define yystate def_state
134 1.1 christos #define yytmp def_tmp
135 1.1 christos #define yyv def_v
136 1.1 christos #define yy_yyv def_yyv
137 1.1 christos #define yyval def_val
138 1.1 christos #define yylloc def_lloc
139 1.1 christos #define yyreds def_reds /* With YYDEBUG defined. */
140 1.1 christos #define yytoks def_toks /* With YYDEBUG defined. */
141 1.1 christos #define yylhs def_yylhs
142 1.1 christos #define yylen def_yylen
143 1.1 christos #define yydefred def_yydefred
144 1.1 christos #define yydgoto def_yydgoto
145 1.1 christos #define yysindex def_yysindex
146 1.1 christos #define yyrindex def_yyrindex
147 1.1 christos #define yygindex def_yygindex
148 1.1 christos #define yytable def_yytable
149 1.1 christos #define yycheck def_yycheck
150 1.1 christos
151 1.1 christos typedef struct def_pool_str {
152 1.1 christos struct def_pool_str *next;
153 1.1 christos char data[1];
154 1.1 christos } def_pool_str;
155 1.1 christos
156 1.1 christos static def_pool_str *pool_strs = NULL;
157 1.1 christos
158 1.1 christos static char *def_pool_alloc (size_t sz);
159 1.1 christos static char *def_pool_strdup (const char *str);
160 1.1 christos static void def_pool_free (void);
161 1.1 christos
162 1.1 christos static void def_description (const char *);
163 1.1 christos static void def_exports (const char *, const char *, int, int, const char *);
164 1.1 christos static void def_heapsize (int, int);
165 1.1 christos static void def_import (const char *, const char *, const char *, const char *,
166 1.1 christos int, const char *);
167 1.3 christos static void def_image_name (const char *, bfd_vma, int);
168 1.1 christos static void def_section (const char *, int);
169 1.1 christos static void def_section_alt (const char *, const char *);
170 1.1 christos static void def_stacksize (int, int);
171 1.1 christos static void def_version (int, int);
172 1.1 christos static void def_directive (char *);
173 1.1 christos static void def_aligncomm (char *str, int align);
174 1.1 christos static int def_parse (void);
175 1.8 christos static void def_error (const char *);
176 1.1 christos static int def_lex (void);
177 1.1 christos
178 1.1 christos static int lex_forced_token = 0;
179 1.1 christos static const char *lex_parse_string = 0;
180 1.1 christos static const char *lex_parse_string_end = 0;
181 1.1 christos
182 1.1 christos
183 1.8 christos #line 184 "deffilep.c"
184 1.1 christos
185 1.8 christos # ifndef YY_CAST
186 1.8 christos # ifdef __cplusplus
187 1.8 christos # define YY_CAST(Type, Val) static_cast<Type> (Val)
188 1.8 christos # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
189 1.8 christos # else
190 1.8 christos # define YY_CAST(Type, Val) ((Type) (Val))
191 1.8 christos # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
192 1.8 christos # endif
193 1.8 christos # endif
194 1.6 christos # ifndef YY_NULLPTR
195 1.8 christos # if defined __cplusplus
196 1.8 christos # if 201103L <= __cplusplus
197 1.8 christos # define YY_NULLPTR nullptr
198 1.8 christos # else
199 1.8 christos # define YY_NULLPTR 0
200 1.8 christos # endif
201 1.6 christos # else
202 1.8 christos # define YY_NULLPTR ((void*)0)
203 1.6 christos # endif
204 1.6 christos # endif
205 1.1 christos
206 1.8 christos /* Use api.header.include to #include this header
207 1.8 christos instead of duplicating it here. */
208 1.6 christos #ifndef YY_YY_DEFFILEP_H_INCLUDED
209 1.6 christos # define YY_YY_DEFFILEP_H_INCLUDED
210 1.6 christos /* Debug traces. */
211 1.6 christos #ifndef YYDEBUG
212 1.6 christos # define YYDEBUG 0
213 1.6 christos #endif
214 1.6 christos #if YYDEBUG
215 1.6 christos extern int yydebug;
216 1.3 christos #endif
217 1.3 christos
218 1.8 christos /* Token kinds. */
219 1.6 christos #ifndef YYTOKENTYPE
220 1.6 christos # define YYTOKENTYPE
221 1.6 christos enum yytokentype
222 1.6 christos {
223 1.8 christos YYEMPTY = -2,
224 1.8 christos YYEOF = 0, /* "end of file" */
225 1.8 christos YYerror = 256, /* error */
226 1.8 christos YYUNDEF = 257, /* "invalid token" */
227 1.8 christos NAME = 258, /* NAME */
228 1.8 christos LIBRARY = 259, /* LIBRARY */
229 1.8 christos DESCRIPTION = 260, /* DESCRIPTION */
230 1.8 christos STACKSIZE_K = 261, /* STACKSIZE_K */
231 1.8 christos HEAPSIZE = 262, /* HEAPSIZE */
232 1.8 christos CODE = 263, /* CODE */
233 1.8 christos DATAU = 264, /* DATAU */
234 1.8 christos DATAL = 265, /* DATAL */
235 1.8 christos SECTIONS = 266, /* SECTIONS */
236 1.8 christos EXPORTS = 267, /* EXPORTS */
237 1.8 christos IMPORTS = 268, /* IMPORTS */
238 1.8 christos VERSIONK = 269, /* VERSIONK */
239 1.8 christos BASE = 270, /* BASE */
240 1.8 christos CONSTANTU = 271, /* CONSTANTU */
241 1.8 christos CONSTANTL = 272, /* CONSTANTL */
242 1.8 christos PRIVATEU = 273, /* PRIVATEU */
243 1.8 christos PRIVATEL = 274, /* PRIVATEL */
244 1.8 christos ALIGNCOMM = 275, /* ALIGNCOMM */
245 1.8 christos READ = 276, /* READ */
246 1.8 christos WRITE = 277, /* WRITE */
247 1.8 christos EXECUTE = 278, /* EXECUTE */
248 1.8 christos SHARED_K = 279, /* SHARED_K */
249 1.8 christos NONAMEU = 280, /* NONAMEU */
250 1.8 christos NONAMEL = 281, /* NONAMEL */
251 1.8 christos DIRECTIVE = 282, /* DIRECTIVE */
252 1.8 christos EQUAL = 283, /* EQUAL */
253 1.8 christos ID = 284, /* ID */
254 1.8 christos DIGITS = 285 /* DIGITS */
255 1.6 christos };
256 1.8 christos typedef enum yytokentype yytoken_kind_t;
257 1.6 christos #endif
258 1.8 christos /* Token kinds. */
259 1.8 christos #define YYEMPTY -2
260 1.8 christos #define YYEOF 0
261 1.8 christos #define YYerror 256
262 1.8 christos #define YYUNDEF 257
263 1.6 christos #define NAME 258
264 1.6 christos #define LIBRARY 259
265 1.6 christos #define DESCRIPTION 260
266 1.6 christos #define STACKSIZE_K 261
267 1.6 christos #define HEAPSIZE 262
268 1.6 christos #define CODE 263
269 1.6 christos #define DATAU 264
270 1.6 christos #define DATAL 265
271 1.6 christos #define SECTIONS 266
272 1.6 christos #define EXPORTS 267
273 1.6 christos #define IMPORTS 268
274 1.6 christos #define VERSIONK 269
275 1.6 christos #define BASE 270
276 1.6 christos #define CONSTANTU 271
277 1.6 christos #define CONSTANTL 272
278 1.6 christos #define PRIVATEU 273
279 1.6 christos #define PRIVATEL 274
280 1.6 christos #define ALIGNCOMM 275
281 1.6 christos #define READ 276
282 1.6 christos #define WRITE 277
283 1.6 christos #define EXECUTE 278
284 1.8 christos #define SHARED_K 279
285 1.6 christos #define NONAMEU 280
286 1.6 christos #define NONAMEL 281
287 1.6 christos #define DIRECTIVE 282
288 1.6 christos #define EQUAL 283
289 1.6 christos #define ID 284
290 1.6 christos #define DIGITS 285
291 1.6 christos
292 1.6 christos /* Value type. */
293 1.1 christos #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
294 1.6 christos union YYSTYPE
295 1.1 christos {
296 1.8 christos #line 114 "deffilep.y"
297 1.6 christos
298 1.1 christos char *id;
299 1.1 christos const char *id_const;
300 1.1 christos int number;
301 1.3 christos bfd_vma vma;
302 1.1 christos char *digits;
303 1.6 christos
304 1.8 christos #line 305 "deffilep.c"
305 1.8 christos
306 1.6 christos };
307 1.6 christos typedef union YYSTYPE YYSTYPE;
308 1.6 christos # define YYSTYPE_IS_TRIVIAL 1
309 1.5 christos # define YYSTYPE_IS_DECLARED 1
310 1.1 christos #endif
311 1.1 christos
312 1.1 christos
313 1.6 christos extern YYSTYPE yylval;
314 1.6 christos
315 1.8 christos
316 1.6 christos int yyparse (void);
317 1.6 christos
318 1.8 christos
319 1.6 christos #endif /* !YY_YY_DEFFILEP_H_INCLUDED */
320 1.8 christos /* Symbol kind. */
321 1.8 christos enum yysymbol_kind_t
322 1.8 christos {
323 1.8 christos YYSYMBOL_YYEMPTY = -2,
324 1.8 christos YYSYMBOL_YYEOF = 0, /* "end of file" */
325 1.8 christos YYSYMBOL_YYerror = 1, /* error */
326 1.8 christos YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
327 1.8 christos YYSYMBOL_NAME = 3, /* NAME */
328 1.8 christos YYSYMBOL_LIBRARY = 4, /* LIBRARY */
329 1.8 christos YYSYMBOL_DESCRIPTION = 5, /* DESCRIPTION */
330 1.8 christos YYSYMBOL_STACKSIZE_K = 6, /* STACKSIZE_K */
331 1.8 christos YYSYMBOL_HEAPSIZE = 7, /* HEAPSIZE */
332 1.8 christos YYSYMBOL_CODE = 8, /* CODE */
333 1.8 christos YYSYMBOL_DATAU = 9, /* DATAU */
334 1.8 christos YYSYMBOL_DATAL = 10, /* DATAL */
335 1.8 christos YYSYMBOL_SECTIONS = 11, /* SECTIONS */
336 1.8 christos YYSYMBOL_EXPORTS = 12, /* EXPORTS */
337 1.8 christos YYSYMBOL_IMPORTS = 13, /* IMPORTS */
338 1.8 christos YYSYMBOL_VERSIONK = 14, /* VERSIONK */
339 1.8 christos YYSYMBOL_BASE = 15, /* BASE */
340 1.8 christos YYSYMBOL_CONSTANTU = 16, /* CONSTANTU */
341 1.8 christos YYSYMBOL_CONSTANTL = 17, /* CONSTANTL */
342 1.8 christos YYSYMBOL_PRIVATEU = 18, /* PRIVATEU */
343 1.8 christos YYSYMBOL_PRIVATEL = 19, /* PRIVATEL */
344 1.8 christos YYSYMBOL_ALIGNCOMM = 20, /* ALIGNCOMM */
345 1.8 christos YYSYMBOL_READ = 21, /* READ */
346 1.8 christos YYSYMBOL_WRITE = 22, /* WRITE */
347 1.8 christos YYSYMBOL_EXECUTE = 23, /* EXECUTE */
348 1.8 christos YYSYMBOL_SHARED_K = 24, /* SHARED_K */
349 1.8 christos YYSYMBOL_NONAMEU = 25, /* NONAMEU */
350 1.8 christos YYSYMBOL_NONAMEL = 26, /* NONAMEL */
351 1.8 christos YYSYMBOL_DIRECTIVE = 27, /* DIRECTIVE */
352 1.8 christos YYSYMBOL_EQUAL = 28, /* EQUAL */
353 1.8 christos YYSYMBOL_ID = 29, /* ID */
354 1.8 christos YYSYMBOL_DIGITS = 30, /* DIGITS */
355 1.8 christos YYSYMBOL_31_ = 31, /* '.' */
356 1.8 christos YYSYMBOL_32_ = 32, /* ',' */
357 1.8 christos YYSYMBOL_33_ = 33, /* '=' */
358 1.8 christos YYSYMBOL_34_ = 34, /* '@' */
359 1.8 christos YYSYMBOL_YYACCEPT = 35, /* $accept */
360 1.8 christos YYSYMBOL_start = 36, /* start */
361 1.8 christos YYSYMBOL_command = 37, /* command */
362 1.8 christos YYSYMBOL_explist = 38, /* explist */
363 1.8 christos YYSYMBOL_expline = 39, /* expline */
364 1.8 christos YYSYMBOL_exp_opt_list = 40, /* exp_opt_list */
365 1.8 christos YYSYMBOL_exp_opt = 41, /* exp_opt */
366 1.8 christos YYSYMBOL_implist = 42, /* implist */
367 1.8 christos YYSYMBOL_impline = 43, /* impline */
368 1.8 christos YYSYMBOL_seclist = 44, /* seclist */
369 1.8 christos YYSYMBOL_secline = 45, /* secline */
370 1.8 christos YYSYMBOL_attr_list = 46, /* attr_list */
371 1.8 christos YYSYMBOL_opt_comma = 47, /* opt_comma */
372 1.8 christos YYSYMBOL_opt_number = 48, /* opt_number */
373 1.8 christos YYSYMBOL_attr = 49, /* attr */
374 1.8 christos YYSYMBOL_keyword_as_name = 50, /* keyword_as_name */
375 1.8 christos YYSYMBOL_opt_name2 = 51, /* opt_name2 */
376 1.8 christos YYSYMBOL_opt_name = 52, /* opt_name */
377 1.8 christos YYSYMBOL_opt_equalequal_name = 53, /* opt_equalequal_name */
378 1.8 christos YYSYMBOL_opt_ordinal = 54, /* opt_ordinal */
379 1.8 christos YYSYMBOL_opt_equal_name = 55, /* opt_equal_name */
380 1.8 christos YYSYMBOL_opt_base = 56, /* opt_base */
381 1.8 christos YYSYMBOL_anylang_id = 57, /* anylang_id */
382 1.8 christos YYSYMBOL_opt_digits = 58, /* opt_digits */
383 1.8 christos YYSYMBOL_opt_id = 59, /* opt_id */
384 1.8 christos YYSYMBOL_NUMBER = 60, /* NUMBER */
385 1.8 christos YYSYMBOL_VMA = 61 /* VMA */
386 1.8 christos };
387 1.8 christos typedef enum yysymbol_kind_t yysymbol_kind_t;
388 1.8 christos
389 1.3 christos
390 1.1 christos
391 1.1 christos
392 1.1 christos #ifdef short
393 1.1 christos # undef short
394 1.1 christos #endif
395 1.1 christos
396 1.8 christos /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
397 1.8 christos <limits.h> and (if available) <stdint.h> are included
398 1.8 christos so that the code can choose integer types of a good width. */
399 1.8 christos
400 1.8 christos #ifndef __PTRDIFF_MAX__
401 1.8 christos # include <limits.h> /* INFRINGES ON USER NAME SPACE */
402 1.8 christos # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
403 1.8 christos # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
404 1.8 christos # define YY_STDINT_H
405 1.8 christos # endif
406 1.8 christos #endif
407 1.8 christos
408 1.8 christos /* Narrow types that promote to a signed type and that can represent a
409 1.8 christos signed or unsigned integer of at least N bits. In tables they can
410 1.8 christos save space and decrease cache pressure. Promoting to a signed type
411 1.8 christos helps avoid bugs in integer arithmetic. */
412 1.8 christos
413 1.8 christos #ifdef __INT_LEAST8_MAX__
414 1.8 christos typedef __INT_LEAST8_TYPE__ yytype_int8;
415 1.8 christos #elif defined YY_STDINT_H
416 1.8 christos typedef int_least8_t yytype_int8;
417 1.1 christos #else
418 1.8 christos typedef signed char yytype_int8;
419 1.1 christos #endif
420 1.1 christos
421 1.8 christos #ifdef __INT_LEAST16_MAX__
422 1.8 christos typedef __INT_LEAST16_TYPE__ yytype_int16;
423 1.8 christos #elif defined YY_STDINT_H
424 1.8 christos typedef int_least16_t yytype_int16;
425 1.6 christos #else
426 1.8 christos typedef short yytype_int16;
427 1.1 christos #endif
428 1.1 christos
429 1.8 christos /* Work around bug in HP-UX 11.23, which defines these macros
430 1.8 christos incorrectly for preprocessor constants. This workaround can likely
431 1.8 christos be removed in 2023, as HPE has promised support for HP-UX 11.23
432 1.8 christos (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
433 1.8 christos <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
434 1.8 christos #ifdef __hpux
435 1.8 christos # undef UINT_LEAST8_MAX
436 1.8 christos # undef UINT_LEAST16_MAX
437 1.8 christos # define UINT_LEAST8_MAX 255
438 1.8 christos # define UINT_LEAST16_MAX 65535
439 1.8 christos #endif
440 1.8 christos
441 1.8 christos #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
442 1.8 christos typedef __UINT_LEAST8_TYPE__ yytype_uint8;
443 1.8 christos #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
444 1.8 christos && UINT_LEAST8_MAX <= INT_MAX)
445 1.8 christos typedef uint_least8_t yytype_uint8;
446 1.8 christos #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
447 1.8 christos typedef unsigned char yytype_uint8;
448 1.1 christos #else
449 1.8 christos typedef short yytype_uint8;
450 1.1 christos #endif
451 1.1 christos
452 1.8 christos #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
453 1.8 christos typedef __UINT_LEAST16_TYPE__ yytype_uint16;
454 1.8 christos #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
455 1.8 christos && UINT_LEAST16_MAX <= INT_MAX)
456 1.8 christos typedef uint_least16_t yytype_uint16;
457 1.8 christos #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
458 1.8 christos typedef unsigned short yytype_uint16;
459 1.1 christos #else
460 1.8 christos typedef int yytype_uint16;
461 1.8 christos #endif
462 1.8 christos
463 1.8 christos #ifndef YYPTRDIFF_T
464 1.8 christos # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
465 1.8 christos # define YYPTRDIFF_T __PTRDIFF_TYPE__
466 1.8 christos # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
467 1.8 christos # elif defined PTRDIFF_MAX
468 1.8 christos # ifndef ptrdiff_t
469 1.8 christos # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
470 1.8 christos # endif
471 1.8 christos # define YYPTRDIFF_T ptrdiff_t
472 1.8 christos # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
473 1.8 christos # else
474 1.8 christos # define YYPTRDIFF_T long
475 1.8 christos # define YYPTRDIFF_MAXIMUM LONG_MAX
476 1.8 christos # endif
477 1.1 christos #endif
478 1.1 christos
479 1.1 christos #ifndef YYSIZE_T
480 1.1 christos # ifdef __SIZE_TYPE__
481 1.1 christos # define YYSIZE_T __SIZE_TYPE__
482 1.1 christos # elif defined size_t
483 1.1 christos # define YYSIZE_T size_t
484 1.8 christos # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
485 1.1 christos # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
486 1.1 christos # define YYSIZE_T size_t
487 1.1 christos # else
488 1.8 christos # define YYSIZE_T unsigned
489 1.1 christos # endif
490 1.1 christos #endif
491 1.1 christos
492 1.8 christos #define YYSIZE_MAXIMUM \
493 1.8 christos YY_CAST (YYPTRDIFF_T, \
494 1.8 christos (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
495 1.8 christos ? YYPTRDIFF_MAXIMUM \
496 1.8 christos : YY_CAST (YYSIZE_T, -1)))
497 1.8 christos
498 1.8 christos #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
499 1.8 christos
500 1.8 christos
501 1.8 christos /* Stored state numbers (used for stacks). */
502 1.8 christos typedef yytype_uint8 yy_state_t;
503 1.8 christos
504 1.8 christos /* State numbers in computations. */
505 1.8 christos typedef int yy_state_fast_t;
506 1.1 christos
507 1.1 christos #ifndef YY_
508 1.1 christos # if defined YYENABLE_NLS && YYENABLE_NLS
509 1.1 christos # if ENABLE_NLS
510 1.1 christos # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
511 1.6 christos # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
512 1.1 christos # endif
513 1.1 christos # endif
514 1.1 christos # ifndef YY_
515 1.6 christos # define YY_(Msgid) Msgid
516 1.6 christos # endif
517 1.6 christos #endif
518 1.6 christos
519 1.8 christos
520 1.8 christos #ifndef YY_ATTRIBUTE_PURE
521 1.8 christos # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
522 1.8 christos # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
523 1.6 christos # else
524 1.8 christos # define YY_ATTRIBUTE_PURE
525 1.6 christos # endif
526 1.6 christos #endif
527 1.6 christos
528 1.6 christos #ifndef YY_ATTRIBUTE_UNUSED
529 1.8 christos # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
530 1.8 christos # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
531 1.6 christos # else
532 1.8 christos # define YY_ATTRIBUTE_UNUSED
533 1.1 christos # endif
534 1.1 christos #endif
535 1.1 christos
536 1.1 christos /* Suppress unused-variable warnings by "using" E. */
537 1.1 christos #if ! defined lint || defined __GNUC__
538 1.8 christos # define YY_USE(E) ((void) (E))
539 1.1 christos #else
540 1.8 christos # define YY_USE(E) /* empty */
541 1.1 christos #endif
542 1.1 christos
543 1.6 christos /* Suppress an incorrect diagnostic about yylval being uninitialized. */
544 1.8 christos #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
545 1.8 christos # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
546 1.8 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
547 1.8 christos _Pragma ("GCC diagnostic push") \
548 1.8 christos _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
549 1.8 christos # else
550 1.8 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
551 1.8 christos _Pragma ("GCC diagnostic push") \
552 1.8 christos _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
553 1.6 christos _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
554 1.8 christos # endif
555 1.8 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
556 1.6 christos _Pragma ("GCC diagnostic pop")
557 1.1 christos #else
558 1.6 christos # define YY_INITIAL_VALUE(Value) Value
559 1.6 christos #endif
560 1.6 christos #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
561 1.6 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
562 1.6 christos # define YY_IGNORE_MAYBE_UNINITIALIZED_END
563 1.3 christos #endif
564 1.6 christos #ifndef YY_INITIAL_VALUE
565 1.6 christos # define YY_INITIAL_VALUE(Value) /* Nothing. */
566 1.1 christos #endif
567 1.1 christos
568 1.8 christos #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
569 1.8 christos # define YY_IGNORE_USELESS_CAST_BEGIN \
570 1.8 christos _Pragma ("GCC diagnostic push") \
571 1.8 christos _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
572 1.8 christos # define YY_IGNORE_USELESS_CAST_END \
573 1.8 christos _Pragma ("GCC diagnostic pop")
574 1.8 christos #endif
575 1.8 christos #ifndef YY_IGNORE_USELESS_CAST_BEGIN
576 1.8 christos # define YY_IGNORE_USELESS_CAST_BEGIN
577 1.8 christos # define YY_IGNORE_USELESS_CAST_END
578 1.8 christos #endif
579 1.8 christos
580 1.8 christos
581 1.8 christos #define YY_ASSERT(E) ((void) (0 && (E)))
582 1.6 christos
583 1.8 christos #if !defined yyoverflow
584 1.1 christos
585 1.1 christos /* The parser invokes alloca or malloc; define the necessary symbols. */
586 1.1 christos
587 1.1 christos # ifdef YYSTACK_USE_ALLOCA
588 1.1 christos # if YYSTACK_USE_ALLOCA
589 1.1 christos # ifdef __GNUC__
590 1.1 christos # define YYSTACK_ALLOC __builtin_alloca
591 1.1 christos # elif defined __BUILTIN_VA_ARG_INCR
592 1.1 christos # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
593 1.1 christos # elif defined _AIX
594 1.1 christos # define YYSTACK_ALLOC __alloca
595 1.1 christos # elif defined _MSC_VER
596 1.1 christos # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
597 1.1 christos # define alloca _alloca
598 1.1 christos # else
599 1.1 christos # define YYSTACK_ALLOC alloca
600 1.6 christos # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
601 1.1 christos # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
602 1.6 christos /* Use EXIT_SUCCESS as a witness for stdlib.h. */
603 1.6 christos # ifndef EXIT_SUCCESS
604 1.6 christos # define EXIT_SUCCESS 0
605 1.1 christos # endif
606 1.1 christos # endif
607 1.1 christos # endif
608 1.1 christos # endif
609 1.1 christos # endif
610 1.1 christos
611 1.1 christos # ifdef YYSTACK_ALLOC
612 1.6 christos /* Pacify GCC's 'empty if-body' warning. */
613 1.6 christos # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
614 1.1 christos # ifndef YYSTACK_ALLOC_MAXIMUM
615 1.1 christos /* The OS might guarantee only one guard page at the bottom of the stack,
616 1.1 christos and a page size can be as small as 4096 bytes. So we cannot safely
617 1.1 christos invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
618 1.1 christos to allow for a few compiler-allocated temporary stack slots. */
619 1.1 christos # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
620 1.1 christos # endif
621 1.1 christos # else
622 1.1 christos # define YYSTACK_ALLOC YYMALLOC
623 1.1 christos # define YYSTACK_FREE YYFREE
624 1.1 christos # ifndef YYSTACK_ALLOC_MAXIMUM
625 1.1 christos # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
626 1.1 christos # endif
627 1.6 christos # if (defined __cplusplus && ! defined EXIT_SUCCESS \
628 1.1 christos && ! ((defined YYMALLOC || defined malloc) \
629 1.6 christos && (defined YYFREE || defined free)))
630 1.1 christos # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
631 1.6 christos # ifndef EXIT_SUCCESS
632 1.6 christos # define EXIT_SUCCESS 0
633 1.1 christos # endif
634 1.1 christos # endif
635 1.1 christos # ifndef YYMALLOC
636 1.1 christos # define YYMALLOC malloc
637 1.6 christos # if ! defined malloc && ! defined EXIT_SUCCESS
638 1.1 christos void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
639 1.1 christos # endif
640 1.1 christos # endif
641 1.1 christos # ifndef YYFREE
642 1.1 christos # define YYFREE free
643 1.6 christos # if ! defined free && ! defined EXIT_SUCCESS
644 1.1 christos void free (void *); /* INFRINGES ON USER NAME SPACE */
645 1.1 christos # endif
646 1.1 christos # endif
647 1.1 christos # endif
648 1.8 christos #endif /* !defined yyoverflow */
649 1.1 christos
650 1.1 christos #if (! defined yyoverflow \
651 1.1 christos && (! defined __cplusplus \
652 1.6 christos || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
653 1.1 christos
654 1.1 christos /* A type that is properly aligned for any stack member. */
655 1.1 christos union yyalloc
656 1.1 christos {
657 1.8 christos yy_state_t yyss_alloc;
658 1.6 christos YYSTYPE yyvs_alloc;
659 1.6 christos };
660 1.1 christos
661 1.1 christos /* The size of the maximum gap between one aligned stack and the next. */
662 1.8 christos # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
663 1.1 christos
664 1.1 christos /* The size of an array large to enough to hold all stacks, each with
665 1.1 christos N elements. */
666 1.1 christos # define YYSTACK_BYTES(N) \
667 1.8 christos ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
668 1.1 christos + YYSTACK_GAP_MAXIMUM)
669 1.1 christos
670 1.6 christos # define YYCOPY_NEEDED 1
671 1.1 christos
672 1.1 christos /* Relocate STACK from its old location to the new one. The
673 1.1 christos local variables YYSIZE and YYSTACKSIZE give the old and new number of
674 1.1 christos elements in the stack, and YYPTR gives the new location of the
675 1.1 christos stack. Advance YYPTR to a properly aligned location for the next
676 1.1 christos stack. */
677 1.6 christos # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
678 1.6 christos do \
679 1.6 christos { \
680 1.8 christos YYPTRDIFF_T yynewbytes; \
681 1.6 christos YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
682 1.6 christos Stack = &yyptr->Stack_alloc; \
683 1.8 christos yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
684 1.8 christos yyptr += yynewbytes / YYSIZEOF (*yyptr); \
685 1.6 christos } \
686 1.6 christos while (0)
687 1.1 christos
688 1.1 christos #endif
689 1.1 christos
690 1.6 christos #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
691 1.6 christos /* Copy COUNT objects from SRC to DST. The source and destination do
692 1.6 christos not overlap. */
693 1.6 christos # ifndef YYCOPY
694 1.6 christos # if defined __GNUC__ && 1 < __GNUC__
695 1.6 christos # define YYCOPY(Dst, Src, Count) \
696 1.8 christos __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
697 1.6 christos # else
698 1.6 christos # define YYCOPY(Dst, Src, Count) \
699 1.6 christos do \
700 1.6 christos { \
701 1.8 christos YYPTRDIFF_T yyi; \
702 1.6 christos for (yyi = 0; yyi < (Count); yyi++) \
703 1.6 christos (Dst)[yyi] = (Src)[yyi]; \
704 1.6 christos } \
705 1.6 christos while (0)
706 1.6 christos # endif
707 1.6 christos # endif
708 1.6 christos #endif /* !YYCOPY_NEEDED */
709 1.6 christos
710 1.1 christos /* YYFINAL -- State number of the termination state. */
711 1.1 christos #define YYFINAL 69
712 1.1 christos /* YYLAST -- Last index in YYTABLE. */
713 1.3 christos #define YYLAST 149
714 1.1 christos
715 1.1 christos /* YYNTOKENS -- Number of terminals. */
716 1.1 christos #define YYNTOKENS 35
717 1.1 christos /* YYNNTS -- Number of nonterminals. */
718 1.3 christos #define YYNNTS 27
719 1.1 christos /* YYNRULES -- Number of rules. */
720 1.3 christos #define YYNRULES 99
721 1.6 christos /* YYNSTATES -- Number of states. */
722 1.3 christos #define YYNSTATES 146
723 1.1 christos
724 1.8 christos /* YYMAXUTOK -- Last valid token kind. */
725 1.1 christos #define YYMAXUTOK 285
726 1.1 christos
727 1.8 christos
728 1.8 christos /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
729 1.8 christos as returned by yylex, with out-of-bounds checking. */
730 1.8 christos #define YYTRANSLATE(YYX) \
731 1.8 christos (0 <= (YYX) && (YYX) <= YYMAXUTOK \
732 1.8 christos ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
733 1.8 christos : YYSYMBOL_YYUNDEF)
734 1.1 christos
735 1.6 christos /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
736 1.8 christos as returned by yylex. */
737 1.8 christos static const yytype_int8 yytranslate[] =
738 1.1 christos {
739 1.1 christos 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
740 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
741 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
742 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
743 1.1 christos 2, 2, 2, 2, 32, 2, 31, 2, 2, 2,
744 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
745 1.1 christos 2, 33, 2, 2, 34, 2, 2, 2, 2, 2,
746 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
747 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
748 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
749 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
750 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
751 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
752 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
753 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
754 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
755 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
756 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
757 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
758 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
759 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
760 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
761 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
762 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
763 1.1 christos 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
764 1.1 christos 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
765 1.1 christos 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
766 1.1 christos 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
767 1.1 christos 25, 26, 27, 28, 29, 30
768 1.1 christos };
769 1.1 christos
770 1.1 christos #if YYDEBUG
771 1.8 christos /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
772 1.8 christos static const yytype_int16 yyrline[] =
773 1.1 christos {
774 1.7 christos 0, 139, 139, 140, 144, 145, 146, 147, 148, 149,
775 1.7 christos 150, 151, 152, 153, 154, 155, 156, 157, 161, 163,
776 1.7 christos 164, 171, 178, 179, 182, 183, 184, 185, 186, 187,
777 1.7 christos 188, 189, 192, 193, 197, 199, 201, 203, 205, 207,
778 1.7 christos 212, 213, 217, 218, 222, 223, 227, 228, 230, 231,
779 1.7 christos 235, 236, 237, 238, 242, 243, 244, 245, 246, 247,
780 1.7 christos 248, 249, 250, 251, 252, 253, 260, 261, 262, 263,
781 1.7 christos 264, 265, 266, 267, 268, 269, 272, 273, 279, 285,
782 1.7 christos 291, 299, 300, 303, 304, 308, 309, 313, 314, 317,
783 1.7 christos 318, 321, 322, 328, 336, 337, 340, 341, 344, 346
784 1.1 christos };
785 1.1 christos #endif
786 1.1 christos
787 1.8 christos /** Accessing symbol of state STATE. */
788 1.8 christos #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
789 1.8 christos
790 1.8 christos #if YYDEBUG || 0
791 1.8 christos /* The user-facing name of the symbol whose (internal) number is
792 1.8 christos YYSYMBOL. No bounds checking. */
793 1.8 christos static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
794 1.8 christos
795 1.1 christos /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
796 1.1 christos First, the terminals, then, starting at YYNTOKENS, nonterminals. */
797 1.1 christos static const char *const yytname[] =
798 1.1 christos {
799 1.8 christos "\"end of file\"", "error", "\"invalid token\"", "NAME", "LIBRARY",
800 1.8 christos "DESCRIPTION", "STACKSIZE_K", "HEAPSIZE", "CODE", "DATAU", "DATAL",
801 1.8 christos "SECTIONS", "EXPORTS", "IMPORTS", "VERSIONK", "BASE", "CONSTANTU",
802 1.8 christos "CONSTANTL", "PRIVATEU", "PRIVATEL", "ALIGNCOMM", "READ", "WRITE",
803 1.8 christos "EXECUTE", "SHARED_K", "NONAMEU", "NONAMEL", "DIRECTIVE", "EQUAL", "ID",
804 1.8 christos "DIGITS", "'.'", "','", "'='", "'@'", "$accept", "start", "command",
805 1.8 christos "explist", "expline", "exp_opt_list", "exp_opt", "implist", "impline",
806 1.8 christos "seclist", "secline", "attr_list", "opt_comma", "opt_number", "attr",
807 1.1 christos "keyword_as_name", "opt_name2", "opt_name", "opt_equalequal_name",
808 1.1 christos "opt_ordinal", "opt_equal_name", "opt_base", "anylang_id", "opt_digits",
809 1.6 christos "opt_id", "NUMBER", "VMA", YY_NULLPTR
810 1.1 christos };
811 1.8 christos
812 1.8 christos static const char *
813 1.8 christos yysymbol_name (yysymbol_kind_t yysymbol)
814 1.8 christos {
815 1.8 christos return yytname[yysymbol];
816 1.8 christos }
817 1.1 christos #endif
818 1.1 christos
819 1.8 christos #define YYPACT_NINF (-82)
820 1.6 christos
821 1.8 christos #define yypact_value_is_default(Yyn) \
822 1.8 christos ((Yyn) == YYPACT_NINF)
823 1.6 christos
824 1.8 christos #define YYTABLE_NINF (-48)
825 1.6 christos
826 1.8 christos #define yytable_value_is_error(Yyn) \
827 1.6 christos 0
828 1.3 christos
829 1.8 christos /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
830 1.8 christos STATE-NUM. */
831 1.6 christos static const yytype_int8 yypact[] =
832 1.5 christos {
833 1.6 christos 122, 11, 11, -25, 9, 9, 53, 53, -17, 11,
834 1.6 christos 14, 9, -18, 20, 95, -82, -82, -82, -82, -82,
835 1.6 christos -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
836 1.6 christos -82, -82, -82, -82, -82, -82, -82, -82, 29, 11,
837 1.6 christos 47, -82, 67, 67, -82, -82, 54, 54, -82, -82,
838 1.6 christos -82, -82, 48, -82, 48, -14, -17, -82, 11, -82,
839 1.6 christos 58, 50, 14, -82, 61, -82, 64, 33, -82, -82,
840 1.6 christos -82, 11, 47, -82, 11, 63, -82, -82, 9, -82,
841 1.6 christos -82, -82, 53, -82, 48, -82, -82, 11, 60, 76,
842 1.6 christos 81, -82, 9, -82, 83, 9, -82, -82, 84, -82,
843 1.6 christos -82, -82, 9, 79, -26, 85, -82, -82, 88, -82,
844 1.6 christos -82, -82, -82, 36, 89, 90, -82, 55, -82, -82,
845 1.6 christos -82, -82, -82, -82, -82, -82, -82, -82, 79, 79,
846 1.6 christos -82, 92, 13, 92, 92, 36, -82, 59, -82, -82,
847 1.6 christos -82, -82, 92, 92, -82, -82
848 1.5 christos };
849 1.3 christos
850 1.8 christos /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
851 1.8 christos Performed when YYTABLE does not specify something else to do. Zero
852 1.8 christos means the default is an error. */
853 1.8 christos static const yytype_int8 yydefact[] =
854 1.5 christos {
855 1.5 christos 0, 82, 82, 0, 0, 0, 0, 0, 0, 18,
856 1.5 christos 0, 0, 0, 0, 0, 3, 66, 60, 73, 64,
857 1.5 christos 55, 58, 59, 63, 65, 74, 54, 56, 57, 69,
858 1.5 christos 70, 71, 75, 62, 72, 67, 68, 61, 76, 0,
859 1.5 christos 0, 81, 90, 90, 6, 98, 49, 49, 50, 51,
860 1.5 christos 52, 53, 9, 45, 10, 0, 11, 41, 12, 19,
861 1.5 christos 88, 0, 13, 33, 14, 91, 0, 0, 16, 1,
862 1.5 christos 2, 0, 77, 78, 0, 0, 4, 5, 0, 7,
863 1.5 christos 8, 46, 0, 43, 42, 40, 20, 0, 86, 0,
864 1.5 christos 0, 32, 0, 92, 95, 0, 80, 79, 0, 48,
865 1.5 christos 44, 87, 0, 47, 84, 0, 15, 94, 97, 17,
866 1.5 christos 99, 89, 85, 23, 0, 0, 39, 0, 96, 93,
867 1.5 christos 28, 29, 26, 27, 30, 31, 24, 25, 47, 47,
868 1.5 christos 83, 84, 84, 84, 84, 23, 38, 0, 36, 37,
869 1.5 christos 21, 22, 84, 84, 34, 35
870 1.5 christos };
871 1.3 christos
872 1.8 christos /* YYPGOTO[NTERM-NUM]. */
873 1.6 christos static const yytype_int16 yypgoto[] =
874 1.6 christos {
875 1.6 christos -82, -82, 107, -82, 65, -11, -82, -82, 75, -82,
876 1.6 christos 82, -4, -81, 93, 57, 102, -8, 141, -75, -82,
877 1.6 christos -82, 101, -82, -82, -82, -5, -82
878 1.6 christos };
879 1.6 christos
880 1.8 christos /* YYDEFGOTO[NTERM-NUM]. */
881 1.8 christos static const yytype_uint8 yydefgoto[] =
882 1.5 christos {
883 1.8 christos 0, 14, 15, 58, 59, 128, 129, 62, 63, 56,
884 1.5 christos 57, 52, 82, 79, 53, 40, 41, 42, 116, 103,
885 1.5 christos 88, 76, 67, 108, 119, 46, 111
886 1.5 christos };
887 1.1 christos
888 1.8 christos /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
889 1.8 christos positive, shift that token. If negative, reduce the rule whose
890 1.8 christos number is the opposite. If YYTABLE_NINF, syntax error. */
891 1.1 christos static const yytype_int16 yytable[] =
892 1.1 christos {
893 1.3 christos 47, 60, 114, 54, 44, 115, 64, 48, 49, 50,
894 1.1 christos 51, 65, 55, 66, 16, 83, 17, 18, 19, 20,
895 1.3 christos 21, 22, 113, 23, 24, 25, 26, 27, 28, 29,
896 1.1 christos 30, 73, 31, 32, 33, 34, 35, 36, 37, 45,
897 1.3 christos 38, 114, 39, 61, 137, 120, 121, 134, 135, 68,
898 1.3 christos 60, 84, 122, 123, 124, 125, 136, 138, 139, 140,
899 1.3 christos 71, 126, 127, 96, 94, 95, 97, 144, 145, -47,
900 1.3 christos -47, -47, -47, 99, 48, 49, 50, 51, 74, 101,
901 1.3 christos 81, 89, 75, 90, 132, 45, 78, 106, 142, 45,
902 1.3 christos 109, 87, 92, 93, 102, 69, 98, 112, 1, 2,
903 1.3 christos 3, 4, 5, 6, 7, 104, 8, 9, 10, 11,
904 1.3 christos 105, 81, 133, 107, 110, 12, 117, 118, 130, 131,
905 1.3 christos 114, 70, 13, 86, 141, 1, 2, 3, 4, 5,
906 1.3 christos 6, 7, 143, 8, 9, 10, 11, 91, 85, 100,
907 1.3 christos 80, 72, 12, 43, 77, 0, 0, 0, 0, 13
908 1.1 christos };
909 1.1 christos
910 1.1 christos static const yytype_int16 yycheck[] =
911 1.1 christos {
912 1.1 christos 5, 9, 28, 7, 29, 31, 11, 21, 22, 23,
913 1.1 christos 24, 29, 29, 31, 3, 29, 5, 6, 7, 8,
914 1.1 christos 9, 10, 103, 12, 13, 14, 15, 16, 17, 18,
915 1.1 christos 19, 39, 21, 22, 23, 24, 25, 26, 27, 30,
916 1.3 christos 29, 28, 31, 29, 31, 9, 10, 128, 129, 29,
917 1.3 christos 58, 55, 16, 17, 18, 19, 131, 132, 133, 134,
918 1.3 christos 31, 25, 26, 71, 31, 32, 74, 142, 143, 21,
919 1.3 christos 22, 23, 24, 78, 21, 22, 23, 24, 31, 87,
920 1.3 christos 32, 31, 15, 33, 29, 30, 32, 92, 29, 30,
921 1.3 christos 95, 33, 31, 29, 34, 0, 33, 102, 3, 4,
922 1.3 christos 5, 6, 7, 8, 9, 29, 11, 12, 13, 14,
923 1.3 christos 29, 32, 117, 30, 30, 20, 31, 29, 29, 29,
924 1.3 christos 28, 14, 27, 58, 135, 3, 4, 5, 6, 7,
925 1.3 christos 8, 9, 137, 11, 12, 13, 14, 62, 56, 82,
926 1.3 christos 47, 39, 20, 2, 43, -1, -1, -1, -1, 27
927 1.1 christos };
928 1.1 christos
929 1.8 christos /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
930 1.8 christos state STATE-NUM. */
931 1.8 christos static const yytype_int8 yystos[] =
932 1.1 christos {
933 1.1 christos 0, 3, 4, 5, 6, 7, 8, 9, 11, 12,
934 1.1 christos 13, 14, 20, 27, 36, 37, 3, 5, 6, 7,
935 1.1 christos 8, 9, 10, 12, 13, 14, 15, 16, 17, 18,
936 1.1 christos 19, 21, 22, 23, 24, 25, 26, 27, 29, 31,
937 1.1 christos 50, 51, 52, 52, 29, 30, 60, 60, 21, 22,
938 1.1 christos 23, 24, 46, 49, 46, 29, 44, 45, 38, 39,
939 1.1 christos 51, 29, 42, 43, 60, 29, 31, 57, 29, 0,
940 1.1 christos 37, 31, 50, 51, 31, 15, 56, 56, 32, 48,
941 1.1 christos 48, 32, 47, 29, 46, 45, 39, 33, 55, 31,
942 1.1 christos 33, 43, 31, 29, 31, 32, 51, 51, 33, 60,
943 1.1 christos 49, 51, 34, 54, 29, 29, 60, 30, 58, 60,
944 1.3 christos 30, 61, 60, 47, 28, 31, 53, 31, 29, 59,
945 1.3 christos 9, 10, 16, 17, 18, 19, 25, 26, 40, 41,
946 1.3 christos 29, 29, 29, 60, 47, 47, 53, 31, 53, 53,
947 1.3 christos 53, 40, 29, 60, 53, 53
948 1.1 christos };
949 1.1 christos
950 1.8 christos /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
951 1.8 christos static const yytype_int8 yyr1[] =
952 1.6 christos {
953 1.6 christos 0, 35, 36, 36, 37, 37, 37, 37, 37, 37,
954 1.6 christos 37, 37, 37, 37, 37, 37, 37, 37, 38, 38,
955 1.6 christos 38, 39, 40, 40, 41, 41, 41, 41, 41, 41,
956 1.6 christos 41, 41, 42, 42, 43, 43, 43, 43, 43, 43,
957 1.6 christos 44, 44, 45, 45, 46, 46, 47, 47, 48, 48,
958 1.6 christos 49, 49, 49, 49, 50, 50, 50, 50, 50, 50,
959 1.6 christos 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
960 1.6 christos 50, 50, 50, 50, 50, 50, 51, 51, 51, 51,
961 1.6 christos 51, 52, 52, 53, 53, 54, 54, 55, 55, 56,
962 1.6 christos 56, 57, 57, 57, 58, 58, 59, 59, 60, 61
963 1.6 christos };
964 1.1 christos
965 1.8 christos /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
966 1.8 christos static const yytype_int8 yyr2[] =
967 1.6 christos {
968 1.6 christos 0, 2, 2, 1, 3, 3, 2, 3, 3, 2,
969 1.6 christos 2, 2, 2, 2, 2, 4, 2, 4, 0, 1,
970 1.6 christos 2, 7, 3, 0, 1, 1, 1, 1, 1, 1,
971 1.6 christos 1, 1, 2, 1, 8, 8, 6, 6, 6, 4,
972 1.6 christos 2, 1, 2, 2, 3, 1, 1, 0, 2, 0,
973 1.6 christos 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
974 1.6 christos 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
975 1.6 christos 1, 1, 1, 1, 1, 1, 1, 2, 2, 3,
976 1.6 christos 3, 1, 0, 2, 0, 2, 0, 2, 0, 3,
977 1.6 christos 0, 1, 2, 4, 1, 0, 1, 0, 1, 1
978 1.6 christos };
979 1.1 christos
980 1.1 christos
981 1.8 christos enum { YYENOMEM = -2 };
982 1.8 christos
983 1.6 christos #define yyerrok (yyerrstatus = 0)
984 1.6 christos #define yyclearin (yychar = YYEMPTY)
985 1.6 christos
986 1.6 christos #define YYACCEPT goto yyacceptlab
987 1.6 christos #define YYABORT goto yyabortlab
988 1.6 christos #define YYERROR goto yyerrorlab
989 1.8 christos #define YYNOMEM goto yyexhaustedlab
990 1.1 christos
991 1.1 christos
992 1.1 christos #define YYRECOVERING() (!!yyerrstatus)
993 1.1 christos
994 1.8 christos #define YYBACKUP(Token, Value) \
995 1.8 christos do \
996 1.8 christos if (yychar == YYEMPTY) \
997 1.8 christos { \
998 1.8 christos yychar = (Token); \
999 1.8 christos yylval = (Value); \
1000 1.8 christos YYPOPSTACK (yylen); \
1001 1.8 christos yystate = *yyssp; \
1002 1.8 christos goto yybackup; \
1003 1.8 christos } \
1004 1.8 christos else \
1005 1.8 christos { \
1006 1.8 christos yyerror (YY_("syntax error: cannot back up")); \
1007 1.8 christos YYERROR; \
1008 1.8 christos } \
1009 1.8 christos while (0)
1010 1.8 christos
1011 1.8 christos /* Backward compatibility with an undocumented macro.
1012 1.8 christos Use YYerror or YYUNDEF. */
1013 1.8 christos #define YYERRCODE YYUNDEF
1014 1.1 christos
1015 1.1 christos
1016 1.1 christos /* Enable debugging if requested. */
1017 1.1 christos #if YYDEBUG
1018 1.1 christos
1019 1.1 christos # ifndef YYFPRINTF
1020 1.1 christos # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1021 1.1 christos # define YYFPRINTF fprintf
1022 1.1 christos # endif
1023 1.1 christos
1024 1.6 christos # define YYDPRINTF(Args) \
1025 1.6 christos do { \
1026 1.6 christos if (yydebug) \
1027 1.6 christos YYFPRINTF Args; \
1028 1.6 christos } while (0)
1029 1.6 christos
1030 1.6 christos
1031 1.3 christos
1032 1.8 christos
1033 1.8 christos # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
1034 1.6 christos do { \
1035 1.6 christos if (yydebug) \
1036 1.6 christos { \
1037 1.6 christos YYFPRINTF (stderr, "%s ", Title); \
1038 1.6 christos yy_symbol_print (stderr, \
1039 1.8 christos Kind, Value); \
1040 1.6 christos YYFPRINTF (stderr, "\n"); \
1041 1.6 christos } \
1042 1.6 christos } while (0)
1043 1.1 christos
1044 1.1 christos
1045 1.8 christos /*-----------------------------------.
1046 1.8 christos | Print this symbol's value on YYO. |
1047 1.8 christos `-----------------------------------*/
1048 1.6 christos
1049 1.1 christos static void
1050 1.8 christos yy_symbol_value_print (FILE *yyo,
1051 1.8 christos yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1052 1.1 christos {
1053 1.8 christos FILE *yyoutput = yyo;
1054 1.8 christos YY_USE (yyoutput);
1055 1.1 christos if (!yyvaluep)
1056 1.1 christos return;
1057 1.8 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1058 1.8 christos YY_USE (yykind);
1059 1.8 christos YY_IGNORE_MAYBE_UNINITIALIZED_END
1060 1.1 christos }
1061 1.1 christos
1062 1.1 christos
1063 1.8 christos /*---------------------------.
1064 1.8 christos | Print this symbol on YYO. |
1065 1.8 christos `---------------------------*/
1066 1.1 christos
1067 1.1 christos static void
1068 1.8 christos yy_symbol_print (FILE *yyo,
1069 1.8 christos yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1070 1.1 christos {
1071 1.8 christos YYFPRINTF (yyo, "%s %s (",
1072 1.8 christos yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
1073 1.1 christos
1074 1.8 christos yy_symbol_value_print (yyo, yykind, yyvaluep);
1075 1.8 christos YYFPRINTF (yyo, ")");
1076 1.1 christos }
1077 1.1 christos
1078 1.1 christos /*------------------------------------------------------------------.
1079 1.1 christos | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1080 1.1 christos | TOP (included). |
1081 1.1 christos `------------------------------------------------------------------*/
1082 1.1 christos
1083 1.1 christos static void
1084 1.8 christos yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1085 1.1 christos {
1086 1.1 christos YYFPRINTF (stderr, "Stack now");
1087 1.6 christos for (; yybottom <= yytop; yybottom++)
1088 1.6 christos {
1089 1.6 christos int yybot = *yybottom;
1090 1.6 christos YYFPRINTF (stderr, " %d", yybot);
1091 1.6 christos }
1092 1.1 christos YYFPRINTF (stderr, "\n");
1093 1.1 christos }
1094 1.1 christos
1095 1.6 christos # define YY_STACK_PRINT(Bottom, Top) \
1096 1.6 christos do { \
1097 1.6 christos if (yydebug) \
1098 1.6 christos yy_stack_print ((Bottom), (Top)); \
1099 1.6 christos } while (0)
1100 1.1 christos
1101 1.1 christos
1102 1.1 christos /*------------------------------------------------.
1103 1.1 christos | Report that the YYRULE is going to be reduced. |
1104 1.1 christos `------------------------------------------------*/
1105 1.1 christos
1106 1.1 christos static void
1107 1.8 christos yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
1108 1.8 christos int yyrule)
1109 1.1 christos {
1110 1.8 christos int yylno = yyrline[yyrule];
1111 1.1 christos int yynrhs = yyr2[yyrule];
1112 1.1 christos int yyi;
1113 1.8 christos YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1114 1.6 christos yyrule - 1, yylno);
1115 1.1 christos /* The symbols being reduced. */
1116 1.1 christos for (yyi = 0; yyi < yynrhs; yyi++)
1117 1.1 christos {
1118 1.6 christos YYFPRINTF (stderr, " $%d = ", yyi + 1);
1119 1.6 christos yy_symbol_print (stderr,
1120 1.8 christos YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
1121 1.8 christos &yyvsp[(yyi + 1) - (yynrhs)]);
1122 1.6 christos YYFPRINTF (stderr, "\n");
1123 1.1 christos }
1124 1.1 christos }
1125 1.1 christos
1126 1.6 christos # define YY_REDUCE_PRINT(Rule) \
1127 1.6 christos do { \
1128 1.6 christos if (yydebug) \
1129 1.6 christos yy_reduce_print (yyssp, yyvsp, Rule); \
1130 1.6 christos } while (0)
1131 1.1 christos
1132 1.1 christos /* Nonzero means print parse trace. It is left uninitialized so that
1133 1.1 christos multiple parsers can coexist. */
1134 1.1 christos int yydebug;
1135 1.1 christos #else /* !YYDEBUG */
1136 1.8 christos # define YYDPRINTF(Args) ((void) 0)
1137 1.8 christos # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1138 1.1 christos # define YY_STACK_PRINT(Bottom, Top)
1139 1.1 christos # define YY_REDUCE_PRINT(Rule)
1140 1.1 christos #endif /* !YYDEBUG */
1141 1.1 christos
1142 1.1 christos
1143 1.1 christos /* YYINITDEPTH -- initial size of the parser's stacks. */
1144 1.6 christos #ifndef YYINITDEPTH
1145 1.1 christos # define YYINITDEPTH 200
1146 1.1 christos #endif
1147 1.1 christos
1148 1.1 christos /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1149 1.1 christos if the built-in stack extension method is used).
1150 1.1 christos
1151 1.1 christos Do not make this value too large; the results are undefined if
1152 1.1 christos YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1153 1.1 christos evaluated with infinite-precision integer arithmetic. */
1154 1.1 christos
1155 1.1 christos #ifndef YYMAXDEPTH
1156 1.1 christos # define YYMAXDEPTH 10000
1157 1.1 christos #endif
1158 1.1 christos
1159 1.1 christos
1160 1.1 christos
1161 1.1 christos
1162 1.1 christos
1163 1.1 christos
1164 1.1 christos /*-----------------------------------------------.
1165 1.1 christos | Release the memory associated to this symbol. |
1166 1.1 christos `-----------------------------------------------*/
1167 1.1 christos
1168 1.1 christos static void
1169 1.8 christos yydestruct (const char *yymsg,
1170 1.8 christos yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
1171 1.1 christos {
1172 1.8 christos YY_USE (yyvaluep);
1173 1.1 christos if (!yymsg)
1174 1.1 christos yymsg = "Deleting";
1175 1.8 christos YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1176 1.1 christos
1177 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1178 1.8 christos YY_USE (yykind);
1179 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_END
1180 1.1 christos }
1181 1.1 christos
1182 1.1 christos
1183 1.8 christos /* Lookahead token kind. */
1184 1.1 christos int yychar;
1185 1.1 christos
1186 1.6 christos /* The semantic value of the lookahead symbol. */
1187 1.1 christos YYSTYPE yylval;
1188 1.1 christos /* Number of syntax errors so far. */
1189 1.1 christos int yynerrs;
1190 1.1 christos
1191 1.1 christos
1192 1.8 christos
1193 1.8 christos
1194 1.1 christos /*----------.
1195 1.1 christos | yyparse. |
1196 1.1 christos `----------*/
1197 1.1 christos
1198 1.1 christos int
1199 1.1 christos yyparse (void)
1200 1.6 christos {
1201 1.8 christos yy_state_fast_t yystate = 0;
1202 1.6 christos /* Number of tokens to shift before error messages enabled. */
1203 1.8 christos int yyerrstatus = 0;
1204 1.6 christos
1205 1.8 christos /* Refer to the stacks through separate pointers, to allow yyoverflow
1206 1.8 christos to reallocate them elsewhere. */
1207 1.6 christos
1208 1.8 christos /* Their size. */
1209 1.8 christos YYPTRDIFF_T yystacksize = YYINITDEPTH;
1210 1.6 christos
1211 1.8 christos /* The state stack: array, bottom, top. */
1212 1.8 christos yy_state_t yyssa[YYINITDEPTH];
1213 1.8 christos yy_state_t *yyss = yyssa;
1214 1.8 christos yy_state_t *yyssp = yyss;
1215 1.6 christos
1216 1.8 christos /* The semantic value stack: array, bottom, top. */
1217 1.6 christos YYSTYPE yyvsa[YYINITDEPTH];
1218 1.8 christos YYSTYPE *yyvs = yyvsa;
1219 1.8 christos YYSTYPE *yyvsp = yyvs;
1220 1.5 christos
1221 1.1 christos int yyn;
1222 1.8 christos /* The return value of yyparse. */
1223 1.1 christos int yyresult;
1224 1.8 christos /* Lookahead symbol kind. */
1225 1.8 christos yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1226 1.6 christos /* The variables used to return semantic value and location from the
1227 1.6 christos action routines. */
1228 1.6 christos YYSTYPE yyval;
1229 1.6 christos
1230 1.8 christos
1231 1.1 christos
1232 1.1 christos #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1233 1.1 christos
1234 1.1 christos /* The number of symbols on the RHS of the reduced rule.
1235 1.1 christos Keep to zero when no symbol should be popped. */
1236 1.1 christos int yylen = 0;
1237 1.1 christos
1238 1.1 christos YYDPRINTF ((stderr, "Starting parse\n"));
1239 1.1 christos
1240 1.6 christos yychar = YYEMPTY; /* Cause a token to be read. */
1241 1.8 christos
1242 1.1 christos goto yysetstate;
1243 1.1 christos
1244 1.8 christos
1245 1.1 christos /*------------------------------------------------------------.
1246 1.8 christos | yynewstate -- push a new state, which is found in yystate. |
1247 1.1 christos `------------------------------------------------------------*/
1248 1.8 christos yynewstate:
1249 1.1 christos /* In all cases, when you get here, the value and location stacks
1250 1.1 christos have just been pushed. So pushing a state here evens the stacks. */
1251 1.1 christos yyssp++;
1252 1.1 christos
1253 1.8 christos
1254 1.8 christos /*--------------------------------------------------------------------.
1255 1.8 christos | yysetstate -- set current state (the top of the stack) to yystate. |
1256 1.8 christos `--------------------------------------------------------------------*/
1257 1.8 christos yysetstate:
1258 1.8 christos YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1259 1.8 christos YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1260 1.8 christos YY_IGNORE_USELESS_CAST_BEGIN
1261 1.8 christos *yyssp = YY_CAST (yy_state_t, yystate);
1262 1.8 christos YY_IGNORE_USELESS_CAST_END
1263 1.8 christos YY_STACK_PRINT (yyss, yyssp);
1264 1.1 christos
1265 1.1 christos if (yyss + yystacksize - 1 <= yyssp)
1266 1.8 christos #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1267 1.8 christos YYNOMEM;
1268 1.8 christos #else
1269 1.1 christos {
1270 1.1 christos /* Get the current used size of the three stacks, in elements. */
1271 1.8 christos YYPTRDIFF_T yysize = yyssp - yyss + 1;
1272 1.1 christos
1273 1.8 christos # if defined yyoverflow
1274 1.1 christos {
1275 1.6 christos /* Give user a chance to reallocate the stack. Use copies of
1276 1.6 christos these so that the &'s don't force the real ones into
1277 1.6 christos memory. */
1278 1.8 christos yy_state_t *yyss1 = yyss;
1279 1.6 christos YYSTYPE *yyvs1 = yyvs;
1280 1.6 christos
1281 1.6 christos /* Each stack pointer address is followed by the size of the
1282 1.6 christos data in use in that stack, in bytes. This used to be a
1283 1.6 christos conditional around just the two extra args, but that might
1284 1.6 christos be undefined if yyoverflow is a macro. */
1285 1.6 christos yyoverflow (YY_("memory exhausted"),
1286 1.8 christos &yyss1, yysize * YYSIZEOF (*yyssp),
1287 1.8 christos &yyvs1, yysize * YYSIZEOF (*yyvsp),
1288 1.6 christos &yystacksize);
1289 1.6 christos yyss = yyss1;
1290 1.6 christos yyvs = yyvs1;
1291 1.1 christos }
1292 1.8 christos # else /* defined YYSTACK_RELOCATE */
1293 1.1 christos /* Extend the stack our own way. */
1294 1.1 christos if (YYMAXDEPTH <= yystacksize)
1295 1.8 christos YYNOMEM;
1296 1.1 christos yystacksize *= 2;
1297 1.1 christos if (YYMAXDEPTH < yystacksize)
1298 1.6 christos yystacksize = YYMAXDEPTH;
1299 1.1 christos
1300 1.1 christos {
1301 1.8 christos yy_state_t *yyss1 = yyss;
1302 1.6 christos union yyalloc *yyptr =
1303 1.8 christos YY_CAST (union yyalloc *,
1304 1.8 christos YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1305 1.6 christos if (! yyptr)
1306 1.8 christos YYNOMEM;
1307 1.6 christos YYSTACK_RELOCATE (yyss_alloc, yyss);
1308 1.6 christos YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1309 1.1 christos # undef YYSTACK_RELOCATE
1310 1.6 christos if (yyss1 != yyssa)
1311 1.6 christos YYSTACK_FREE (yyss1);
1312 1.1 christos }
1313 1.1 christos # endif
1314 1.1 christos
1315 1.1 christos yyssp = yyss + yysize - 1;
1316 1.1 christos yyvsp = yyvs + yysize - 1;
1317 1.1 christos
1318 1.8 christos YY_IGNORE_USELESS_CAST_BEGIN
1319 1.8 christos YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1320 1.8 christos YY_CAST (long, yystacksize)));
1321 1.8 christos YY_IGNORE_USELESS_CAST_END
1322 1.1 christos
1323 1.1 christos if (yyss + yystacksize - 1 <= yyssp)
1324 1.6 christos YYABORT;
1325 1.1 christos }
1326 1.8 christos #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1327 1.1 christos
1328 1.1 christos
1329 1.6 christos if (yystate == YYFINAL)
1330 1.6 christos YYACCEPT;
1331 1.6 christos
1332 1.1 christos goto yybackup;
1333 1.1 christos
1334 1.8 christos
1335 1.1 christos /*-----------.
1336 1.1 christos | yybackup. |
1337 1.1 christos `-----------*/
1338 1.1 christos yybackup:
1339 1.1 christos /* Do appropriate processing given the current state. Read a
1340 1.6 christos lookahead token if we need one and don't already have one. */
1341 1.1 christos
1342 1.6 christos /* First try to decide what to do without reference to lookahead token. */
1343 1.1 christos yyn = yypact[yystate];
1344 1.6 christos if (yypact_value_is_default (yyn))
1345 1.1 christos goto yydefault;
1346 1.1 christos
1347 1.6 christos /* Not known => get a lookahead token if don't already have one. */
1348 1.1 christos
1349 1.8 christos /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1350 1.1 christos if (yychar == YYEMPTY)
1351 1.1 christos {
1352 1.8 christos YYDPRINTF ((stderr, "Reading a token\n"));
1353 1.6 christos yychar = yylex ();
1354 1.1 christos }
1355 1.1 christos
1356 1.1 christos if (yychar <= YYEOF)
1357 1.1 christos {
1358 1.8 christos yychar = YYEOF;
1359 1.8 christos yytoken = YYSYMBOL_YYEOF;
1360 1.1 christos YYDPRINTF ((stderr, "Now at end of input.\n"));
1361 1.1 christos }
1362 1.8 christos else if (yychar == YYerror)
1363 1.8 christos {
1364 1.8 christos /* The scanner already issued an error message, process directly
1365 1.8 christos to error recovery. But do not keep the error token as
1366 1.8 christos lookahead, it is too special and may lead us to an endless
1367 1.8 christos loop in error recovery. */
1368 1.8 christos yychar = YYUNDEF;
1369 1.8 christos yytoken = YYSYMBOL_YYerror;
1370 1.8 christos goto yyerrlab1;
1371 1.8 christos }
1372 1.1 christos else
1373 1.1 christos {
1374 1.1 christos yytoken = YYTRANSLATE (yychar);
1375 1.1 christos YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1376 1.1 christos }
1377 1.1 christos
1378 1.1 christos /* If the proper action on seeing token YYTOKEN is to reduce or to
1379 1.1 christos detect an error, take that action. */
1380 1.1 christos yyn += yytoken;
1381 1.1 christos if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1382 1.1 christos goto yydefault;
1383 1.1 christos yyn = yytable[yyn];
1384 1.1 christos if (yyn <= 0)
1385 1.1 christos {
1386 1.6 christos if (yytable_value_is_error (yyn))
1387 1.6 christos goto yyerrlab;
1388 1.1 christos yyn = -yyn;
1389 1.1 christos goto yyreduce;
1390 1.1 christos }
1391 1.1 christos
1392 1.1 christos /* Count tokens shifted since error; after three, turn off error
1393 1.1 christos status. */
1394 1.1 christos if (yyerrstatus)
1395 1.1 christos yyerrstatus--;
1396 1.1 christos
1397 1.6 christos /* Shift the lookahead token. */
1398 1.1 christos YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1399 1.1 christos yystate = yyn;
1400 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1401 1.1 christos *++yyvsp = yylval;
1402 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_END
1403 1.1 christos
1404 1.8 christos /* Discard the shifted token. */
1405 1.8 christos yychar = YYEMPTY;
1406 1.1 christos goto yynewstate;
1407 1.1 christos
1408 1.1 christos
1409 1.1 christos /*-----------------------------------------------------------.
1410 1.1 christos | yydefault -- do the default action for the current state. |
1411 1.1 christos `-----------------------------------------------------------*/
1412 1.1 christos yydefault:
1413 1.1 christos yyn = yydefact[yystate];
1414 1.1 christos if (yyn == 0)
1415 1.1 christos goto yyerrlab;
1416 1.1 christos goto yyreduce;
1417 1.1 christos
1418 1.1 christos
1419 1.1 christos /*-----------------------------.
1420 1.8 christos | yyreduce -- do a reduction. |
1421 1.1 christos `-----------------------------*/
1422 1.1 christos yyreduce:
1423 1.1 christos /* yyn is the number of a rule to reduce with. */
1424 1.1 christos yylen = yyr2[yyn];
1425 1.1 christos
1426 1.1 christos /* If YYLEN is nonzero, implement the default value of the action:
1427 1.6 christos '$$ = $1'.
1428 1.1 christos
1429 1.1 christos Otherwise, the following line sets YYVAL to garbage.
1430 1.1 christos This behavior is undocumented and Bison
1431 1.1 christos users should not rely upon it. Assigning to YYVAL
1432 1.1 christos unconditionally makes the parser a bit smaller, and it avoids a
1433 1.1 christos GCC warning that YYVAL may be used uninitialized. */
1434 1.1 christos yyval = yyvsp[1-yylen];
1435 1.1 christos
1436 1.1 christos
1437 1.1 christos YY_REDUCE_PRINT (yyn);
1438 1.1 christos switch (yyn)
1439 1.1 christos {
1440 1.8 christos case 4: /* command: NAME opt_name opt_base */
1441 1.8 christos #line 144 "deffilep.y"
1442 1.8 christos { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 0); }
1443 1.8 christos #line 1444 "deffilep.c"
1444 1.1 christos break;
1445 1.1 christos
1446 1.8 christos case 5: /* command: LIBRARY opt_name opt_base */
1447 1.8 christos #line 145 "deffilep.y"
1448 1.8 christos { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 1); }
1449 1.8 christos #line 1450 "deffilep.c"
1450 1.1 christos break;
1451 1.1 christos
1452 1.8 christos case 6: /* command: DESCRIPTION ID */
1453 1.8 christos #line 146 "deffilep.y"
1454 1.8 christos { def_description ((yyvsp[0].id));}
1455 1.8 christos #line 1456 "deffilep.c"
1456 1.1 christos break;
1457 1.1 christos
1458 1.8 christos case 7: /* command: STACKSIZE_K NUMBER opt_number */
1459 1.8 christos #line 147 "deffilep.y"
1460 1.8 christos { def_stacksize ((yyvsp[-1].number), (yyvsp[0].number));}
1461 1.8 christos #line 1462 "deffilep.c"
1462 1.1 christos break;
1463 1.1 christos
1464 1.8 christos case 8: /* command: HEAPSIZE NUMBER opt_number */
1465 1.8 christos #line 148 "deffilep.y"
1466 1.8 christos { def_heapsize ((yyvsp[-1].number), (yyvsp[0].number));}
1467 1.8 christos #line 1468 "deffilep.c"
1468 1.1 christos break;
1469 1.1 christos
1470 1.8 christos case 9: /* command: CODE attr_list */
1471 1.8 christos #line 149 "deffilep.y"
1472 1.8 christos { def_section ("CODE", (yyvsp[0].number));}
1473 1.8 christos #line 1474 "deffilep.c"
1474 1.1 christos break;
1475 1.1 christos
1476 1.8 christos case 10: /* command: DATAU attr_list */
1477 1.8 christos #line 150 "deffilep.y"
1478 1.8 christos { def_section ("DATA", (yyvsp[0].number));}
1479 1.8 christos #line 1480 "deffilep.c"
1480 1.1 christos break;
1481 1.1 christos
1482 1.8 christos case 14: /* command: VERSIONK NUMBER */
1483 1.8 christos #line 154 "deffilep.y"
1484 1.8 christos { def_version ((yyvsp[0].number), 0);}
1485 1.8 christos #line 1486 "deffilep.c"
1486 1.1 christos break;
1487 1.1 christos
1488 1.8 christos case 15: /* command: VERSIONK NUMBER '.' NUMBER */
1489 1.8 christos #line 155 "deffilep.y"
1490 1.8 christos { def_version ((yyvsp[-2].number), (yyvsp[0].number));}
1491 1.8 christos #line 1492 "deffilep.c"
1492 1.1 christos break;
1493 1.1 christos
1494 1.8 christos case 16: /* command: DIRECTIVE ID */
1495 1.8 christos #line 156 "deffilep.y"
1496 1.8 christos { def_directive ((yyvsp[0].id));}
1497 1.8 christos #line 1498 "deffilep.c"
1498 1.1 christos break;
1499 1.1 christos
1500 1.8 christos case 17: /* command: ALIGNCOMM anylang_id ',' NUMBER */
1501 1.8 christos #line 157 "deffilep.y"
1502 1.8 christos { def_aligncomm ((yyvsp[-2].id), (yyvsp[0].number));}
1503 1.8 christos #line 1504 "deffilep.c"
1504 1.1 christos break;
1505 1.1 christos
1506 1.8 christos case 21: /* expline: opt_name2 opt_equal_name opt_ordinal opt_comma exp_opt_list opt_comma opt_equalequal_name */
1507 1.8 christos #line 172 "deffilep.y"
1508 1.8 christos { def_exports ((yyvsp[-6].id), (yyvsp[-5].id), (yyvsp[-4].number), (yyvsp[-2].number), (yyvsp[0].id)); }
1509 1.8 christos #line 1510 "deffilep.c"
1510 1.1 christos break;
1511 1.1 christos
1512 1.8 christos case 22: /* exp_opt_list: exp_opt opt_comma exp_opt_list */
1513 1.8 christos #line 178 "deffilep.y"
1514 1.8 christos { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); }
1515 1.8 christos #line 1516 "deffilep.c"
1516 1.1 christos break;
1517 1.1 christos
1518 1.8 christos case 23: /* exp_opt_list: %empty */
1519 1.8 christos #line 179 "deffilep.y"
1520 1.8 christos { (yyval.number) = 0; }
1521 1.8 christos #line 1522 "deffilep.c"
1522 1.1 christos break;
1523 1.1 christos
1524 1.8 christos case 24: /* exp_opt: NONAMEU */
1525 1.8 christos #line 182 "deffilep.y"
1526 1.8 christos { (yyval.number) = 1; }
1527 1.8 christos #line 1528 "deffilep.c"
1528 1.1 christos break;
1529 1.1 christos
1530 1.8 christos case 25: /* exp_opt: NONAMEL */
1531 1.8 christos #line 183 "deffilep.y"
1532 1.8 christos { (yyval.number) = 1; }
1533 1.8 christos #line 1534 "deffilep.c"
1534 1.1 christos break;
1535 1.1 christos
1536 1.8 christos case 26: /* exp_opt: CONSTANTU */
1537 1.8 christos #line 184 "deffilep.y"
1538 1.8 christos { (yyval.number) = 2; }
1539 1.8 christos #line 1540 "deffilep.c"
1540 1.1 christos break;
1541 1.1 christos
1542 1.8 christos case 27: /* exp_opt: CONSTANTL */
1543 1.8 christos #line 185 "deffilep.y"
1544 1.8 christos { (yyval.number) = 2; }
1545 1.8 christos #line 1546 "deffilep.c"
1546 1.1 christos break;
1547 1.1 christos
1548 1.8 christos case 28: /* exp_opt: DATAU */
1549 1.8 christos #line 186 "deffilep.y"
1550 1.8 christos { (yyval.number) = 4; }
1551 1.8 christos #line 1552 "deffilep.c"
1552 1.1 christos break;
1553 1.1 christos
1554 1.8 christos case 29: /* exp_opt: DATAL */
1555 1.8 christos #line 187 "deffilep.y"
1556 1.8 christos { (yyval.number) = 4; }
1557 1.8 christos #line 1558 "deffilep.c"
1558 1.1 christos break;
1559 1.1 christos
1560 1.8 christos case 30: /* exp_opt: PRIVATEU */
1561 1.8 christos #line 188 "deffilep.y"
1562 1.8 christos { (yyval.number) = 8; }
1563 1.8 christos #line 1564 "deffilep.c"
1564 1.1 christos break;
1565 1.1 christos
1566 1.8 christos case 31: /* exp_opt: PRIVATEL */
1567 1.8 christos #line 189 "deffilep.y"
1568 1.8 christos { (yyval.number) = 8; }
1569 1.8 christos #line 1570 "deffilep.c"
1570 1.1 christos break;
1571 1.1 christos
1572 1.8 christos case 34: /* impline: ID '=' ID '.' ID '.' ID opt_equalequal_name */
1573 1.8 christos #line 198 "deffilep.y"
1574 1.8 christos { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1575 1.8 christos #line 1576 "deffilep.c"
1576 1.1 christos break;
1577 1.1 christos
1578 1.8 christos case 35: /* impline: ID '=' ID '.' ID '.' NUMBER opt_equalequal_name */
1579 1.8 christos #line 200 "deffilep.y"
1580 1.8 christos { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id), 0, (yyvsp[-1].number), (yyvsp[0].id)); }
1581 1.8 christos #line 1582 "deffilep.c"
1582 1.1 christos break;
1583 1.1 christos
1584 1.8 christos case 36: /* impline: ID '=' ID '.' ID opt_equalequal_name */
1585 1.8 christos #line 202 "deffilep.y"
1586 1.8 christos { def_import ((yyvsp[-5].id), (yyvsp[-3].id), 0, (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1587 1.8 christos #line 1588 "deffilep.c"
1588 1.1 christos break;
1589 1.1 christos
1590 1.8 christos case 37: /* impline: ID '=' ID '.' NUMBER opt_equalequal_name */
1591 1.8 christos #line 204 "deffilep.y"
1592 1.8 christos { def_import ((yyvsp[-5].id), (yyvsp[-3].id), 0, 0, (yyvsp[-1].number), (yyvsp[0].id)); }
1593 1.8 christos #line 1594 "deffilep.c"
1594 1.1 christos break;
1595 1.1 christos
1596 1.8 christos case 38: /* impline: ID '.' ID '.' ID opt_equalequal_name */
1597 1.8 christos #line 206 "deffilep.y"
1598 1.8 christos { def_import( 0, (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1599 1.8 christos #line 1600 "deffilep.c"
1600 1.1 christos break;
1601 1.1 christos
1602 1.8 christos case 39: /* impline: ID '.' ID opt_equalequal_name */
1603 1.8 christos #line 208 "deffilep.y"
1604 1.8 christos { def_import ( 0, (yyvsp[-3].id), 0, (yyvsp[-1].id), -1, (yyvsp[0].id)); }
1605 1.8 christos #line 1606 "deffilep.c"
1606 1.1 christos break;
1607 1.1 christos
1608 1.8 christos case 42: /* secline: ID attr_list */
1609 1.8 christos #line 217 "deffilep.y"
1610 1.8 christos { def_section ((yyvsp[-1].id), (yyvsp[0].number));}
1611 1.8 christos #line 1612 "deffilep.c"
1612 1.1 christos break;
1613 1.1 christos
1614 1.8 christos case 43: /* secline: ID ID */
1615 1.8 christos #line 218 "deffilep.y"
1616 1.8 christos { def_section_alt ((yyvsp[-1].id), (yyvsp[0].id));}
1617 1.8 christos #line 1618 "deffilep.c"
1618 1.1 christos break;
1619 1.1 christos
1620 1.8 christos case 44: /* attr_list: attr_list opt_comma attr */
1621 1.8 christos #line 222 "deffilep.y"
1622 1.8 christos { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); }
1623 1.8 christos #line 1624 "deffilep.c"
1624 1.1 christos break;
1625 1.1 christos
1626 1.8 christos case 45: /* attr_list: attr */
1627 1.8 christos #line 223 "deffilep.y"
1628 1.8 christos { (yyval.number) = (yyvsp[0].number); }
1629 1.8 christos #line 1630 "deffilep.c"
1630 1.1 christos break;
1631 1.1 christos
1632 1.8 christos case 48: /* opt_number: ',' NUMBER */
1633 1.8 christos #line 230 "deffilep.y"
1634 1.8 christos { (yyval.number)=(yyvsp[0].number);}
1635 1.8 christos #line 1636 "deffilep.c"
1636 1.1 christos break;
1637 1.1 christos
1638 1.8 christos case 49: /* opt_number: %empty */
1639 1.8 christos #line 231 "deffilep.y"
1640 1.8 christos { (yyval.number)=-1;}
1641 1.8 christos #line 1642 "deffilep.c"
1642 1.1 christos break;
1643 1.1 christos
1644 1.8 christos case 50: /* attr: READ */
1645 1.8 christos #line 235 "deffilep.y"
1646 1.8 christos { (yyval.number) = 1;}
1647 1.8 christos #line 1648 "deffilep.c"
1648 1.1 christos break;
1649 1.1 christos
1650 1.8 christos case 51: /* attr: WRITE */
1651 1.8 christos #line 236 "deffilep.y"
1652 1.8 christos { (yyval.number) = 2;}
1653 1.8 christos #line 1654 "deffilep.c"
1654 1.1 christos break;
1655 1.1 christos
1656 1.8 christos case 52: /* attr: EXECUTE */
1657 1.8 christos #line 237 "deffilep.y"
1658 1.8 christos { (yyval.number)=4;}
1659 1.8 christos #line 1660 "deffilep.c"
1660 1.1 christos break;
1661 1.1 christos
1662 1.8 christos case 53: /* attr: SHARED_K */
1663 1.8 christos #line 238 "deffilep.y"
1664 1.8 christos { (yyval.number)=8;}
1665 1.8 christos #line 1666 "deffilep.c"
1666 1.1 christos break;
1667 1.1 christos
1668 1.8 christos case 54: /* keyword_as_name: BASE */
1669 1.8 christos #line 242 "deffilep.y"
1670 1.8 christos { (yyval.id_const) = "BASE"; }
1671 1.8 christos #line 1672 "deffilep.c"
1672 1.1 christos break;
1673 1.1 christos
1674 1.8 christos case 55: /* keyword_as_name: CODE */
1675 1.8 christos #line 243 "deffilep.y"
1676 1.8 christos { (yyval.id_const) = "CODE"; }
1677 1.8 christos #line 1678 "deffilep.c"
1678 1.1 christos break;
1679 1.1 christos
1680 1.8 christos case 56: /* keyword_as_name: CONSTANTU */
1681 1.8 christos #line 244 "deffilep.y"
1682 1.8 christos { (yyval.id_const) = "CONSTANT"; }
1683 1.8 christos #line 1684 "deffilep.c"
1684 1.1 christos break;
1685 1.1 christos
1686 1.8 christos case 57: /* keyword_as_name: CONSTANTL */
1687 1.8 christos #line 245 "deffilep.y"
1688 1.8 christos { (yyval.id_const) = "constant"; }
1689 1.8 christos #line 1690 "deffilep.c"
1690 1.1 christos break;
1691 1.1 christos
1692 1.8 christos case 58: /* keyword_as_name: DATAU */
1693 1.8 christos #line 246 "deffilep.y"
1694 1.8 christos { (yyval.id_const) = "DATA"; }
1695 1.8 christos #line 1696 "deffilep.c"
1696 1.1 christos break;
1697 1.1 christos
1698 1.8 christos case 59: /* keyword_as_name: DATAL */
1699 1.8 christos #line 247 "deffilep.y"
1700 1.8 christos { (yyval.id_const) = "data"; }
1701 1.8 christos #line 1702 "deffilep.c"
1702 1.1 christos break;
1703 1.1 christos
1704 1.8 christos case 60: /* keyword_as_name: DESCRIPTION */
1705 1.8 christos #line 248 "deffilep.y"
1706 1.8 christos { (yyval.id_const) = "DESCRIPTION"; }
1707 1.8 christos #line 1708 "deffilep.c"
1708 1.1 christos break;
1709 1.1 christos
1710 1.8 christos case 61: /* keyword_as_name: DIRECTIVE */
1711 1.8 christos #line 249 "deffilep.y"
1712 1.8 christos { (yyval.id_const) = "DIRECTIVE"; }
1713 1.8 christos #line 1714 "deffilep.c"
1714 1.1 christos break;
1715 1.1 christos
1716 1.8 christos case 62: /* keyword_as_name: EXECUTE */
1717 1.8 christos #line 250 "deffilep.y"
1718 1.8 christos { (yyval.id_const) = "EXECUTE"; }
1719 1.8 christos #line 1720 "deffilep.c"
1720 1.1 christos break;
1721 1.1 christos
1722 1.8 christos case 63: /* keyword_as_name: EXPORTS */
1723 1.8 christos #line 251 "deffilep.y"
1724 1.8 christos { (yyval.id_const) = "EXPORTS"; }
1725 1.8 christos #line 1726 "deffilep.c"
1726 1.1 christos break;
1727 1.1 christos
1728 1.8 christos case 64: /* keyword_as_name: HEAPSIZE */
1729 1.8 christos #line 252 "deffilep.y"
1730 1.8 christos { (yyval.id_const) = "HEAPSIZE"; }
1731 1.8 christos #line 1732 "deffilep.c"
1732 1.1 christos break;
1733 1.1 christos
1734 1.8 christos case 65: /* keyword_as_name: IMPORTS */
1735 1.8 christos #line 253 "deffilep.y"
1736 1.8 christos { (yyval.id_const) = "IMPORTS"; }
1737 1.8 christos #line 1738 "deffilep.c"
1738 1.1 christos break;
1739 1.1 christos
1740 1.8 christos case 66: /* keyword_as_name: NAME */
1741 1.8 christos #line 260 "deffilep.y"
1742 1.8 christos { (yyval.id_const) = "NAME"; }
1743 1.8 christos #line 1744 "deffilep.c"
1744 1.1 christos break;
1745 1.1 christos
1746 1.8 christos case 67: /* keyword_as_name: NONAMEU */
1747 1.8 christos #line 261 "deffilep.y"
1748 1.8 christos { (yyval.id_const) = "NONAME"; }
1749 1.8 christos #line 1750 "deffilep.c"
1750 1.1 christos break;
1751 1.1 christos
1752 1.8 christos case 68: /* keyword_as_name: NONAMEL */
1753 1.8 christos #line 262 "deffilep.y"
1754 1.8 christos { (yyval.id_const) = "noname"; }
1755 1.8 christos #line 1756 "deffilep.c"
1756 1.1 christos break;
1757 1.1 christos
1758 1.8 christos case 69: /* keyword_as_name: PRIVATEU */
1759 1.8 christos #line 263 "deffilep.y"
1760 1.8 christos { (yyval.id_const) = "PRIVATE"; }
1761 1.8 christos #line 1762 "deffilep.c"
1762 1.1 christos break;
1763 1.1 christos
1764 1.8 christos case 70: /* keyword_as_name: PRIVATEL */
1765 1.8 christos #line 264 "deffilep.y"
1766 1.8 christos { (yyval.id_const) = "private"; }
1767 1.8 christos #line 1768 "deffilep.c"
1768 1.1 christos break;
1769 1.1 christos
1770 1.8 christos case 71: /* keyword_as_name: READ */
1771 1.8 christos #line 265 "deffilep.y"
1772 1.8 christos { (yyval.id_const) = "READ"; }
1773 1.8 christos #line 1774 "deffilep.c"
1774 1.1 christos break;
1775 1.1 christos
1776 1.8 christos case 72: /* keyword_as_name: SHARED_K */
1777 1.8 christos #line 266 "deffilep.y"
1778 1.8 christos { (yyval.id_const) = "SHARED"; }
1779 1.8 christos #line 1780 "deffilep.c"
1780 1.1 christos break;
1781 1.1 christos
1782 1.8 christos case 73: /* keyword_as_name: STACKSIZE_K */
1783 1.8 christos #line 267 "deffilep.y"
1784 1.8 christos { (yyval.id_const) = "STACKSIZE"; }
1785 1.8 christos #line 1786 "deffilep.c"
1786 1.1 christos break;
1787 1.1 christos
1788 1.8 christos case 74: /* keyword_as_name: VERSIONK */
1789 1.8 christos #line 268 "deffilep.y"
1790 1.8 christos { (yyval.id_const) = "VERSION"; }
1791 1.8 christos #line 1792 "deffilep.c"
1792 1.1 christos break;
1793 1.1 christos
1794 1.8 christos case 75: /* keyword_as_name: WRITE */
1795 1.8 christos #line 269 "deffilep.y"
1796 1.8 christos { (yyval.id_const) = "WRITE"; }
1797 1.8 christos #line 1798 "deffilep.c"
1798 1.1 christos break;
1799 1.1 christos
1800 1.8 christos case 76: /* opt_name2: ID */
1801 1.8 christos #line 272 "deffilep.y"
1802 1.8 christos { (yyval.id) = (yyvsp[0].id); }
1803 1.8 christos #line 1804 "deffilep.c"
1804 1.1 christos break;
1805 1.1 christos
1806 1.8 christos case 77: /* opt_name2: '.' keyword_as_name */
1807 1.8 christos #line 274 "deffilep.y"
1808 1.8 christos {
1809 1.6 christos char *name = xmalloc (strlen ((yyvsp[0].id_const)) + 2);
1810 1.6 christos sprintf (name, ".%s", (yyvsp[0].id_const));
1811 1.1 christos (yyval.id) = name;
1812 1.1 christos }
1813 1.8 christos #line 1814 "deffilep.c"
1814 1.1 christos break;
1815 1.1 christos
1816 1.8 christos case 78: /* opt_name2: '.' opt_name2 */
1817 1.8 christos #line 280 "deffilep.y"
1818 1.8 christos {
1819 1.6 christos char *name = def_pool_alloc (strlen ((yyvsp[0].id)) + 2);
1820 1.6 christos sprintf (name, ".%s", (yyvsp[0].id));
1821 1.1 christos (yyval.id) = name;
1822 1.1 christos }
1823 1.8 christos #line 1824 "deffilep.c"
1824 1.1 christos break;
1825 1.1 christos
1826 1.8 christos case 79: /* opt_name2: keyword_as_name '.' opt_name2 */
1827 1.8 christos #line 286 "deffilep.y"
1828 1.8 christos {
1829 1.6 christos char *name = def_pool_alloc (strlen ((yyvsp[-2].id_const)) + 1 + strlen ((yyvsp[0].id)) + 1);
1830 1.6 christos sprintf (name, "%s.%s", (yyvsp[-2].id_const), (yyvsp[0].id));
1831 1.1 christos (yyval.id) = name;
1832 1.1 christos }
1833 1.8 christos #line 1834 "deffilep.c"
1834 1.1 christos break;
1835 1.1 christos
1836 1.8 christos case 80: /* opt_name2: ID '.' opt_name2 */
1837 1.8 christos #line 292 "deffilep.y"
1838 1.8 christos {
1839 1.6 christos char *name = def_pool_alloc (strlen ((yyvsp[-2].id)) + 1 + strlen ((yyvsp[0].id)) + 1);
1840 1.6 christos sprintf (name, "%s.%s", (yyvsp[-2].id), (yyvsp[0].id));
1841 1.1 christos (yyval.id) = name;
1842 1.1 christos }
1843 1.8 christos #line 1844 "deffilep.c"
1844 1.1 christos break;
1845 1.1 christos
1846 1.8 christos case 81: /* opt_name: opt_name2 */
1847 1.8 christos #line 299 "deffilep.y"
1848 1.8 christos { (yyval.id) = (yyvsp[0].id); }
1849 1.8 christos #line 1850 "deffilep.c"
1850 1.1 christos break;
1851 1.1 christos
1852 1.8 christos case 82: /* opt_name: %empty */
1853 1.8 christos #line 300 "deffilep.y"
1854 1.8 christos { (yyval.id) = ""; }
1855 1.8 christos #line 1856 "deffilep.c"
1856 1.1 christos break;
1857 1.1 christos
1858 1.8 christos case 83: /* opt_equalequal_name: EQUAL ID */
1859 1.8 christos #line 303 "deffilep.y"
1860 1.8 christos { (yyval.id) = (yyvsp[0].id); }
1861 1.8 christos #line 1862 "deffilep.c"
1862 1.1 christos break;
1863 1.1 christos
1864 1.8 christos case 84: /* opt_equalequal_name: %empty */
1865 1.8 christos #line 304 "deffilep.y"
1866 1.8 christos { (yyval.id) = 0; }
1867 1.8 christos #line 1868 "deffilep.c"
1868 1.1 christos break;
1869 1.1 christos
1870 1.8 christos case 85: /* opt_ordinal: '@' NUMBER */
1871 1.8 christos #line 308 "deffilep.y"
1872 1.8 christos { (yyval.number) = (yyvsp[0].number);}
1873 1.8 christos #line 1874 "deffilep.c"
1874 1.1 christos break;
1875 1.1 christos
1876 1.8 christos case 86: /* opt_ordinal: %empty */
1877 1.8 christos #line 309 "deffilep.y"
1878 1.8 christos { (yyval.number) = -1;}
1879 1.8 christos #line 1880 "deffilep.c"
1880 1.1 christos break;
1881 1.1 christos
1882 1.8 christos case 87: /* opt_equal_name: '=' opt_name2 */
1883 1.8 christos #line 313 "deffilep.y"
1884 1.8 christos { (yyval.id) = (yyvsp[0].id); }
1885 1.8 christos #line 1886 "deffilep.c"
1886 1.1 christos break;
1887 1.1 christos
1888 1.8 christos case 88: /* opt_equal_name: %empty */
1889 1.8 christos #line 314 "deffilep.y"
1890 1.8 christos { (yyval.id) = 0; }
1891 1.8 christos #line 1892 "deffilep.c"
1892 1.1 christos break;
1893 1.1 christos
1894 1.8 christos case 89: /* opt_base: BASE '=' VMA */
1895 1.8 christos #line 317 "deffilep.y"
1896 1.8 christos { (yyval.vma) = (yyvsp[0].vma);}
1897 1.8 christos #line 1898 "deffilep.c"
1898 1.1 christos break;
1899 1.1 christos
1900 1.8 christos case 90: /* opt_base: %empty */
1901 1.8 christos #line 318 "deffilep.y"
1902 1.8 christos { (yyval.vma) = (bfd_vma) -1;}
1903 1.8 christos #line 1904 "deffilep.c"
1904 1.1 christos break;
1905 1.1 christos
1906 1.8 christos case 91: /* anylang_id: ID */
1907 1.8 christos #line 321 "deffilep.y"
1908 1.8 christos { (yyval.id) = (yyvsp[0].id); }
1909 1.8 christos #line 1910 "deffilep.c"
1910 1.1 christos break;
1911 1.1 christos
1912 1.8 christos case 92: /* anylang_id: '.' ID */
1913 1.8 christos #line 323 "deffilep.y"
1914 1.8 christos {
1915 1.6 christos char *id = def_pool_alloc (strlen ((yyvsp[0].id)) + 2);
1916 1.6 christos sprintf (id, ".%s", (yyvsp[0].id));
1917 1.1 christos (yyval.id) = id;
1918 1.1 christos }
1919 1.8 christos #line 1920 "deffilep.c"
1920 1.1 christos break;
1921 1.1 christos
1922 1.8 christos case 93: /* anylang_id: anylang_id '.' opt_digits opt_id */
1923 1.8 christos #line 329 "deffilep.y"
1924 1.8 christos {
1925 1.6 christos char *id = def_pool_alloc (strlen ((yyvsp[-3].id)) + 1 + strlen ((yyvsp[-1].digits)) + strlen ((yyvsp[0].id)) + 1);
1926 1.6 christos sprintf (id, "%s.%s%s", (yyvsp[-3].id), (yyvsp[-1].digits), (yyvsp[0].id));
1927 1.1 christos (yyval.id) = id;
1928 1.1 christos }
1929 1.8 christos #line 1930 "deffilep.c"
1930 1.1 christos break;
1931 1.1 christos
1932 1.8 christos case 94: /* opt_digits: DIGITS */
1933 1.8 christos #line 336 "deffilep.y"
1934 1.8 christos { (yyval.digits) = (yyvsp[0].digits); }
1935 1.8 christos #line 1936 "deffilep.c"
1936 1.1 christos break;
1937 1.1 christos
1938 1.8 christos case 95: /* opt_digits: %empty */
1939 1.8 christos #line 337 "deffilep.y"
1940 1.8 christos { (yyval.digits) = ""; }
1941 1.8 christos #line 1942 "deffilep.c"
1942 1.1 christos break;
1943 1.1 christos
1944 1.8 christos case 96: /* opt_id: ID */
1945 1.8 christos #line 340 "deffilep.y"
1946 1.8 christos { (yyval.id) = (yyvsp[0].id); }
1947 1.8 christos #line 1948 "deffilep.c"
1948 1.1 christos break;
1949 1.1 christos
1950 1.8 christos case 97: /* opt_id: %empty */
1951 1.8 christos #line 341 "deffilep.y"
1952 1.8 christos { (yyval.id) = ""; }
1953 1.8 christos #line 1954 "deffilep.c"
1954 1.1 christos break;
1955 1.1 christos
1956 1.8 christos case 98: /* NUMBER: DIGITS */
1957 1.8 christos #line 344 "deffilep.y"
1958 1.8 christos { (yyval.number) = strtoul ((yyvsp[0].digits), 0, 0); }
1959 1.8 christos #line 1960 "deffilep.c"
1960 1.3 christos break;
1961 1.3 christos
1962 1.8 christos case 99: /* VMA: DIGITS */
1963 1.8 christos #line 346 "deffilep.y"
1964 1.8 christos { (yyval.vma) = (bfd_vma) strtoull ((yyvsp[0].digits), 0, 0); }
1965 1.8 christos #line 1966 "deffilep.c"
1966 1.1 christos break;
1967 1.1 christos
1968 1.1 christos
1969 1.8 christos #line 1970 "deffilep.c"
1970 1.8 christos
1971 1.1 christos default: break;
1972 1.1 christos }
1973 1.6 christos /* User semantic actions sometimes alter yychar, and that requires
1974 1.6 christos that yytoken be updated with the new translation. We take the
1975 1.6 christos approach of translating immediately before every use of yytoken.
1976 1.6 christos One alternative is translating here after every semantic action,
1977 1.6 christos but that translation would be missed if the semantic action invokes
1978 1.6 christos YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1979 1.6 christos if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1980 1.6 christos incorrect destructor might then be invoked immediately. In the
1981 1.6 christos case of YYERROR or YYBACKUP, subsequent parser actions might lead
1982 1.6 christos to an incorrect destructor call or verbose syntax error message
1983 1.6 christos before the lookahead is translated. */
1984 1.8 christos YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1985 1.1 christos
1986 1.1 christos YYPOPSTACK (yylen);
1987 1.1 christos yylen = 0;
1988 1.1 christos
1989 1.1 christos *++yyvsp = yyval;
1990 1.1 christos
1991 1.6 christos /* Now 'shift' the result of the reduction. Determine what state
1992 1.1 christos that goes to, based on the state we popped back to and the rule
1993 1.1 christos number reduced by. */
1994 1.8 christos {
1995 1.8 christos const int yylhs = yyr1[yyn] - YYNTOKENS;
1996 1.8 christos const int yyi = yypgoto[yylhs] + *yyssp;
1997 1.8 christos yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1998 1.8 christos ? yytable[yyi]
1999 1.8 christos : yydefgoto[yylhs]);
2000 1.8 christos }
2001 1.1 christos
2002 1.1 christos goto yynewstate;
2003 1.1 christos
2004 1.1 christos
2005 1.6 christos /*--------------------------------------.
2006 1.6 christos | yyerrlab -- here on detecting error. |
2007 1.6 christos `--------------------------------------*/
2008 1.1 christos yyerrlab:
2009 1.6 christos /* Make sure we have latest lookahead translation. See comments at
2010 1.6 christos user semantic actions for why this is necessary. */
2011 1.8 christos yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
2012 1.1 christos /* If not already recovering from an error, report this error. */
2013 1.1 christos if (!yyerrstatus)
2014 1.1 christos {
2015 1.1 christos ++yynerrs;
2016 1.1 christos yyerror (YY_("syntax error"));
2017 1.1 christos }
2018 1.1 christos
2019 1.1 christos if (yyerrstatus == 3)
2020 1.1 christos {
2021 1.6 christos /* If just tried and failed to reuse lookahead token after an
2022 1.6 christos error, discard it. */
2023 1.1 christos
2024 1.1 christos if (yychar <= YYEOF)
2025 1.6 christos {
2026 1.6 christos /* Return failure if at end of input. */
2027 1.6 christos if (yychar == YYEOF)
2028 1.6 christos YYABORT;
2029 1.6 christos }
2030 1.1 christos else
2031 1.6 christos {
2032 1.6 christos yydestruct ("Error: discarding",
2033 1.6 christos yytoken, &yylval);
2034 1.6 christos yychar = YYEMPTY;
2035 1.6 christos }
2036 1.1 christos }
2037 1.1 christos
2038 1.6 christos /* Else will try to reuse lookahead token after shifting the error
2039 1.1 christos token. */
2040 1.1 christos goto yyerrlab1;
2041 1.1 christos
2042 1.1 christos
2043 1.1 christos /*---------------------------------------------------.
2044 1.1 christos | yyerrorlab -- error raised explicitly by YYERROR. |
2045 1.1 christos `---------------------------------------------------*/
2046 1.1 christos yyerrorlab:
2047 1.8 christos /* Pacify compilers when the user code never invokes YYERROR and the
2048 1.8 christos label yyerrorlab therefore never appears in user code. */
2049 1.8 christos if (0)
2050 1.8 christos YYERROR;
2051 1.8 christos ++yynerrs;
2052 1.1 christos
2053 1.6 christos /* Do not reclaim the symbols of the rule whose action triggered
2054 1.1 christos this YYERROR. */
2055 1.1 christos YYPOPSTACK (yylen);
2056 1.1 christos yylen = 0;
2057 1.1 christos YY_STACK_PRINT (yyss, yyssp);
2058 1.1 christos yystate = *yyssp;
2059 1.1 christos goto yyerrlab1;
2060 1.1 christos
2061 1.1 christos
2062 1.1 christos /*-------------------------------------------------------------.
2063 1.1 christos | yyerrlab1 -- common code for both syntax error and YYERROR. |
2064 1.1 christos `-------------------------------------------------------------*/
2065 1.1 christos yyerrlab1:
2066 1.6 christos yyerrstatus = 3; /* Each real token shifted decrements this. */
2067 1.1 christos
2068 1.8 christos /* Pop stack until we find a state that shifts the error token. */
2069 1.1 christos for (;;)
2070 1.1 christos {
2071 1.1 christos yyn = yypact[yystate];
2072 1.6 christos if (!yypact_value_is_default (yyn))
2073 1.6 christos {
2074 1.8 christos yyn += YYSYMBOL_YYerror;
2075 1.8 christos if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2076 1.6 christos {
2077 1.6 christos yyn = yytable[yyn];
2078 1.6 christos if (0 < yyn)
2079 1.6 christos break;
2080 1.6 christos }
2081 1.6 christos }
2082 1.1 christos
2083 1.1 christos /* Pop the current state because it cannot handle the error token. */
2084 1.1 christos if (yyssp == yyss)
2085 1.6 christos YYABORT;
2086 1.1 christos
2087 1.1 christos
2088 1.1 christos yydestruct ("Error: popping",
2089 1.8 christos YY_ACCESSING_SYMBOL (yystate), yyvsp);
2090 1.1 christos YYPOPSTACK (1);
2091 1.1 christos yystate = *yyssp;
2092 1.1 christos YY_STACK_PRINT (yyss, yyssp);
2093 1.1 christos }
2094 1.1 christos
2095 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2096 1.1 christos *++yyvsp = yylval;
2097 1.6 christos YY_IGNORE_MAYBE_UNINITIALIZED_END
2098 1.1 christos
2099 1.1 christos
2100 1.1 christos /* Shift the error token. */
2101 1.8 christos YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
2102 1.1 christos
2103 1.1 christos yystate = yyn;
2104 1.1 christos goto yynewstate;
2105 1.1 christos
2106 1.1 christos
2107 1.1 christos /*-------------------------------------.
2108 1.1 christos | yyacceptlab -- YYACCEPT comes here. |
2109 1.1 christos `-------------------------------------*/
2110 1.1 christos yyacceptlab:
2111 1.1 christos yyresult = 0;
2112 1.8 christos goto yyreturnlab;
2113 1.8 christos
2114 1.1 christos
2115 1.1 christos /*-----------------------------------.
2116 1.1 christos | yyabortlab -- YYABORT comes here. |
2117 1.1 christos `-----------------------------------*/
2118 1.1 christos yyabortlab:
2119 1.1 christos yyresult = 1;
2120 1.8 christos goto yyreturnlab;
2121 1.8 christos
2122 1.1 christos
2123 1.8 christos /*-----------------------------------------------------------.
2124 1.8 christos | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2125 1.8 christos `-----------------------------------------------------------*/
2126 1.1 christos yyexhaustedlab:
2127 1.1 christos yyerror (YY_("memory exhausted"));
2128 1.1 christos yyresult = 2;
2129 1.8 christos goto yyreturnlab;
2130 1.8 christos
2131 1.1 christos
2132 1.8 christos /*----------------------------------------------------------.
2133 1.8 christos | yyreturnlab -- parsing is finished, clean up and return. |
2134 1.8 christos `----------------------------------------------------------*/
2135 1.8 christos yyreturnlab:
2136 1.6 christos if (yychar != YYEMPTY)
2137 1.6 christos {
2138 1.6 christos /* Make sure we have latest lookahead translation. See comments at
2139 1.6 christos user semantic actions for why this is necessary. */
2140 1.6 christos yytoken = YYTRANSLATE (yychar);
2141 1.6 christos yydestruct ("Cleanup: discarding lookahead",
2142 1.6 christos yytoken, &yylval);
2143 1.6 christos }
2144 1.6 christos /* Do not reclaim the symbols of the rule whose action triggered
2145 1.1 christos this YYABORT or YYACCEPT. */
2146 1.1 christos YYPOPSTACK (yylen);
2147 1.1 christos YY_STACK_PRINT (yyss, yyssp);
2148 1.1 christos while (yyssp != yyss)
2149 1.1 christos {
2150 1.1 christos yydestruct ("Cleanup: popping",
2151 1.8 christos YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
2152 1.1 christos YYPOPSTACK (1);
2153 1.1 christos }
2154 1.1 christos #ifndef yyoverflow
2155 1.1 christos if (yyss != yyssa)
2156 1.1 christos YYSTACK_FREE (yyss);
2157 1.1 christos #endif
2158 1.8 christos
2159 1.6 christos return yyresult;
2160 1.1 christos }
2161 1.8 christos
2162 1.8 christos #line 348 "deffilep.y"
2163 1.1 christos
2164 1.1 christos
2165 1.1 christos /*****************************************************************************
2166 1.1 christos API
2167 1.1 christos *****************************************************************************/
2168 1.1 christos
2169 1.1 christos static FILE *the_file;
2170 1.1 christos static const char *def_filename;
2171 1.1 christos static int linenumber;
2172 1.1 christos static def_file *def;
2173 1.1 christos static int saw_newline;
2174 1.1 christos
2175 1.1 christos struct directive
2176 1.1 christos {
2177 1.1 christos struct directive *next;
2178 1.1 christos char *name;
2179 1.1 christos int len;
2180 1.1 christos };
2181 1.1 christos
2182 1.1 christos static struct directive *directives = 0;
2183 1.1 christos
2184 1.1 christos def_file *
2185 1.1 christos def_file_empty (void)
2186 1.1 christos {
2187 1.1 christos def_file *rv = xmalloc (sizeof (def_file));
2188 1.1 christos memset (rv, 0, sizeof (def_file));
2189 1.1 christos rv->is_dll = -1;
2190 1.1 christos rv->base_address = (bfd_vma) -1;
2191 1.1 christos rv->stack_reserve = rv->stack_commit = -1;
2192 1.1 christos rv->heap_reserve = rv->heap_commit = -1;
2193 1.1 christos rv->version_major = rv->version_minor = -1;
2194 1.1 christos return rv;
2195 1.1 christos }
2196 1.1 christos
2197 1.1 christos def_file *
2198 1.1 christos def_file_parse (const char *filename, def_file *add_to)
2199 1.1 christos {
2200 1.1 christos struct directive *d;
2201 1.1 christos
2202 1.1 christos the_file = fopen (filename, "r");
2203 1.1 christos def_filename = filename;
2204 1.1 christos linenumber = 1;
2205 1.1 christos if (!the_file)
2206 1.1 christos {
2207 1.1 christos perror (filename);
2208 1.1 christos return 0;
2209 1.1 christos }
2210 1.1 christos if (add_to)
2211 1.1 christos {
2212 1.1 christos def = add_to;
2213 1.1 christos }
2214 1.1 christos else
2215 1.1 christos {
2216 1.1 christos def = def_file_empty ();
2217 1.1 christos }
2218 1.1 christos
2219 1.1 christos saw_newline = 1;
2220 1.1 christos if (def_parse ())
2221 1.1 christos {
2222 1.1 christos def_file_free (def);
2223 1.1 christos fclose (the_file);
2224 1.1 christos def_pool_free ();
2225 1.1 christos return 0;
2226 1.1 christos }
2227 1.1 christos
2228 1.1 christos fclose (the_file);
2229 1.1 christos
2230 1.1 christos while ((d = directives) != NULL)
2231 1.1 christos {
2232 1.1 christos #if TRACE
2233 1.1 christos printf ("Adding directive %08x `%s'\n", d->name, d->name);
2234 1.1 christos #endif
2235 1.1 christos def_file_add_directive (def, d->name, d->len);
2236 1.1 christos directives = d->next;
2237 1.1 christos free (d->name);
2238 1.1 christos free (d);
2239 1.1 christos }
2240 1.1 christos def_pool_free ();
2241 1.1 christos
2242 1.1 christos return def;
2243 1.1 christos }
2244 1.1 christos
2245 1.1 christos void
2246 1.1 christos def_file_free (def_file *fdef)
2247 1.1 christos {
2248 1.1 christos int i;
2249 1.1 christos
2250 1.1 christos if (!fdef)
2251 1.1 christos return;
2252 1.8 christos free (fdef->name);
2253 1.8 christos free (fdef->description);
2254 1.1 christos
2255 1.1 christos if (fdef->section_defs)
2256 1.1 christos {
2257 1.1 christos for (i = 0; i < fdef->num_section_defs; i++)
2258 1.1 christos {
2259 1.8 christos free (fdef->section_defs[i].name);
2260 1.8 christos free (fdef->section_defs[i].class);
2261 1.1 christos }
2262 1.1 christos free (fdef->section_defs);
2263 1.1 christos }
2264 1.1 christos
2265 1.1 christos if (fdef->exports)
2266 1.1 christos {
2267 1.1 christos for (i = 0; i < fdef->num_exports; i++)
2268 1.1 christos {
2269 1.8 christos if (fdef->exports[i].internal_name != fdef->exports[i].name)
2270 1.1 christos free (fdef->exports[i].internal_name);
2271 1.8 christos free (fdef->exports[i].name);
2272 1.8 christos free (fdef->exports[i].its_name);
2273 1.1 christos }
2274 1.1 christos free (fdef->exports);
2275 1.1 christos }
2276 1.1 christos
2277 1.1 christos if (fdef->imports)
2278 1.1 christos {
2279 1.1 christos for (i = 0; i < fdef->num_imports; i++)
2280 1.1 christos {
2281 1.8 christos if (fdef->imports[i].internal_name != fdef->imports[i].name)
2282 1.1 christos free (fdef->imports[i].internal_name);
2283 1.8 christos free (fdef->imports[i].name);
2284 1.8 christos free (fdef->imports[i].its_name);
2285 1.1 christos }
2286 1.1 christos free (fdef->imports);
2287 1.1 christos }
2288 1.1 christos
2289 1.1 christos while (fdef->modules)
2290 1.1 christos {
2291 1.1 christos def_file_module *m = fdef->modules;
2292 1.1 christos
2293 1.1 christos fdef->modules = fdef->modules->next;
2294 1.1 christos free (m);
2295 1.1 christos }
2296 1.1 christos
2297 1.1 christos while (fdef->aligncomms)
2298 1.1 christos {
2299 1.1 christos def_file_aligncomm *c = fdef->aligncomms;
2300 1.1 christos
2301 1.1 christos fdef->aligncomms = fdef->aligncomms->next;
2302 1.1 christos free (c->symbol_name);
2303 1.1 christos free (c);
2304 1.1 christos }
2305 1.1 christos
2306 1.1 christos free (fdef);
2307 1.1 christos }
2308 1.1 christos
2309 1.1 christos #ifdef DEF_FILE_PRINT
2310 1.1 christos void
2311 1.1 christos def_file_print (FILE *file, def_file *fdef)
2312 1.1 christos {
2313 1.1 christos int i;
2314 1.1 christos
2315 1.1 christos fprintf (file, ">>>> def_file at 0x%08x\n", fdef);
2316 1.1 christos if (fdef->name)
2317 1.1 christos fprintf (file, " name: %s\n", fdef->name ? fdef->name : "(unspecified)");
2318 1.1 christos if (fdef->is_dll != -1)
2319 1.1 christos fprintf (file, " is dll: %s\n", fdef->is_dll ? "yes" : "no");
2320 1.1 christos if (fdef->base_address != (bfd_vma) -1)
2321 1.3 christos {
2322 1.3 christos fprintf (file, " base address: 0x");
2323 1.3 christos fprintf_vma (file, fdef->base_address);
2324 1.3 christos fprintf (file, "\n");
2325 1.3 christos }
2326 1.1 christos if (fdef->description)
2327 1.1 christos fprintf (file, " description: `%s'\n", fdef->description);
2328 1.1 christos if (fdef->stack_reserve != -1)
2329 1.1 christos fprintf (file, " stack reserve: 0x%08x\n", fdef->stack_reserve);
2330 1.1 christos if (fdef->stack_commit != -1)
2331 1.1 christos fprintf (file, " stack commit: 0x%08x\n", fdef->stack_commit);
2332 1.1 christos if (fdef->heap_reserve != -1)
2333 1.1 christos fprintf (file, " heap reserve: 0x%08x\n", fdef->heap_reserve);
2334 1.1 christos if (fdef->heap_commit != -1)
2335 1.1 christos fprintf (file, " heap commit: 0x%08x\n", fdef->heap_commit);
2336 1.1 christos
2337 1.1 christos if (fdef->num_section_defs > 0)
2338 1.1 christos {
2339 1.1 christos fprintf (file, " section defs:\n");
2340 1.1 christos
2341 1.1 christos for (i = 0; i < fdef->num_section_defs; i++)
2342 1.1 christos {
2343 1.1 christos fprintf (file, " name: `%s', class: `%s', flags:",
2344 1.1 christos fdef->section_defs[i].name, fdef->section_defs[i].class);
2345 1.1 christos if (fdef->section_defs[i].flag_read)
2346 1.1 christos fprintf (file, " R");
2347 1.1 christos if (fdef->section_defs[i].flag_write)
2348 1.1 christos fprintf (file, " W");
2349 1.1 christos if (fdef->section_defs[i].flag_execute)
2350 1.1 christos fprintf (file, " X");
2351 1.1 christos if (fdef->section_defs[i].flag_shared)
2352 1.1 christos fprintf (file, " S");
2353 1.1 christos fprintf (file, "\n");
2354 1.1 christos }
2355 1.1 christos }
2356 1.1 christos
2357 1.1 christos if (fdef->num_exports > 0)
2358 1.1 christos {
2359 1.1 christos fprintf (file, " exports:\n");
2360 1.1 christos
2361 1.1 christos for (i = 0; i < fdef->num_exports; i++)
2362 1.1 christos {
2363 1.1 christos fprintf (file, " name: `%s', int: `%s', ordinal: %d, flags:",
2364 1.1 christos fdef->exports[i].name, fdef->exports[i].internal_name,
2365 1.1 christos fdef->exports[i].ordinal);
2366 1.1 christos if (fdef->exports[i].flag_private)
2367 1.1 christos fprintf (file, " P");
2368 1.1 christos if (fdef->exports[i].flag_constant)
2369 1.1 christos fprintf (file, " C");
2370 1.1 christos if (fdef->exports[i].flag_noname)
2371 1.1 christos fprintf (file, " N");
2372 1.1 christos if (fdef->exports[i].flag_data)
2373 1.1 christos fprintf (file, " D");
2374 1.1 christos fprintf (file, "\n");
2375 1.1 christos }
2376 1.1 christos }
2377 1.1 christos
2378 1.1 christos if (fdef->num_imports > 0)
2379 1.1 christos {
2380 1.1 christos fprintf (file, " imports:\n");
2381 1.1 christos
2382 1.1 christos for (i = 0; i < fdef->num_imports; i++)
2383 1.1 christos {
2384 1.1 christos fprintf (file, " int: %s, from: `%s', name: `%s', ordinal: %d\n",
2385 1.1 christos fdef->imports[i].internal_name,
2386 1.1 christos fdef->imports[i].module,
2387 1.1 christos fdef->imports[i].name,
2388 1.1 christos fdef->imports[i].ordinal);
2389 1.1 christos }
2390 1.1 christos }
2391 1.1 christos
2392 1.1 christos if (fdef->version_major != -1)
2393 1.1 christos fprintf (file, " version: %d.%d\n", fdef->version_major, fdef->version_minor);
2394 1.1 christos
2395 1.1 christos fprintf (file, "<<<< def_file at 0x%08x\n", fdef);
2396 1.1 christos }
2397 1.1 christos #endif
2398 1.1 christos
2399 1.1 christos /* Helper routine to check for identity of string pointers,
2400 1.1 christos which might be NULL. */
2401 1.1 christos
2402 1.1 christos static int
2403 1.1 christos are_names_equal (const char *s1, const char *s2)
2404 1.1 christos {
2405 1.1 christos if (!s1 && !s2)
2406 1.1 christos return 0;
2407 1.1 christos if (!s1 || !s2)
2408 1.1 christos return (!s1 ? -1 : 1);
2409 1.1 christos return strcmp (s1, s2);
2410 1.1 christos }
2411 1.1 christos
2412 1.1 christos static int
2413 1.1 christos cmp_export_elem (const def_file_export *e, const char *ex_name,
2414 1.1 christos const char *in_name, const char *its_name,
2415 1.1 christos int ord)
2416 1.1 christos {
2417 1.1 christos int r;
2418 1.1 christos
2419 1.1 christos if ((r = are_names_equal (ex_name, e->name)) != 0)
2420 1.1 christos return r;
2421 1.1 christos if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2422 1.1 christos return r;
2423 1.1 christos if ((r = are_names_equal (its_name, e->its_name)) != 0)
2424 1.1 christos return r;
2425 1.1 christos return (ord - e->ordinal);
2426 1.1 christos }
2427 1.1 christos
2428 1.1 christos /* Search the position of the identical element, or returns the position
2429 1.1 christos of the next higher element. If last valid element is smaller, then MAX
2430 1.1 christos is returned. */
2431 1.1 christos
2432 1.1 christos static int
2433 1.1 christos find_export_in_list (def_file_export *b, int max,
2434 1.1 christos const char *ex_name, const char *in_name,
2435 1.1 christos const char *its_name, int ord, int *is_ident)
2436 1.1 christos {
2437 1.1 christos int e, l, r, p;
2438 1.1 christos
2439 1.1 christos *is_ident = 0;
2440 1.1 christos if (!max)
2441 1.1 christos return 0;
2442 1.1 christos if ((e = cmp_export_elem (b, ex_name, in_name, its_name, ord)) <= 0)
2443 1.1 christos {
2444 1.1 christos if (!e)
2445 1.6 christos *is_ident = 1;
2446 1.1 christos return 0;
2447 1.1 christos }
2448 1.1 christos if (max == 1)
2449 1.1 christos return 1;
2450 1.1 christos if ((e = cmp_export_elem (b + (max - 1), ex_name, in_name, its_name, ord)) > 0)
2451 1.1 christos return max;
2452 1.1 christos else if (!e || max == 2)
2453 1.1 christos {
2454 1.1 christos if (!e)
2455 1.1 christos *is_ident = 1;
2456 1.1 christos return max - 1;
2457 1.1 christos }
2458 1.1 christos l = 0; r = max - 1;
2459 1.1 christos while (l < r)
2460 1.1 christos {
2461 1.1 christos p = (l + r) / 2;
2462 1.1 christos e = cmp_export_elem (b + p, ex_name, in_name, its_name, ord);
2463 1.1 christos if (!e)
2464 1.6 christos {
2465 1.6 christos *is_ident = 1;
2466 1.6 christos return p;
2467 1.6 christos }
2468 1.1 christos else if (e < 0)
2469 1.6 christos r = p - 1;
2470 1.1 christos else if (e > 0)
2471 1.6 christos l = p + 1;
2472 1.1 christos }
2473 1.1 christos if ((e = cmp_export_elem (b + l, ex_name, in_name, its_name, ord)) > 0)
2474 1.1 christos ++l;
2475 1.1 christos else if (!e)
2476 1.1 christos *is_ident = 1;
2477 1.1 christos return l;
2478 1.1 christos }
2479 1.1 christos
2480 1.1 christos def_file_export *
2481 1.1 christos def_file_add_export (def_file *fdef,
2482 1.1 christos const char *external_name,
2483 1.1 christos const char *internal_name,
2484 1.1 christos int ordinal,
2485 1.1 christos const char *its_name,
2486 1.1 christos int *is_dup)
2487 1.1 christos {
2488 1.1 christos def_file_export *e;
2489 1.1 christos int pos;
2490 1.1 christos int max_exports = ROUND_UP(fdef->num_exports, 32);
2491 1.1 christos
2492 1.1 christos if (internal_name && !external_name)
2493 1.1 christos external_name = internal_name;
2494 1.1 christos if (external_name && !internal_name)
2495 1.1 christos internal_name = external_name;
2496 1.1 christos
2497 1.1 christos /* We need to avoid duplicates. */
2498 1.1 christos *is_dup = 0;
2499 1.1 christos pos = find_export_in_list (fdef->exports, fdef->num_exports,
2500 1.1 christos external_name, internal_name,
2501 1.1 christos its_name, ordinal, is_dup);
2502 1.1 christos
2503 1.1 christos if (*is_dup != 0)
2504 1.1 christos return (fdef->exports + pos);
2505 1.1 christos
2506 1.1 christos if (fdef->num_exports >= max_exports)
2507 1.1 christos {
2508 1.1 christos max_exports = ROUND_UP(fdef->num_exports + 1, 32);
2509 1.1 christos if (fdef->exports)
2510 1.1 christos fdef->exports = xrealloc (fdef->exports,
2511 1.1 christos max_exports * sizeof (def_file_export));
2512 1.1 christos else
2513 1.1 christos fdef->exports = xmalloc (max_exports * sizeof (def_file_export));
2514 1.1 christos }
2515 1.1 christos
2516 1.1 christos e = fdef->exports + pos;
2517 1.1 christos if (pos != fdef->num_exports)
2518 1.1 christos memmove (&e[1], e, (sizeof (def_file_export) * (fdef->num_exports - pos)));
2519 1.1 christos memset (e, 0, sizeof (def_file_export));
2520 1.1 christos e->name = xstrdup (external_name);
2521 1.1 christos e->internal_name = xstrdup (internal_name);
2522 1.1 christos e->its_name = (its_name ? xstrdup (its_name) : NULL);
2523 1.1 christos e->ordinal = ordinal;
2524 1.1 christos fdef->num_exports++;
2525 1.1 christos return e;
2526 1.1 christos }
2527 1.1 christos
2528 1.1 christos def_file_module *
2529 1.1 christos def_get_module (def_file *fdef, const char *name)
2530 1.1 christos {
2531 1.1 christos def_file_module *s;
2532 1.1 christos
2533 1.1 christos for (s = fdef->modules; s; s = s->next)
2534 1.1 christos if (strcmp (s->name, name) == 0)
2535 1.1 christos return s;
2536 1.1 christos
2537 1.1 christos return NULL;
2538 1.1 christos }
2539 1.1 christos
2540 1.1 christos static def_file_module *
2541 1.1 christos def_stash_module (def_file *fdef, const char *name)
2542 1.1 christos {
2543 1.1 christos def_file_module *s;
2544 1.1 christos
2545 1.1 christos if ((s = def_get_module (fdef, name)) != NULL)
2546 1.1 christos return s;
2547 1.1 christos s = xmalloc (sizeof (def_file_module) + strlen (name));
2548 1.1 christos s->next = fdef->modules;
2549 1.1 christos fdef->modules = s;
2550 1.1 christos s->user_data = 0;
2551 1.1 christos strcpy (s->name, name);
2552 1.1 christos return s;
2553 1.1 christos }
2554 1.1 christos
2555 1.1 christos static int
2556 1.1 christos cmp_import_elem (const def_file_import *e, const char *ex_name,
2557 1.1 christos const char *in_name, const char *module,
2558 1.1 christos int ord)
2559 1.1 christos {
2560 1.1 christos int r;
2561 1.1 christos
2562 1.1 christos if ((r = are_names_equal (module, (e->module ? e->module->name : NULL))))
2563 1.1 christos return r;
2564 1.1 christos if ((r = are_names_equal (ex_name, e->name)) != 0)
2565 1.1 christos return r;
2566 1.1 christos if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2567 1.1 christos return r;
2568 1.1 christos if (ord != e->ordinal)
2569 1.1 christos return (ord < e->ordinal ? -1 : 1);
2570 1.1 christos return 0;
2571 1.1 christos }
2572 1.1 christos
2573 1.1 christos /* Search the position of the identical element, or returns the position
2574 1.1 christos of the next higher element. If last valid element is smaller, then MAX
2575 1.1 christos is returned. */
2576 1.1 christos
2577 1.1 christos static int
2578 1.1 christos find_import_in_list (def_file_import *b, int max,
2579 1.1 christos const char *ex_name, const char *in_name,
2580 1.1 christos const char *module, int ord, int *is_ident)
2581 1.1 christos {
2582 1.1 christos int e, l, r, p;
2583 1.1 christos
2584 1.1 christos *is_ident = 0;
2585 1.1 christos if (!max)
2586 1.1 christos return 0;
2587 1.1 christos if ((e = cmp_import_elem (b, ex_name, in_name, module, ord)) <= 0)
2588 1.1 christos {
2589 1.1 christos if (!e)
2590 1.6 christos *is_ident = 1;
2591 1.1 christos return 0;
2592 1.1 christos }
2593 1.1 christos if (max == 1)
2594 1.1 christos return 1;
2595 1.1 christos if ((e = cmp_import_elem (b + (max - 1), ex_name, in_name, module, ord)) > 0)
2596 1.1 christos return max;
2597 1.1 christos else if (!e || max == 2)
2598 1.1 christos {
2599 1.1 christos if (!e)
2600 1.6 christos *is_ident = 1;
2601 1.1 christos return max - 1;
2602 1.1 christos }
2603 1.1 christos l = 0; r = max - 1;
2604 1.1 christos while (l < r)
2605 1.1 christos {
2606 1.1 christos p = (l + r) / 2;
2607 1.1 christos e = cmp_import_elem (b + p, ex_name, in_name, module, ord);
2608 1.1 christos if (!e)
2609 1.6 christos {
2610 1.6 christos *is_ident = 1;
2611 1.6 christos return p;
2612 1.6 christos }
2613 1.1 christos else if (e < 0)
2614 1.6 christos r = p - 1;
2615 1.1 christos else if (e > 0)
2616 1.6 christos l = p + 1;
2617 1.1 christos }
2618 1.1 christos if ((e = cmp_import_elem (b + l, ex_name, in_name, module, ord)) > 0)
2619 1.1 christos ++l;
2620 1.1 christos else if (!e)
2621 1.1 christos *is_ident = 1;
2622 1.1 christos return l;
2623 1.1 christos }
2624 1.1 christos
2625 1.6 christos static void
2626 1.6 christos fill_in_import (def_file_import *i,
2627 1.6 christos const char *name,
2628 1.6 christos def_file_module *module,
2629 1.6 christos int ordinal,
2630 1.6 christos const char *internal_name,
2631 1.6 christos const char *its_name)
2632 1.6 christos {
2633 1.6 christos memset (i, 0, sizeof (def_file_import));
2634 1.6 christos if (name)
2635 1.6 christos i->name = xstrdup (name);
2636 1.6 christos i->module = module;
2637 1.6 christos i->ordinal = ordinal;
2638 1.6 christos if (internal_name)
2639 1.6 christos i->internal_name = xstrdup (internal_name);
2640 1.6 christos else
2641 1.6 christos i->internal_name = i->name;
2642 1.6 christos i->its_name = (its_name ? xstrdup (its_name) : NULL);
2643 1.6 christos }
2644 1.6 christos
2645 1.1 christos def_file_import *
2646 1.1 christos def_file_add_import (def_file *fdef,
2647 1.1 christos const char *name,
2648 1.1 christos const char *module,
2649 1.1 christos int ordinal,
2650 1.1 christos const char *internal_name,
2651 1.1 christos const char *its_name,
2652 1.1 christos int *is_dup)
2653 1.1 christos {
2654 1.1 christos def_file_import *i;
2655 1.1 christos int pos;
2656 1.1 christos int max_imports = ROUND_UP (fdef->num_imports, 16);
2657 1.1 christos
2658 1.1 christos /* We need to avoid here duplicates. */
2659 1.1 christos *is_dup = 0;
2660 1.1 christos pos = find_import_in_list (fdef->imports, fdef->num_imports,
2661 1.1 christos name,
2662 1.1 christos (!internal_name ? name : internal_name),
2663 1.1 christos module, ordinal, is_dup);
2664 1.1 christos if (*is_dup != 0)
2665 1.1 christos return fdef->imports + pos;
2666 1.1 christos
2667 1.1 christos if (fdef->num_imports >= max_imports)
2668 1.1 christos {
2669 1.1 christos max_imports = ROUND_UP (fdef->num_imports+1, 16);
2670 1.1 christos
2671 1.1 christos if (fdef->imports)
2672 1.1 christos fdef->imports = xrealloc (fdef->imports,
2673 1.1 christos max_imports * sizeof (def_file_import));
2674 1.1 christos else
2675 1.1 christos fdef->imports = xmalloc (max_imports * sizeof (def_file_import));
2676 1.1 christos }
2677 1.1 christos i = fdef->imports + pos;
2678 1.1 christos if (pos != fdef->num_imports)
2679 1.6 christos memmove (i + 1, i, sizeof (def_file_import) * (fdef->num_imports - pos));
2680 1.6 christos
2681 1.6 christos fill_in_import (i, name, def_stash_module (fdef, module), ordinal,
2682 1.6 christos internal_name, its_name);
2683 1.6 christos fdef->num_imports++;
2684 1.6 christos
2685 1.6 christos return i;
2686 1.6 christos }
2687 1.6 christos
2688 1.6 christos int
2689 1.6 christos def_file_add_import_from (def_file *fdef,
2690 1.6 christos int num_imports,
2691 1.6 christos const char *name,
2692 1.6 christos const char *module,
2693 1.6 christos int ordinal,
2694 1.6 christos const char *internal_name,
2695 1.6 christos const char *its_name ATTRIBUTE_UNUSED)
2696 1.6 christos {
2697 1.6 christos def_file_import *i;
2698 1.6 christos int is_dup;
2699 1.6 christos int pos;
2700 1.6 christos int max_imports = ROUND_UP (fdef->num_imports, 16);
2701 1.6 christos
2702 1.6 christos /* We need to avoid here duplicates. */
2703 1.6 christos is_dup = 0;
2704 1.6 christos pos = find_import_in_list (fdef->imports, fdef->num_imports,
2705 1.6 christos name, internal_name ? internal_name : name,
2706 1.6 christos module, ordinal, &is_dup);
2707 1.6 christos if (is_dup != 0)
2708 1.6 christos return -1;
2709 1.6 christos if (fdef->imports && pos != fdef->num_imports)
2710 1.6 christos {
2711 1.6 christos i = fdef->imports + pos;
2712 1.6 christos if (i->module && strcmp (i->module->name, module) == 0)
2713 1.6 christos return -1;
2714 1.6 christos }
2715 1.6 christos
2716 1.6 christos if (fdef->num_imports + num_imports - 1 >= max_imports)
2717 1.6 christos {
2718 1.6 christos max_imports = ROUND_UP (fdef->num_imports + num_imports, 16);
2719 1.6 christos
2720 1.6 christos if (fdef->imports)
2721 1.6 christos fdef->imports = xrealloc (fdef->imports,
2722 1.6 christos max_imports * sizeof (def_file_import));
2723 1.6 christos else
2724 1.6 christos fdef->imports = xmalloc (max_imports * sizeof (def_file_import));
2725 1.6 christos }
2726 1.6 christos i = fdef->imports + pos;
2727 1.6 christos if (pos != fdef->num_imports)
2728 1.6 christos memmove (i + num_imports, i,
2729 1.6 christos sizeof (def_file_import) * (fdef->num_imports - pos));
2730 1.6 christos
2731 1.6 christos return pos;
2732 1.6 christos }
2733 1.6 christos
2734 1.6 christos def_file_import *
2735 1.6 christos def_file_add_import_at (def_file *fdef,
2736 1.6 christos int pos,
2737 1.6 christos const char *name,
2738 1.6 christos const char *module,
2739 1.6 christos int ordinal,
2740 1.6 christos const char *internal_name,
2741 1.6 christos const char *its_name)
2742 1.6 christos {
2743 1.6 christos def_file_import *i = fdef->imports + pos;
2744 1.6 christos
2745 1.6 christos fill_in_import (i, name, def_stash_module (fdef, module), ordinal,
2746 1.6 christos internal_name, its_name);
2747 1.1 christos fdef->num_imports++;
2748 1.1 christos
2749 1.1 christos return i;
2750 1.1 christos }
2751 1.1 christos
2752 1.1 christos struct
2753 1.1 christos {
2754 1.1 christos char *param;
2755 1.1 christos int token;
2756 1.1 christos }
2757 1.1 christos diropts[] =
2758 1.1 christos {
2759 1.1 christos { "-heap", HEAPSIZE },
2760 1.1 christos { "-stack", STACKSIZE_K },
2761 1.1 christos { "-attr", SECTIONS },
2762 1.1 christos { "-export", EXPORTS },
2763 1.1 christos { "-aligncomm", ALIGNCOMM },
2764 1.1 christos { 0, 0 }
2765 1.1 christos };
2766 1.1 christos
2767 1.1 christos void
2768 1.1 christos def_file_add_directive (def_file *my_def, const char *param, int len)
2769 1.1 christos {
2770 1.1 christos def_file *save_def = def;
2771 1.1 christos const char *pend = param + len;
2772 1.1 christos char * tend = (char *) param;
2773 1.1 christos int i;
2774 1.1 christos
2775 1.1 christos def = my_def;
2776 1.1 christos
2777 1.1 christos while (param < pend)
2778 1.1 christos {
2779 1.1 christos while (param < pend
2780 1.1 christos && (ISSPACE (*param) || *param == '\n' || *param == 0))
2781 1.1 christos param++;
2782 1.1 christos
2783 1.1 christos if (param == pend)
2784 1.1 christos break;
2785 1.1 christos
2786 1.1 christos /* Scan forward until we encounter any of:
2787 1.6 christos - the end of the buffer
2788 1.1 christos - the start of a new option
2789 1.6 christos - a newline separating options
2790 1.6 christos - a NUL separating options. */
2791 1.1 christos for (tend = (char *) (param + 1);
2792 1.1 christos (tend < pend
2793 1.1 christos && !(ISSPACE (tend[-1]) && *tend == '-')
2794 1.1 christos && *tend != '\n' && *tend != 0);
2795 1.1 christos tend++)
2796 1.1 christos ;
2797 1.1 christos
2798 1.1 christos for (i = 0; diropts[i].param; i++)
2799 1.1 christos {
2800 1.1 christos len = strlen (diropts[i].param);
2801 1.1 christos
2802 1.1 christos if (tend - param >= len
2803 1.1 christos && strncmp (param, diropts[i].param, len) == 0
2804 1.1 christos && (param[len] == ':' || param[len] == ' '))
2805 1.1 christos {
2806 1.1 christos lex_parse_string_end = tend;
2807 1.1 christos lex_parse_string = param + len + 1;
2808 1.1 christos lex_forced_token = diropts[i].token;
2809 1.1 christos saw_newline = 0;
2810 1.1 christos if (def_parse ())
2811 1.1 christos continue;
2812 1.1 christos break;
2813 1.1 christos }
2814 1.1 christos }
2815 1.1 christos
2816 1.1 christos if (!diropts[i].param)
2817 1.1 christos {
2818 1.3 christos if (tend < pend)
2819 1.3 christos {
2820 1.3 christos char saved;
2821 1.1 christos
2822 1.3 christos saved = * tend;
2823 1.3 christos * tend = 0;
2824 1.3 christos /* xgettext:c-format */
2825 1.3 christos einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
2826 1.3 christos * tend = saved;
2827 1.3 christos }
2828 1.3 christos else
2829 1.3 christos {
2830 1.3 christos einfo (_("Warning: corrupt .drectve at end of def file\n"));
2831 1.3 christos }
2832 1.1 christos }
2833 1.1 christos
2834 1.1 christos lex_parse_string = 0;
2835 1.1 christos param = tend;
2836 1.1 christos }
2837 1.1 christos
2838 1.1 christos def = save_def;
2839 1.1 christos def_pool_free ();
2840 1.1 christos }
2841 1.1 christos
2842 1.1 christos /* Parser Callbacks. */
2843 1.1 christos
2844 1.1 christos static void
2845 1.3 christos def_image_name (const char *name, bfd_vma base, int is_dll)
2846 1.1 christos {
2847 1.1 christos /* If a LIBRARY or NAME statement is specified without a name, there is nothing
2848 1.1 christos to do here. We retain the output filename specified on command line. */
2849 1.1 christos if (*name)
2850 1.1 christos {
2851 1.1 christos const char* image_name = lbasename (name);
2852 1.1 christos
2853 1.1 christos if (image_name != name)
2854 1.1 christos einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
2855 1.1 christos def_filename, linenumber, is_dll ? "LIBRARY" : "NAME",
2856 1.1 christos name);
2857 1.8 christos free (def->name);
2858 1.3 christos /* Append the default suffix, if none specified. */
2859 1.1 christos if (strchr (image_name, '.') == 0)
2860 1.1 christos {
2861 1.1 christos const char * suffix = is_dll ? ".dll" : ".exe";
2862 1.1 christos
2863 1.1 christos def->name = xmalloc (strlen (image_name) + strlen (suffix) + 1);
2864 1.1 christos sprintf (def->name, "%s%s", image_name, suffix);
2865 1.6 christos }
2866 1.1 christos else
2867 1.1 christos def->name = xstrdup (image_name);
2868 1.1 christos }
2869 1.1 christos
2870 1.1 christos /* Honor a BASE address statement, even if LIBRARY string is empty. */
2871 1.1 christos def->base_address = base;
2872 1.1 christos def->is_dll = is_dll;
2873 1.1 christos }
2874 1.1 christos
2875 1.1 christos static void
2876 1.1 christos def_description (const char *text)
2877 1.1 christos {
2878 1.1 christos int len = def->description ? strlen (def->description) : 0;
2879 1.1 christos
2880 1.1 christos len += strlen (text) + 1;
2881 1.1 christos if (def->description)
2882 1.1 christos {
2883 1.1 christos def->description = xrealloc (def->description, len);
2884 1.1 christos strcat (def->description, text);
2885 1.1 christos }
2886 1.1 christos else
2887 1.1 christos {
2888 1.1 christos def->description = xmalloc (len);
2889 1.1 christos strcpy (def->description, text);
2890 1.1 christos }
2891 1.1 christos }
2892 1.1 christos
2893 1.1 christos static void
2894 1.1 christos def_stacksize (int reserve, int commit)
2895 1.1 christos {
2896 1.1 christos def->stack_reserve = reserve;
2897 1.1 christos def->stack_commit = commit;
2898 1.1 christos }
2899 1.1 christos
2900 1.1 christos static void
2901 1.1 christos def_heapsize (int reserve, int commit)
2902 1.1 christos {
2903 1.1 christos def->heap_reserve = reserve;
2904 1.1 christos def->heap_commit = commit;
2905 1.1 christos }
2906 1.1 christos
2907 1.1 christos static void
2908 1.1 christos def_section (const char *name, int attr)
2909 1.1 christos {
2910 1.1 christos def_file_section *s;
2911 1.1 christos int max_sections = ROUND_UP (def->num_section_defs, 4);
2912 1.1 christos
2913 1.1 christos if (def->num_section_defs >= max_sections)
2914 1.1 christos {
2915 1.1 christos max_sections = ROUND_UP (def->num_section_defs+1, 4);
2916 1.1 christos
2917 1.1 christos if (def->section_defs)
2918 1.1 christos def->section_defs = xrealloc (def->section_defs,
2919 1.1 christos max_sections * sizeof (def_file_import));
2920 1.1 christos else
2921 1.1 christos def->section_defs = xmalloc (max_sections * sizeof (def_file_import));
2922 1.1 christos }
2923 1.1 christos s = def->section_defs + def->num_section_defs;
2924 1.1 christos memset (s, 0, sizeof (def_file_section));
2925 1.1 christos s->name = xstrdup (name);
2926 1.1 christos if (attr & 1)
2927 1.1 christos s->flag_read = 1;
2928 1.1 christos if (attr & 2)
2929 1.1 christos s->flag_write = 1;
2930 1.1 christos if (attr & 4)
2931 1.1 christos s->flag_execute = 1;
2932 1.1 christos if (attr & 8)
2933 1.1 christos s->flag_shared = 1;
2934 1.1 christos
2935 1.1 christos def->num_section_defs++;
2936 1.1 christos }
2937 1.1 christos
2938 1.1 christos static void
2939 1.1 christos def_section_alt (const char *name, const char *attr)
2940 1.1 christos {
2941 1.1 christos int aval = 0;
2942 1.1 christos
2943 1.1 christos for (; *attr; attr++)
2944 1.1 christos {
2945 1.1 christos switch (*attr)
2946 1.1 christos {
2947 1.1 christos case 'R':
2948 1.1 christos case 'r':
2949 1.1 christos aval |= 1;
2950 1.1 christos break;
2951 1.1 christos case 'W':
2952 1.1 christos case 'w':
2953 1.1 christos aval |= 2;
2954 1.1 christos break;
2955 1.1 christos case 'X':
2956 1.1 christos case 'x':
2957 1.1 christos aval |= 4;
2958 1.1 christos break;
2959 1.1 christos case 'S':
2960 1.1 christos case 's':
2961 1.1 christos aval |= 8;
2962 1.1 christos break;
2963 1.1 christos }
2964 1.1 christos }
2965 1.1 christos def_section (name, aval);
2966 1.1 christos }
2967 1.1 christos
2968 1.1 christos static void
2969 1.1 christos def_exports (const char *external_name,
2970 1.1 christos const char *internal_name,
2971 1.1 christos int ordinal,
2972 1.1 christos int flags,
2973 1.1 christos const char *its_name)
2974 1.1 christos {
2975 1.1 christos def_file_export *dfe;
2976 1.1 christos int is_dup = 0;
2977 1.1 christos
2978 1.1 christos if (!internal_name && external_name)
2979 1.1 christos internal_name = external_name;
2980 1.1 christos #if TRACE
2981 1.1 christos printf ("def_exports, ext=%s int=%s\n", external_name, internal_name);
2982 1.1 christos #endif
2983 1.1 christos
2984 1.1 christos dfe = def_file_add_export (def, external_name, internal_name, ordinal,
2985 1.1 christos its_name, &is_dup);
2986 1.1 christos
2987 1.1 christos /* We might check here for flag redefinition and warn. For now we
2988 1.1 christos ignore duplicates silently. */
2989 1.1 christos if (is_dup)
2990 1.1 christos return;
2991 1.1 christos
2992 1.1 christos if (flags & 1)
2993 1.1 christos dfe->flag_noname = 1;
2994 1.1 christos if (flags & 2)
2995 1.1 christos dfe->flag_constant = 1;
2996 1.1 christos if (flags & 4)
2997 1.1 christos dfe->flag_data = 1;
2998 1.1 christos if (flags & 8)
2999 1.1 christos dfe->flag_private = 1;
3000 1.1 christos }
3001 1.1 christos
3002 1.1 christos static void
3003 1.1 christos def_import (const char *internal_name,
3004 1.1 christos const char *module,
3005 1.1 christos const char *dllext,
3006 1.1 christos const char *name,
3007 1.1 christos int ordinal,
3008 1.1 christos const char *its_name)
3009 1.1 christos {
3010 1.1 christos char *buf = 0;
3011 1.1 christos const char *ext = dllext ? dllext : "dll";
3012 1.1 christos int is_dup = 0;
3013 1.3 christos
3014 1.1 christos buf = xmalloc (strlen (module) + strlen (ext) + 2);
3015 1.1 christos sprintf (buf, "%s.%s", module, ext);
3016 1.1 christos module = buf;
3017 1.1 christos
3018 1.1 christos def_file_add_import (def, name, module, ordinal, internal_name, its_name,
3019 1.1 christos &is_dup);
3020 1.1 christos free (buf);
3021 1.1 christos }
3022 1.1 christos
3023 1.1 christos static void
3024 1.1 christos def_version (int major, int minor)
3025 1.1 christos {
3026 1.1 christos def->version_major = major;
3027 1.1 christos def->version_minor = minor;
3028 1.1 christos }
3029 1.1 christos
3030 1.1 christos static void
3031 1.1 christos def_directive (char *str)
3032 1.1 christos {
3033 1.1 christos struct directive *d = xmalloc (sizeof (struct directive));
3034 1.1 christos
3035 1.1 christos d->next = directives;
3036 1.1 christos directives = d;
3037 1.1 christos d->name = xstrdup (str);
3038 1.1 christos d->len = strlen (str);
3039 1.1 christos }
3040 1.1 christos
3041 1.1 christos static void
3042 1.1 christos def_aligncomm (char *str, int align)
3043 1.1 christos {
3044 1.1 christos def_file_aligncomm *c, *p;
3045 1.3 christos
3046 1.1 christos p = NULL;
3047 1.1 christos c = def->aligncomms;
3048 1.1 christos while (c != NULL)
3049 1.1 christos {
3050 1.1 christos int e = strcmp (c->symbol_name, str);
3051 1.1 christos if (!e)
3052 1.1 christos {
3053 1.1 christos /* Not sure if we want to allow here duplicates with
3054 1.1 christos different alignments, but for now we keep them. */
3055 1.1 christos e = (int) c->alignment - align;
3056 1.1 christos if (!e)
3057 1.1 christos return;
3058 1.1 christos }
3059 1.1 christos if (e > 0)
3060 1.6 christos break;
3061 1.1 christos c = (p = c)->next;
3062 1.1 christos }
3063 1.1 christos
3064 1.1 christos c = xmalloc (sizeof (def_file_aligncomm));
3065 1.1 christos c->symbol_name = xstrdup (str);
3066 1.1 christos c->alignment = (unsigned int) align;
3067 1.1 christos if (!p)
3068 1.1 christos {
3069 1.1 christos c->next = def->aligncomms;
3070 1.1 christos def->aligncomms = c;
3071 1.1 christos }
3072 1.1 christos else
3073 1.1 christos {
3074 1.1 christos c->next = p->next;
3075 1.1 christos p->next = c;
3076 1.1 christos }
3077 1.1 christos }
3078 1.1 christos
3079 1.8 christos static void
3080 1.1 christos def_error (const char *err)
3081 1.1 christos {
3082 1.1 christos einfo ("%P: %s:%d: %s\n",
3083 1.1 christos def_filename ? def_filename : "<unknown-file>", linenumber, err);
3084 1.1 christos }
3085 1.1 christos
3086 1.1 christos
3087 1.1 christos /* Lexical Scanner. */
3088 1.1 christos
3089 1.1 christos #undef TRACE
3090 1.1 christos #define TRACE 0
3091 1.1 christos
3092 1.1 christos /* Never freed, but always reused as needed, so no real leak. */
3093 1.1 christos static char *buffer = 0;
3094 1.1 christos static int buflen = 0;
3095 1.1 christos static int bufptr = 0;
3096 1.1 christos
3097 1.1 christos static void
3098 1.1 christos put_buf (char c)
3099 1.1 christos {
3100 1.1 christos if (bufptr == buflen)
3101 1.1 christos {
3102 1.1 christos buflen += 50; /* overly reasonable, eh? */
3103 1.1 christos if (buffer)
3104 1.1 christos buffer = xrealloc (buffer, buflen + 1);
3105 1.1 christos else
3106 1.1 christos buffer = xmalloc (buflen + 1);
3107 1.1 christos }
3108 1.1 christos buffer[bufptr++] = c;
3109 1.1 christos buffer[bufptr] = 0; /* not optimal, but very convenient. */
3110 1.1 christos }
3111 1.1 christos
3112 1.1 christos static struct
3113 1.1 christos {
3114 1.1 christos char *name;
3115 1.1 christos int token;
3116 1.1 christos }
3117 1.1 christos tokens[] =
3118 1.1 christos {
3119 1.1 christos { "BASE", BASE },
3120 1.1 christos { "CODE", CODE },
3121 1.1 christos { "CONSTANT", CONSTANTU },
3122 1.1 christos { "constant", CONSTANTL },
3123 1.1 christos { "DATA", DATAU },
3124 1.1 christos { "data", DATAL },
3125 1.1 christos { "DESCRIPTION", DESCRIPTION },
3126 1.1 christos { "DIRECTIVE", DIRECTIVE },
3127 1.1 christos { "EXECUTE", EXECUTE },
3128 1.1 christos { "EXPORTS", EXPORTS },
3129 1.1 christos { "HEAPSIZE", HEAPSIZE },
3130 1.1 christos { "IMPORTS", IMPORTS },
3131 1.1 christos { "LIBRARY", LIBRARY },
3132 1.1 christos { "NAME", NAME },
3133 1.1 christos { "NONAME", NONAMEU },
3134 1.1 christos { "noname", NONAMEL },
3135 1.1 christos { "PRIVATE", PRIVATEU },
3136 1.1 christos { "private", PRIVATEL },
3137 1.1 christos { "READ", READ },
3138 1.1 christos { "SECTIONS", SECTIONS },
3139 1.1 christos { "SEGMENTS", SECTIONS },
3140 1.8 christos { "SHARED", SHARED_K },
3141 1.1 christos { "STACKSIZE", STACKSIZE_K },
3142 1.1 christos { "VERSION", VERSIONK },
3143 1.1 christos { "WRITE", WRITE },
3144 1.1 christos { 0, 0 }
3145 1.1 christos };
3146 1.1 christos
3147 1.1 christos static int
3148 1.1 christos def_getc (void)
3149 1.1 christos {
3150 1.1 christos int rv;
3151 1.1 christos
3152 1.1 christos if (lex_parse_string)
3153 1.1 christos {
3154 1.1 christos if (lex_parse_string >= lex_parse_string_end)
3155 1.1 christos rv = EOF;
3156 1.1 christos else
3157 1.1 christos rv = *lex_parse_string++;
3158 1.1 christos }
3159 1.1 christos else
3160 1.1 christos {
3161 1.1 christos rv = fgetc (the_file);
3162 1.1 christos }
3163 1.1 christos if (rv == '\n')
3164 1.1 christos saw_newline = 1;
3165 1.1 christos return rv;
3166 1.1 christos }
3167 1.1 christos
3168 1.1 christos static int
3169 1.1 christos def_ungetc (int c)
3170 1.1 christos {
3171 1.1 christos if (lex_parse_string)
3172 1.1 christos {
3173 1.1 christos lex_parse_string--;
3174 1.1 christos return c;
3175 1.1 christos }
3176 1.1 christos else
3177 1.1 christos return ungetc (c, the_file);
3178 1.1 christos }
3179 1.1 christos
3180 1.1 christos static int
3181 1.1 christos def_lex (void)
3182 1.1 christos {
3183 1.1 christos int c, i, q;
3184 1.1 christos
3185 1.1 christos if (lex_forced_token)
3186 1.1 christos {
3187 1.1 christos i = lex_forced_token;
3188 1.1 christos lex_forced_token = 0;
3189 1.1 christos #if TRACE
3190 1.1 christos printf ("lex: forcing token %d\n", i);
3191 1.1 christos #endif
3192 1.1 christos return i;
3193 1.1 christos }
3194 1.1 christos
3195 1.1 christos c = def_getc ();
3196 1.1 christos
3197 1.1 christos /* Trim leading whitespace. */
3198 1.1 christos while (c != EOF && (c == ' ' || c == '\t') && saw_newline)
3199 1.1 christos c = def_getc ();
3200 1.1 christos
3201 1.1 christos if (c == EOF)
3202 1.1 christos {
3203 1.1 christos #if TRACE
3204 1.1 christos printf ("lex: EOF\n");
3205 1.1 christos #endif
3206 1.1 christos return 0;
3207 1.1 christos }
3208 1.1 christos
3209 1.1 christos if (saw_newline && c == ';')
3210 1.1 christos {
3211 1.1 christos do
3212 1.1 christos {
3213 1.1 christos c = def_getc ();
3214 1.1 christos }
3215 1.1 christos while (c != EOF && c != '\n');
3216 1.1 christos if (c == '\n')
3217 1.1 christos return def_lex ();
3218 1.1 christos return 0;
3219 1.1 christos }
3220 1.1 christos
3221 1.1 christos /* Must be something else. */
3222 1.1 christos saw_newline = 0;
3223 1.1 christos
3224 1.1 christos if (ISDIGIT (c))
3225 1.1 christos {
3226 1.1 christos bufptr = 0;
3227 1.1 christos while (c != EOF && (ISXDIGIT (c) || (c == 'x')))
3228 1.1 christos {
3229 1.1 christos put_buf (c);
3230 1.1 christos c = def_getc ();
3231 1.1 christos }
3232 1.1 christos if (c != EOF)
3233 1.1 christos def_ungetc (c);
3234 1.1 christos yylval.digits = def_pool_strdup (buffer);
3235 1.1 christos #if TRACE
3236 1.1 christos printf ("lex: `%s' returns DIGITS\n", buffer);
3237 1.1 christos #endif
3238 1.1 christos return DIGITS;
3239 1.1 christos }
3240 1.1 christos
3241 1.1 christos if (ISALPHA (c) || strchr ("$:-_?@", c))
3242 1.1 christos {
3243 1.1 christos bufptr = 0;
3244 1.1 christos q = c;
3245 1.1 christos put_buf (c);
3246 1.1 christos c = def_getc ();
3247 1.1 christos
3248 1.1 christos if (q == '@')
3249 1.1 christos {
3250 1.6 christos if (ISBLANK (c) ) /* '@' followed by whitespace. */
3251 1.1 christos return (q);
3252 1.6 christos else if (ISDIGIT (c)) /* '@' followed by digit. */
3253 1.6 christos {
3254 1.1 christos def_ungetc (c);
3255 1.6 christos return (q);
3256 1.1 christos }
3257 1.1 christos #if TRACE
3258 1.1 christos printf ("lex: @ returns itself\n");
3259 1.1 christos #endif
3260 1.1 christos }
3261 1.1 christos
3262 1.1 christos while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@<>", c)))
3263 1.1 christos {
3264 1.1 christos put_buf (c);
3265 1.1 christos c = def_getc ();
3266 1.1 christos }
3267 1.1 christos if (c != EOF)
3268 1.1 christos def_ungetc (c);
3269 1.1 christos if (ISALPHA (q)) /* Check for tokens. */
3270 1.1 christos {
3271 1.6 christos for (i = 0; tokens[i].name; i++)
3272 1.1 christos if (strcmp (tokens[i].name, buffer) == 0)
3273 1.1 christos {
3274 1.1 christos #if TRACE
3275 1.1 christos printf ("lex: `%s' is a string token\n", buffer);
3276 1.1 christos #endif
3277 1.1 christos return tokens[i].token;
3278 1.1 christos }
3279 1.1 christos }
3280 1.1 christos #if TRACE
3281 1.1 christos printf ("lex: `%s' returns ID\n", buffer);
3282 1.1 christos #endif
3283 1.1 christos yylval.id = def_pool_strdup (buffer);
3284 1.1 christos return ID;
3285 1.1 christos }
3286 1.1 christos
3287 1.1 christos if (c == '\'' || c == '"')
3288 1.1 christos {
3289 1.1 christos q = c;
3290 1.1 christos c = def_getc ();
3291 1.1 christos bufptr = 0;
3292 1.1 christos
3293 1.1 christos while (c != EOF && c != q)
3294 1.1 christos {
3295 1.1 christos put_buf (c);
3296 1.1 christos c = def_getc ();
3297 1.1 christos }
3298 1.1 christos yylval.id = def_pool_strdup (buffer);
3299 1.1 christos #if TRACE
3300 1.1 christos printf ("lex: `%s' returns ID\n", buffer);
3301 1.1 christos #endif
3302 1.1 christos return ID;
3303 1.1 christos }
3304 1.1 christos
3305 1.1 christos if ( c == '=')
3306 1.1 christos {
3307 1.1 christos c = def_getc ();
3308 1.1 christos if (c == '=')
3309 1.6 christos {
3310 1.1 christos #if TRACE
3311 1.6 christos printf ("lex: `==' returns EQUAL\n");
3312 1.1 christos #endif
3313 1.6 christos return EQUAL;
3314 1.6 christos }
3315 1.1 christos def_ungetc (c);
3316 1.1 christos #if TRACE
3317 1.1 christos printf ("lex: `=' returns itself\n");
3318 1.1 christos #endif
3319 1.1 christos return '=';
3320 1.1 christos }
3321 1.1 christos if (c == '.' || c == ',')
3322 1.1 christos {
3323 1.1 christos #if TRACE
3324 1.1 christos printf ("lex: `%c' returns itself\n", c);
3325 1.1 christos #endif
3326 1.1 christos return c;
3327 1.1 christos }
3328 1.1 christos
3329 1.1 christos if (c == '\n')
3330 1.1 christos {
3331 1.1 christos linenumber++;
3332 1.1 christos saw_newline = 1;
3333 1.1 christos }
3334 1.1 christos
3335 1.1 christos /*printf ("lex: 0x%02x ignored\n", c); */
3336 1.1 christos return def_lex ();
3337 1.1 christos }
3338 1.1 christos
3339 1.1 christos static char *
3340 1.1 christos def_pool_alloc (size_t sz)
3341 1.1 christos {
3342 1.1 christos def_pool_str *e;
3343 1.1 christos
3344 1.1 christos e = (def_pool_str *) xmalloc (sizeof (def_pool_str) + sz);
3345 1.1 christos e->next = pool_strs;
3346 1.1 christos pool_strs = e;
3347 1.1 christos return e->data;
3348 1.1 christos }
3349 1.1 christos
3350 1.1 christos static char *
3351 1.1 christos def_pool_strdup (const char *str)
3352 1.1 christos {
3353 1.1 christos char *s;
3354 1.1 christos size_t len;
3355 1.1 christos if (!str)
3356 1.1 christos return NULL;
3357 1.1 christos len = strlen (str) + 1;
3358 1.1 christos s = def_pool_alloc (len);
3359 1.1 christos memcpy (s, str, len);
3360 1.1 christos return s;
3361 1.1 christos }
3362 1.1 christos
3363 1.1 christos static void
3364 1.1 christos def_pool_free (void)
3365 1.1 christos {
3366 1.1 christos def_pool_str *p;
3367 1.1 christos while ((p = pool_strs) != NULL)
3368 1.1 christos {
3369 1.1 christos pool_strs = p->next;
3370 1.1 christos free (p);
3371 1.1 christos }
3372 1.1 christos }
3373