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